query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Caches the available locales list as both strings and symbols in a Set, so that we can have faster lookups to do the available locales enforce check. source://i18n//lib/i18n/config.rb50
|
def available_locales_set; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def used_locales\r\n locales = globalize.stash.keys.concat(globalize.stash.keys).concat(translations.translated_locales)\r\n locales.uniq!\r\n locales\r\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def available_locales=(locales); end",
"def available_locales\n self.locales.map { |locale| locale.to_sym }\n end",
"def locales\n map(&:locale)\n end",
"def all_locales\n configatron.full_locales | preferred_locales\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def test_available_locales\n locales = %w[ar az bg bs ca cs da de el en en-GB es es-PA et eu fa fi fr gl he hr hu id it ja ko lt lv mk mn nl no pl pt pt-BR ro ru sk sl sq sr sr-YU sv th tr uk vi zh zh-TW]\n assert_equal locales.uniq.sort.map(&:to_sym), MessageCustomize::Locale.available_locales\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def available_locales; end",
"def available_locales; end",
"def available_locales\n translation_model.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def translated_locales\r\n all.distinct(\"locale\").sort{ |x,y| x.to_s <=> y.to_s }.map(&:to_sym)\r\n end",
"def available_locales\n []\n end",
"def locales\n locale_counts.keys\n end",
"def enabled_locales=(values)\n languages = values.reject{|x| x.blank?}\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def clear_available_locales_set; end",
"def enabled_locales=(values)\n languages = values.reject { |x| x.blank? }\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def available_locale_preferences\n [@no_preference] + available_locales\n end",
"def locales\n locale_sources.compact.downcase.map {|loc| WorldFlags.locale(loc) unless loc.blank? }\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def locales\n get(\"locales\")[\"locales\"]\n end",
"def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end",
"def available_locales\n translations = Dir.glob('config/locales/*').map { |locale| locale.split('/').last.split('.').first }\n locales = []\n translations.each do |t|\n value = (t == 'zh' ? 'zh-CN' : t)\n locales << [LanguageList::LanguageInfo.find(t).name, value]\n end\n locales\n end",
"def locales\n EnvironmentLocaleMethodsFactory.new(self)\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def locales(locale_type)\n locs = Set.new\n\n each_bathing_water do |bw|\n l = bw[locale_type]\n locs << l if l.is_a?(LdaResource)\n end\n\n locs.to_a.sort_by(&:label)\n end",
"def all_locales\n locales = slugged_attributes\n .map { |attr| send(\"#{attr}_translations\").keys if respond_to?(\"#{attr}_translations\") }\n .flatten.compact.uniq\n locales = I18n.available_locales if locales.empty?\n locales\n end",
"def preferred_locales\n read_attribute(\"preferred_locales\").map(&:to_sym)\n end",
"def in_available_locales\n locales = if respond_to?(:available_locales)\n available_locales\n else\n I18n.available_locales\n end\n\n locales.flat_map { |locale| I18n.with_locale(locale) { yield } }\n end",
"def locales\n @env.locales\n end",
"def locale\n @locales = Ramaze::Tool::Localize.languages.map{ |lang|\n [\n Ramaze::Tool::Localize.localize('locale_menu_descrition', lang),\n Ramaze::Tool::Localize.localize('locale_name', lang),\n lang\n ]\n }\n end",
"def get_locales\n fall_back = [:ru].to_yaml\n locales = CustomSetting.find_or_create_by_name(\"languages\").value || fall_back\n begin\n locales = YAML::load(locales)\n rescue\n locales = YAML::load(fall_back)\n end\n end",
"def localizations\n @@locales[Locale.code] || {}\n end",
"def translated_in=(locales)\n self._locales = locales.map(&:to_sym)\n end",
"def available_locales_initialized?; end",
"def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end",
"def localeList\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\t@locales\n\t\tend",
"def normalize_locales\n self.preferred_locales = preferred_locales.map { |l| l.to_s.downcase.gsub(/[^a-z]/, \"\")[0,2] }\n true\n end",
"def user_languages_hash\n result = Hash.new\n\n I18n.available_locales.each do |locale|\n result[t(\"languages.#{locale.to_s}\")] = locale.to_s\n end\n \n return result\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def available_locales\n @available_locales ||= self.languages.published\n end",
"def lookup_chain = locale(true).lookup",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def site_locales\n preferred_locales.split(/,\\s*/)\n end",
"def site_locales\n preferred_locales.split(/,\\s*/)\n end",
"def enforce_available_locales!(locale); end",
"def matching_locales\n @_matching_locales ||= ::I18n.available_locales.select do |locale|\n locale.to_s.split(\"-\")[0] == language_code\n end\n end",
"def available_translations\n {\n 'en' => 'English',\n 'es' => 'Español',\n 'pt-BR' => 'Português do Brasil'\n }\n end",
"def locales(display = :flags)\n c = ''\n # TODO: The checking for entry or tag is primative and does not cover predefined tags\n page = @entry || @tag\n ls = ((display == :locales) || (display == :allflags) ? SemiStatic::Engine.config.localeDomains : SemiStatic::Engine.config.localeDomains.reject{|k, v| k.to_s == I18n.locale.to_s})\n unless ((display == :locales) && (ls.size == 1))\n ls.each{|l, u|\n if u.downcase == 'translate' \n link = \"http://translate.google.com/translate?hl=&sl=auto&tl=#{l}&u=#{url_encode(request.url)}\"\n else\n # If this is a special page, with no tag or entry, then it will not be seoable so just point locales to the root of the alternate locale website\n page.nil? && (link = u)\n end\n if (display == :flags) || (display == :allflags)\n c+= \"<li class='locale #{l}'><a href='#{link || page.hreflang_link(l) || u}'>#{image_tag(\"flags/\" + l + \".png\", :alt => \"locale #{l}\")}</a></li>\".html_safe\n elsif display == :text\n c+= \"<li class='locale #{l}'><a href='#{link || page.hreflang_link(l) || u}'>#{I18n.t(l)}</a></li>\".html_safe\n else\n if session[:locale] == l\n c+= \"<li class='locale #{l} selected'><a href='#{link || page.hreflang_link(l) || u}'>#{l}</a></li>\".html_safe\n else\n c+= \"<li class='locale #{l}'><a href='#{link || page.hreflang_link(l) || u}'>#{l}</a></li>\".html_safe\n end\n end\n }\n end\n c.html_safe\n end",
"def preferred_locales_str\n (preferred_locales || []).join(\",\")\n end",
"def locale_matches\n matches = {}\n I18n.available_locales.map(&:to_s).each do |locale|\n matches[locale] = locale\n matches[locale[0, 2]] = locale if locale.length > 2\n end\n matches\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def select_languages_localized\n available_languages.map{ |x| known_languages.assoc(x)}.map{ |y| [y[2],y[0]]}.sort!\n end",
"def match_locale_and_set_locale\n changed = false\n if I18n.available_locales.map(&:to_s).include?(configuration_params[:locale])\n unless cookies[:locale] == configuration_params[:locale]\n I18n.locale = cookies[:locale] = configuration_params[:locale] \n changed = true\n end\n changed\n end\n end",
"def locales\n self.site.locales || []\n end",
"def translated_locales\n self.i18n.keys\n end",
"def locale_flag_map\n\t\t\t@locale_flag_map ||= keys_to_sym(locale_flag_hash) \n\t\tend",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def locales(website)\n if product_families.size > 0\n @locales ||= product_families.map do |pf|\n pf.find_ultimate_parent.locales(website)\n end.flatten.uniq - locales_where_hidden\n else\n @locales ||= website.list_of_all_locales - locales_where_hidden\n end\n end",
"def local_names\n ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq\n reload\n\n @local_names ||= languages.map { |language| translations[language] }\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def localized_names\n @localized_names ||= []\n end",
"def locale=(input)\n input = [input] unless input.is_a?(Array)\n @locales = input\n end",
"def translations_for route\n available_locales.map do |locale|\n translate_route(route, locale.dup) #we duplicate the locale string to ensure it's not frozen\n end\n end",
"def getlist\r\n result = SUPPORTED_LANG_LIST\r\n end",
"def all_locales\n locales = []\n Rails.root.glob(\"config/locales/*.yml\").each do |file|\n match = /(\\w+).yml$/.match(file.to_s)\n locales << match[1] if match\n end\n locales\nend",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def rtl_locales\n %i[ar]\n end",
"def list\n @@translatable ||= Hash.new\n end",
"def set_locale\n accept_language = request.headers['Accept-Language']\n return if accept_language.blank?\n\n available = %w{en ja}\n accept_language.split(',').each do |locale_set|\n locale = locale_set.split(';').first\n if available.include?(locale)\n I18n.locale = locale\n break\n end\n end\n end",
"def loaded_languages\n @@cached_language_data.keys\n end",
"def accepted_locales\n http_accept_language = request.env['HTTP_ACCEPT_LANGUAGE']\n return [] if http_accept_language.blank?\n langs = http_accept_language.scan(/([a-zA-Z]{2,4})(?:-[a-zA-Z]{2})?(?:;q=(1|0?\\.[0-9]{1,3}))?/).map do |pair|\n lang, q = pair\n [lang.to_sym, (q || '1').to_f]\n end\n langs.sort_by { |lang, q| q }.map { |lang, q| lang }.reverse.uniq\n end",
"def all_published_locales\n translations.where(published: true).map{|x| x.locale}.uniq.sort\n end",
"def discover_locale\n locales = Dir[\"#{locale_dir}/*\"]\n locales.map! { |e| File.basename(e) }\n locales.join(\" \")\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def descriptions\n I18n.available_locales.map {|l| [l, description(l)] }.to_h\n end",
"def resolve_runtime_locale_values(hsh)\n hsh.each do |key, value|\n if value.is_a?(Hash)\n meta = value[helpers::META[:meta]]\n if meta && (meta.to_h)[helpers::META[:decorators][:runtime_locales]]\n hsh[key] = get_runtime_locale_value(value)\n else\n hsh[key] = resolve_runtime_locale_values(value)\n end\n end\n end\n return hsh\n end",
"def each_locale(include_default_locale = true, &block)\n current_locale = ::Mongoid::Fields::I18n.locale\n _locales = include_default_locale ? self.locales : (self.locales - [self.default_locale])\n\n _locales.each do |locale|\n ::Mongoid::Fields::I18n.with_locale(locale) do\n yield locale, current_locale.to_s == locale.to_s\n end\n end\n end",
"def translations_for_select\n Alchemy::I18n.available_locales.map do |locale|\n [_t(locale, :scope => :translations), locale]\n end\n end",
"def translations\n translated_locales = @bindings[:object].translated_locales\n available_locales.collect do |locale|\n translated_locales.include?(locale) ? @bindings[:object].translation_for(locale) : @bindings[:object].translations.new({ locale: locale })\n end\n end",
"def load_all_metas\n Thread.current[:metas] = I18n.available_locales.inject({}) do |acc, locale|\n acc.merge!(load_metas_for_locale(locale))\n acc\n end\n end",
"def country_code_locales(c)\n if c.nil? || ! @cc.has_key?(c.downcase.to_sym)\n Rails.logger.warn \"Unknown country code: #{c}\"\n c = DEFAULT_COUNTRY_CODE\n end\n\n @cc[c.downcase.to_sym][:locales]\n end",
"def initialize_i18n_hashes\n self.i18n ||= Hash.new\n self.i18n[ I18n.locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n if I18n.locale != I18n.default_locale\n self.i18n[ I18n.default_locale ] ||= Hash.new(Hash.zip(translated_attribute_names,[]))\n end\n end",
"def testlocale\n check_path = 'config/locales/'\n locale_list = %w(vi en ja)\n\n @missing_files = []\n @missing_keys = []\n # begin checking if all the necessary locale files exist\n folders = Dir.glob(\"#{check_path}**/*/\").push(check_path)\n for folder in folders do\n key_list = []\n for locale in locale_list do\n file = \"#{folder}#{locale}.yml\"\n if File.exist?(file)\n thing = YAML.load_file(file)\n key_list.push(flatten_keys(thing[locale]))\n else\n @missing_files.push(file)\n end\n end\n key_list.each_with_index do |key1,k1|\n for key2 in key_list do\n missing = key2 - key1\n if missing.any?\n missing.each { |key| @missing_keys.push(\"Missing #{key} in #{folder}#{locale_list[k1]}.yml\") }\n end\n\n end\n end\n end\n\n end",
"def QueryAvailableLocaleIDs()\r\n ret = @dispatch._invoke(1610743830, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def activate\n\tAVAILABLE_LOCALES.clear.merge!('en-US' => \"English US\", 'mx' =>\"Spanish ES\")\n end",
"def check_locales!\n default_locale = self.mounting_point.default_locale.to_s\n locales = self.site.locales.map(&:to_s)\n remote_locales = self.remote_site['locales']\n message = nil\n\n unless locales.all? { |l| remote_locales.include?(l) }\n message = \"Your site locales (#{locales.join(', ')}) do not match exactly the ones of your target (#{remote_locales.join(', ')})\"\n end\n\n if default_locale != remote_locales.first\n message = \"Your default site locale (#{default_locale.inspect}) is not the same as the one of your target (#{remote_locales.first.inspect})\"\n end\n\n if message\n self.output_resource_op self.site\n self.output_resource_op_status self.site, :error, message\n raise Mounter::WriterException.new('Use the force option in order to force your locale settings.')\n end\n end"
] |
[
"0.7525165",
"0.72818416",
"0.72818416",
"0.72321254",
"0.72142446",
"0.71887887",
"0.71097803",
"0.71097803",
"0.7088116",
"0.70164996",
"0.6978896",
"0.69147426",
"0.6868781",
"0.68599707",
"0.6820874",
"0.6819864",
"0.67624193",
"0.6753491",
"0.6753491",
"0.67385703",
"0.67143565",
"0.670123",
"0.6688275",
"0.6651494",
"0.66248834",
"0.6620536",
"0.65597534",
"0.65370905",
"0.65341616",
"0.65303004",
"0.65005624",
"0.6468735",
"0.6459892",
"0.64509237",
"0.64320344",
"0.6384253",
"0.6370151",
"0.6332846",
"0.63270134",
"0.6321768",
"0.6316299",
"0.63124126",
"0.6292318",
"0.6283021",
"0.6268549",
"0.6229309",
"0.6201659",
"0.6165566",
"0.61470556",
"0.611222",
"0.6080853",
"0.60779905",
"0.6069729",
"0.6063853",
"0.60573053",
"0.5990815",
"0.5990815",
"0.5980595",
"0.59738207",
"0.59435695",
"0.5939681",
"0.592087",
"0.5863889",
"0.584751",
"0.58330286",
"0.5814805",
"0.5797133",
"0.5784019",
"0.57765734",
"0.57543606",
"0.5732611",
"0.57214665",
"0.5685841",
"0.5635876",
"0.56337976",
"0.56271815",
"0.5613336",
"0.56115454",
"0.5606125",
"0.5582064",
"0.5581119",
"0.55679244",
"0.55530214",
"0.55350834",
"0.55268055",
"0.5523481",
"0.55121654",
"0.5495264",
"0.5464626",
"0.545884",
"0.54460967",
"0.5390783",
"0.53897065",
"0.5371309",
"0.53658974",
"0.5359402",
"0.53546023",
"0.5352649",
"0.53512096",
"0.5340243"
] |
0.7505384
|
1
|
Returns the current backend. Defaults to +Backend::Simple+. source://i18n//lib/i18n/config.rb20
|
def backend; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def backend\n @backend ||= Configurator.new(self, :backend)\n end",
"def backend\n @backend ||= self.class.backend\n end",
"def backend_name\n config['backend']\n end",
"def active_backend\n SSHKit::Custom::Config::Store.active_backend\n end",
"def default_backend\n attributes_class.defaults[:backend]\n end",
"def backend(value = nil)\n if value.is_a?(Symbol)\n require \"down/#{value}\"\n @backend = Down.const_get(value.to_s.split(\"_\").map(&:capitalize).join)\n elsif value\n @backend = value\n else\n @backend\n end\n end",
"def backend_name\n self.class.name.split(\"::\")[-1].split(\"Store\")[0].downcase\n end",
"def backend\n :ruby\n end",
"def backend\n # Hard-coded backend\n if @options[:backend]\n return OctocatalogDiff::CatalogUtil::ENC::Noop.new(@options) if @options[:backend] == :noop\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:backend] == :pe\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:backend] == :script\n raise ArgumentError, \"Unknown backend :#{@options[:backend]}\"\n end\n\n # Determine backend based on arguments\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:pe_enc_url]\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:enc]\n\n # At this point we do not know what backend to use for the ENC\n raise ArgumentError, 'Unable to determine ENC backend to use'\n end",
"def backend\n # Hard-coded backend\n if @options[:backend]\n return OctocatalogDiff::CatalogUtil::ENC::Noop.new(@options) if @options[:backend] == :noop\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:backend] == :pe\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:backend] == :script\n raise ArgumentError, \"Unknown backend :#{@options[:backend]}\"\n end\n\n # Determine backend based on arguments\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:pe_enc_url]\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:enc]\n\n # At this point we do not know what backend to use for the ENC\n raise ArgumentError, 'Unable to determine ENC backend to use'\n end",
"def for backend\n registry[backend]\n end",
"def platform\n backend.platform\n end",
"def backend(backend, options = {})\n @backends ||= []\n if backend.is_a?(Symbol)\n require \"global/backend/#{backend}\"\n backend_class = Global::Backend.const_get(camel_case(backend.to_s))\n @backends.push backend_class.new(options)\n elsif backend.respond_to?(:load)\n @backends.push backend\n else\n raise 'Backend must be either a Global::Backend class or a symbol'\n end\n end",
"def backend_klass; end",
"def default_backend\n case environment\n when 'production', 'staging'\n StatsD::Instrument::Backends::UDPBackend.new(ENV['STATSD_ADDR'], ENV['STATSD_IMPLEMENTATION'])\n when 'test'\n StatsD::Instrument::Backends::NullBackend.new\n else\n StatsD::Instrument::Backends::LoggerBackend.new(StatsD.logger)\n end\n end",
"def host\n active_backend.host\n end",
"def backend\n set_default_backend unless defined?(@backend)\n raise OEmbed::FormatNotSupported, :xml unless defined?(@backend)\n @backend\n end",
"def set_backend\n @backend = Backend.find(params[:id])\n end",
"def backend_instance\n if Rails.env.test?\n # turn off caching for tests\n @backend_instance = Backend.new(current_user)\n else\n @backend_instance ||= Backend.new(current_user)\n end\n end",
"def backends; end",
"def hashback_backend\n self.class.__send__(:class_variable_get, :@@_backend) \n end",
"def backend=(backend)\n @backend = backend&.to_sym\n set_encoder\n end",
"def get_server_base_config\n backend_conf = @opts['backend_conf'] || {}\n return backend_conf\n end",
"def locale_backend; end",
"def codebase()\n \"Hiera::Backend::Simp_compliance_enforcement_backend\"\n end",
"def current_framework\n @current_framework ||= self.default_framework\n return @current_framework\n end",
"def get\n\n BabboBackend.instance ||= BabboBackend.new\n end",
"def inspect\n \"Inspec::Backend::Class @transport=#{backend.class}\"\n end",
"def backend\n return @backend if @backend && @last_choice_on > 10.minutes.ago\n\n @backend ||= @backends.first\n\n @last_choice_on = Time.now\n challenger, height = @backends\n .reject{|b| b == @backend }\n .collect{|b| [b, b.block_height] }\n .sort_by(&:last)\n .last\n\n @backend = height > (@backend.block_height + 1) ? challenger : @backend\n end",
"def backend_node(name, locale = Mobility.locale)\n @klass.mobility_backend_class(name)[name, locale]\n end",
"def backend=(backend); end",
"def backend=(backend)\n RSpec.configuration.formatters\n .find_all { |c| c.is_a?(Inspec::Formatters::Base) }\n .each do |fmt|\n fmt.backend = backend\n end\n end",
"def set_backend(val)\n end",
"def current_framework=(value)\n @current_framework ||= self.current_framework\n @current_framework = value.to_sym\n return @current_framework\n end",
"def mobility_backend_class(name)\n @backends ||= BackendsCache.new(self)\n @backends[name.to_sym]\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def current\n RequestStore.store[:alchemy_current_language] || default\n end",
"def current_adapter\n ENV.fetch('TEMPING_ADAPTER')\n end",
"def initialize( backend = nil, config = {} )\n backend ||= :memory\n \n begin\n adapter = RG::Adapters.const_get(\"#{backend.to_s.capitalize}Adapter\")\n @adapter = adapter.new(config)\n rescue LoadError\n Raise \"Cannot find the backend #{backend}\"\n end\n \n end",
"def build_backend(backend_id, backend_options = {})\n backend_options ||= {}\n return provided_backends[backend_id].call(backend_options)\n rescue NoMethodError\n return nil\n end",
"def default_backend(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"default_backend \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def current_language\n @@current_language\n end",
"def backends\n # Lets cache the values and return the cache\n if @backends.nil?\n @backends = {}\n backend_instances.each do | name, backend|\n @backends[name] = backend.servers\n end\n end\n @backends\n end",
"def scm config\n # no engine specified\n if !config\n return nil\n end\n\n # git backend\n if config['scm'] == 'git'\n return Git.new(self)\n end\n end",
"def load_backend(name)\n begin\n require \"shoes/#{name.to_s.downcase}\"\n Shoes.const_get(name.to_s.capitalize)\n rescue LoadError => e\n raise LoadError, \"Couldn't load backend Shoes::#{name.capitalize}'. Error: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n end\n end",
"def index\n @backends = Backend.all\n end",
"def current\n locale = I18n.locale\n @current ||=\n Rails.cache.fetch(\"languages/current/#{locale}\") do\n l = Language.find_by_group(locale)\n l ||= Language.english\n end\n end",
"def primary_storage_adapter\n @storage_adapters.first\n end",
"def backends=(_arg0); end",
"def default(app = Rails.application)\n adapters[app.config.console] || adapters[Dummy]\n end",
"def frontend\n @frontend ||= Configurator.new(self, :frontend)\n end",
"def to_s\n \"Inspec::Backend::Class\"\n end",
"def add_backend(backend)\n hash = fetcher.client.post(\"#{Director.put_path(self)}/backend/#{backend.name}\")\n !hash.nil?\n end",
"def framework_name\n self.name.split(\"::\").last.downcase\n end",
"def framework_name\n self.name.split(\"::\").last.downcase\n end",
"def default_locale\n FastGettext.available_locales.first\n end",
"def current_engine\n end",
"def typus_application\n Typus::Configuration.config[name][\"application\"] || \"Unknown\"\n end",
"def default_adapter\n make_adapter @@manager.DefaultAdapter[0]\n end",
"def show\n @sm_backend_config = SmBackendConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sm_backend_config }\n end\n end",
"def framework_name; registered_framework_name; end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def current_engine\n unless defined?(@current_engine)\n processors = environment.attributes_for(self.pathname).processors\n processors.each do |processor|\n if engine = CAPTURE_ENGINES[processor.to_s]\n @current_engine = engine\n break\n end\n end\n end\n\n @current_engine\n end",
"def platform_name; non_framework_platforms.first; end",
"def framework\n @framework\n end",
"def io_selector_backend(backend); end",
"def platform\n return @platform\n end",
"def language_code\n if self.class.globalized?\n unless @original_language.nil?\n code = @original_language.code\n else\n code = Globalize::Locale.base_language.code\n end\n elsif Globalize::Locale.language.nil?\n code = Globalize::Locale.base_language.code\n else\n code = Globalize::Locale.language.code\n end\n code\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def best_backend(force_unsafe = false)\n if Backends::PosixSpawn.available?(force_unsafe)\n Backends::PosixSpawn.new\n elsif Backends::Spawn.available?(force_unsafe)\n Backends::Spawn.new\n elsif Backends::Backticks.available?(force_unsafe)\n Backends::Backticks.new\n else\n Backends::Fake.new\n end\n end",
"def default_language\n @default_language || :en\n end",
"def lang_code\n (self.path_lang && self.path_lang.length > 0) ? self.path_lang : @settings['default_lang']\n end",
"def enable_backend\n add option: \"-backend=true\"\n end",
"def framework\n\t\treturn self.class.framework\n\tend",
"def default_locale\n client.default_locale\n end",
"def set_backend_category\n @backend_category = Backend::Category.find(params[:id])\n end",
"def adapter\n cfg_get(:adapter) || HyperResource::Adapter::HAL_JSON\n end",
"def current_server\n @_current_server\n end",
"def current_server\n @_current_server\n end",
"def driver\n storage_hash = get_api_node(['storage-pools', resource[:name]])\n driver = storage_hash['driver']\n return driver\n end",
"def adapter\n cfg_get(:adapter) ||\n HyperResource::Adapter::HAL_JSON\n end",
"def bind_backend(controller_class, topic)\n backend = Kernel.const_get(\"::Karafka::Backends::#{topic.backend.to_s.capitalize}\")\n controller_class.include backend\n end",
"def default_app()\n @apps[0]\n end",
"def get_current_client\n get_current_hub&.current_client\n end",
"def adapter\n return @adapter if @adapter\n self.use self.default_adapter\n @adapter\n end",
"def adapter\n return @adapter if @adapter\n self.use self.default_adapter\n @adapter\n end",
"def engine\n SettingMaster.engine\n end",
"def current_weblab\n return $current_weblab\n end",
"def current_settings\n Weby::Settings\n end",
"def current_company_curr\n Currency.where('client_id = ? and default_currency = ?', current_subdomain, \"t\").first.try(:currency_symbol)\n end",
"def set_backend_location\r\n @backend_location = Backend::Location.find(params[:id])\r\n end",
"def current_language\n @attributes[:current_language]\n end",
"def class_settings\n if controller.controller_name == 'settings'\n \"current\"\n end\n end",
"def choose_layout\n logger.info \"\\n HOST #{request.host}\\n\"\n if current_user.present?\n if current_user.role?(:admin)\n 'backend_admin'\n else\n 'backend'\n end\n else\n 'application'\n end\n end",
"def current_subdomain\n self.subdomain_klass.current\n end",
"def scheme\n\t\t\t@options[:scheme]\n\t\tend",
"def show\n @http_backend = Http::Backend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @http_backend }\n end\n end",
"def engine\n data[:engine]\n end",
"def engine\n data[:engine]\n end",
"def current\n @env.first\n end"
] |
[
"0.80344975",
"0.7752104",
"0.77507573",
"0.7545812",
"0.73210055",
"0.69849074",
"0.68068075",
"0.6760333",
"0.6757637",
"0.6757637",
"0.664916",
"0.6618469",
"0.6605976",
"0.6582485",
"0.65360755",
"0.6420126",
"0.6333426",
"0.6315479",
"0.6283491",
"0.62307334",
"0.62208474",
"0.62175256",
"0.6070022",
"0.6054933",
"0.60542274",
"0.6050478",
"0.6021599",
"0.60057694",
"0.5991113",
"0.59832877",
"0.5972213",
"0.5858919",
"0.5823638",
"0.5818115",
"0.5770851",
"0.5748905",
"0.5694198",
"0.5578683",
"0.5572709",
"0.5540365",
"0.55191684",
"0.54893553",
"0.54870045",
"0.5451513",
"0.54188544",
"0.54135203",
"0.5387168",
"0.5359735",
"0.5357617",
"0.5349949",
"0.534021",
"0.5333867",
"0.5317919",
"0.5311586",
"0.5311586",
"0.5272666",
"0.5248994",
"0.5219834",
"0.5209646",
"0.5192706",
"0.5192094",
"0.51737154",
"0.5165772",
"0.5161478",
"0.5143536",
"0.51344824",
"0.5133607",
"0.51312023",
"0.512815",
"0.50977093",
"0.5073903",
"0.5070666",
"0.5062646",
"0.50537807",
"0.5038942",
"0.5035776",
"0.502316",
"0.5009564",
"0.5009564",
"0.50014377",
"0.49926537",
"0.49837238",
"0.4982779",
"0.4976022",
"0.49709418",
"0.49705163",
"0.49699116",
"0.49688095",
"0.4968466",
"0.49659327",
"0.4949236",
"0.49471936",
"0.4924007",
"0.49180275",
"0.49158564",
"0.4914621",
"0.49070865",
"0.4904264",
"0.4904264",
"0.49038982"
] |
0.62047493
|
22
|
Sets the current backend. Used to set a custom backend. source://i18n//lib/i18n/config.rb25
|
def backend=(backend); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_backend(val)\n end",
"def set_backend\n @backend = Backend.find(params[:id])\n end",
"def backend=(backend)\n @backend = backend&.to_sym\n set_encoder\n end",
"def backend\n @backend ||= Configurator.new(self, :backend)\n end",
"def backend=(backend)\n RSpec.configuration.formatters\n .find_all { |c| c.is_a?(Inspec::Formatters::Base) }\n .each do |fmt|\n fmt.backend = backend\n end\n end",
"def backend_name\n config['backend']\n end",
"def backend\n @backend ||= self.class.backend\n end",
"def active_backend\n SSHKit::Custom::Config::Store.active_backend\n end",
"def backend(backend, options = {})\n @backends ||= []\n if backend.is_a?(Symbol)\n require \"global/backend/#{backend}\"\n backend_class = Global::Backend.const_get(camel_case(backend.to_s))\n @backends.push backend_class.new(options)\n elsif backend.respond_to?(:load)\n @backends.push backend\n else\n raise 'Backend must be either a Global::Backend class or a symbol'\n end\n end",
"def default_backend\n attributes_class.defaults[:backend]\n end",
"def add_backend(auth_backend)\n @backends << auth_backend\n end",
"def enable_backend\n add option: \"-backend=true\"\n end",
"def add_backend(backend)\n hash = fetcher.client.post(\"#{Director.put_path(self)}/backend/#{backend.name}\")\n !hash.nil?\n end",
"def backend(value = nil)\n if value.is_a?(Symbol)\n require \"down/#{value}\"\n @backend = Down.const_get(value.to_s.split(\"_\").map(&:capitalize).join)\n elsif value\n @backend = value\n else\n @backend\n end\n end",
"def backend\n # Hard-coded backend\n if @options[:backend]\n return OctocatalogDiff::CatalogUtil::ENC::Noop.new(@options) if @options[:backend] == :noop\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:backend] == :pe\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:backend] == :script\n raise ArgumentError, \"Unknown backend :#{@options[:backend]}\"\n end\n\n # Determine backend based on arguments\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:pe_enc_url]\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:enc]\n\n # At this point we do not know what backend to use for the ENC\n raise ArgumentError, 'Unable to determine ENC backend to use'\n end",
"def backend\n # Hard-coded backend\n if @options[:backend]\n return OctocatalogDiff::CatalogUtil::ENC::Noop.new(@options) if @options[:backend] == :noop\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:backend] == :pe\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:backend] == :script\n raise ArgumentError, \"Unknown backend :#{@options[:backend]}\"\n end\n\n # Determine backend based on arguments\n return OctocatalogDiff::CatalogUtil::ENC::PE.new(@options) if @options[:pe_enc_url]\n return OctocatalogDiff::CatalogUtil::ENC::Script.new(@options) if @options[:enc]\n\n # At this point we do not know what backend to use for the ENC\n raise ArgumentError, 'Unable to determine ENC backend to use'\n end",
"def set_backend_category\n @backend_category = Backend::Category.find(params[:id])\n end",
"def backend; end",
"def locale_backend; end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def backends; end",
"def backend\n :ruby\n end",
"def default_backend(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"default_backend \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def backends=(_arg0); end",
"def set_backend_location\r\n @backend_location = Backend::Location.find(params[:id])\r\n end",
"def current_framework=(value)\n @current_framework ||= self.current_framework\n @current_framework = value.to_sym\n return @current_framework\n end",
"def backend_klass; end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end",
"def set_backend_user\n @backend_user = User.find(params[:id])\n end",
"def hashback_backend\n self.class.__send__(:class_variable_get, :@@_backend) \n end",
"def initialize( backend = nil, config = {} )\n backend ||= :memory\n \n begin\n adapter = RG::Adapters.const_get(\"#{backend.to_s.capitalize}Adapter\")\n @adapter = adapter.new(config)\n rescue LoadError\n Raise \"Cannot find the backend #{backend}\"\n end\n \n end",
"def use_backend(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"use_backend \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def set_language\n params[:lang] ||= 'en'\n Localization.use params[:lang]\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def setupBackend\n lBackendInitHere = false\n if (!@BackendInit)\n @BackendInstance.init_session(@Conf[:Backends][@Backend])\n @BackendInit = true\n lBackendInitHere = true\n end\n yield\n if (lBackendInitHere)\n @BackendInstance.close_session\n @BackendInit = false\n end\n end",
"def backend\n set_default_backend unless defined?(@backend)\n raise OEmbed::FormatNotSupported, :xml unless defined?(@backend)\n @backend\n end",
"def set_current_language(lang)\n GetText.locale, prev_value = sanitize_lang(lang), GetText.locale\n prev_value\n end",
"def set_backend_article\n @backend_article = Backend::Article.find(params[:id])\n end",
"def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_backend_conf_activity\n @backend_conf_activity = Conf::Activity.find(params[:id])\n end",
"def use_i18n=(value); end",
"def set_backend_conf_event\n @backend_conf_event = Conf::Event.find(params[:id])\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def for backend\n registry[backend]\n end",
"def initialize(backend, content_type)\n @backend = backend\n @content_type = content_type\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_lang(lang)\n\t\t\tlang = 'en' unless languages.include? lang\n\t\t\t@lang = lang.to_sym\n\t\tend",
"def backend_instance\n if Rails.env.test?\n # turn off caching for tests\n @backend_instance = Backend.new(current_user)\n else\n @backend_instance ||= Backend.new(current_user)\n end\n end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def backend_name\n self.class.name.split(\"::\")[-1].split(\"Store\")[0].downcase\n end",
"def set_locale\n if params[:controller] == \"rails_admin/main\"\n I18n.locale = :en\n else\n I18n.locale = :ru\n end\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def set_Language(value)\n set_input(\"Language\", value)\n end",
"def set_Language(value)\n set_input(\"Language\", value)\n end",
"def set_Language(value)\n set_input(\"Language\", value)\n end",
"def set_Language(value)\n set_input(\"Language\", value)\n end",
"def set_Language(value)\n set_input(\"Language\", value)\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def default_locale=(locale); end",
"def set_language\n I18n.locale = params[:locale] || I18n.default_locale\n @lang = Wzs::Multilang::get_language(I18n.locale)\n end",
"def configure_backend!(config, backend, id = nil, secret = nil)\n return unless Rails.env.test? || APP_CONFIG.enabled?(\"oauth.#{backend}\")\n\n options = send(\"#{backend}_fetch_options\")\n\n if id\n config.omniauth backend, id, secret, options\n else\n config.omniauth backend, options\n end\nend",
"def bind_backend(controller_class, topic)\n backend = Kernel.const_get(\"::Karafka::Backends::#{topic.backend.to_s.capitalize}\")\n controller_class.include backend\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def configure_inline_support(backend)\n # Temporally monky-patching IRuby kernel to enable flushing and closing figures.\n # TODO: Make this feature a pull-request for sciruby/iruby.\n kernel = ::IRuby::Kernel.instance\n kernel.extend HookExtension unless kernel.respond_to?(:events)\n if backend == GUI_BACKEND_MAP[:inline]\n if kernel.respond_to?(:register_event)\n kernel.register_event(:post_execute, method(:flush_figures))\n else\n @post_execute_func = kernel.events.register(:post_execute, &method(:flush_figures))\n end\n\n # TODO: save original rcParams and overwrite rcParams with IRuby-specific configuration\n new_backend_name = :inline\n else\n if kernel.respond_to?(:unregister_event)\n kernel.unregister_event(:post_execute, method(:flush_figures))\n elsif @post_execute_func\n kernel.events.unregister(:post_execute, @post_execute_func)\n @post_execute_func = nil\n end\n\n # TODO: restore saved original rcParams\n new_backend_name = :not_inline\n end\n if new_backend_name != @current_backend\n # TODO: select figure formats\n @current_backend = new_backend_name\n end\n end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_preferred_language\n if !first_domain_part.blank? && valid_locale?(first_domain_part)\n set_locale_with_fallback first_domain_part.to_sym\n else\n set_locale_with_fallback Locale.find_main_cached.short.to_sym\n end\n end",
"def set_locale\n # Either through a param, that has highest priority\n locale = if params[:locale]\n params[:locale].to_s\n # Then let's check the browser if there was no param\n elsif accept_language = request.env['HTTP_ACCEPT_LANGUAGE']\n # TODO: Facebook would like to have the country when using authentication there. We should save the browser country somewhere.\n accept_language.scan(/^[a-z]{2}/).first.to_s\n end\n I18n.locale = locale if locale.present? and I18n.available_locales.include?(locale.to_sym)\n end",
"def set_locale\n\t\tif current_user\n\t\t\tRails.logger.debug { \"Setting locale <#{current_user.country.locale.to_sym}> using current user: #{current_user}\" }\n\t\t\tI18n.locale = current_user.country.locale.to_sym\n\t\telse\n\t\t\tRails.logger.debug { \"Using default locale <#{I18n.default_locale}>, because no user is signed in.\" }\n\t\t\tI18n.locale = I18n.default_locale\n\t\tend\n\tend",
"def initialize_options(original_options)\n super\n\n case options[:backend]\n when String, Symbol, Class\n @backend, @backend_options = options[:backend], options.dup\n when Array\n @backend, @backend_options = options[:backend]\n @backend_options = @backend_options.merge(options)\n when NilClass\n @backend = @backend_options = nil\n else\n raise ArgumentError, \"backend must be either a backend name, a backend class, or a two-element array\"\n end\n\n @backend = load_backend(backend)\n end",
"def frontend\n @frontend ||= Configurator.new(self, :frontend)\n end",
"def host\n active_backend.host\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_locale\n \n #raise \"params[:locale] = #{params[:locale].present?}\"\n #raise \"params[:locale] = #{params[:locale].blank?}\"\n # Se non ho assegnato il parametro :locale allora gli passo la lingua impostata sul browser \n # (per testare usa Google chrome Extension: Locale Switcher)\n params[:locale] = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '').scan(/[a-z]{2}/).first if params[:locale].blank?\n #raise \"params[:locale] = #{params[:locale]}\"\n\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n end",
"def set_language\n\n if current_user.nil? || params[:controller] =~ /rails_admin/i\n I18n.locale = params[:language] || I18n.default_locale\n else\n I18n.locale = params[:language] || current_user.language.try(:iso_code) || I18n.default_locale\n end\n end",
"def set_locale\n locale = request.subdomains.first\n locale = (logged_in? ?\n current_user.profile.language :\n browser_language) if locale.blank? || !I18n.available_locales.include?(locale.to_sym)\n I18n.locale = locale\n end",
"def framework=(fw)\n @framework = fw\n end",
"def set_locale\n I18n.locale = current_user.try(:locale) || I18n.default_locale\n end",
"def platform\n backend.platform\n end",
"def default_backend\n case environment\n when 'production', 'staging'\n StatsD::Instrument::Backends::UDPBackend.new(ENV['STATSD_ADDR'], ENV['STATSD_IMPLEMENTATION'])\n when 'test'\n StatsD::Instrument::Backends::NullBackend.new\n else\n StatsD::Instrument::Backends::LoggerBackend.new(StatsD.logger)\n end\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_translation\n if params[:locale].blank? && session[:current_locale].present?\n ::I18n.locale = session[:current_locale]\n elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)\n session[:current_locale] = ::I18n.locale = params[:locale]\n elsif current_alchemy_user && current_alchemy_user.respond_to?(:language) && current_alchemy_user.language.present?\n ::I18n.locale = current_alchemy_user.language\n else\n ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale\n end\n end",
"def set_locale\n I18n.select_locale( params[:locale], session[:locale], I18n.from_http_header(request) )\n logger.info \"Using language: #{I18n.locale}\"\n session[:locale] = I18n.locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end"
] |
[
"0.7529817",
"0.73311514",
"0.7327457",
"0.71799064",
"0.68861926",
"0.658184",
"0.6571819",
"0.65657586",
"0.62031704",
"0.610168",
"0.6049615",
"0.604867",
"0.6046211",
"0.60309273",
"0.60204005",
"0.60204005",
"0.5998594",
"0.5903728",
"0.58489794",
"0.5844033",
"0.5838511",
"0.5739595",
"0.571795",
"0.5701831",
"0.5693683",
"0.56890565",
"0.5675673",
"0.5675454",
"0.56748116",
"0.5668286",
"0.56506103",
"0.5637823",
"0.5596552",
"0.55854774",
"0.5571378",
"0.5571378",
"0.556193",
"0.55598855",
"0.5506788",
"0.5499553",
"0.54983246",
"0.54723954",
"0.5433594",
"0.541126",
"0.539698",
"0.53947365",
"0.53947365",
"0.5387364",
"0.53669816",
"0.53627574",
"0.5339436",
"0.5318443",
"0.530732",
"0.5291143",
"0.5289983",
"0.52888656",
"0.52888656",
"0.52860844",
"0.52824485",
"0.5282421",
"0.52822983",
"0.52822983",
"0.52822655",
"0.52822655",
"0.5281989",
"0.5279695",
"0.52493733",
"0.5246053",
"0.5232535",
"0.522404",
"0.5223672",
"0.52224356",
"0.52224356",
"0.52224356",
"0.52224356",
"0.52100337",
"0.5197702",
"0.5197378",
"0.5193688",
"0.5192421",
"0.5161308",
"0.5159243",
"0.5151095",
"0.5138765",
"0.5123338",
"0.5120788",
"0.5095552",
"0.50928986",
"0.5083599",
"0.5076628",
"0.50764275",
"0.50705695",
"0.5069568",
"0.5069158",
"0.50618774",
"0.50599104",
"0.5057897",
"0.5057897",
"0.5049479",
"0.50439876"
] |
0.72503394
|
3
|
Clears the available locales set so it can be recomputed again after I18n gets reloaded. source://i18n//lib/i18n/config.rb70
|
def clear_available_locales_set; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset_stats!\r\n @@available_locales = nil\r\n @@enabled_locales = nil\r\n @@language_completion = nil\r\n @@all_translation_info = nil\r\n @@datetime_vars = nil\r\n end",
"def used_locales\r\n locales = globalize.stash.keys.concat(globalize.stash.keys).concat(translations.translated_locales)\r\n locales.uniq!\r\n locales\r\n end",
"def all_locales\n configatron.full_locales | preferred_locales\n end",
"def clear_translations!\r\n @translation_caches = {}\r\n @stop_merging_translated_attributes = nil\r\n end",
"def reset_i18n()\n I18n.backend = I18n::Backend::Simple.new\nend",
"def clear_registered_linters\n registered_linters.clear\n end",
"def clear\n\t\t\t@store.transaction { @store.delete(:custom_numerals); @store.commit}\n\t\t\tputs \"User defined Roman Numerals cleared.\"\n\t\t\tconfig(true)\t\t\t\n\t\tend",
"def unregister_all\n registry.clear.default = nil\n end",
"def ClearAll\n ClearErrors()\n ClearWarnings()\n ClearMessages()\n ClearYesNoMessages()\n\n nil\n end",
"def available_locales=(locales); end",
"def clear_options(contexts = nil)\n Config::Options.clear(contexts)\n end",
"def clear_cache_i18n\n Rails.cache.delete_matched 'views/i18n/*'\n end",
"def available_locales_set; end",
"def reset\n [topics, queues, subscriptions].each do |resource|\n resource.values.each(&:delete)\n resource.clear\n end\n end",
"def clear!\n defined_settings.each {|setting| instance_variable_set(\"@#{setting}\", nil)}\n @storage_adapters = []\n @cached_paths = {}\n end",
"def missing_locales\n project.locales.reject do |locale|\n translations.map(&:locale_id).include? locale.id\n end\n end",
"def reset(options={})\n options = {\n :clear => true\n }.merge(options)\n\n registry.each do |option|\n if option.respond_to?(:reset)\n option.reset\n end\n end\n\n config.clear if options[:clear]\n self\n end",
"def reset_all_option_configs_resource_names!\n @all_option_configs_resource_names = nil\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def clear_properties\n Config::Collection.clear\n end",
"def reset!\n @setting_objects = @setting_templates.map { |k, _| [k, []] }.to_h\n @settings.values.each(&:reset!)\n end",
"def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = nil\n metrics.each_key { |metric| singleton_class.send(:remove_method, metric) if respond_to?(metric) }\n @metrics = nil\n collectors.clear\n configurators.clear\n instance_variable_set(:@configured_by, nil)\n instance_variable_set(:@debug_was_enabled_by, nil)\n end",
"def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end",
"def clear_all!\n @commands_and_opts.clear\n self\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def clear(config)\n Array(config).each do |setting|\n delete_setting setting\n end\n end",
"def clear_domains\n clear_all_dependencies\n puts \"All domains removed from the monitoring list\"\n end",
"def clear_options\r\n\t\tself.option_values.clear\r\n\tend",
"def reset_locale(locale = nil, force = false)\n return if explicit_locale? and !force\n @locale = locale\n @territory = nil\n @data_locale = nil\n @locale_config = nil\n @timezone = nil\n @calendar = nil\n @currency = nil\n @info = {}\n end",
"def reset!\n Unleashed::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Unleashed::Default.options[key])\n end\n\n self\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end",
"def clear_all\n clear_modules\n end",
"def enabled_locales=(values)\n languages = values.reject{|x| x.blank?}\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def all_locales\n locales = slugged_attributes\n .map { |attr| send(\"#{attr}_translations\").keys if respond_to?(\"#{attr}_translations\") }\n .flatten.compact.uniq\n locales = I18n.available_locales if locales.empty?\n locales\n end",
"def reset_locale language\n if language.nil? or language.empty?\n return\n end\n create_base_yml_file_without_missions(language) unless File.exists?(yml_path(language))\n\n I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]\n I18n.locale = language\nend",
"def locales\n @env.locales\n end",
"def enabled_locales=(values)\n languages = values.reject { |x| x.blank? }\n # add default, since it's the configured fallback it must exist\n languages = (languages << I18n.default_locale.to_s).uniq\n self[:enabled_locales] = languages.join(\",\")\n end",
"def clear_system_defaults\n @region = nil if @region == Rudy::DEFAULT_REGION\n @zone = nil if @zone == Rudy::DEFAULT_ZONE\n @environment = nil if @environment == Rudy::DEFAULT_ENVIRONMENT\n @role = nil if @role == Rudy::DEFAULT_ROLE\n @localhost = nil if @localhost == (Rudy.sysinfo.hostname || 'localhost')\n @auto = nil if @auto == false\n end",
"def locales\n EnvironmentLocaleMethodsFactory.new(self)\n end",
"def activate\n\tAVAILABLE_LOCALES.clear.merge!('en-US' => \"English US\", 'mx' =>\"Spanish ES\")\n end",
"def locales\n locale_counts.keys\n end",
"def translated_in=(locales)\n self._locales = locales.map(&:to_sym)\n end",
"def clear\n @already_searched = {}\n Facter.clear_messages\n LegacyFacter.clear\n Options[:custom_dir] = []\n LegacyFacter.collection.invalidate_custom_facts\n LegacyFacter.collection.reload_custom_facts\n SessionCache.invalidate_all_caches\n nil\n end",
"def clear_options\n @entries = {}\n end",
"def clear\n ve 'rm(list=ls())'\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n @read.map do |pattern|\n [pattern, Dir.glob(pattern % {locale: '*'})] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { $1 == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n if re =~ path\n locales << $1\n end\n end\n end\n locales\n end\n end",
"def available_locales\n []\n end",
"def translations reset_cache=false\n return @translations if @translations && !reset_cache\n b = bindings || @bindings\n\n translations = b[:object].translations_by_locale\n new_locales = available_locales - translations.keys.map(&:to_sym)\n\n new_locales.map do |locale|\n translations[locale] = b[:object].translations.new({ locale: locale })\n end\n\n @translations = translations\n end",
"def clear\n @errors.clear\n @warnings.clear\n @notices.clear\n end",
"def test_available_locales\n locales = %w[ar az bg bs ca cs da de el en en-GB es es-PA et eu fa fi fr gl he hr hu id it ja ko lt lv mk mn nl no pl pt pt-BR ro ru sk sl sq sr sr-YU sv th tr uk vi zh zh-TW]\n assert_equal locales.uniq.sort.map(&:to_sym), MessageCustomize::Locale.available_locales\n end",
"def reset_package_sets\n @package_sets.clear\n end",
"def available_locale_preferences\n [@no_preference] + available_locales\n end",
"def reset_defaults_and_overrides\n default.clear\n override.clear\n end",
"def delete_all\n @configuration = nil\n end",
"def delete_all\n @configuration = nil\n end",
"def locales\n map(&:locale)\n end",
"def locales\n self.site.locales || []\n end",
"def clear\n @registry = {}\n end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def available_locales\n locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?\n (locales.presence || [default_locale])\n end",
"def translated_locales\r\n all.distinct(\"locale\").sort{ |x,y| x.to_s <=> y.to_s }.map(&:to_sym)\r\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def reset_themes\n @theme_options = {}\n end",
"def clear_transforms\n rm(\"/augeas/load/*\")\n end",
"def subscriptions_reset\n self.subscriptions = Subscription.defaults\n end",
"def delete_all\n @loaded_constants.each do |const_name|\n if Object.const_defined?(const_name)\n Object.send(:remove_const, const_name)\n end\n end\n Ichiban::HTMLCompiler::Context.clear_user_defined_helpers\n end",
"def clear\n validate_arguments!\n action(\"Removing all domain names from #{app}\") do\n api.delete_domains(app)\n end\n end",
"def clear\n @mutex.synchronize do\n raise ConfigurationLockedError if @locked\n @patterns.clear\n @types.clear\n @categories.clear\n @methods.clear\n end\n self\n end",
"def reset!\n Whitehouse::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Whitehouse::Default.options[key])\n end\n self\n end",
"def clear!\n @all = Set.new\n end",
"def clear_messages\n @messages.clear\n end",
"def reset\n self.configuration = ({})\n config_contexts.values.each(&:reset)\n end",
"def reset(scope = :all)\n case scope\n when :all\n %i[singulars plurals uncountables].map {|s| clear(s) }\n else\n clear(scope)\n end\n end",
"def clear_users\n @users = {}\n end",
"def available_locales; end",
"def available_locales; end",
"def clear\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n projectFile.clear()\n end\n end",
"def clear_messages\n Facter::Log.clear_messages\n end",
"def clear\n require 'rbconfig'\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n \n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n \t\tputs \"hallo\"\n\n system('cls')\n else\n \t\tputs('mac')\n system('clear')\n end\n end",
"def reset\n self.options = nil\n self.option_processors = nil\n end",
"def reset!\n CodesWholesale::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", CodesWholesale::Default.options[key])\n end\n self\n end",
"def clear_symbols\n @interface.clear_symbols\n end",
"def reset_all\n clear_commands\n reset_colors\n @app_info = nil\n @app_exe = nil\n @verbose_parameters = true\n @@default_method = nil\n @@class_cache = {}\n end",
"def clear\n self.configuration = {}\n end",
"def clear_paths\n mutate_config(:paths) do |paths|\n paths.clear\n end\n end",
"def available_translations\n missing_locales = Gallifreyian::Configuration.available_locales - translations.map(&:language)\n missing_locales.each do |locale|\n self.translations << Gallifreyian::Translation::I18nKey.new(language: locale)\n end\n self.translations.order_by({:language => :asc})\n end",
"def reset_formats\n original_formats = [:db, :time, :short, :date, :long, :long_ordinal, :rfc822]\n formats = @@formats.delete_if{|format, v| !original_formats.include?(format)}\n end",
"def reload\r\n translated_attribute_names.each { |name| @attributes.delete(name.to_s) }\r\n globalize.reset\r\n super\r\n end",
"def reset_all_channels\n @channels = {}\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def clear_emails\n all_emails.clear\n self.current_emails = nil\n self.current_email = nil\n end",
"def remove_locale_file language\n File.delete yml_path(language) if File.exists?(yml_path language)\n\n new_load_paths = I18n.load_path.map do |path|\n path unless path.include?(\"#{language}.yml\")\n end.compact\n\n I18n.load_path = new_load_paths\n\n I18n.locale = I18n.default_locale\nend",
"def reload!\n @initialized = false\n @translations = nil\n super\n end",
"def unregister_all\n @@urls = {}\n @@fallback = []\n end",
"def delete_all_modes\n @_modes = nil\n end",
"def clear!\n @handlers = {}\n @environments = {}\n @requests = []\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end"
] |
[
"0.6305831",
"0.63036907",
"0.621971",
"0.61627036",
"0.5980066",
"0.5942033",
"0.5900893",
"0.5896212",
"0.58955187",
"0.5887825",
"0.5867933",
"0.5847686",
"0.5841113",
"0.5746414",
"0.5731636",
"0.5727976",
"0.5725601",
"0.5716796",
"0.5686499",
"0.56807715",
"0.5673065",
"0.56493795",
"0.5621983",
"0.5611831",
"0.55768365",
"0.557474",
"0.55700886",
"0.55242217",
"0.5521029",
"0.55164397",
"0.5508806",
"0.5500171",
"0.5500171",
"0.54961616",
"0.54898816",
"0.548226",
"0.54791456",
"0.5467773",
"0.5467461",
"0.5461156",
"0.54409194",
"0.5385516",
"0.53838694",
"0.538292",
"0.5369316",
"0.5369054",
"0.53643817",
"0.5360707",
"0.5359169",
"0.5353091",
"0.53429425",
"0.5337204",
"0.5316446",
"0.5311905",
"0.53101254",
"0.53093445",
"0.5309255",
"0.5309255",
"0.53058916",
"0.5292327",
"0.52891517",
"0.528098",
"0.52729094",
"0.5267954",
"0.52622443",
"0.52593434",
"0.525885",
"0.5255364",
"0.5254254",
"0.5251427",
"0.52491456",
"0.5248961",
"0.52484643",
"0.5248108",
"0.5237045",
"0.5237022",
"0.522679",
"0.5225033",
"0.5225033",
"0.52062297",
"0.52000797",
"0.51981425",
"0.5198131",
"0.5192889",
"0.5184626",
"0.51808107",
"0.51790035",
"0.5170782",
"0.5166606",
"0.5165828",
"0.5164587",
"0.51629686",
"0.51592773",
"0.51561725",
"0.5153117",
"0.5150426",
"0.51482564",
"0.51470673",
"0.51433814",
"0.5142444"
] |
0.8240911
|
0
|
Returns the current default locale. Defaults to :'en' source://i18n//lib/i18n/config.rb30
|
def default_locale; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def default_locale\n client.default_locale\n end",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def default_locale\n AppConfig.default_locale\n end",
"def default_locale\n FastGettext.available_locales.first\n end",
"def default_language\n @default_language || :en\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def get_locale\n I18n.locale = session[:i18n] || I18n.default_locale || :en\n end",
"def locale\n current_site.locale || I18n.default_locale.to_s\n end",
"def system\n locale_from_env || default_locale\n end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def setup_default_locale\n locale = config.dig(\"locale\").split(\"- \").last\n\n application nil do\n <<~CONFS\n # Default i18n locale\n config.i18n.default_locale = :#{locale}\n\n CONFS\n end\n\n template \"templates/default_locale.tt\", \"config/locales/#{locale}.yml\" if locale != \"en\"\n end",
"def default_lang\n GamePlay::Load::DEFAULT_GAME_LANGUAGE\n end",
"def locale\n if self.language\n LANGUAGE_CODE[self.language]\n end\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n if !language.nil?\n language.abbreviation\n elsif !org.nil?\n org.locale\n end\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def locale\n @locale || { :country => \"US\", :language => \"en\", :variant => nil }\n end",
"def locale\n @locale || YodleeApi.locale\n end",
"def set_default_language\n I18n.locale = :ja\n end",
"def locale\n lang = params.fetch(:language, I18n.default_locale).to_sym\n I18n.available_locales.include?(lang) ? lang : I18n.default_locale\n end",
"def find_locale\n locale = locales.all.detect(&:default)\n return locale.code if locale\n\n default_locale\n end",
"def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end",
"def default_language\n languages.find_by(default: true)\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end",
"def find_best_locale\n browser_locale =\n http_accept_language.preferred_language_from(\n Rails.application.config.automatic_locales\n )\n return browser_locale if browser_locale.present?\n\n I18n.default_locale\n end",
"def locale\n self.padma.try :locale\n end",
"def locale=(locale)\n @@default_locale = locale\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n elsif !self.org.nil?\n return self.org.get_locale\n else\n return nil\n end\n end",
"def locale\n return @locale\n end",
"def locale\n return @locale\n end",
"def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end",
"def locale_language(locale=nil)\n \"#{locale || I18n.locale}\"[0, 2].to_sym\n end",
"def default_locale=(locale); end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def locale\n configatron.ramazon.locale || :us\n end",
"def locale_defaults\n if by_subdomain?\n defaults.merge(subdomain: locale.to_s)\n else\n defaults.merge(locale: locale.to_s)\n end\n end",
"def locale\n favored_locale\n end",
"def get_locale(locale = nil)\n locale || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale\n end",
"def default_language?\n return true unless params[:locale]\n\n params[:locale].to_s == I18n.default_locale.to_s\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_default_main_locale\n self.main_locale = self.content_type.mounting_point.default_locale\n end",
"def locale_from_env\n locale = nil\n # At least one environment valiables should be set on *nix system.\n [ENV[\"LC_ALL\"], ENV[\"LC_MESSAGES\"], ENV[\"LANG\"]].each do |loc|\n\tif loc != nil and loc.size > 0\n\t locale = Locale::Object.new(loc)\n\t locale.charset ||= get_charset(locale)\n\t break\n\tend\n end\n locale\n end",
"def locale_name\n YAML.load(translation || \"{}\").with_indifferent_access[locale] || survey.default_locale_name\n end",
"def current_language\n @@current_language\n end",
"def locale_to_translate_into\n multilanguage_site = settings.multilanguage_site\n default_language = settings.default_language\n if multilanguage_site and session[:locale] != default_language\n session[:locale]\n else\n nil\n end\n end",
"def preferred_language\n mother_tongues.first || self.last_login_language || Language[I18n.default_locale]\n end",
"def set_locale\n if (user_signed_in? && I18n.available_locales.include?(current_user.lang))\n # If a user is signed in, put the preferred language.\n I18n.locale = current_user.lang\n else\n # If there isn't a logged in user, use the default value\n # defined in config.\n I18n.locale = I18n.default_locale\n end\n return\n end",
"def current\n RequestStore.store[:alchemy_current_language] || default\n end",
"def locale_language(locale = nil)\n (locale || I18n.locale).to_s.match(/^(\\w{2})/) ? $1.to_sym : nil\n end",
"def full_locale(lang = I18n.locale)\n case lang\n when :en\n \"en_US\"\n else\n \"#{lang.downcase}_#{lang.upcase}\"\n end\n end",
"def set_default_locale\n if !cookies[:locale] && (default_locale = current_conference.config(:default_locale))\n cookies[:locale] = default_locale\n end\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def user_locale(user = current_user)\n locale = if user && user.language != 'default'\n user.language\n else\n http_accept_language.language_region_compatible_from(I18n.available_locales)\n end\n\n begin\n I18n.locale = locale.tr('-', '_') unless locale.nil?\n rescue\n # Default to English if there are any issues in language\n logger.error(\"Support: User locale is not supported (#{locale}\")\n I18n.locale = \"en\"\n end\n end",
"def options_locale\n current_user.try(:locale) ||\n session[:locale] ||\n http_accept_language.compatible_language_from(I18n.available_locales) ||\n I18n.default_locale\n end",
"def current\n locale = I18n.locale\n @current ||=\n Rails.cache.fetch(\"languages/current/#{locale}\") do\n l = Language.find_by_group(locale)\n l ||= Language.english\n end\n end",
"def not_the_default_current_locale?\n current_site.localized? && current_content_locale.to_s != current_site.default_locale.to_s\n end",
"def not_the_default_current_locale?\n current_site.localized? && current_content_locale.to_s != current_site.default_locale.to_s\n end",
"def full_locale(lang=I18n.locale.to_s)\n if lang == \"en\"\n \"en_US\"\n else\n \"#{lang.downcase}_#{lang.upcase}\"\n end\n end",
"def get_locale_from_session\n if (session && session[:language])\n lang = session[:language]\n else\n lang = default_language\n end\n lang\n end",
"def locale_backend; end",
"def get_locale(host)\r\n host.gsub(I18n.config.host_locale_regex, '\\1') || I18n.default_locale\r\n end",
"def display_language\n default = I18n.locale.try {|l| l.to_s.gsub(/\\-.*$/, '')} || \"en\"\n\n this_doc = self.language_obj.try(:iso_639_1)\n\n return nil if this_doc == default\n\n self.language_str\n end",
"def default_language=(language)\n raise ArgumentError unless [:en, :pt].include?(language.to_sym)\n @default_language = language.to_sym\n end",
"def getLocaleCode\n # first default locale to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # next set locale to the locale in user record\n @locale_code = current_user.try(:locale) || @locale_code\n # next set locale to the locale passed as the locale param\n if (params.present? &&\n params['locale'].present? &&\n BaseRec::VALID_LOCALES.include?(params['locale'].to_s)\n )\n @locale_code = params['locale']\n end\n # set the locale in I18n\n I18n.locale = @locale_code\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n end",
"def locale(force = true)\n @locale || negotiate_locale(force)\n end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def po_locale\n @po_locale\n end",
"def set_locale\n if user_signed_in?\n I18n.locale = current_user.language.to_sym\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def locale\n @values.fetch('ai.device.locale') { \n @values['ai.device.locale'] = nil\n }\n end",
"def get_locale_from_session\n if (session && session[:language])\n logger.debug \"*** Language from Session '#{session[:language]}'\"\n lang = session[:language]\n else\n lang = default_language\n end\n lang\n end",
"def language_code\n if self.class.globalized?\n unless @original_language.nil?\n code = @original_language.code\n else\n code = Globalize::Locale.base_language.code\n end\n elsif Globalize::Locale.language.nil?\n code = Globalize::Locale.base_language.code\n else\n code = Globalize::Locale.language.code\n end\n code\n end",
"def locale\n frontmatter_locale = data['locale'] || data['lang']\n filename_locale = path_part('locale') || path_part('lang')\n\n raise \"The locale in #{path}'s filename (#{filename_locale.inspect}) doesn't match the lang in its frontmatter (#{frontmatter_locale.inspect})\" if frontmatter_locale && filename_locale && frontmatter_locale != filename_locale\n\n default_locale = I18n.default_locale if defined? ::I18n\n\n found_locale = frontmatter_locale || filename_locale || default_locale\n found_locale&.to_sym\n end",
"def locale\r\n read_attribute(:locale).to_sym\r\n end",
"def get(locale = Localization.default_locale)\n @locales[locale.to_s]\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def track_locale\n I18n.locale = session[:current_locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = if user_signed_in?\n current_user.language.to_sym\n else\n I18n.default_locale\n end\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def with_default_locale(&block)\n ::Mongoid::Fields::I18n.with_locale(self.default_locale) do\n yield\n end\n end",
"def default_value\n config[:default]\n end",
"def default_url_options\n { locale: I18n.locale }\n end",
"def default_url_options\n { locale: I18n.locale }\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end"
] |
[
"0.8744718",
"0.85260564",
"0.851315",
"0.8174861",
"0.8157387",
"0.8117677",
"0.81124645",
"0.8079371",
"0.7882876",
"0.78363305",
"0.78314203",
"0.75377023",
"0.74629706",
"0.74251395",
"0.7372892",
"0.7318558",
"0.7318558",
"0.7317624",
"0.7209973",
"0.71269745",
"0.70478725",
"0.703534",
"0.703534",
"0.6996379",
"0.697336",
"0.6972156",
"0.69231135",
"0.68702227",
"0.6865422",
"0.68382037",
"0.68325764",
"0.6819036",
"0.6757899",
"0.67465913",
"0.6721404",
"0.67209446",
"0.66354626",
"0.66011226",
"0.66011226",
"0.65964186",
"0.65827674",
"0.6582141",
"0.65692484",
"0.6569093",
"0.6516988",
"0.65107095",
"0.6491274",
"0.6464859",
"0.6374767",
"0.63662744",
"0.6358024",
"0.6324419",
"0.63240033",
"0.6290466",
"0.6263414",
"0.6249249",
"0.62358594",
"0.62353176",
"0.6191197",
"0.6181999",
"0.61792415",
"0.61644244",
"0.6159113",
"0.6137621",
"0.6132655",
"0.6101367",
"0.6101367",
"0.61006165",
"0.60958296",
"0.60871404",
"0.6086156",
"0.60714805",
"0.6069511",
"0.60334384",
"0.6032917",
"0.6008604",
"0.6008604",
"0.6008604",
"0.6008604",
"0.6008604",
"0.6008604",
"0.6008604",
"0.59928733",
"0.59837794",
"0.5976986",
"0.597209",
"0.59695333",
"0.59694",
"0.5957098",
"0.59411573",
"0.5935868",
"0.59358317",
"0.5934484",
"0.5922759",
"0.5908256",
"0.590644",
"0.5893371",
"0.586895",
"0.586895",
"0.5861832"
] |
0.7483424
|
12
|
Sets the current default locale. Used to set a custom default locale. source://i18n//lib/i18n/config.rb35
|
def default_locale=(locale); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def setup_default_locale\n locale = config.dig(\"locale\").split(\"- \").last\n\n application nil do\n <<~CONFS\n # Default i18n locale\n config.i18n.default_locale = :#{locale}\n\n CONFS\n end\n\n template \"templates/default_locale.tt\", \"config/locales/#{locale}.yml\" if locale != \"en\"\n end",
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def locale=(locale)\n @@default_locale = locale\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_default_language\n I18n.locale = :ja\n end",
"def set_default_main_locale\n self.main_locale = self.content_type.mounting_point.default_locale\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_locale\n\t\tif current_user\n\t\t\tRails.logger.debug { \"Setting locale <#{current_user.country.locale.to_sym}> using current user: #{current_user}\" }\n\t\t\tI18n.locale = current_user.country.locale.to_sym\n\t\telse\n\t\t\tRails.logger.debug { \"Using default locale <#{I18n.default_locale}>, because no user is signed in.\" }\n\t\t\tI18n.locale = I18n.default_locale\n\t\tend\n\tend",
"def set_default_locale\n if !cookies[:locale] && (default_locale = current_conference.config(:default_locale))\n cookies[:locale] = default_locale\n end\n end",
"def set_locale\n I18n.locale = current_user.try(:locale) || I18n.default_locale\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def set_locale\n if (user_signed_in? && I18n.available_locales.include?(current_user.lang))\n # If a user is signed in, put the preferred language.\n I18n.locale = current_user.lang\n else\n # If there isn't a logged in user, use the default value\n # defined in config.\n I18n.locale = I18n.default_locale\n end\n return\n end",
"def default_locale\n client.default_locale\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n if user_signed_in?\n I18n.locale = current_user.language.to_sym\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = if user_signed_in?\n current_user.language.to_sym\n else\n I18n.default_locale\n end\n end",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def default_locale\n AppConfig.default_locale\n end",
"def default_locale; end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n end",
"def set_language\n @lecture.update(locale: I18n.default_locale.to_s)\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def set_locale\n I18n.locale = set_locale_from_params || I18n.default_locale\n Rails.application.routes.default_url_options[:locale]= I18n.locale\n end",
"def with_default_locale(&block)\n ::Mongoid::Fields::I18n.with_locale(self.default_locale) do\n yield\n end\n end",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def set_locale\n if params[:locale]\n I18n.locale = session[:locale] = params[:locale] || I18n.default_locale\n else\n I18n.locale = session[:locale] || I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n if cookies[:locale].nil?\n if signed_in?\n I18n.locale = cookies[:locale] = current_user.language\n end\n #if not signed in, the locale will be the default (en)\n else\n I18n.locale = cookies[:locale]\n end\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end",
"def set_locale\n I18n.locale = cookies[:locale] || params[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale\n end",
"def set_locale\n locale = request.subdomains.first\n locale = (logged_in? ?\n current_user.profile.language :\n browser_language) if locale.blank? || !I18n.available_locales.include?(locale.to_sym)\n I18n.locale = locale\n end",
"def set_locale\n\t\t\tif current_user.present? && current_user.locales.present? && current_user.locales.count == 1\n\t\t\t\tI18n.locale = params[:locale] || current_user.locales.first || I18n.default_locale\n\t\t\telse\n\t\t\t\tI18n.locale = params[:locale] || I18n.default_locale\n\t\t\tend\n\t\tend",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def set_locale\n available = %w{en de}\n I18n.locale = params[:locale] || request.compatible_language_from(available)\n end",
"def set_locale\n locale = params[:locale] || session[:locale] ||\n # (current_user.site_language if user_signed_in?) ||\n I18n.default_locale\n locale = AVAILABLE_LOCALES.keys.include?(locale) ? locale : I18n.default_locale\n session[:locale] = I18n.locale = locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n if logged_in?\n if !current_user.shainmaster.setting.nil?\n if !current_user.shainmaster.setting.local.nil? && current_user.shainmaster.setting.local != ''\n I18n.locale = current_user.shainmaster.setting.local\n end\n end\n end\n end",
"def set_locale\n rxp = Regexp.new('[a-zA-Z]{2}')\n user_locale = cookies[:locale] || params[:locale]\n user_locale = user_locale.present? ? user_locale.scan(rxp) : 'en'\n # Check, is this locale available for using.\n # Please note: this needed for disable invalid locale warning.\n available = I18n.available_locales.include?(user_locale[0].to_sym)\n I18n.locale = available ? user_locale[0] : 'en'\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n #Rails.application.routes.default_url_options[:locale]= I18n.locale \n end",
"def set_locale\n I18n.locale = extract_locale || session[:locale] || I18n.default_locale\n session[:locale] = I18n.locale\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def default_language=(language)\n raise ArgumentError unless [:en, :pt].include?(language.to_sym)\n @default_language = language.to_sym\n end",
"def default_language\n @default_language || :en\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = 'en'\n\n # if params[:locale].present? || session[:locale].present?\n # session[:locale] = params[:locale] if params[:locale].present?\n # I18n.locale = session[:locale]\n # else\n # logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n # I18n.locale = extract_locale_from_accept_language_header\n # logger.debug \"* Locale set to '#{I18n.locale}'\"\n # end\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def set_user_language\n I18n.locale = 'es-VE'\n end",
"def set_locale\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = params[:locale] || locale_from_header || I18n.default_locale\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n Rails.application.routes.default_url_options[:locale]= I18n.locale\n end",
"def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end",
"def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def set_locale\n if params[:locale]\n cookies[:locale] = params[:locale]\n redirect_to request.referer || root_url\n end\n I18n.locale = cookies[:locale] || I18n.default_locale\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def set_locale \n locale = params[:locale]\n locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\n I18n.locale = (locale && I18n.available_locales.include?(locale.to_sym)) ? locale : I18n.default_locale\n end",
"def set_locale\n I18n.select_locale( params[:locale], session[:locale], I18n.from_http_header(request) )\n logger.info \"Using language: #{I18n.locale}\"\n session[:locale] = I18n.locale\n end",
"def default_locale\n FastGettext.available_locales.first\n end",
"def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end"
] |
[
"0.8020997",
"0.7959246",
"0.7887661",
"0.7816902",
"0.74436617",
"0.7337984",
"0.7262668",
"0.7251115",
"0.72001535",
"0.71888775",
"0.71722114",
"0.71719927",
"0.7158044",
"0.71401674",
"0.71401674",
"0.71345735",
"0.7017585",
"0.70039713",
"0.69755846",
"0.6938289",
"0.6904218",
"0.68688005",
"0.68688005",
"0.68322027",
"0.68103695",
"0.68103695",
"0.68103695",
"0.68103695",
"0.6793184",
"0.67883456",
"0.6780049",
"0.6762129",
"0.6749531",
"0.6708974",
"0.6674438",
"0.66385746",
"0.66266984",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.6593679",
"0.65724665",
"0.65396464",
"0.6532393",
"0.6523959",
"0.6523959",
"0.6514542",
"0.65001965",
"0.65000194",
"0.6483663",
"0.64532197",
"0.645113",
"0.64373225",
"0.6436697",
"0.64216423",
"0.6413144",
"0.6411941",
"0.6410155",
"0.64028275",
"0.6398272",
"0.63982433",
"0.6347855",
"0.6331804",
"0.6331269",
"0.6317963",
"0.63090456",
"0.6307742",
"0.6297036",
"0.62965",
"0.6286236",
"0.62837064",
"0.6267476",
"0.6259286",
"0.62540495",
"0.62525433",
"0.6249289",
"0.6243017",
"0.6229481",
"0.6227155",
"0.62132394",
"0.6202133",
"0.61929834",
"0.6186288",
"0.61566097",
"0.6151592",
"0.61485916",
"0.6146361",
"0.61392796",
"0.6129789",
"0.61231685"
] |
0.75714976
|
4
|
Returns the current default scope separator. Defaults to '.' source://i18n//lib/i18n/config.rb75
|
def default_separator; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def period_separator\n '.'\n end",
"def default_line_separator\n @def_line_sep ||= infer_line_separator\n end",
"def default_separator=(separator); end",
"def default_separator(value = T.unsafe(nil)); end",
"def trailing_dots_to_scope_name!\n @hsh = self.class.tdtsn @hsh, scope_name\n end",
"def default_scope\n @default_scope ||= 'entitlements'\n end",
"def scope_name; end",
"def current_scope\n params[:scope].try(:to_sym) || railgun_resource.default_scope.try(:key)\n end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def separator\n return @separator\n end",
"def separator\n \":\"\n end",
"def default_scope\n Configuration::Scope.new(Configuration.new)\n end",
"def scope\n if @scope.kind_of? String\n @scope = @scope.split \",\"\n else\n @scope || []\n end\n end",
"def scope_name scope\n\t\traise \"No data-source set\" unless data_source\n\t\tdata_source.scopes.get(scope).human_name\n\tend",
"def separator\n nil\n end",
"def name_with_separator(locale)\n (name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{name(locale)} \" : name(locale)\n end",
"def name_with_separator(locale)\n (name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{name(locale)} \" : name(locale)\n end",
"def display_scope_path\n\t\t\n\t\tif @current_scope != nil\n\t\t\tnode = @current_scope\n\t\t\tprintout = String(node.scope_number) + \"> \"\n\t\t\t\n\t\t\twhile node.parent != nil\n\t\t\t\tnode = node.parent\n\t\t\t\tprintout = String(node.scope_number) + \"> \" + printout\n\t\t\tend\n\t\t\t\n\t\t\treturn printout\n\t\telse\n\t\t\treturn \"\"\n\t\tend \n\t\t\n\tend",
"def separator\n ','\n end",
"def preferred_delimiters; end",
"def sep; end",
"def sep; end",
"def default_annotation_scope\n if self.default_options[:annotation].blank?\n nil\n else\n # last part of the annotation string\n self.default_options[:annotation].split('--')[2]\n end\n end",
"def current_scope\n @scope\n end",
"def default_scope; end",
"def default_scopes\n Doorkeeper.config.default_scopes.to_a\n end",
"def global_name\n pcs = []\n cursor = self\n begin\n pcs << cursor.name\n cursor = cursor.parent\n end while cursor\n\n pcs.reverse.join(\".\")\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def full_name_with_separator(locale)\n (full_name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{full_name(locale)} \" : full_name(locale)\n end",
"def full_name_with_separator(locale)\n (full_name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{full_name(locale)} \" : full_name(locale)\n end",
"def default_path\n [ (std_path || key).to_s ]\n end",
"def scope_name(scope, task_name)\n (scope + [task_name]).join(':')\n end",
"def default_graphql_name\n to_s.split(\"::\").last.sub(/\\Z/, \"\")\n end",
"def delimiter\n \" \"\n end",
"def delimiter\n \" \"\n end",
"def default_base_path_name\n self.name.split('::').last.downcase\n end",
"def controller_scope_name\n @controller_scope_name ||= 'admin.' + self.class.name.sub(/Controller$/, '').underscore.tr('/', '_')\n end",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def default_param_group_scope\n @scope\n end",
"def with_default(name)\n name.include?('::') ? name : \"#{name}::default\"\n end",
"def with_default(name)\n name.include?('::') ? name : \"#{name}::default\"\n end",
"def get_default_base_dn\n\t\treturn self.root_dse[:namingContexts].first.dn\n\tend",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def global_prefix\n self.class.global_prefix\n end",
"def separator; end",
"def escape_translation_key(key, scope=nil, separator=nil)\n scope ? \"#{scope}#{separator || I18n.default_separator}\\\"#{key}\\\"\" : \"\\\"#{key}\\\"\"\n end",
"def scopes_from(request)\n return nil if request.scope.nil?\n\n Array(request.scope).join(' ')\n end",
"def custom_scope_get scope_name\n\t\t\tThread.current[SESSION].custom_scope_get scope_name\n\t\tend",
"def inferred_separator\n SUPPORTED_SEPARATORS.each do |sep|\n return sep if data.scan(sep).length > 0\n end\n\n raise UnknownFormat.new(@path)\n end",
"def csvColSepChar()\n c = getConf(:csvColSep)\n case(c)\n when :comma, nil ; return \",\" ;\n when :tab ; return \"\\t\" ;\n when :space ; return \" \" ;\n else\n if(c.is_a?(String)) then\n return c ;\n else\n raise \"unknown CSV column separator: '#{c}'\" ;\n end\n end\n end",
"def default_locale\n AppConfig.default_locale\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def ancestor_scope_name(scope)\n return_scope = scope\n while (return_scope = return_scope.parent)\n return return_scope.name unless return_scope.name.nil? || return_scope.block_scope?\n end\n end",
"def excerpt_separator\n @excerpt_separator ||= (data[\"excerpt_separator\"] || site.config[\"excerpt_separator\"]).to_s\n end",
"def scope_name name\n name.to_s.pluralize.to_sym\n end",
"def default_prop_group_scope\n class_scope\n end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def delimiter\n BlacklightBrowseNearby::Engine.config.key_delimiter\n end",
"def format\n self.class.name.split('::').last.downcase.to_sym\n end",
"def default_root(endpoint)\n innermost_scope = if endpoint.respond_to?(:namespace_stackable)\n endpoint.namespace_stackable(:namespace).last\n else\n endpoint.settings.peek[:namespace]\n end\n\n if innermost_scope\n innermost_scope.space\n else\n endpoint.options[:path][0].to_s.split('/')[-1]\n end\n end",
"def prompt_separator\n @prompt_separator ||= defined?(RbReadline) ? '>' : \"\\u00BB\"\n end",
"def initials_string\n if @initials.nil? \n nil\n else \n @initials.join(\".\") + \".\" \n end \n end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def base_name\n @base_name ||= if base = name.to_s.split(\"::\").first\n base.underscore\n end\n end",
"def path_sep=(val)\n Vitals::Utils.path_sep = val\n end",
"def get_current_scope\n get_current_hub&.current_scope\n end",
"def preferred_locales_str\n (preferred_locales || []).join(\",\")\n end",
"def separator=(value)\n @separator = value\n end",
"def owners_locale\n default = :\"en-US\"\n if self.owner.is_a?(Person)\n self.owner.default_locale || default\n elsif self.owner.is_a?(Tier)\n self.owner.default_locale || default\n else\n default\n end\n end",
"def module_name(scope)\n scope.logical_path\n end",
"def current\n\t\t\t\t\treturn Pathname.new(\".\")\n\t\t\t\tend",
"def default_column_prefix\n \"\"\n end",
"def notice_scope_name\n 'notices.' + controller_scope_name\n end",
"def current_scope\n if ss = method.staticscope\n return ss.module\n else\n home.current_scope\n end\n end",
"def i18n_scope\n @i18n_scope ||= nil\n end",
"def scope_names\n keys.map { |k| k.to_s }\n end",
"def namespace_name\n @namespace_name ||= namespaces.join('::')\n end",
"def stringify_joiner\n \"__\"\n end",
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def current_sep\n active_seps.max { |sep| sep.end_date }\n end",
"def left_delimiter\n @left_delimiter || World.left_delimiter\n end",
"def default_tree_name\n ''\n end",
"def account_prefix\n current_account.account_prefix\n end",
"def locale_scope\n I18n::Scope.new(locale_translations)\n end",
"def thousands_separator; end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def i18n_scope\n self.class.i18n_scope\n end",
"def to_s\n format(:default)\n end",
"def join(symbols = {}, scope = \"\")\n self.inject(\"\") do |ss, s|\n (ss.empty? ? \"\" : ss + self.class.format) + s.to_s(symbols, scope)\n end\n end",
"def ancestors_name\n if parent\n \"#{parent.ancestors_name} #{parent.name}:\"\n else\n \"\"\n end\n end",
"def _default_param_group_scope\n @param_group && @param_group[:scope]\n end",
"def default_locale\n client.default_locale\n end",
"def lsep\n \"==================================================================================\"\n end",
"def global_name\n @appl_settings[:global_dir]\n end",
"def default_locale; end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end",
"def namespace\n return self.name ? self.name.downcase.gsub(/[^0-9A-Za-z ]/, '').gsub(' ', '-') : ''\n end",
"def pedant_orgname\n Pedant::Config.use_default_org ? Pedant::Config.default_orgname : Pedant::Config[:org][:name]\n end"
] |
[
"0.6190831",
"0.61389744",
"0.606381",
"0.58894265",
"0.5763356",
"0.567675",
"0.55871004",
"0.55486345",
"0.55370724",
"0.5493453",
"0.5467525",
"0.5446332",
"0.5423758",
"0.53667825",
"0.53614277",
"0.5360762",
"0.5360762",
"0.53599805",
"0.5357077",
"0.53401446",
"0.5319591",
"0.5319591",
"0.5301295",
"0.52948904",
"0.52945495",
"0.52738184",
"0.5260512",
"0.5258756",
"0.52542734",
"0.52542734",
"0.52344483",
"0.5234212",
"0.523403",
"0.52118784",
"0.52118784",
"0.52081054",
"0.52068007",
"0.5204773",
"0.51821536",
"0.51497954",
"0.51497954",
"0.51208764",
"0.51152873",
"0.5113405",
"0.51067793",
"0.5036206",
"0.5027232",
"0.5027071",
"0.50249684",
"0.50124425",
"0.4986616",
"0.4985362",
"0.49846703",
"0.49829003",
"0.49765247",
"0.4974043",
"0.4965586",
"0.49643788",
"0.4958443",
"0.49582338",
"0.4955498",
"0.4942396",
"0.4914195",
"0.49020934",
"0.490171",
"0.4900647",
"0.48969465",
"0.489583",
"0.48957372",
"0.4895547",
"0.4876168",
"0.48755127",
"0.48672158",
"0.48520765",
"0.48498285",
"0.4849501",
"0.48392567",
"0.48378268",
"0.4833772",
"0.4832967",
"0.48324987",
"0.48312682",
"0.48308972",
"0.48296916",
"0.48241448",
"0.48137888",
"0.48050603",
"0.47944912",
"0.47944912",
"0.47875854",
"0.47835422",
"0.4773315",
"0.47731578",
"0.47705266",
"0.47694883",
"0.47693616",
"0.47678533",
"0.47677076",
"0.47652698",
"0.47629282"
] |
0.63961184
|
0
|
Sets the current default scope separator. source://i18n//lib/i18n/config.rb80
|
def default_separator=(separator); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_line_separator\n @def_line_sep ||= infer_line_separator\n end",
"def default_separator; end",
"def default_separator(value = T.unsafe(nil)); end",
"def separator=(value)\n @separator = value\n end",
"def path_sep=(val)\n Vitals::Utils.path_sep = val\n end",
"def separator\n \":\"\n end",
"def separator\n nil\n end",
"def default_locale=(locale); end",
"def preferred_delimiters; end",
"def separator; end",
"def normalize_list_style(default = :space)\n case self\n when /^c(om|sv)/i\n :comma\n when /^c/i\n :column\n when /^t/i\n :tab\n else\n default.is_a?(Symbol) ? default : default.normalize_list_style\n end\n end",
"def separator\n ','\n end",
"def sep; end",
"def sep; end",
"def name_with_separator(locale)\n (name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{name(locale)} \" : name(locale)\n end",
"def name_with_separator(locale)\n (name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{name(locale)} \" : name(locale)\n end",
"def escape_translation_key(key, scope=nil, separator=nil)\n scope ? \"#{scope}#{separator || I18n.default_separator}\\\"#{key}\\\"\" : \"\\\"#{key}\\\"\"\n end",
"def period_separator\n '.'\n end",
"def option_separator(text = '')\n @cl_parser.separator(text)\n end",
"def on_words_sep(token)\n log \"WORDS_SEP: '#{token}'\"\n super(token)\n end",
"def set_default_indent(line)\n $default_indent = count_indent(line)\nend",
"def prompt_separator\n @prompt_separator ||= defined?(RbReadline) ? '>' : \"\\u00BB\"\n end",
"def separator\n return @separator\n end",
"def reset_separator_levels par\n paragraph_level=par['level']\n chars=par['characters']\n len=chars.length\n before_sep=true\n (len-1).downto 0 do |ind|\n char=chars[ind]\n if char['bidiType']=='B' or char['bidiType']=='S'\n before_sep=true\n char['level']=paragraph_level\n next\n end\n char['level']=paragraph_level if char['bidiType']=='WS' and before_sep\n before_sep = false if char['bidiType'] != 'WS'\n end\n end",
"def separator\n @parts.push(separator: true)\n end",
"def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end",
"def set_delimiter delim\n @lt2_delimiter = case delim\n when Regexp\n delim\n else\n delim.to_s\n end\n end",
"def default_scope\n @default_scope ||= 'entitlements'\n end",
"def scope\n if @scope.kind_of? String\n @scope = @scope.split \",\"\n else\n @scope || []\n end\n end",
"def separator(str)\n # We store separators as simple strings in the options array to maintain\n # order. They are ignored by the parser.\n @@options << str\n end",
"def trailing_dots_to_scope_name!\n @hsh = self.class.tdtsn @hsh, scope_name\n end",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def default_scope; end",
"def lsep\n \"==================================================================================\"\n end",
"def default_locale; end",
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def set_delimiters(start, stop)\n @start_delim = start\n @stop_delim = stop\n puts \"FileGenTask: Setting token delimeters to #{@start_delim}, #{@stop_delim}\" if @verbose\n end",
"def i18n_scope=(scope)\n @i18n_scope = scope\n end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def locale=(locale)\n @@default_locale = locale\n end",
"def default_scope\n Configuration::Scope.new(Configuration.new)\n end",
"def setup_default_locale\n locale = config.dig(\"locale\").split(\"- \").last\n\n application nil do\n <<~CONFS\n # Default i18n locale\n config.i18n.default_locale = :#{locale}\n\n CONFS\n end\n\n template \"templates/default_locale.tt\", \"config/locales/#{locale}.yml\" if locale != \"en\"\n end",
"def full_name_with_separator(locale)\n (full_name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{full_name(locale)} \" : full_name(locale)\n end",
"def full_name_with_separator(locale)\n (full_name(locale).include?(\" \") && locale.to_s.eql?(\"fi\")) ? \"#{full_name(locale)} \" : full_name(locale)\n end",
"def default_param_group_scope\n @scope\n end",
"def default_scope=(_arg0); end",
"def translate_with_namespace(namespace, arg = nil, default = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def delimiter\n \" \"\n end",
"def delimiter\n \" \"\n end",
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def locale_defaults\n if by_subdomain?\n defaults.merge(subdomain: locale.to_s)\n else\n defaults.merge(locale: locale.to_s)\n end\n end",
"def csvColSepChar()\n c = getConf(:csvColSep)\n case(c)\n when :comma, nil ; return \",\" ;\n when :tab ; return \"\\t\" ;\n when :space ; return \" \" ;\n else\n if(c.is_a?(String)) then\n return c ;\n else\n raise \"unknown CSV column separator: '#{c}'\" ;\n end\n end\n end",
"def set_locale\n\t\tif current_user\n\t\t\tRails.logger.debug { \"Setting locale <#{current_user.country.locale.to_sym}> using current user: #{current_user}\" }\n\t\t\tI18n.locale = current_user.country.locale.to_sym\n\t\telse\n\t\t\tRails.logger.debug { \"Using default locale <#{I18n.default_locale}>, because no user is signed in.\" }\n\t\t\tI18n.locale = I18n.default_locale\n\t\tend\n\tend",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def on_semicolon(token)\n log \"SEMICOLON: '#{token}'\"\n super(token)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def define_scopes(custom_plural = T.unsafe(nil)); end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def excerpt_separator\n @excerpt_separator ||= (data[\"excerpt_separator\"] || site.config[\"excerpt_separator\"]).to_s\n end",
"def delimiter_always_precedes_last!\n options[:'delimiter-precedes-last'] = :always\n self\n end",
"def inferred_separator\n SUPPORTED_SEPARATORS.each do |sep|\n return sep if data.scan(sep).length > 0\n end\n\n raise UnknownFormat.new(@path)\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def default_locale\n AppConfig.default_locale\n end",
"def fix_separators!(separator)\n return self if separator.nil? || separator.empty?\n\n r = Regexp.escape(separator)\n\n # No more than one of the separator in a row.\n substitute!(/#{r}{2,}/, separator)\n\n # Remove leading/trailing separator.\n substitute!(/^#{r}|#{r}$/i, '')\n end",
"def locale_scope\n I18n::Scope.new(locale_translations)\n end",
"def separator(type); end",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def project_separator_add(project_id, separator)\n put(\"/projects/#{project_id}/separators\", nil, separator)\n end",
"def thousands_separator; end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def scope=(val)\n set_scope(val)\n val\n end",
"def sequence_separator=(_arg0); end",
"def sequence_separator=(_arg0); end",
"def set_locale\n locale = request.subdomains.first\n locale = (logged_in? ?\n current_user.profile.language :\n browser_language) if locale.blank? || !I18n.available_locales.include?(locale.to_sym)\n I18n.locale = locale\n end",
"def delimiter_contextually_precedes_last!\n options[:'delimiter-precedes-last'] = :contextual\n self\n end",
"def sequence_separator; end",
"def prefix(default)\n case default\n when Symbol then ':'\n when String then '\"'\n when Time, Date, DateTime then '\"'\n end\n end",
"def locale=(locale); end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end"
] |
[
"0.6848044",
"0.67540807",
"0.62274724",
"0.609345",
"0.5825628",
"0.53762394",
"0.5374709",
"0.5310626",
"0.52978414",
"0.52885926",
"0.52831006",
"0.52605486",
"0.5254276",
"0.5254276",
"0.5233846",
"0.5233846",
"0.5230837",
"0.52280027",
"0.51832384",
"0.51468235",
"0.5114898",
"0.50812465",
"0.5076923",
"0.5073715",
"0.50633454",
"0.5062346",
"0.5062035",
"0.50579053",
"0.50552094",
"0.50142926",
"0.500376",
"0.4991693",
"0.4973136",
"0.49703273",
"0.4963646",
"0.49591285",
"0.48834848",
"0.48805374",
"0.48643523",
"0.4854345",
"0.48410925",
"0.48380044",
"0.4832336",
"0.48272917",
"0.48272917",
"0.48149273",
"0.4805248",
"0.4757404",
"0.4749103",
"0.4749103",
"0.4742519",
"0.4741068",
"0.47375077",
"0.4737425",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4732234",
"0.4731479",
"0.47303662",
"0.47303662",
"0.4723328",
"0.4723328",
"0.47156852",
"0.47039452",
"0.47016603",
"0.46804008",
"0.46670917",
"0.46559018",
"0.46556437",
"0.46502918",
"0.46468434",
"0.46449372",
"0.46448007",
"0.4643201",
"0.46417361",
"0.46409976",
"0.463995",
"0.4627266",
"0.46253112",
"0.46252903",
"0.46252903",
"0.46178514",
"0.4616613",
"0.46153557",
"0.46151608",
"0.46136552",
"0.46127328",
"0.46127328",
"0.46127328",
"0.46127328",
"0.46127328",
"0.46127328"
] |
0.7294296
|
0
|
Returns the current exception handler. Defaults to an instance of I18n::ExceptionHandler. source://i18n//lib/i18n/config.rb86
|
def exception_handler; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def exception_handler\n @exception_handler ||= {}\n end",
"def get_exception_handler(e)\n table = self.class.exception_handler\n e.class.ancestors.each do |mod|\n return table[mod] if table.has_key?(mod)\n end\n end",
"def config\n Wrangler::ExceptionHandler.config\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def error_handler\n @error_handler || DEFAULT_ERROR_HANDLER\n end",
"def custom_exception_handler(exception)\n custom_exception_handlers[exception.to_s]\n end",
"def error_handler()\n return @error_handler unless @error_handler.nil?\n eh = find_task(:error)\n return eh unless eh.nil?\n @env.error_handler\n end",
"def exception\n @context[:exception]\n end",
"def current_handler\n @current_handler || @default_handler\n end",
"def get_handler\n handler = YAML.load(self.code)\n # If it could not be deserialized property try registering its class\n # Constantize supposedly only converts a string into the constant,\n # but somehow it is allowing YAML to create the correct instance.\n # Black magic, clearly, but it works, as black magic usually does.\n if handler.instance_of? YAML::Object\n handler.class.constantize\n handler = YAML.load(self.code)\n end\n\n handler\n end",
"def exception_handling_data(e)\n self.rescue_handlers.each do |handler|\n return handler if (handler.key?(:exception_classes) && handler[:exception_classes].include?(e.class))\n if handler.key?(:exception_ancestor_classes)\n handler[:exception_ancestor_classes].each do |ancestor|\n return handler if e.class.ancestors.include?(ancestor)\n end\n elsif !handler.key?(:exception_classes) && !handler.key?(:exception_ancestor_classes)\n return handler\n end\n end\n nil\n end",
"def message\n configuration.default_message || @exception.message\n end",
"def handler_for_rescue(exception) # :nodoc:\n self.class.handler_for_rescue exception, object: self\n end",
"def default_error_handler( state, node, exception )\n\t\tcase self.options[:on_render_error].to_s\n\t\twhen 'ignore'\n\t\t\tself.log.debug \" not rendering anything for the error\"\n\t\t\treturn ''\n\n\t\twhen 'comment'\n\t\t\tself.log.debug \" rendering error as a comment\"\n\t\t\tmsg = \"%s: %s\" % [ exception.class.name, exception.message ]\n\t\t\tif self.options[:debugging_comments]\n\t\t\t\texception.backtrace.each {|line| msg << \"\\n\" << line }\n\t\t\tend\n\t\t\treturn self.make_comment( msg )\n\n\t\twhen 'propagate'\n\t\t\tself.log.debug \" propagating error while rendering\"\n\t\t\traise( exception )\n\n\t\telse\n\t\t\traise Inversion::OptionsError,\n\t\t\t\t\"unknown exception-handling mode: %p\" % [ self.options[:on_render_error] ]\n\t\tend\n\tend",
"def exception_handler=(exception_handler); end",
"def rescue_with_handler(exception)\n to_return = super\n if to_return\n verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?\n logger.info(\"[RESCUE STYLE] rescue_with_handler\") if verbose\n data = get_exception_data\n status_code = status_code_for_exception(exception)\n #We only send email if it has been configured in environment\n send_email = should_email_on_exception?(exception, status_code, verbose)\n #We only send web hooks if they've been configured in environment\n send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)\n the_blamed = ExceptionNotification::Notifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)\n rejected_sections = %w(request session)\n # Debugging output\n verbose_output(exception, status_code, \"rescued by handler\", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose\n # Send the exception notification email\n perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email\n # Send Web Hook requests\n ExceptionNotification::HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotification::Notifier.config, exception, self, request, data, the_blamed) if send_web_hooks\n pass_it_on(exception, ENV, verbose)\n end\n to_return\n end",
"def middleware\n @middleware ||= ExceptionalMiddleware::MiddlewareStack.new\n end",
"def exception_handler(&hndlr)\n @j_del.exceptionHandler(hndlr)\n self\n end",
"def handler\n @handler ||=\n case ENV['HANDLER'] || Config::CONFIG['host_os']\n when /darwin|mach|osx|fsevents?/i\n if Watchr::HAVE_FSE\n Watchr::EventHandler::Darwin\n else\n Watchr.debug \"fsevent not found. `gem install ruby-fsevent` to get evented handler\"\n Watchr::EventHandler::Portable\n end\n when /sunos|solaris|bsd|linux|unix/i\n if Watchr::HAVE_COOLIO\n Watchr::EventHandler::Unix\n else\n Watchr.debug \"coolio not found. `gem install coolio` to get evented handler\"\n Watchr::EventHandler::Portable\n end\n when /mswin|windows|cygwin/i\n Watchr::EventHandler::Portable\n else\n Watchr::EventHandler::Portable\n end\n end",
"def exception_class; end",
"def service_exception\n if current_module.const_defined?('ServiceException')\n current_module.const_get('ServiceException')\n else\n current_module.const_set('ServiceException', Class.new(Common::Exceptions::BackendServiceException))\n end\n end",
"def exception\n request.env['action_dispatch.exception']\n end",
"def set_exception_handler(context)\r\n # construct and set exception handler in current frame\r\n if @current_exception_table then\r\n cursig = context.to_signature\r\n ncontext = context.dup\r\n handler = CodeSpace.new\r\n oldcs = ncontext.set_code_space(handler)\r\n casm = ncontext.assembler\r\n\r\n # rescue\r\n if entbasetab = @current_exception_table[:rescue] then\r\n entbasetab.each do |ents|\r\n ent = ents[3]\r\n if ent then\r\n csadd = ent.get_code_space(cursig).var_base_address\r\n casm.with_retry do\r\n casm.call(csadd)\r\n end\r\n end\r\n end\r\n end\r\n\r\n # ensure\r\n ent = nil\r\n if entbasetab = @current_exception_table[:ensure] then\r\n casm.with_retry do\r\n casm.push(TMPR) # ensure returns no value\r\n end\r\n entbasetab.each do |ents|\r\n ent = ents[3]\r\n if ent then\r\n csadd = ent.get_code_space(cursig).var_base_address\r\n casm.with_retry do\r\n casm.call(csadd)\r\n end\r\n end\r\n end\r\n casm.with_retry do\r\n casm.pop(TMPR)\r\n end\r\n end\r\n\r\n casm.with_retry do\r\n casm.pop(TMPR3)\r\n casm.pop(PROFR)\r\n end\r\n\r\n enode = @frame_info.parent.end_nodes[0]\r\n ncontext = enode.gen_method_epilogue(ncontext)\r\n \r\n casm.with_retry do\r\n casm.jmp(TMPR3)\r\n end\r\n \r\n context.set_code_space(oldcs)\r\n foff = @frame_info.parent.frame_offset\r\n handoff = AsmType::MACHINE_WORD.size * 2 + foff\r\n handop = OpIndirect.new(BPR, handoff)\r\n casm = context.assembler\r\n casm.with_retry do\r\n casm.mov(handop, handler.var_base_immidiate_address)\r\n end\r\n context.set_reg_content(handoff, :first_exception_entry)\r\n end\r\n\r\n context\r\n end",
"def exception\n @__exception\n end",
"def rescue_with_handler(exception)\n self.class.rescue_with_handler exception, object: self\n end",
"def exception\n @exception&.object\n end",
"def error_handler()\n @error_handler\n end",
"def error_handler()\n return @error_handler unless @error_handler.nil?\n @flow.error_handler()\n end",
"def handler\n @handler ||= Type.for(type).new(type_options)\n rescue StandardError => ex\n raise ex, \"#{name}: #{ex.message}\"\n end",
"def on_exception( handler = nil, &block )\n @exception_handler_method = handler\n @exception_handler_block = block\n end",
"def find_error_handler(response_params)\n instance.error_handlers.reverse_each do |error_handler|\n result = error_handler.call(instance, response_params)\n return result unless result.nil?\n end\n nil\n end",
"def handler(error_class)\n error_class.kind_of?(String) ? key = error_class : key = error_class.to_s\n handlers.has_key?(key) ? handlers.fetch(key) : raise(WebFlowError.new, \"There's no handler defined for the error class '#{key}'.\")\n end",
"def define_exception_handler(data)\n exception_handler.merge!(data)\n end",
"def framework_exception(env)\n env['action_dispatch.exception'] ||\n env['sinatra.error'] ||\n env['rack.exception']\n end",
"def framework_exception(env)\n env['action_dispatch.exception'] ||\n env['sinatra.error'] ||\n env['rack.exception']\n end",
"def find_handler_class location\n @@archive_handlers.each do |h|\n return h if h.handles?(location)\n end\n return nil\n end",
"def exception_handler\n if block_given?\n @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling exception_handler()\"\n end",
"def error_handler\n begin\n yield\n rescue => exception\n options = Rails.env.development? ? {:backtrace => exception.backtrace, :class => exception.class.to_s} : {}\n render_error(exception.message, options)\n end\n end",
"def raise_handler_error\n raise Error, \"Handler needs to be a class name or a symbol name\"\n end",
"def default_handler\n @default_handler\n end",
"def exception_handler(ex)\n \nend",
"def exceptions_app; end",
"def exceptions_app; end",
"def context\n @context ||= [{'server' => hostname, 'type' => 'exception'}]\n end",
"def current_context\n context = Validation::Context.current\n valid_context?(context) ? context : :default\n end",
"def handle_exception(exception, options = {})\n request = options[:request]\n render_errors = options[:render_errors] || false\n proc_name = options[:proc_name] || config[:app_name]\n error_messages = options[:error_messages] || ['']\n\n error_messages = [error_messages] unless error_messages.is_a?(Array)\n\n if exception.respond_to?(:backtrace)\n backtrace = exception.backtrace\n else\n backtrace = caller\n end\n\n # extract the relevant request data and also filter out any params\n # that should NOT be logged/emailed (passwords etc.)\n request_data = request_data_from_request(request) unless request.nil?\n\n supplementary_info = nil\n\n unless config[:call_for_supplementary_info].nil?\n supplementary_info = config[:call_for_supplementary_info].call(request)\n supplementary_info = [supplementary_info] unless supplementary_info.is_a?(Array)\n end\n\n unless supplementary_info.blank?\n error_messages << \"Supplementary info:\"\n error_messages += supplementary_info\n end\n\n if exception.nil?\n exception_classname = nil\n status_code = nil\n log_error error_messages.inspect\n log_error backtrace\n log_error \"Request params were:\"\n log_error request_data.to_yaml\n error_string = error_messages.shift\n else\n status_code =\n Wrangler::ExceptionHandler.status_code_for_exception(exception)\n\n log_exception(exception, request_data, status_code, error_messages)\n\n if exception.is_a?(Class)\n exception_classname = exception.name\n else\n exception_classname = exception.class.name\n end\n\n if exception.respond_to?(:message)\n error_string = exception.message\n else\n error_string = exception.to_s\n end\n end\n\n if send_notification?(exception, request, status_code)\n if notify_with_delayed_job?\n # don't pass in request as it contains not-easily-serializable stuff\n log_error \"Wrangler sending email notification asynchronously\"\n Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,\n exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data)\n else\n log_error \"Wrangler sending email notification synchronously\"\n Wrangler::ExceptionNotifier.deliver_exception_notification(exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data,\n request)\n end\n end\n\n if render_errors\n render_error_template(exception, status_code)\n end\n\n rescue Exception => unhandled_exception\n # if it looks like a temporary error interacting with SMTP, then enqueue\n # the error using delayed job if possible\n # (testing by name this way in case the exception isn't loaded into\n # environment, which would cause a NameError and be counterproductive...)\n if unhandled_exception.class.name == 'Net::SMTPAuthenticationError' &&\n Wrangler::ExceptionNotifier.respond_to?(:send_later)\n\n log_error \"Wrangler failed to send error notification: #{unhandled_exception.class.name}:\"\n log_error \" #{unhandled_exception.to_s}\"\n\n # note: this is specific to an old-ish version of delayed job...should\n # make wrangler compatible with the old and the new...\n log_error \"Wrangler attempting to send via delayed job\"\n Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,\n exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data)\n else\n log_error \"/!\\\\ FAILSAFE /!\\\\ Wrangler encountered an unhandled exception \" +\n \"while trying to handle an error. The arguments it received \" +\n \"were:\"\n log_error \" exception: #{exception.inspect}\"\n log_error \" options: #{options.inspect}\"\n log_error \"The unhandled error encountered was #{unhandled_exception.class.name}:\"\n log_error \" #{unhandled_exception.to_s}\"\n end\n end",
"def in_exception_context?; end",
"def error_handling\n @@error_handling ||= nil\n end",
"def handler\n @handler ||= MailboxHandler.new(@mailbox, imap)\n end",
"def bounced_email_handler\n if @__bounced_email_handler.is_a?(String)\n @__bounced_email_handler = @__bounced_email_handler.constantize\n end\n @__bounced_email_handler\n end",
"def exception_context(exception)\n context(:exception => exception.class.to_s)\n end",
"def handler_name\n module_info['HandlerName']\n end",
"def default_exception_renderer=(_arg0); end",
"def exception_hook=(val); @rye_exception_hook = val; end",
"def handlers_for_exception(exception)\n prioritized_handlers.select { |handler| handler === exception }\n end",
"def type\n @exception.class.to_s\n end",
"def __value\n unless defined?(@value)\n __get_value\n end\n\n if @value.is_a?(WrappedException)\n ::Kernel.raise @value\n end\n\n @value\n end",
"def step_1_exceptions\n @step_1_exceptions ||= load_settings(\"step_1_exceptions\")\n end",
"def handler(filename)\n Template.handlers.each do |pattern, klass|\n return klass if filename =~ pattern\n end\n warning { \"No template handler found for: #{filename}\" }\n Template::Runner::Base\n end",
"def handler_config\n\t\treturn self.configured_handlers.where(\n\t\t\tsend_spec: self.conn.sub_addr,\n\t\t\trecv_spec: self.conn.pub_addr\n\t\t).first\n\tend",
"def exception_callback\n @exception_callback\n end",
"def step_0_exceptions\n @step_0_exceptions ||= load_settings(\"step_0_exceptions\")\n end",
"def handler_for(path)\n handler[ path.split('.').last ]\n end",
"def rescue_with_handler(exception)\n\t\tif current_user and current_user.is_administrator?\n\t\t\treturn\n\t\t\t@exception = exception\n\t\tend\n\t\t\n\t\tif current_user\n\t\t\trender template: \"errors/500\"\n\t\telse\n\t\t\trender template: \"errors/500\", layout:\"login\"\n\t\tend\n\tend",
"def handler_base_class; end",
"def run_custom_exception_handling(exception)\n case handler = custom_exception_handler(exception)\n when String\n write handler \n when Symbol\n self.send(custom_exception_handler(exception))\n end\n end",
"def exceptions\n @exceptions ||= key[:exceptions]\n end",
"def set_admin_sidekiq_exception\n @admin_sidekiq_exception = Admin::SidekiqException.find(params[:id])\n end",
"def error_type\n @error_type ||=\n if (c = self_class)\n type = c.safe_const_get(:ERROR_TYPE)\n type ||= c.name&.demodulize&.to_s&.underscore&.remove(/_error$/)\n type&.to_sym\n end\n end",
"def exception_set\n return @children['exception-set'][:value]\n end",
"def exceptions\n return @exceptions\n end",
"def exceptions\n return @exceptions\n end",
"def handle_exception(endpoint, e, t0)\n fatal = @options[:fatal] || DEFAULT_FATAL_PROC\n\n #The option may be a proc or lambda; call it to get input\n fatal = fatal.call(e) if fatal.respond_to?(:call)\n\n #The options may be single exception classes, in which case we want to expand\n #it out into a list\n fatal = [fatal] if fatal.is_a?(Class)\n\n #The option may be a list of exception classes, in which case we want to evaluate\n #whether the exception we're handling is an instance of any mentioned exception\n #class\n fatal = fatal.any?{ |c| e.is_a?(c) } if fatal.respond_to?(:any?)\n duration = sprintf('%.4f', Time.now - t0)\n msg = \"RequestBalancer: rescued #{fatal ? 'fatal' : 'retryable'} #{e.class.name} during request to #{endpoint}: #{e.message} after #{duration} seconds\"\n logger.error msg\n @options[:on_exception].call(fatal, e, endpoint) if @options[:on_exception]\n\n if fatal\n #Final decision: did we identify it as fatal?\n return e\n else\n return nil\n end\n end",
"def exception_message\n @e_m ||= @exception.nil? ? '' : @exception.message\n end",
"def translation_class\n const_get translation_class_name\n end",
"def express_error_context resource\n I18n.t \"errors.action.#{params[:controller]}.#{params[:action]}.#{resource.class.model_name.i18n_key}\",\n default: \"Couldn't #{params[:action]} the #{resource.class.to_s.downcase}\"\n end",
"def exception_renderer; end",
"def dispatch_default_exception(klass, request, response, e)\n controller = klass.build(request, response, e.class::STATUS)\n if e.is_a? ControllerExceptions::Redirection\n controller.headers.merge!('Location' => e.message)\n controller.instance_variable_set(\"@_body\", %{ }) #fix\n else\n @exception = e # for ERB\n controller.instance_variable_set(\"@_body\", DEFAULT_ERROR_TEMPLATE.result(binding))\n end\n [controller, e.name]\n end",
"def on_exception(&f)\n @on_exception = f\n end",
"def logger\n @logger ||= Esi.config.logger || Logger.new(Esi.config.log_target).tap do |l|\n l.level = Logger.const_get(Esi.config.log_level.upcase)\n end\n end",
"def exception_cause(ex)\n if ex.respond_to?(:cause)\n ex.cause\n elsif ex.respond_to?(:parent)\n ex.parent\n else\n nil\n end\n end",
"def get_handler(handle_name)\n return @handlers.find {|handler| handler.name == handle_name }\n end",
"def interrupt_handler\n @interrupt_handler ||= {}\n end",
"def exception\n @local_task.exception\n end",
"def enter_exception_context(exception); end",
"def handler_for_code(code)\n @handlers.fetch(code, method(:unhandled))\n end",
"def exceptions\n @values['exceptions']\n end",
"def resource_exception\n remote_errors.exception || super\n end",
"def exception\n exception_class = error_class\n return unless exception_class\n\n exception_class.new(nil, stdout, stderr)\n end",
"def egregious_exception_handler(exception)\n egregious_flash(exception)\n egregious_log(exception)\n egregious_respond_to(exception)\n end",
"def set_error_handler handler\n @station.error_handler = handler\n end",
"def on_exception(&blk)\n @on_exception = blk\n end",
"def handle(remote_exception)\n handlers_for_exception(remote_exception.exception).each do |handler|\n handler.handle(remote_exception)\n break if remote_exception.action?\n end\n nil\n end",
"def parent_mailer_class\n config[:parent_mailer].presence&.constantize || EffectiveResources.parent_mailer_class\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def handle_exception(e, msg = '') # :nodoc:\n if USE_NEW_EXCEPTION\n http_exception = Net::HTTPClientException\n else\n http_exception = Net::HTTPServerException\n end\n case e\n when http_exception, SocketError, Errno::ECONNREFUSED\n msg = \"unable to connect to the validator at #{@validator_uri} (response was #{e.message}).\"\n raise ValidatorUnavailable, msg, caller\n when JSON::ParserError, Nokogiri::XML::SyntaxError\n msg = \"unable to parse the response from the validator.\"\n raise ParsingError, msg, caller\n else\n raise e\n end\n\n if e.respond_to?(:error_handler_before)\n fcall(e, :error_handler_before, self)\n end\n\n if e.respond_to?(:error_handler_instead)\n fcall(e, :error_handler_instead, self)\n else\n if e.respond_to? :status\n exit_status(( e.status ))\n end\n\n if SystemExit === e\n stderr.puts e.message unless(SystemExit === e and e.message.to_s == 'exit') ### avoids double message for abort('message')\n end\n end\n\n if e.respond_to?(:error_handler_after)\n fcall(e, :error_handler_after, self)\n end\n\n exit_status(( exit_failure )) if exit_status == exit_success\n exit_status(( Integer(exit_status) rescue(exit_status ? 0 : 1) ))\n exit exit_status\n end",
"def endpoint\n @endpoint ||= subclass(:Endpoint).new @locale\n end",
"def raise_exceptions\n al = @alerts.sort.first\n raise ValidationError.from_alert(al) if al && al.type == :error\n self\n end",
"def error_key\n self.class.error_key\n end",
"def exception_is_handled?(exception)\n custom_exception_handler(exception)\n end"
] |
[
"0.6627483",
"0.6569164",
"0.6310145",
"0.6192599",
"0.6063831",
"0.59797996",
"0.59267753",
"0.56218183",
"0.54783636",
"0.535776",
"0.5351201",
"0.53141886",
"0.51999336",
"0.5161768",
"0.5095055",
"0.5076625",
"0.5074937",
"0.5032617",
"0.49993965",
"0.49705985",
"0.49545935",
"0.49382898",
"0.49286672",
"0.48966017",
"0.48676264",
"0.4850293",
"0.48406202",
"0.4836576",
"0.4834237",
"0.48276874",
"0.48247615",
"0.47602063",
"0.47300267",
"0.4728918",
"0.4728918",
"0.47110707",
"0.47107425",
"0.4702075",
"0.46853822",
"0.4681579",
"0.46745935",
"0.46651903",
"0.46651903",
"0.46484187",
"0.46343806",
"0.46283343",
"0.46168807",
"0.45813927",
"0.45347226",
"0.44962567",
"0.44955558",
"0.44902048",
"0.4481566",
"0.4474606",
"0.4471126",
"0.44609922",
"0.44583103",
"0.44552386",
"0.44317335",
"0.44280317",
"0.44190204",
"0.44076183",
"0.440633",
"0.4399118",
"0.43976146",
"0.438762",
"0.43778545",
"0.43768656",
"0.43696874",
"0.4366682",
"0.4353583",
"0.4353583",
"0.4348716",
"0.43368322",
"0.43129712",
"0.43101385",
"0.43028075",
"0.4301395",
"0.430028",
"0.42882574",
"0.42611843",
"0.42602348",
"0.42385212",
"0.42297494",
"0.42244998",
"0.42194048",
"0.4211367",
"0.4201726",
"0.41996297",
"0.41805843",
"0.4171915",
"0.4160191",
"0.41559747",
"0.4151812",
"0.41505405",
"0.41494387",
"0.41402757",
"0.41362047",
"0.41360494",
"0.4131818"
] |
0.49354693
|
22
|
Sets the exception handler. source://i18n//lib/i18n/config.rb91
|
def exception_handler=(exception_handler); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def exception_handler\n @exception_handler ||= {}\n end",
"def on_exception( handler = nil, &block )\n @exception_handler_method = handler\n @exception_handler_block = block\n end",
"def set_error_handler handler\n @station.error_handler = handler\n end",
"def custom_exception_handler(exception)\n custom_exception_handlers[exception.to_s]\n end",
"def config\n Wrangler::ExceptionHandler.config\n end",
"def set_exception(e)\n @exception = e\n end",
"def exception_hook=(val); @rye_exception_hook = val; end",
"def exception_handler; end",
"def run_custom_exception_handling(exception)\n case handler = custom_exception_handler(exception)\n when String\n write handler \n when Symbol\n self.send(custom_exception_handler(exception))\n end\n end",
"def define_exception_handler(data)\n exception_handler.merge!(data)\n end",
"def error_handler\n @error_handler || DEFAULT_ERROR_HANDLER\n end",
"def exception_handler(ex)\n \nend",
"def __set_handler(handler)\n @__handler = handler\n end",
"def with_error_handler( handler )\n\t\toriginal_handler = self.errhandler\n\t\traise ArgumentError, \"%p doesn't respond_to #call\" unless handler.respond_to?( :call )\n\t\t@errhandler = handler\n\n\t\tyield\n\n\tensure\n\t\t@errhandler = original_handler\n\tend",
"def error_handler\n begin\n yield\n rescue => exception\n options = Rails.env.development? ? {:backtrace => exception.backtrace, :class => exception.class.to_s} : {}\n render_error(exception.message, options)\n end\n end",
"def rescue_with_handler(exception)\n self.class.rescue_with_handler exception, object: self\n end",
"def handler_for_rescue(exception) # :nodoc:\n self.class.handler_for_rescue exception, object: self\n end",
"def error_handler()\n @error_handler\n end",
"def set_exception_handler(context)\r\n # construct and set exception handler in current frame\r\n if @current_exception_table then\r\n cursig = context.to_signature\r\n ncontext = context.dup\r\n handler = CodeSpace.new\r\n oldcs = ncontext.set_code_space(handler)\r\n casm = ncontext.assembler\r\n\r\n # rescue\r\n if entbasetab = @current_exception_table[:rescue] then\r\n entbasetab.each do |ents|\r\n ent = ents[3]\r\n if ent then\r\n csadd = ent.get_code_space(cursig).var_base_address\r\n casm.with_retry do\r\n casm.call(csadd)\r\n end\r\n end\r\n end\r\n end\r\n\r\n # ensure\r\n ent = nil\r\n if entbasetab = @current_exception_table[:ensure] then\r\n casm.with_retry do\r\n casm.push(TMPR) # ensure returns no value\r\n end\r\n entbasetab.each do |ents|\r\n ent = ents[3]\r\n if ent then\r\n csadd = ent.get_code_space(cursig).var_base_address\r\n casm.with_retry do\r\n casm.call(csadd)\r\n end\r\n end\r\n end\r\n casm.with_retry do\r\n casm.pop(TMPR)\r\n end\r\n end\r\n\r\n casm.with_retry do\r\n casm.pop(TMPR3)\r\n casm.pop(PROFR)\r\n end\r\n\r\n enode = @frame_info.parent.end_nodes[0]\r\n ncontext = enode.gen_method_epilogue(ncontext)\r\n \r\n casm.with_retry do\r\n casm.jmp(TMPR3)\r\n end\r\n \r\n context.set_code_space(oldcs)\r\n foff = @frame_info.parent.frame_offset\r\n handoff = AsmType::MACHINE_WORD.size * 2 + foff\r\n handop = OpIndirect.new(BPR, handoff)\r\n casm = context.assembler\r\n casm.with_retry do\r\n casm.mov(handop, handler.var_base_immidiate_address)\r\n end\r\n context.set_reg_content(handoff, :first_exception_entry)\r\n end\r\n\r\n context\r\n end",
"def exception_handler(&hndlr)\n @j_del.exceptionHandler(hndlr)\n self\n end",
"def on_exception(&f)\n @on_exception = f\n end",
"def on_exception(&blk)\n @on_exception = blk\n end",
"def on_error(&block)\n @error_handler = block\n end",
"def on_error(&blk)\n @error_handler = blk\n self\n end",
"def default_error_handler( state, node, exception )\n\t\tcase self.options[:on_render_error].to_s\n\t\twhen 'ignore'\n\t\t\tself.log.debug \" not rendering anything for the error\"\n\t\t\treturn ''\n\n\t\twhen 'comment'\n\t\t\tself.log.debug \" rendering error as a comment\"\n\t\t\tmsg = \"%s: %s\" % [ exception.class.name, exception.message ]\n\t\t\tif self.options[:debugging_comments]\n\t\t\t\texception.backtrace.each {|line| msg << \"\\n\" << line }\n\t\t\tend\n\t\t\treturn self.make_comment( msg )\n\n\t\twhen 'propagate'\n\t\t\tself.log.debug \" propagating error while rendering\"\n\t\t\traise( exception )\n\n\t\telse\n\t\t\traise Inversion::OptionsError,\n\t\t\t\t\"unknown exception-handling mode: %p\" % [ self.options[:on_render_error] ]\n\t\tend\n\tend",
"def setup_error_handling(rack_env)\n end",
"def rescue_with_handler(exception)\n\t\tif current_user and current_user.is_administrator?\n\t\t\treturn\n\t\t\t@exception = exception\n\t\tend\n\t\t\n\t\tif current_user\n\t\t\trender template: \"errors/500\"\n\t\telse\n\t\t\trender template: \"errors/500\", layout:\"login\"\n\t\tend\n\tend",
"def exception_handler\n if block_given?\n @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling exception_handler()\"\n end",
"def rescue_with_handler(exception)\n to_return = super\n if to_return\n verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?\n logger.info(\"[RESCUE STYLE] rescue_with_handler\") if verbose\n data = get_exception_data\n status_code = status_code_for_exception(exception)\n #We only send email if it has been configured in environment\n send_email = should_email_on_exception?(exception, status_code, verbose)\n #We only send web hooks if they've been configured in environment\n send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)\n the_blamed = ExceptionNotification::Notifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)\n rejected_sections = %w(request session)\n # Debugging output\n verbose_output(exception, status_code, \"rescued by handler\", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose\n # Send the exception notification email\n perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email\n # Send Web Hook requests\n ExceptionNotification::HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotification::Notifier.config, exception, self, request, data, the_blamed) if send_web_hooks\n pass_it_on(exception, ENV, verbose)\n end\n to_return\n end",
"def set_admin_sidekiq_exception\n @admin_sidekiq_exception = Admin::SidekiqException.find(params[:id])\n end",
"def exceptions=(value)\n @exceptions = value\n end",
"def exceptions=(value)\n @exceptions = value\n end",
"def default_exception_renderer=(_arg0); end",
"def raise_handler_error\n raise Error, \"Handler needs to be a class name or a symbol name\"\n end",
"def exceptions=(value)\n @values['exceptions'] = value\n end",
"def error_handler()\n return @error_handler unless @error_handler.nil?\n eh = find_task(:error)\n return eh unless eh.nil?\n @env.error_handler\n end",
"def register_exception(exception_class, handler: nil, **options)\n raise ArgumentError, \"#{exception_class} is not an Exception\" unless exception_class <= Exception\n\n if owner.respond_to?(:default_exception_handler)\n handler ||= owner.default_exception_handler\n end\n raise ArgumentError, \"handler must be provided\" unless handler\n\n status = options[:status] ||= handler.default_status\n raise ArgumentError, \"status must be provided\" unless status\n unless status.is_a?(Integer) || (passthrough_allowed? && status == :passthrough)\n raise ArgumentError, \"invalid status: #{status}\"\n end\n\n # TODO: Validate options here\n\n # We assign the status here as a default when looking up by class (and not instance)\n @handlers[exception_class] = [handler, options]\n end",
"def handle_exception(e, msg = '') # :nodoc:\n if USE_NEW_EXCEPTION\n http_exception = Net::HTTPClientException\n else\n http_exception = Net::HTTPServerException\n end\n case e\n when http_exception, SocketError, Errno::ECONNREFUSED\n msg = \"unable to connect to the validator at #{@validator_uri} (response was #{e.message}).\"\n raise ValidatorUnavailable, msg, caller\n when JSON::ParserError, Nokogiri::XML::SyntaxError\n msg = \"unable to parse the response from the validator.\"\n raise ParsingError, msg, caller\n else\n raise e\n end\n\n if e.respond_to?(:error_handler_before)\n fcall(e, :error_handler_before, self)\n end\n\n if e.respond_to?(:error_handler_instead)\n fcall(e, :error_handler_instead, self)\n else\n if e.respond_to? :status\n exit_status(( e.status ))\n end\n\n if SystemExit === e\n stderr.puts e.message unless(SystemExit === e and e.message.to_s == 'exit') ### avoids double message for abort('message')\n end\n end\n\n if e.respond_to?(:error_handler_after)\n fcall(e, :error_handler_after, self)\n end\n\n exit_status(( exit_failure )) if exit_status == exit_success\n exit_status(( Integer(exit_status) rescue(exit_status ? 0 : 1) ))\n exit exit_status\n end",
"def handle_error(error_messages, options = {})\n options.merge! :error_messages => error_messages\n handle_exception(nil, options)\n end",
"def set_error(span, exception)\n raise NotImplementedError\n end",
"def on_exception(&value)\n @on_exception = value if block_given?\n \n @on_exception\n end",
"def error_handler(exception)\n puts exception\n end",
"def exceptions_app; end",
"def exceptions_app; end",
"def abort_on_exception=(val)\n @abort_on_exception = val\n end",
"def set_message_handler &block\n @message_handler = block\n end",
"def stub_log_error\n ExceptionHandling.stub_handler = self\n end",
"def on_error(handler = nil, &block)\n raise ArgumentError, 'You cannot specify error handler with both Symbol and block' if handler && block\n raise ArgumentError, 'You must specify error handler with either Symbol or block' unless handler || block\n\n @_on_error = block || validated_error_handler(handler)\n end",
"def default_errors!\n configure :production do\n error ::Exception do\n boom = env['sinatra.error']\n logger.error [\"#{boom.class} - #{boom.message}:\", *boom.backtrace].join(\"\\n \")\n response.status = 500\n content_type 'text/html'\n '<h1>Internal Server Error</h1>'\n end\n end\n end",
"def set_handler(handler)\n self.code = handler.to_yaml\n end",
"def exception_renderer; end",
"def exception_callback\n @exception_callback\n end",
"def display_exceptions=(flag)\n if flag\n @exception_display_handler ||= on_exception do |kind, error, tasks|\n level = if kind == EXCEPTION_HANDLED then :debug\n else :warn\n end\n\n send(level) do\n send(level, \"encountered a #{kind} exception\")\n Roby.log_exception_with_backtrace(error.exception, self, level)\n if kind == EXCEPTION_HANDLED\n send(level, \"the exception was handled by\")\n else\n send(level, \"the exception involved\")\n end\n tasks.each do |t|\n send(level, \" #{t}\")\n end\n break\n end\n end\n else\n remove_exception_listener(@exception_display_handler)\n @exception_display_handler = nil\n end\n end",
"def egregious_exception_handler(exception)\n egregious_flash(exception)\n egregious_log(exception)\n egregious_respond_to(exception)\n end",
"def set_exception(worker_name, exc_or_message)\n if exc_or_message.is_a?(Exception)\n self.exception = JobException.from_exception(exc_or_message)\n exception.worker_name = worker_name\n else\n build_exception(\n class_name: 'RocketJob::DirmonEntryException',\n message: exc_or_message,\n backtrace: [],\n worker_name: worker_name\n )\n end\n end",
"def handle_exception(exception, request, response)\n response.flush\n response.status = 500\n\n if config.development?\n response.content_type = \"text/html\"\n response.puts(Rack::ShowExceptions.new(nil).pretty(request.env, exception))\n else\n response.layout = \"layouts/exception\" if Harbor::View.exists?(\"layouts/exception\")\n\n if Harbor::View.exists?(\"exceptions/500.html.erb\")\n response.render \"exceptions/500.html.erb\", :exception => exception\n else\n response.puts \"We're sorry, but something went wrong.\"\n end\n end\n\n raise_event(:exception, Events::ServerErrorEvent.new(request, response, exception))\n end",
"def handler(error_class)\n error_class.kind_of?(String) ? key = error_class : key = error_class.to_s\n handlers.has_key?(key) ? handlers.fetch(key) : raise(WebFlowError.new, \"There's no handler defined for the error class '#{key}'.\")\n end",
"def handle_error(e)\n raise e\n end",
"def setup_exception_context(ex, _pry_, options={})\n _pry_.last_exception = ex \n _pry_.backtrace = (ex.backtrace || [])\n\n PryStackExplorer.frame_manager(_pry_).user[:exception] = ex\n PryStackExplorer.frame_manager(_pry_).user[:inline_exception] = !!options[:inline]\n end",
"def on_exception=(value)\n raise TypeError, 'on_exception must be a Proc or respond to #call' unless value.is_a?(Proc) || value.respond_to?(:call)\n \n @on_exception = value\n end",
"def on_error_in node_type, &block\n @exceptions[node_type] = block\n end",
"def with_error_handling(event)\n\tbegin\n\t\tyield\n\trescue => e\n\t\tevent.respond \"Had an error: \" + e.class.to_s\n\t\traise e\n\tend\nend",
"def handle_error(env = nil, &block)\n begin\n yield\n rescue Aws::DynamoDB::Errors::Base,\n Aws::SessionStore::DynamoDB::InvalidIDError => e\n @config.error_handler.handle_error(e, env)\n end\n end",
"def handle_error(ex)\n if react_to?(ex)\n begin\n ex.command = self\n ex.react!\n rescue Quickl::Error => ex2\n handle_error(ex2)\n end\n else\n raise ex\n end\n end",
"def on_connection_exception(&block)\n @exception_block = block\n end",
"def exception_renderer=(_arg0); end",
"def error(exception)\n logger.error \"Beetle: handler execution raised an exception: #{exception.class}(#{exception.message})\"\n end",
"def handle_exception(e)\n if e.flags.has_key?(:layout) then\n @_layout = e.flags[:layout]\n end\n\n if e.flags.has_key?(:no_after_filters) then\n @_stop_no_after_filters = true\n end\n\n if e.flags.has_key?(:redirect) then\n @_layout = false\n to = e.flags[:redirect]\n clear\n @_content = \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 4.0 Transitional//EN\\\"><html><head><title>Redirecting...</title><meta http-equiv=\\\"REFRESH\\\" content=\\\"0;url=#{to}\\\"></HEAD></HTML>\"\n @cancel_execution = true\n end\n\n if e.flags.has_key?(:error) then\n @_layout = false\n http_status \"SERVER_ERROR\"\n clear\n @error_message = e.flags[:error]\n @cancel_execution = true\n trace = ''\n if Cuca::App.config['display_errors'] then\n e.backtrace.each do |b|\n trace<< \"<br/>#{b}\"\n end\n end\n mab { html { body { h2 \"Error\"; text @error_message; br; text trace }}}\n end\n \n if e.flags.has_key?(:cancel_execution) then\n @cancel_execution = true\n end\n end",
"def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end",
"def fallback_error_handler(exception)\n __debug_exception('RESCUE_FROM', exception, trace: true)\n self.status = :internal_server_error\n if rendering_html?\n flash_now_alert(exception)\n render\n elsif posting_html?\n redirect_back(fallback_location: root_path, alert: exception.message)\n end\n rescue => error\n error_handler_deep_fallback(__method__, error)\n end",
"def enter_exception_context(exception); end",
"def translate_exception(e)\n exception_translator.register_exception e\n end",
"def register_exception(e)\n @exceptions << e\n end",
"def handle_exception(exception)\n end",
"def pass_exception\n throw :next_exception_handler\n end",
"def error_handling\n @@error_handling ||= nil\n end",
"def get_exception_handler(e)\n table = self.class.exception_handler\n e.class.ancestors.each do |mod|\n return table[mod] if table.has_key?(mod)\n end\n end",
"def amf_exception_handler(ex)\n RAILS_DEFAULT_LOGGER.error ex.message\n RAILS_DEFAULT_LOGGER.error ex.backtrace.join( \"\\n\" )\n render :amf => FaultObject.new(ex.to_s) if is_amf\n end",
"def set_statement_handler(handler)\n @statement_handler = handler\n end",
"def error_handler()\n return @error_handler unless @error_handler.nil?\n @flow.error_handler()\n end",
"def handler\n @handler ||= Type.for(type).new(type_options)\n rescue StandardError => ex\n raise ex, \"#{name}: #{ex.message}\"\n end",
"def on_exception(proc = nil, &blk)\n raise 'No callback provided for on_exception' unless proc || blk\n @exception_callback = proc || blk\n end",
"def handle_exception(exception, options = {})\n request = options[:request]\n render_errors = options[:render_errors] || false\n proc_name = options[:proc_name] || config[:app_name]\n error_messages = options[:error_messages] || ['']\n\n error_messages = [error_messages] unless error_messages.is_a?(Array)\n\n if exception.respond_to?(:backtrace)\n backtrace = exception.backtrace\n else\n backtrace = caller\n end\n\n # extract the relevant request data and also filter out any params\n # that should NOT be logged/emailed (passwords etc.)\n request_data = request_data_from_request(request) unless request.nil?\n\n supplementary_info = nil\n\n unless config[:call_for_supplementary_info].nil?\n supplementary_info = config[:call_for_supplementary_info].call(request)\n supplementary_info = [supplementary_info] unless supplementary_info.is_a?(Array)\n end\n\n unless supplementary_info.blank?\n error_messages << \"Supplementary info:\"\n error_messages += supplementary_info\n end\n\n if exception.nil?\n exception_classname = nil\n status_code = nil\n log_error error_messages.inspect\n log_error backtrace\n log_error \"Request params were:\"\n log_error request_data.to_yaml\n error_string = error_messages.shift\n else\n status_code =\n Wrangler::ExceptionHandler.status_code_for_exception(exception)\n\n log_exception(exception, request_data, status_code, error_messages)\n\n if exception.is_a?(Class)\n exception_classname = exception.name\n else\n exception_classname = exception.class.name\n end\n\n if exception.respond_to?(:message)\n error_string = exception.message\n else\n error_string = exception.to_s\n end\n end\n\n if send_notification?(exception, request, status_code)\n if notify_with_delayed_job?\n # don't pass in request as it contains not-easily-serializable stuff\n log_error \"Wrangler sending email notification asynchronously\"\n Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,\n exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data)\n else\n log_error \"Wrangler sending email notification synchronously\"\n Wrangler::ExceptionNotifier.deliver_exception_notification(exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data,\n request)\n end\n end\n\n if render_errors\n render_error_template(exception, status_code)\n end\n\n rescue Exception => unhandled_exception\n # if it looks like a temporary error interacting with SMTP, then enqueue\n # the error using delayed job if possible\n # (testing by name this way in case the exception isn't loaded into\n # environment, which would cause a NameError and be counterproductive...)\n if unhandled_exception.class.name == 'Net::SMTPAuthenticationError' &&\n Wrangler::ExceptionNotifier.respond_to?(:send_later)\n\n log_error \"Wrangler failed to send error notification: #{unhandled_exception.class.name}:\"\n log_error \" #{unhandled_exception.to_s}\"\n\n # note: this is specific to an old-ish version of delayed job...should\n # make wrangler compatible with the old and the new...\n log_error \"Wrangler attempting to send via delayed job\"\n Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,\n exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data)\n else\n log_error \"/!\\\\ FAILSAFE /!\\\\ Wrangler encountered an unhandled exception \" +\n \"while trying to handle an error. The arguments it received \" +\n \"were:\"\n log_error \" exception: #{exception.inspect}\"\n log_error \" options: #{options.inspect}\"\n log_error \"The unhandled error encountered was #{unhandled_exception.class.name}:\"\n log_error \" #{unhandled_exception.to_s}\"\n end\n end",
"def set_message_for(exception, env)\n session = env[ActionDispatch::Request::Session::ENV_SESSION_KEY] || {}\n env[ActionDispatch::Flash::KEY] ||= ActionDispatch::Flash::FlashHash.from_session_value session['flash']\n flash = env[ActionDispatch::Flash::KEY]\n flash[:alert] = exception.message\n end",
"def each_exception_handler(&iterator); model.each_exception_handler(&iterator) end",
"def each_exception_handler(&iterator)\n model.each_exception_handler(&iterator)\n end",
"def step_0_exceptions\n @step_0_exceptions ||= load_settings(\"step_0_exceptions\")\n end",
"def step_1_exceptions\n @step_1_exceptions ||= load_settings(\"step_1_exceptions\")\n end",
"def exceptions_app=(_arg0); end",
"def exceptions_app=(_arg0); end",
"def framework_exception(env)\n env['action_dispatch.exception'] ||\n env['sinatra.error'] ||\n env['rack.exception']\n end",
"def framework_exception(env)\n env['action_dispatch.exception'] ||\n env['sinatra.error'] ||\n env['rack.exception']\n end",
"def set_message_handler(&block); end",
"def initialize\r\n\r\n I18n.exception_handler = I18n::LinguaFrancaMissingTranslation.new\r\n unless File.exist?(I18n.config.info_file)\r\n dir = File.dirname(I18n.config.info_file)\r\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\r\n File.open(I18n.config.info_file, 'w+')\r\n end\r\n\r\n # throw an exception if we're missing the pluralizations rules file\r\n throw Exception(\"Lingua Franca: Missing Pluralization File #{I18n.config.languages_file}\") unless File.exist?(I18n.config.languages_file)\r\n \r\n super\r\n end",
"def exception\n @context[:exception]\n end",
"def setup_method_handler(method_handler)\n @handler = method_handler\n end",
"def parse_error(env, status_to_render)\n raise Common::Exceptions::BackendServiceException.new(\n \"VETEXT_#{status_to_render}\",\n {\n detail: parse_detail(env.body),\n code: \"VETEXT_#{env.status}\",\n source: \"#{env.method.upcase}: #{env.url.path}\"\n },\n env.status,\n env.body\n )\n end",
"def serve_exception(_exception); end",
"def with_ruby_exception(matcher)\n with_original_exception(matcher)\n @ruby_exception_class = matcher\n self\n end"
] |
[
"0.7286301",
"0.6443783",
"0.6399727",
"0.62148654",
"0.6202593",
"0.61766106",
"0.59608763",
"0.5849426",
"0.5799362",
"0.57777995",
"0.5645895",
"0.5636454",
"0.56064546",
"0.5556423",
"0.55394614",
"0.5509799",
"0.55031306",
"0.5468964",
"0.5463749",
"0.5441261",
"0.5438178",
"0.53555447",
"0.5345188",
"0.53421813",
"0.53416055",
"0.53137195",
"0.5301848",
"0.52167445",
"0.5211342",
"0.5185842",
"0.5174031",
"0.51519716",
"0.51519716",
"0.5144004",
"0.5140148",
"0.50886595",
"0.506221",
"0.50511914",
"0.5044038",
"0.50287646",
"0.50147414",
"0.50126445",
"0.50107163",
"0.5006544",
"0.5006544",
"0.4990426",
"0.49855202",
"0.49852863",
"0.49659604",
"0.49495456",
"0.49318364",
"0.48917186",
"0.48639536",
"0.48312563",
"0.48275045",
"0.481556",
"0.4810657",
"0.48073864",
"0.48055705",
"0.47820967",
"0.47816995",
"0.47638032",
"0.4757993",
"0.4735629",
"0.47151342",
"0.47086385",
"0.47019094",
"0.47002146",
"0.46993086",
"0.46976635",
"0.4695193",
"0.46951675",
"0.46799386",
"0.467094",
"0.46708792",
"0.4668317",
"0.46529692",
"0.46487322",
"0.46478844",
"0.4646001",
"0.46151304",
"0.46064445",
"0.46044856",
"0.46008062",
"0.45740178",
"0.4571732",
"0.45668095",
"0.45662782",
"0.4559925",
"0.45521098",
"0.45521098",
"0.45032045",
"0.45032045",
"0.44982928",
"0.44956785",
"0.44886",
"0.44712055",
"0.4459609",
"0.4458895",
"0.4457681"
] |
0.6949438
|
1
|
Returns the current interpolation patterns. Defaults to I18n::DEFAULT_INTERPOLATION_PATTERNS. source://i18n//lib/i18n/config.rb151
|
def interpolation_patterns; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def region_patterns\n @@region_patterns\n end",
"def interpolators()\n return @interpolators\n end",
"def term_qa_replacement_patterns\n Config.config_value(term_config, :qa_replacement_patterns)\n end",
"def patterns_for_file( file )\n Hash(config_file(file)[:patterns]).keys + \\\n Hash(defaults[:patterns]).keys\n end",
"def substitutions\n subs = self.instance_variables\n subs.delete(config.format_key)\n subs.map { |s| s.to_s.gsub('@', '').to_sym }\n end",
"def patterns\n @patterns ||=\n [\n {\n :type => :erb,\n :rx => /\\.erb\\Z/,\n :rep => '',\n },\n {\n :type => :none,\n :rx => /\\Z/,\n :rep => '',\n },\n ]\n end",
"def routing_params_with_patterns\n @routing_params_with_patterns ||= begin\n Gapic::UriTemplate.parse_arguments(path).map do |name, pattern|\n [name, pattern.empty? ? \"*\" : pattern]\n end\n end\n end",
"def pattern_names\n # This removes the path and extensions\n patterns.map { |pat| pat.name.gsub(/.*[\\\\\\/]/, '').gsub(/\\..*/, '') }\n end",
"def patterns\n #@rules.every.pattern\n @rules.map {|r| r.pattern }\n end",
"def patterns\n @patterns ||= []\n end",
"def get_patterns\n patterns = BASE_PATTERNS\n # add the colour keywords. generate these from the colour wheel's constants\n colours = Yay::ColourWheel::all_names.join('|')\n patterns.unshift [:colour, Regexp.new(\"\\\\b(#{colours})\\\\b\", Regexp::IGNORECASE)]\n return patterns\n end",
"def routing_params_with_patterns\n bindings.first&.routing_params_with_patterns || []\n end",
"def patterns\n\t\t@@patterns ||= []\n\n\t\tif @@patterns.size == 0\n\t\t\tfor i in 0..9\n\t\t\t\tfor j in 0..9\n\t\t\t\t\tfor k in 0..9\n\t\t\t\t\t\tfor l in 0..9\n\t\t\t\t\t\t\t@@patterns << Regexp.new(\"[#{i}]{4}[#{j}]{4}[#{k}]{4}[#{l}]{4}\")\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t@@patterns\n\tend",
"def interpolation\n # Just return the interpolation type for pre-2012 setups\n return (@interpolation || :constant) unless has_2012_tangents?\n \n return :constant if curve_order.to_s == \"constant\"\n return :hermite if curve_order.to_s == \"cubic\" && (curve_mode.to_s == \"hermite\" || curve_mode.to_s == \"natural\")\n return :bezier if curve_order.to_s == \"cubic\" && curve_mode.to_s == \"bezier\"\n return :linear if curve_order.to_s == \"linear\"\n \n raise \"Cannot determine interpolation for #{inspect}\"\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def pattern\n Regexp.union(pattern_classifiers.map(&:pattern))\n end",
"def patterns\n # BNodes in statements are existential variables.\n @patterns ||= enum_for(:each_pattern).to_a\n end",
"def group_patterns\n\t\t\tpatterns = @glob.split(' ')\n\t\t\tnegatives = []\n\t\t\tpositives = []\n\t\t\tpatterns.each do |x|\n\t\t\t\tif is_negative?(x)\n\t\t\t\t\tnegatives << x\n\t\t\t\telse\n\t\t\t\t\tpositives << x\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn { negatives: negatives, positives: positives }\n\t\tend",
"def string_interpolation?(value = @value)\n !value.index(INTERPOLATION).nil?\n end",
"def all_patterns\n @mutex.synchronize do\n @patterns.keys.map{ |a_| a_.dup }\n end\n end",
"def pattern_template\n pattern\n end",
"def pattern_template\n pattern\n end",
"def determine_pattern_replacements(patterns)\n seen_patterns = []\n replacements = {}\n\n # Pattern names are sorted to ensure predictable pattern replacement. Makes tests easier to write.\n pattern_names = patterns.keys.sort\n\n # Detect duplicates\n pattern_names.each do |pattern_name|\n pattern = patterns[pattern_name]\n found_duplicate = false\n seen_patterns.each do |seen_pattern|\n if !found_duplicate && pattern.same_tracks_as?(seen_pattern)\n replacements[pattern.name.to_sym] = seen_pattern.name.to_sym\n found_duplicate = true\n end\n end\n\n if !found_duplicate\n seen_patterns << pattern\n end\n end\n\n replacements\n end",
"def file_patterns\n [@file_patterns].flatten.compact.uniq\n end",
"def check_patterns\n [@check_patterns].flatten.compact.uniq\n end",
"def pattern(default = '')\n return get(:pattern, default)\n end",
"def format_patterns(patterns)\n patterns.collect {|x| \"\\\"fast:#{x}\\\"\"}.join(' ')\nend",
"def expanded_paths(patterns, options = {})\n return [] if patterns.empty?\n path_list.glob(patterns, options).flatten.compact.uniq\n end",
"def patterns_path\n patterns_path = []\n case ecs_compatibility\n when :disabled\n patterns_path << LogStash::Patterns::Core.path # :legacy\n when :v1\n patterns_path << LogStash::Patterns::Core.path('ecs-v1')\n when :v8\n @logger.warn(\"ECS v8 support is a preview of the unreleased ECS v8, and uses the v1 patterns. When Version 8 of the Elastic Common Schema becomes available, this plugin will need to be updated\")\n patterns_path << LogStash::Patterns::Core.path('ecs-v1')\n else\n fail(NotImplementedError, \"ECS #{ecs_compatibility} is not supported by this plugin.\")\n end\n # allow plugin to be instantiated outside the LS environment (in tests)\n if defined? LogStash::Environment.pattern_path\n patterns_path << LogStash::Environment.pattern_path(\"*\")\n end\n patterns_path\n end",
"def stress_data_patterns\n lu = \"Line-Up\"\n default_data_patterns.merge({\n seq_histories: /(\\d+) histories computed/,\n seq_time: /histories computed in ([0-9.]+s)/,\n avg_lins: /#{lu} performed (\\d+) \\(avg\\)/,\n max_lins: / (\\d+) \\(max\\) linearizations/,\n })\nend",
"def simplified_pattern\n pattern\n end",
"def simplified_pattern\n pattern\n end",
"def contains_interpolation?(string)\n contains_connect_variables?(string) || contains_puppet_variables?(string)\n end",
"def interpolation_options\n { resource_name: @term.display_name }\n end",
"def pattern_template\n \"*\"\n end",
"def interpolated_markup\n visualization.markup.tap do |markup|\n interpolation_values.each do |k,v|\n markup.gsub!(\"__#{k.upcase}__\", v.to_s)\n end\n end\n end",
"def get_patterns(pattern_string)\r\n split_and_strip(pattern_string, \";\").select do |name|\r\n name != \"\"\r\n end.map {|name| Regexp.new(name, true)}\r\n end",
"def select_default_ignore_patterns\n @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup\n end",
"def templates\n # Some cheap memoiziation\n @templates ||= begin\n files = Dir.glob(template_glob)\n # Check to see what mode we are in, that'll define how we parse the file names\n if Gluttonberg.localized? or Gluttonberg.translated?\n # Figure out what regex we need\n matcher, mode = if Gluttonberg.localized?\n [/\\/#{filename}.(\\w+).([a-z-]+).(\\w+).(erb|mab|haml)/, :localized]\n elsif Gluttonberg.translated?\n [/\\/#{filename}.([a-z-]+).(\\w+).(erb|mab|haml)/, :translated]\n end\n files.inject({}) do |memo, file|\n match = file.match(matcher)\n extract_template_details(memo, mode, match) if match\n memo\n end\n else\n # For the non-localized/dialect mode, just collect the various formats\n files.inject([]) do |memo, file|\n match = file.match(/#{filename}.(\\w+).(erb|mab|haml)/)\n memo << match[1] if match\n memo\n end\n end\n end\n end",
"def pattern\n @pattern ||= Pattern.patterns[pattern_name]\n end",
"def query_api_patterns\n @query_api_patterns ||= {}\n # The current set of patterns may override whatever is defined at the class level.\n self.class.query_api_patterns.merge(@query_api_patterns)\n end",
"def select_default_ignore_patterns\n\t@exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup\n end",
"def patterns; end",
"def event_patterns\n return [] if current_table.nil?\n current_table.event_patterns\n end",
"def i18n_options\n default_i18n_options.merge(event_interpolations).transform_values do |value|\n if value.is_a?(String)\n decidim_html_escape(value)\n else\n value\n end\n end\n end",
"def pluralization_rules\n if defined?(@pluralization_regex) && @pluralization_regex\n return [@pluralization_regex, @pluralization_hash]\n end\n @pluralization_regex = Regexp.new(\"(\" + @plural_rules.map {|s,p| s}.join(\"|\") + \")$\", \"i\")\n @pluralization_hash = Hash[*@plural_rules.flatten]\n [@pluralization_regex, @pluralization_hash]\n end",
"def routing_params\n routing_params_with_patterns.map { |param, _| param }\n end",
"def word_pattern\n @emphasis[:word_pattern]\n end",
"def interpolated_description(assertion, setups)\n setups = setups ? setups.select { |s| s.component } : []\n substitutes = {}\n setups.each do |setup| substitutes[setup.component] = setup.substitute end\n assertion.interpolated_description(substitutes)\n end",
"def path_string\n pattern\n end",
"def infer_interpolation_key(string, others)\n key = string.downcase\n key.sub!(/\\.html_safe\\z/, '')\n key.gsub!(/[^a-z0-9]/, ' ')\n key.strip!\n key.gsub!(/ +/, '_')\n key.slice!(20)\n i = 0\n base_key = key\n while others.key?(key) && others[key] != string\n key = \"#{base_key}_#{i}\"\n i += 1\n end\n key\n end",
"def default_templates\n assets, logs, steps = @options.values_at(:assets, :logs, :steps)\n\n {\n asset: \":protocol://#{assets}/:prefix/:timestamp\",\n log: \":protocol://#{logs}/:prefix/:timestamp\",\n step: \":protocol://#{steps}/:prefix\",\n shared_asset: \":protocol://#{assets}/:prefix/shared/:datestamp\",\n bucket_relative_asset: ':prefix/:timestamp',\n }\n end",
"def template_extensions\n EXTENSIONS.keys\n end",
"def interpoltype()\n return :linear\n end",
"def pattern_classifiers\n classifiers.grep(Pattern)\n end",
"def routing_params\n routing_params_with_patterns.map { |param, _| param }\n end",
"def build_interpolators()\n vlists = [[],[],[],[]]\n self.colorlist.foreach do |index, color|\n values = []\n if self.interpoldomain == :rgb\n\tvalues = color.rgba\n elsif self.interpoldomain == :hsv\n\tvalues = color.hsva\n elsif self.interpoldomain == :hsl\n\tvalues = color.hsla\n else\n\traise RuntimeError.new(\"#{self.interpoldomain} is an unknown color scheme.\")\n end\n vlists[0] += [index, values[0] ]\n vlists[1] += [index, values[1] ]\n vlists[2] += [index, values[2] ]\n vlists[3] += [index, values[3] ]\n end\n @interpolators = vlists.map {|samplelist| Interpolator[ :samplelist, samplelist, :interpoltype, self.interpoltype]}\n end",
"def to_regex_str\n raise \"Not implemented for multivariate ResourceId segments\" if resource_patterns.count > 1\n\n resource_pattern = if resource_patterns[0].nil?\n \"*\"\n else\n resource_patterns[0]\n end\n\n resource_pattern_regex = Gapic::PathPattern::Parser.parse(resource_pattern).to_regex_str\n\n \"(?<#{resource_names[0]}>#{resource_pattern_regex})\"\n end",
"def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end",
"def formatting_values\n values = self.class.formatting_variables_lookup_table.map do |key, value|\n value = public_send(value) unless value.nil?\n\n [key, value]\n end\n\n Hash[values]\n end",
"def pattern\n @pattern\n end",
"def regexp_variables\n return @regexp_variables if @regexp_variables\n @regexp_variables = Array.new\n @base_theme.scan(VARIABLE_MATCHER) { @regexp_variables << $2 }\n @regexp_variables\n end",
"def file_pattern(name)\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\n raise ArgumentError.new(\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\")\n end\n get_config_val(@file_patterns, name)\n end",
"def available_locales\n @available_locales ||= begin\n locales = Set.new\n Array(config[:read]).map do |pattern|\n [pattern, Dir.glob(format(pattern, locale: '*'))] if pattern.include?('%{locale}')\n end.compact.each do |pattern, paths|\n p = pattern.gsub('\\\\', '\\\\\\\\').gsub('/', '\\/').gsub('.', '\\.')\n p = p.gsub(/(\\*+)/) { Regexp.last_match(1) == '**' ? '.*' : '[^/]*?' }.gsub('%{locale}', '([^/.]+)')\n re = /\\A#{p}\\z/\n paths.each do |path|\n locales << Regexp.last_match(1) if re =~ path\n end\n end\n locales\n end\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end",
"def url_placeholders\n my_palceholders = super\n if site.config['content_pages'] && site.config['content_pages']['url_placeholders']\n site.config['content_pages']['url_placeholders'].each do |key,value|\n my_palceholders[key] = @page_info[\"#{value}\"]\n end\n end\n return my_palceholders\n end",
"def recognizer_pattern\n @recognizer_pattern ||= Regexp.escape(pattern)+'\\z'\n end",
"def greetings_interpolation(name)\n # code goes here\nend",
"def interpolate(string, values); end",
"def interpolation_options\n { resource_name: @organization.name }\n end",
"def pattern\n if valid_period?\n @pattern = eval(\"RecurringTodos::#{recurring_period.capitalize}RecurrencePattern.new(user)\")\n @pattern.build_from_recurring_todo(self)\n end\n @pattern\n end",
"def pattern(options_hash)\n settings[options_hash[:country]]['regexp']\n end",
"def generate_pattern(pattern)\n plist.dict do\n append_single('begin', pattern.begin)\n append_dictionary('beginCaptures', pattern.begin_captures)\n append_dictionary('captures', pattern.captures)\n append_single('comment', pattern.comment)\n append_single('contentName', pattern.content_name)\n append_single('disabled', 1) if pattern.disabled\n append_single('end', pattern.end)\n append_dictionary('endCaptures', pattern.end_captures)\n append_single('include', pattern.include)\n append_single('match', pattern.match)\n append_single('name', pattern.name)\n append_array('patterns', pattern.patterns)\n end\n end",
"def plurals\n @plurals\n end",
"def to_a\n @patterns\n end",
"def from_pattern_match(keys, pattern, match)\n keys.each_with_index.map do |key, idx|\n # Check if there is any replacement specified\n if pattern[key]\n interpolate(pattern[key], match)\n else\n # No replacement defined, just return correct match group\n match[idx + 1]\n end\n end\n end",
"def interpolation_options\n { model: model.model_name.human, name: member.instance_name }\n end",
"def template_regex(type: :export)\n type = valid_type(type)\n pattern = []\n plugs = plugins[type].clone\n plugs.delete_if { |_, o| o[:templates].nil? }.each do |_, options|\n options[:templates].each do |t|\n pattern << t[:trigger].normalize_trigger\n end\n end\n Regexp.new(\"^(?:#{pattern.join('|')})$\", true)\n end",
"def interpolation_statement(prior_segments)\n chunks = prior_segments.collect { |s| s.interpolation_chunk }\n chunks << interpolation_chunk\n \"\\\"#{chunks * ''}\\\"#{all_optionals_available_condition(prior_segments)}\"\n end",
"def make_recognizer token_regexps={}\n return RECOGNIZER_REGEXPS[pattern] if RECOGNIZER_REGEXPS[pattern]\n tokens = []\n recognizer = recognizer_pattern.gsub(/:(\\\\\\{\\w+\\\\\\}|\\w+)/) do\n tok = $1.gsub(/\\W/,'')\n tokens << tok.to_sym\n '('+recognize_replace(tok, token_regexps)+')'\n end\n RECOGNIZER_REGEXPS[pattern] = [Regexp.new(recognizer), tokens]\n end",
"def templates\n @template_paths ||= Tilt.mappings.map do |ext, engines|\n Dir.glob(@root+\"/**/*.#{ext}\") if engines.map(&:default_mime_type).include?('text/html')\n end.flatten.compact\n end",
"def url_placeholders\n {\n path: @dir,\n basename: @basename,\n output_ext: output_ext,\n }\n end",
"def term_replacements\n return @term_replacements unless @term_replacements.nil?\n @term_replacements = {}\n @term_replacements = term_url_mappings.select { |k, _v| !term_qa_replacement_patterns.value?(k.to_s) } unless term_config.nil? || term_url_mappings.nil?\n @term_replacements\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def scope_url_pattern\n return @scope_url_pattern if @scope_url_pattern\n\n domains = [uri.host + uri.path]\n\n domains += if scope.domains.empty?\n Array(scope.invalid_domains[1..-1])\n else\n Array(scope.domains[1..-1]).map(&:to_s) + scope.invalid_domains\n end\n\n domains.map! { |d| Regexp.escape(d.delete_suffix('/')).gsub('\\*', '.*').gsub('/', '\\\\\\\\\\?/') }\n\n domains[0].gsub!(Regexp.escape(uri.host), \"#{Regexp.escape(uri.host)}(?::\\\\d+)?\") if uri.port\n\n @scope_url_pattern = %r{https?:\\\\?/\\\\?/(?:#{domains.join('|')})\\\\?/?}i\n end",
"def monitored_paths\n paths = Dir['**/*'].select do |path|\n @script.patterns.any? {|p| path.match(p) }\n end\n paths.push(@script.path).compact!\n paths.map {|path| Pathname(path).expand_path }\n end",
"def project_used_keys(search_pattern=nil)\n regex = /(I18n.| |\\>|\\(|=|\\[|\\{|I18n::|,|\\+)t[( ]?([\\\"\\'][a-zA-Z0-9._]+[\\\"\\'])(, :count => [@a-zA-Z0-9.]+|)[)]?/\n search_pattern ||= 'app/**/*.{rb,erb}'\n\n keys = Hash.new\n Dir[search_pattern].each do |path|\n File.open( path ) do |f|\n f.grep(regex) do |line|\n i18n_call = line.scan(regex)\n i18n_call.each do |k|\n key = k[1]\n key.delete! \"\\\"\\'\"\n key.insert(0,locale.to_s+'.')\n if k[2].include? \":count\"\n keys[(key+'.'+'zero').to_sym] = 0\n keys[(key+'.'+'one').to_sym] = 0\n keys[(key+'.'+'two').to_sym] = 0\n keys[(key+'.'+'few').to_sym] = 0\n keys[(key+'.'+'many').to_sym] = 0\n keys[(key+'.'+'other').to_sym] = 0\n else\n keys[key.to_sym] = 0\n end\n end\n end\n end\n end\n keys\n end",
"def gather_endpoints_to_check\n Rails.application.routes.routes.map do |route|\n verb = route.verb.downcase.to_sym\n example_path = route.path.spec\n .to_s.gsub('(.:format)', '')\n .gsub(/:([^\\/]+)/,'SOME_PLACEHOLDER_PARAM')\n .gsub('*path', 'SOME_PLACEHOLDER_PATH')\n .gsub('*filename','SOME_PLACEHOLDER_FILENAME')\n next unless verb.present?\n [verb, example_path]\n end.compact\n end",
"def query_patterns\n self.rdf_statements.select{|rdfs| rdfs[1] != Vocabularies::Alignment.measure}.collect{|qp|\n RDF::Query::Pattern.new(*qp.map!{|x| x == resource ? :cell : x })\n }\n end",
"def interpolate(path, template_name = nil)\n path.gsub!('%e', Tiller::config[:environment])\n path.gsub!('%t', template_name) if template_name\n path\n end",
"def paths\n Array(config.path).map(&:to_s)\n end",
"def pattern\n segs = @tags.map { |tagged_segment| build_segment(tagged_segment) }\n segs.last.gsub!(/\\.$/, '')\n segs.unshift \"^\"\n segs.push \"\\\\.?$\"\n Regexp.new(segs.join)\n end",
"def preferred_delimiters; end",
"def describe_parameter_extra_regexps(name)\n [\n \"#{name}::\",\n \"+#{name}+::\",\n \"<tt>#{name}</tt>::\"\n ].map do |pattern|\n r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)\n /#{r}\\n\\ {2,}.+/m\n end\n end",
"def get_formatting_data\n format = @data[country][:format]\n prefix = @data[country][Core::NATIONAL_PREFIX]\n rule = (format[Core::NATIONAL_PREFIX_RULE] ||\n @data[country][Core::NATIONAL_PREFIX_RULE] || '$1')\n\n [format, prefix, rule]\n end",
"def template_path_with_engine_additions\n \"{#{template_paths.join(\",\")}}\"\n end",
"def formatters\n @formatters ||= {}\n end",
"def interpolate(text, args)\n results = []\n while text.include?('[-]')\n head, text = *text.split('[-]', 2)\n results << head << args.shift\n end\n results << text \n results << args unless args.empty?\n \n return results.compact\n end",
"def apply_config_interpolations(item, units:, **)\n if item.is_a?(Hash)\n item.transform_values { |v| send(__method__, v, units: units) }\n elsif item.is_a?(Array)\n item.map { |v| send(__method__, v, units: units) }\n elsif item.is_a?(String) && item.include?('%{')\n item.gsub(SPRINTF_NAMED_REFERENCE) { |s| units[$1&.to_sym] || s }\n else\n item\n end\n end",
"def path_regex\n Regexp.new path_pattern, 'i'\n end"
] |
[
"0.58912766",
"0.5884981",
"0.58711416",
"0.5808277",
"0.5632519",
"0.5521293",
"0.5463352",
"0.5445024",
"0.54146683",
"0.53358305",
"0.5327459",
"0.5255294",
"0.51123923",
"0.5088376",
"0.50714624",
"0.50555164",
"0.5011109",
"0.49977556",
"0.4968294",
"0.4949765",
"0.49326354",
"0.49326354",
"0.48984435",
"0.48583305",
"0.4827222",
"0.4803933",
"0.47953403",
"0.47613057",
"0.47607958",
"0.47311217",
"0.46948528",
"0.46948528",
"0.46816152",
"0.46686012",
"0.46673682",
"0.46428257",
"0.46375954",
"0.46301052",
"0.46277577",
"0.4616484",
"0.46034193",
"0.45924687",
"0.4581606",
"0.4578031",
"0.4570972",
"0.45592675",
"0.45415306",
"0.45396867",
"0.4538498",
"0.4537476",
"0.4531504",
"0.45274028",
"0.45118475",
"0.45005667",
"0.4498432",
"0.44940606",
"0.4493065",
"0.44810945",
"0.44736162",
"0.44667673",
"0.44644016",
"0.44526303",
"0.44521707",
"0.44343153",
"0.4433822",
"0.44320828",
"0.44300777",
"0.44189703",
"0.44165552",
"0.43950245",
"0.43750224",
"0.4364826",
"0.4364679",
"0.43628317",
"0.4354883",
"0.4342828",
"0.43338764",
"0.43241617",
"0.43201068",
"0.43149906",
"0.4310196",
"0.43030864",
"0.42971182",
"0.42950705",
"0.42946702",
"0.42841527",
"0.42724293",
"0.4272132",
"0.42585042",
"0.42556354",
"0.42528495",
"0.42489004",
"0.42468458",
"0.4242871",
"0.42410105",
"0.42378843",
"0.42308658",
"0.4213504",
"0.41982156",
"0.41909915"
] |
0.7268299
|
0
|
Allow clients to register paths providing translation data sources. The backend defines acceptable sources. E.g. the provided SimpleBackend accepts a list of paths to translation files which are either named .rb and contain plain Ruby Hashes or are named .yml and contain YAML data. So for the SimpleBackend clients may register translation files like this: I18n.load_path << 'path/to/locale/en.yml' source://i18n//lib/i18n/config.rb126
|
def load_path; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def load_backends(path = MDS::DEFAULT_BACKEND_PATHS)\r\n Dir.glob(File.expand_path(path)) do |path|\r\n begin\r\n require path\r\n rescue LoadError\r\n end\r\n end\r\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def load_source_for(klass, source, source_vars)\n if source.nil? || source !~ /\\n/m\n base_names = [source, Utils.class_name_to_path(context.name), Utils.class_name_to_type(context.name)]\n paths = base_names.map{|bn| [\"#{Conf.elastics_dir}/#{bn}.yml\", \"#{Conf.elastics_dir}/#{bn}.yml.erb\"]}.flatten\n paths << source.to_s\n source = paths.find {|p| File.exist?(p)}\n end\n raise ArgumentError, \"Unable to load the source: expected a string, got #{source.inspect}\" \\\n unless source.is_a?(String)\n @sources << [klass, source, source_vars]\n do_load_source(klass, source, source_vars)\n # fixes the legacy empty stubs, which should call super instead\n # @templates.keys.each do |name|\n # meta_context.send(:define_method, name){|*vars| super *vars }\n # end\n end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def override_source_paths(*paths)\n # Using string with instance_eval because block doesnt have access to path at runtime.\n self.class.instance_eval %{\n def self.source_paths\n #{paths.flatten.inspect}\n end\n }\n end",
"def load_paths\n @load_paths ||= [\"urls.rb\", \"config/urls.rb\", \"mailers/*.rb\", \"controllers/**/*.rb\", \"controllers.rb\", \"helpers/*.rb\"]\n end",
"def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def paths\n @paths ||= begin\n paths = super\n paths.add 'config/routes.rb', with: 'routes.rb'\n paths.add 'config/locales', with: 'locales', glob: \"**/*.{rb,yml}\"\n paths\n end\n end",
"def load_source\n case File.extname(config[:source])\n when '.json'\n Yajl.load(File.open(config[:source]))\n when '.yml'\n YAML.load(File.open(config[:source]))\n else\n raise 'unknown source file extension'\n end\n end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def for(host, files = expandable_default_files)\n translate(files.inject({}) { |settings, file|\n load(file, host, settings)\n })\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def load_files(*sources); end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end",
"def generate\n I18n.backend.load_translations\n translations = wrap(source_translations)\n I18n.backend.store_translations(destination_locale, translations)\n I18n.available_locales += [destination_locale]\n end",
"def add_source(*source_paths)\n source_paths.each do |source|\n new_path = Pathname.new(source)\n # Check if the source path is a directory\n next unless new_path.file?\n # Add the new source to the list of source file paths\n @sources.push(new_path)\n end\n end",
"def load_translations(*filenames)\n filenames = I18n.load_path if filenames.empty?\n \n @filenames = filenames.flatten\n \n @filenames.each { |filename| load_file(filename) }\n end",
"def load_translations_and_collect_file_errors(files); end",
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if File.exists?(\"#{lang_file_without_ext}.rb\")\n end\n self.use languages.first if current_language.nil?\n end",
"def rails_localization_files\n loc_files = Dir[File.join( RAILS_ROOT, '/vendor/plugins/globalite/lang/rails/', '*.{yml,yaml}')]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def locale_files\n Dir[File.join(File.dirname(__FILE__), \"polish\", \"locale\", \"**/*\")]\n end",
"def yml_path language\n Rails.root.join('config', 'locales', \"#{language}.yml\")\nend",
"def add_template_repository_to_source_path\n source_paths.unshift(File.dirname(__FILE__))\nend",
"def add_plugin_load_paths\n configuration.add_plugin_paths(extension_loader.paths(:plugin))\n super\n ActiveSupport::Dependencies.autoload_once_paths -= extension_loader.paths(:load)\n end",
"def load(*languages)\n languages.flatten!\n languages.each do |lang_code|\n lang_file = LangFile.new lang_code, self.lang_file_dirs\n @@languages[lang_code.to_sym] = lang_file\n lang_file.load\n end\n self.use languages.first if current_language.nil?\n end",
"def backend(backend, options = {})\n @backends ||= []\n if backend.is_a?(Symbol)\n require \"global/backend/#{backend}\"\n backend_class = Global::Backend.const_get(camel_case(backend.to_s))\n @backends.push backend_class.new(options)\n elsif backend.respond_to?(:load)\n @backends.push backend\n else\n raise 'Backend must be either a Global::Backend class or a symbol'\n end\n end",
"def load_snippet_configs path\n return [] unless path\n Dir.chdir path do\n Dir.glob(\"**/*.json\").map do |file_path|\n json = JSON.load_file file_path\n proto = Google::Cloud::Tools::Snippetgen::Configlanguage::V1::SnippetConfig.new underscore_keys json\n proto.json_representation = json\n proto\n end\n end\n end",
"def append_path(*paths)\n @load_paths.push(*(paths.flatten))\n end",
"def load_paths\n @load_paths ||= Config::LoadPaths.new\n end",
"def translate_paths(body, env); end",
"def addFileDataSource(filePath)\n addSequenceSource(Sequence::File.new(File.new(filePath)))\n end",
"def update(target, *source_paths)\n patterns = Parser.new(*source_paths).patterns[:simple]\n LocaleFile.new(target).update(patterns)\n end",
"def register converter, *backends\n backends.each {|backend| backend == '*' ? (registry.default = converter) : (registry[backend] = converter) }\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def translate_json prefix, src\n json = JSON.parse src\n json.each do |translation_json|\n qualified_key = join_keys prefix, translation_json[\"value\"]\n translations.add locale, qualified_key, translation_json[\"name\"]\n end\n end",
"def load(path); end",
"def require_paths\n raise NotImplementedError\n end",
"def update_sources\n source_files_path = Dir['config/locales/**/*.en-EU.yml']\n source_files_path.each do |path|\n puts \"update #{path}\"\n @crowdin.update_file([{ dest: \"/#{File.basename(path).gsub('en-EU', 'en')}\",\n source: path }])\n end\n\n source_files_path = Dir['config/locales/main/en-EU.yml']\n source_files_path.each do |path|\n puts \"update #{path}\"\n @crowdin.update_file([{ dest: '/main.en.yml',\n source: path }])\n end\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end",
"def locale_file_path(locale)\n \"config/locales/#{locale}.yml\"\n end",
"def load_path=(load_path); end",
"def load_extension path\n instance_eval(File.read(File.join(File.dirname(__FILE__), path)))\n end",
"def add_to_dependency_load_paths #:nodoc:\n Dependencies.load_paths.concat(load_paths)\n end",
"def initialize(*paths)\n @configuration = {}\n paths.each { |f| load f }\n end",
"def init_translations; end",
"def paths(reload = T.unsafe(nil)); end",
"def setup_language_resources\n I18n.load_path = ['features/resources/localisation/english.yml']\n\n case ENV['Language']\n when 'english'\n I18n.locale = :en\n when 'spanish'\n I18n.locale = :es\n when 'italian'\n I18n.locale = :it\n else\n abort(\"Incorrect language set, cannot continue the test run: supported are 'english', 'italian' or 'spanish'\")\n end\nend",
"def set_load_paths(*paths)\n $:.concat(paths); load_paths.concat(paths)\n $:.uniq!; load_paths.uniq!\n end",
"def prepend_paths(*paths)\n self.paths.unshift(*paths)\n end",
"def add_autoload_paths_to_load_path=(_arg0); end",
"def add_autoload_paths_to_load_path=(_arg0); end",
"def create_locale_files\n @i18n_scope = model.i18n_scope.to_s\n @i18n_key = model.model_name.i18n_key.to_s\n @columns = model.column_names\n\n options[:locales].each do |locale|\n @locale = locale\n locale_file = File.join(\n 'config/locales/models', model_name.underscore, \"#{@locale}.yml\"\n )\n template 'locale.yml', locale_file\n end\n rescue NameError\n puts \"#{model_name} is undefined.\"\n end",
"def setLocale locale\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\tif @locales.empty?\n\t\t\t\traise SimpleLion::FilesystemException.new(@basepath, \"No SLLF files present!\")\n\t\t\tend\n\t\t\tif locale != nil\n\t\t\t\tif !@locales.include?(locale)\n\t\t\t\t\traise SimpleLion::FileException.new(@basepath + \"/\" + locale + \".sllf\", \"No such locale!\")\n\t\t\t\tend\n\t\t\t\t@locale = locale\n\t\t\t\t@file = []\n\t\t\t\tfilepath = @basepath + \"/\" + @locale + \".sllf\"\n\t\t\t\tFile.open(filepath) do |fh|\n\t\t\t\t\tname = \"\"\n\t\t\t\t\tvalue = \"\"\n\t\t\t\t\tcategory = nil\n\t\t\t\t\tcategories = []\n\t\t\t\t\ti = 0\n\t\t\t\t\tfh.readlines.each do |line|\n\t\t\t\t\t\tline.strip!\n\t\t\t\t\t\ti = i+1\n\t\t\t\t\t\tif line[0] == '['\n\t\t\t\t\t\t\tif !name.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Not adding previous string because found the beginning of another string declaration!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tparsed = line.partition(\"[\").last.partition(\"]\").first\n\t\t\t\t\t\t\tsep1 = line.partition(\"[\")[1]\n\t\t\t\t\t\t\tsep2 = line.partition(\"[\").last.partition(\"]\")[1]\n\t\t\t\t\t\t\tif sep1.empty? || sep2.empty?\n\t\t\t\t\t\t\t\tparsed = \"\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif parsed.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping invalid/empty string declaration!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tname = parsed\n\t\t\t\t\t\telsif line[0] == '{'\n\t\t\t\t\t\t\tparsed = line.partition(\"{\").last.partition(\"}\").first\n\t\t\t\t\t\t\tsep1 = line.partition(\"{\")[1]\n\t\t\t\t\t\t\tsep2 = line.partition(\"{\").last.partition(\"}\")[1]\n\t\t\t\t\t\t\tif sep1.empty? || sep2.empty?\n\t\t\t\t\t\t\t\tparsed = \"\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif parsed.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping invalid/empty category declaration!\\n\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif parsed == \"end\"\n\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Encountered end-of-category not matching to a category! Skipping...\\n\"\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\ttmpcat = category\n\t\t\t\t\t\t\t\t\t\tcategory = categories.pop\n\t\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\t\t@file << tmpcat\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\tcategory.addLocalizationEntry(tmpcat)\n\t\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tif category != nil\n\t\t\t\t\t\t\t\t\t\tcategories << category\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tcategory = SimpleLion::LocalizationCategory.new(parsed)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tvalue = line\n\t\t\t\t\t\t\tif name.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping value of invalid/empty string declaration!\\n\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif value.empty?\n\t\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping empty value of string!\\n\"\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tstr = SimpleLion::LocalizationString.new(name, value)\n\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\t@file << str\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tcategory.addLocalizationEntry(str)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tname = \"\"\n\t\t\t\t\t\t\tvalue = \"\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def set_sources\n @yaml[:sources].each do |name, path|\n @sources << Yuyi::Source.new(name, path)\n end\n end",
"def create_local\n template \"config/locales/en.rb\", \"config/locales/#{class_name.underscore}.en.yml\"\n end",
"def add_sources(builder)\n builder.add_source(CommandLineSource, :usage, \"Usage: ruby #{$0} [options]\")\n builder.add_source(YamlConfigFileSource, :from_complete_path, \"#{@config_file}\") if @config_file.match(/yml|yaml/i)\n builder.add_source(XmlConfigFileSource, :from_complete_path, \"#{@config_file}\") if @config_file.match(/xml/i)\n builder.add_source(EnvironmentSource, :with_prefix, \"portscan_\")\n end",
"def push_path(type, path, file_glob = \"**/*.rb\") \n\t\t enforce!(type => Symbol)\n\t\t load_paths[type] = [path, file_glob]\n\t\tend",
"def paths\n @paths ||= begin\n paths = super\n paths.add 'config/secrets', with: Ecrire::Theme.path + 'secrets.yml'\n paths.add 'config/database', with: Ecrire::Theme.path + 'secrets.yml'\n paths.add 'config/routes.rb', with: 'routes.rb'\n paths.add 'config/locales', with: 'locales', glob: \"**/*.{rb,yml}\"\n\n paths.add 'lib/tasks', with: 'tasks', glob: '**/*.rake'\n paths\n end\n end",
"def add_backend(auth_backend)\n @backends << auth_backend\n end",
"def i18n\n %w(en es).each do |locale|\n copy_file \"i18n.#{ locale }.yml\", \"config/locales/seo_landing_pages.#{ locale }.yml\"\n end\n end",
"def load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if !@loaded_paths.include?( expanded_path ) && File.exists?( expanded_path )\n $CLASSPATH << expanded_path\n load_paths << expanded_path\n @loaded_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def add_sass_load_path!(*paths)\n Sass.load_paths << File.join(*paths)\n end",
"def paths\n @paths ||= [\n data_path,\n output_path,\n converted_path,\n converted_fail_path,\n unpacked_path,\n unpacked_fail_path,\n recreated_path,\n ]\n end",
"def add(*files)\n # due to the multi passing of splat args, we can get Array-in-Array situations here\n files.flatten.each do |fn|\n @files.push(fn)\n if ! File.exists?(fn)\n next if self.class.skipmissing\n raise ArgumentError, \"file #{fn} does not exist\"\n end\n begin\n data = YAML.load(File.open(fn))\n if ! data.instance_of?(Hash)\n raise ArgumentError, \"file #{fn} does not contain a Hash\"\n end\n @cfg.deep_merge!(data.deep_symbolize_keys).deep_symbolize_keys\n rescue\n if ! self.class.skipbad\n raise\n end\n end\n end\n\n # resolve templates\n if self.class.templates\n resolve_templates\n end\n end",
"def preloaded_module_paths(resolver:, cache_key: T.unsafe(nil)); end",
"def register_template_path(path)\n template_paths.unshift(path)\n end",
"def load_api_source(source=nil, source_vars=nil)\n load_source_for(Elastics::Template::Api, source, source_vars)\n end",
"def initial_paths; end",
"def initialize(path, path_type = :full)\n super()\n @ext_name = :yml\n @path_type = path_type\n @path = path\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def loadpath(*list)\n @loadpath.concat(makelist(list)) unless list.empty?\n @loadpath\n end",
"def push_path(type, path, file_glob = \"**/*.rb\")\n enforce!(type => Symbol)\n load_paths[type] = [path, file_glob]\n end",
"def push_path(type, path, file_glob = \"**/*.rb\")\n enforce!(type => Symbol)\n load_paths[type] = [path, file_glob]\n end",
"def add_paths(paths)\n @paths.update(paths)\n end",
"def load_paths\n [root.join('lib'), root.join('spec')].join(':')\n end",
"def in_source_dir(*paths); end",
"def use_i18n; end",
"def loadpath(*paths)\r\n paths.reverse_each do |path|\r\n $LOAD_PATH.unshift File.expand_path(path)\r\n end\r\n \r\n $LOAD_PATH.uniq!\r\n $LOAD_PATH\r\n end",
"def template_path_with_engine_additions\n \"{#{template_paths.join(\",\")}}\"\n end",
"def sources\n %w[\n sample_source\n ]\nend",
"def inject_into_load_path\n \n # Add ALL paths under the engine root to the load path\n %w(app/controllers \n app/helpers \n app/models\n components\n lib).collect { |dir|\n File.join(root, dir)\n }.select { |dir| File.directory?(dir) }.each do |path|\n insert_into_load_path(path) \n end\n end",
"def load(path, host, settings = T.unsafe(nil), base_dir = T.unsafe(nil)); end",
"def from_path(path); end",
"def load_localization(locale = nil)\n if locale.blank?\n @current_localization = load_default_localizations\n else\n @current_localization = localizations.where(\"locale_id = ? AND path LIKE ?\", locale.id, \"#{path}%\").first\n end\n end",
"def load_settings(path)\n\n # Load the data files\n Konfig.load_directory(path)\n\n # Load all adapters\n built_in_adapters = File.join(File.dirname(__FILE__), 'adapters', '*.rb')\n require_all built_in_adapters\n\n user_adapters = File.join(path, 'adapters', '*_adapter.rb')\n require_all user_adapters\n\n # Apply the adapters to the data\n Adapter.create_child_instances(Konfig.default_store.data)\n Adapter.send_to_child_instances :adapt\n end",
"def set_paths(paths)\n @paths = paths\n self\n end",
"def set_paths(paths)\n @paths = paths\n self\n end",
"def initialize(path, language)\n @path = path\n @language = language\n end",
"def paths=(raw_paths)\n raw_paths = [raw_paths] unless raw_paths.respond_to? :each\n\n @paths = raw_paths.map { |path| Pathname.new(path) }\n end"
] |
[
"0.61598873",
"0.6106891",
"0.6106891",
"0.6089461",
"0.5996335",
"0.5996335",
"0.5957018",
"0.58532643",
"0.5843913",
"0.5732151",
"0.54969555",
"0.54711854",
"0.5455898",
"0.5443114",
"0.5434977",
"0.54027766",
"0.5373866",
"0.53678334",
"0.534962",
"0.52857524",
"0.52833754",
"0.52747756",
"0.52247214",
"0.52113086",
"0.520283",
"0.51760894",
"0.5169692",
"0.5157541",
"0.51418346",
"0.51232064",
"0.51232064",
"0.50996375",
"0.50785744",
"0.5044548",
"0.50300896",
"0.5014474",
"0.49847773",
"0.49842358",
"0.49813196",
"0.497883",
"0.49683905",
"0.49648863",
"0.49363324",
"0.4912653",
"0.49085337",
"0.4908494",
"0.49038655",
"0.4885166",
"0.48806638",
"0.48703286",
"0.48641253",
"0.4863919",
"0.48395583",
"0.48385468",
"0.4838157",
"0.48308933",
"0.48173523",
"0.4810644",
"0.48089606",
"0.48054805",
"0.47949386",
"0.47949386",
"0.4794601",
"0.47905162",
"0.47886676",
"0.47866166",
"0.47795674",
"0.47618198",
"0.47569692",
"0.47557238",
"0.47482795",
"0.47393754",
"0.47361568",
"0.47325572",
"0.47221372",
"0.4719341",
"0.47157678",
"0.47076815",
"0.47066966",
"0.47064418",
"0.47056514",
"0.4701117",
"0.4692006",
"0.4692006",
"0.4683941",
"0.46830863",
"0.46790096",
"0.4676008",
"0.46750724",
"0.4673104",
"0.4670112",
"0.46664482",
"0.4664602",
"0.4663516",
"0.46617934",
"0.46553916",
"0.4652163",
"0.4652163",
"0.46484816",
"0.46478143"
] |
0.5185214
|
25
|
Sets the load path instance. Custom implementations are expected to behave like a Ruby Array. source://i18n//lib/i18n/config.rb132
|
def load_path=(load_path); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def loadpath=(list)\n @loadpath = makelist(list)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_paths\n @load_paths ||= Config::LoadPaths.new\n end",
"def initialize(load_path: LOAD_PATH)\n @load_path = load_path\n end",
"def configure_i18n\n I18n.load_path += Dir[self.class.root_pathname.join('config', 'locales', '*.{rb,yml}')]\n end",
"def set_load_path!\n load_paths = configuration.load_paths || [] # TODO: from script/console the configuration isn't ran.\n load_paths.reverse_each { |dir| $LOAD_PATH.unshift(dir) if File.directory?(dir) } unless Rucola::RCApp.test? # FIXME: why??\n $LOAD_PATH.uniq!\n end",
"def load_path; end",
"def initialize_i18n\n trusty_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]\n configuration.i18n.load_path = trusty_locale_paths + extension_loader.paths(:locale)\n super\n end",
"def post_configure\n super\n @path = File.expand_path(path)\n end",
"def config_file_path=(path)\n self.config_file_paths = [path]\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end",
"def load_paths\n @load_paths ||= [\"urls.rb\", \"config/urls.rb\", \"mailers/*.rb\", \"controllers/**/*.rb\", \"controllers.rb\", \"helpers/*.rb\"]\n end",
"def load_path\n paths, file = [\"\"], current_file\n paths << File.dirname(file) if file\n paths + LOAD_PATH\n end",
"def locales_path=(path)\n # getting rid of the trailing slash\n if path.slice(path.size-1, path.size) == '/'\n path = path.slice(0, path.size-1)\n end\n\n @locales_path = path\n end",
"def set_load_paths(*paths)\n $:.concat(paths); load_paths.concat(paths)\n $:.uniq!; load_paths.uniq!\n end",
"def initialize(path, path_type = :full)\n super()\n @ext_name = :yml\n @path_type = path_type\n @original_path = path\n @relative_save_file_path = PathnameManager.new(path, path_type).relative_save_file_path\n end",
"def initialize(path, path_type = :full)\n super()\n @ext_name = :yml\n @path_type = path_type\n @path = path\n end",
"def initializer(path)\n super\n end",
"def initializer(path)\n super\n end",
"def require_paths=(val)\n @require_paths = Array(val)\n end",
"def require_path=(path)\n self.require_paths = Array(path)\n end",
"def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end",
"def inject_into_load_path\n \n # Add ALL paths under the engine root to the load path\n %w(app/controllers \n app/helpers \n app/models\n components\n lib).collect { |dir|\n File.join(root, dir)\n }.select { |dir| File.directory?(dir) }.each do |path|\n insert_into_load_path(path) \n end\n end",
"def load_path\n data[:load_path].nil? ? \"\" : data[:load_path]\n end",
"def initialize(parent_loader, loaders, module_name, path, loader_name, loadables)\n super(parent_loader, loader_name, loaders.environment)\n\n raise ArgumentError, 'path based loader cannot be instantiated without a path' if path.nil? || path.empty?\n\n @module_name = module_name\n @path = path\n @smart_paths = LoaderPaths::SmartPaths.new(self)\n @loaders = loaders\n @loadables = loadables\n unless (loadables - LOADABLE_KINDS).empty?\n #TRANSLATORS 'loadables' is a variable containing loadable modules and should not be translated\n raise ArgumentError, _('given loadables are not of supported loadable kind')\n end\n loaders.add_loader_by_name(self)\n end",
"def add_load_path(path)\n\t\t\t# Allow loading library code from lib directory:\n\t\t\t$LOAD_PATH << File.expand_path(path, site_root)\n\t\tend",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def _load(path)\n path = Pathname.new(path)\n @loader.load(path)\n end",
"def template_load_path\n @template_load_path ||= File.expand_path(File.dirname(self.filename))\n end",
"def loaded_from= path\n @loaded_from = path && path.to_s\n\n @full_gem_path = nil\n @gems_dir = nil\n @base_dir = nil\n end",
"def loaded_path; end",
"def initialize(*paths)\n @configuration = {}\n paths.each { |f| load f }\n end",
"def includes_load_paths; end",
"def set_paths(paths)\n @paths = paths\n self\n end",
"def set_paths(paths)\n @paths = paths\n self\n end",
"def load\n configuration # Need to call this to make sure it's populated\n self.instance_eval(IO.read(path), path, 1) if path && File.exists?(path)\n self\n end",
"def load_paths\n @_load_paths_was = %w(lib models shared).map { |path| Padrino.root(path) }\n @_load_paths ||= @_load_paths_was\n end",
"def internal_load_paths(paths)\n load_paths = []\n unless paths.is_a? Array\n paths = [paths]\n end\n \n paths.each do |path|\n expanded_path = File.expand_path(path)\n if File.exists?( expanded_path )\n @class_loader.addPath( expanded_path )\n \n load_paths << expanded_path\n end\n end\n \n load_paths\n end",
"def load_path\n # TODO: Could this be used to load app dir and blueprint.yml?\n # If not remove it\n owner.before_load_path(rootpath, self) if owner.respond_to?(:before_load_path)\n create_assets\n validate_if_segment\n create_components\n end",
"def path=(path)\n @path = File.expand_path(path)\n end",
"def set_path(path)\n @path = path\n end",
"def set_default_path\n unless @resource_config[:path]\n suffix = self.to_s.split('::').last\n @resource_config[:path] = Utility.underscore(suffix)\n end\n end",
"def load(path); end",
"def translations\n raise \"i18n has no load_path(s)\" if ::I18n.load_path.empty?\n ::I18n.backend.instance_eval do\n init_translations unless initialized?\n translations\n end\n end",
"def config_path=(value)\n @config_path = value\n end",
"def initialize(parent_loader, loaders, module_name, path, loader_name, loadables = LOADABLE_KINDS)\n super\n @path_index = Set.new\n end",
"def load_from(path)\n self.configure(Halcyon::Config::File.load(path))\n self\n end",
"def load_paths=(dirs)\n dirs.each do |dir|\n directory = File.expand_path(dir)\n $LOAD_PATH.unshift(directory) unless $LOAD_PATH.include?(directory)\n Dir[\"#{directory}/*.rb\"].each { |file| require file }\n end\n end",
"def initialize(path)\n @path = File.expand_path(path)\n end",
"def path=(path)\n Tidylib.load(path)\n @path = path\n end",
"def initialize(path, load=nil)\n @path = path\n @inihash = {}\n \n if load or ( load.nil? and FileTest.readable_real? @path )\n restore()\n end\n end",
"def paths\n @paths ||= begin\n paths = super\n paths.add 'config/routes.rb', with: 'routes.rb'\n paths.add 'config/locales', with: 'locales', glob: \"**/*.{rb,yml}\"\n paths\n end\n end",
"def loadpath(*paths)\r\n paths.reverse_each do |path|\r\n $LOAD_PATH.unshift File.expand_path(path)\r\n end\r\n \r\n $LOAD_PATH.uniq!\r\n $LOAD_PATH\r\n end",
"def add_autoload_paths_to_load_path=(_arg0); end",
"def add_autoload_paths_to_load_path=(_arg0); end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency\n self.class.mixable_app_types.keys.map(&:to_s).sort.each do |type|\n path = \"#{app_path}/#{type}\"\n @load_paths << path if File.directory?(path)\n end\n end\n end\n \n @load_paths\n end",
"def loadpath(*list)\n @loadpath.concat(makelist(list)) unless list.empty?\n @loadpath\n end",
"def set_path(path)\n path\n end",
"def initialize(filepath = nil)\n @path = filepath ? File.expand_path(filepath.to_s) : nil\n load\n end",
"def initialize path\n @path, @weight = path, 0\n @dependencies, @permissions, = [], []\n @name = File.basename(path).to_sym\n load_yaml\n end",
"def add_plugin_load_paths\n configuration.add_plugin_paths(extension_loader.paths(:plugin))\n super\n ActiveSupport::Dependencies.autoload_once_paths -= extension_loader.paths(:load)\n end",
"def load!(path=nil)\n if path\n super(path)\n else\n if root\n #load_version_stamp\n super\n end\n end\n self\n end",
"def using_yaml_path=(path)\n @using_yaml_path = path && Pathname.new(path)\n end",
"def settextpath(*)\n super\n end",
"def assign_paths\n self.path = generate_path(self)\n end",
"def set_path(v)\n @path = v\n end",
"def initialize(path)\n @path = path.to_s\n end",
"def add_to_dependency_load_paths #:nodoc:\n Dependencies.load_paths.concat(load_paths)\n end",
"def set_config_paths\n @config_file_path = \"config/dissect/\"\n end",
"def load_localization!\n reset_l10n_data\n\n # Load the rails localization\n if rails_localization_files\n rails_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n # if a country is defined\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n if locales.include?(\"#{lang}-#{country}\".to_sym)\n @@locales[\"#{lang}-#{country}\".to_sym].merge(YAML.load_file(file).symbolize_keys)\n else\n @@locales[\"#{lang}-#{country}\".to_sym] = YAML.load_file(file).symbolize_keys\n @@rails_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n @@languages << lang unless @@languages.include? lang\n else\n @@languages << lang unless @@languages.include? lang\n @f_locale = \"#{lang}-*\".to_sym\n @@locales[@f_locale] = @@locales[@f_locale].merge(YAML.load_file(file).symbolize_keys) if locales.include?(@f_locale)\n @@locales[@f_locale] = YAML.load_file(file).symbolize_keys unless locales.include?(@f_locale)\n end\n end\n end\n alias :load_translations! :load_localization!\n alias :load_localizations! :load_localization!\n\n # Load the UI localization\n if ui_localization_files\n ui_localization_files.each do |file|\n lang = File.basename(file, '.*')[0,2].downcase.to_sym\n if File.basename(file, '.*')[3,5]\n country = File.basename(file, '.*')[3,5].upcase.to_sym\n else\n country = '*'.to_sym\n end\n @@languages << lang unless @@languages.include? lang\n @@countries << country if ( country != :* && !@@countries.include?(country) )\n @file_locale = \"#{lang}-#{country}\".to_sym\n if locales.include?(@file_locale)\n @@locales[@file_locale] = @@locales[@file_locale].merge(YAML.load_file(file).symbolize_keys)\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n else\n @@locales[@file_locale] = YAML.load_file(file).symbolize_keys\n @@ui_locales[locale_name(\"#{lang}-#{country}\")] = \"#{lang}-#{country}\".to_sym\n end\n end\n end\n localize_rails\n # Return the path of the localization files\n return \"#{ui_localization_files} | #{rails_localization_files}\".to_s\n end",
"def initialize(path)\n @path = path\n @config = { PARAMETER_KEY => {}, METRIC_KEY => {} }\n @config_loaded = false\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def path=(path)\n @path = to_pathname(path)\n end",
"def load(path, env)\n yaml_safe_load(File.open(path).read)[env].each do |section, settings|\n section = instance_variable_get(\"@#{section}\")\n next unless section\n settings.each do |setting, value|\n unless section == @index || section == @source\n value = interpolate_string(value, nil)\n end\n setter(section, setting, value)\n end\n end\n end",
"def initialize path\n @__path = path\n @__evaluated = false\n @__emissions = []\n \n if evaluate_source_file path\n cache.load if Cache.exists? @__name\n\n Emissions.each do |emission|\n @__emissions.push emission if respond_to? emission\n end\n \n __send__ :loaded if respond_to? :loaded\n __send__ :module_init if respond_to? :module_init\n end\n end",
"def load(pathname, options={}) #, &block)\n $LOAD_MANAGER.load(pathname, options)\n end",
"def load_paths\n [root.join('lib'), root.join('spec')].join(':')\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def load!\n raise \"Source settler.yml not set. Please create one and set it by using Settler.source = <file>. When using Rails, please create a settler.yml file in the config directory.\" unless source\n\n self.config = File.exist?(source) ? YAML.load(ERB.new(File.read(source)).result).to_hash : {}\n self.config = config[namespace] || {} if namespace\n\n setting_class.build_settings! config\n setting_class.all.each{ |s| key = s.key; Settler.class.send(:define_method, key){ setting_for(key) } unless Settler.class.respond_to?(key) }\n end",
"def init(filepath)\n\t\tsuper # This loads the parent's init method (which stores self.root)\n\tend",
"def path(path)\n @path = path\n end",
"def add_location_to_context(iLocation)\n # * *iLocation* (_String_): Directory\n $LOAD_PATH << iLocation\n end",
"def add_autoload_paths_to_load_path; end",
"def add_autoload_paths_to_load_path; end",
"def use_i18n=(value); end",
"def PATH()\n $LOAD_MANAGER.PATH()\n end",
"def initialize(path)\n @data = YAML.load_file(path)\n end",
"def load_paths\n unless @load_paths\n @load_paths = []\n \n if File.directory?(app_path)\n @load_paths << app_path\n \n # Sort for consistency across platforms\n @load_paths.concat(Dir[\"#{app_path}/*/\"].map(&:chop).sort!)\n end\n end\n \n @load_paths\n end",
"def initialize(path, language)\n @path = path\n @language = language\n end",
"def load!\n if(path)\n if(File.directory?(path))\n conf = Dir.glob(File.join(path, '*')).sort.inject(Smash.new) do |memo, file_path|\n memo.deep_merge(load_file(file_path))\n end\n elsif(File.file?(path))\n conf = load_file(path)\n else\n raise Errno::ENOENT.new path\n end\n conf\n end\n end",
"def initialize(path)\n\t# path attribute that gets set on initialization\n\t\t@path = path\n\tend",
"def load_extension path\n instance_eval(File.read(File.join(File.dirname(__FILE__), path)))\n end",
"def load(path, host, settings = T.unsafe(nil), base_dir = T.unsafe(nil)); end",
"def load\n if File.exist?(@path) && !self.loaded?\n @source = File.read(@path)\n context = Context.new(self)\n eval @source, context.binding, @path.to_s, 1\n @loaded = true\n end \n end",
"def add_to_load_path #:nodoc:\n $LOAD_PATH.insert($LOAD_PATH.index(\"#{RAILS_ROOT}/lib\") + 1, *load_paths)\n end",
"def paths\n self.config[:paths]\n end",
"def path=(path)\n @path= path\n end",
"def initialize path\n @absolute_path = File.expand_path(path)\n end",
"def default_loadpath\n ['lib']\n end"
] |
[
"0.6769355",
"0.6761703",
"0.6761703",
"0.6641526",
"0.6622645",
"0.6529562",
"0.6456223",
"0.6377205",
"0.6334327",
"0.62206495",
"0.6048509",
"0.59980035",
"0.59872425",
"0.5951372",
"0.5912234",
"0.5900734",
"0.5899993",
"0.58590525",
"0.5852497",
"0.5852497",
"0.57656765",
"0.5757061",
"0.57547945",
"0.57384586",
"0.5731371",
"0.57092386",
"0.57069665",
"0.5695592",
"0.5694084",
"0.5676696",
"0.5676293",
"0.56434",
"0.5612539",
"0.55855733",
"0.55793333",
"0.55793333",
"0.5576991",
"0.555749",
"0.5552423",
"0.5549017",
"0.5545452",
"0.5488383",
"0.54797524",
"0.54536486",
"0.5436432",
"0.5419975",
"0.5415251",
"0.5400002",
"0.5388109",
"0.53851414",
"0.53841907",
"0.5371449",
"0.53695184",
"0.5363865",
"0.53590834",
"0.53590834",
"0.53446454",
"0.5344224",
"0.533563",
"0.5326969",
"0.53268915",
"0.5325617",
"0.5309969",
"0.530275",
"0.53024966",
"0.5301206",
"0.5300547",
"0.5297181",
"0.5287297",
"0.52849686",
"0.52761",
"0.52744925",
"0.52729756",
"0.526798",
"0.52639055",
"0.5260462",
"0.5258227",
"0.52580553",
"0.5255618",
"0.52546114",
"0.5253315",
"0.52525085",
"0.52426326",
"0.52416146",
"0.52416146",
"0.5226388",
"0.52213055",
"0.52180797",
"0.5213132",
"0.52128905",
"0.52127373",
"0.5210243",
"0.5200473",
"0.5199269",
"0.51958895",
"0.5182683",
"0.5181146",
"0.5180881",
"0.51801085",
"0.5177392"
] |
0.72574174
|
0
|
The only configuration value that is not global and scoped to thread is :locale. It defaults to the default_locale. source://i18n//lib/i18n/config.rb9
|
def locale; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_locale\n AppConfig.default_locale\n end",
"def default_locale=(locale); end",
"def default_locale; end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def locale=(locale)\n Thread.current[:locale] = locale.to_s\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def setup_default_locale\n locale = config.dig(\"locale\").split(\"- \").last\n\n application nil do\n <<~CONFS\n # Default i18n locale\n config.i18n.default_locale = :#{locale}\n\n CONFS\n end\n\n template \"templates/default_locale.tt\", \"config/locales/#{locale}.yml\" if locale != \"en\"\n end",
"def get_locale\n I18n.locale = session[:i18n] || I18n.default_locale || :en\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def system\n locale_from_env || default_locale\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def locale_defaults\n if by_subdomain?\n defaults.merge(subdomain: locale.to_s)\n else\n defaults.merge(locale: locale.to_s)\n end\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale=(locale)\n @@default_locale = locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def locale=(locale); end",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def locale_backend; end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value)\n @locale = value\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n if logged_in?\n if !current_user.shainmaster.setting.nil?\n if !current_user.shainmaster.setting.local.nil? && current_user.shainmaster.setting.local != ''\n I18n.locale = current_user.shainmaster.setting.local\n end\n end\n end\n end",
"def locale_name\n YAML.load(translation || \"{}\").with_indifferent_access[locale] || survey.default_locale_name\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_gettext_locale_db\n params[:locale] ||= User.current.try(:locale)\n end",
"def locale\n @locale || YodleeApi.locale\n end",
"def set_locale\n if request.subdomain == 'en'\n I18n.locale = request.subdomain\n else\n I18n.locale = params[:locale] || I18n.default_locale\n end\n end",
"def default_locale\n client.default_locale\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def locale\n @locale || { :country => \"US\", :language => \"en\", :variant => nil }\n end",
"def apply_locale; end",
"def options_locale\n current_user.try(:locale) ||\n session[:locale] ||\n http_accept_language.compatible_language_from(I18n.available_locales) ||\n I18n.default_locale\n end",
"def locale\n if self.language\n LANGUAGE_CODE[self.language]\n end\n end",
"def set_locale\n I18n.locale = params[:locale] if params[:locale].present?\n # \"en\"\n # params[:locale] if params[:locale].present?\n # current_user.locale\n # request.subdomain\n # request.env[\"HTTP_ACCEPT_LANGUAGE\"]\n # request.remote_ip\n end",
"def track_locale\n I18n.locale = session[:current_locale] || I18n.default_locale\n end",
"def set_locale\n if params[:locale]\n I18n.locale = session[:locale] = params[:locale] || I18n.default_locale\n else\n I18n.locale = session[:locale] || I18n.default_locale\n end\n end",
"def default_locale\n FastGettext.available_locales.first\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def locale\n self.padma.try :locale\n end",
"def locale\n lang = params.fetch(:language, I18n.default_locale).to_sym\n I18n.available_locales.include?(lang) ? lang : I18n.default_locale\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def locale=(value)\n if value == @defaults['ai.device.locale']\n @values.delete 'ai.device.locale' if @values.key? 'ai.device.locale'\n else\n @values['ai.device.locale'] = value\n end\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end",
"def set_locale\n I18n.locale = extract_locale || session[:locale] || I18n.default_locale\n session[:locale] = I18n.locale\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n if (user_signed_in? && I18n.available_locales.include?(current_user.lang))\n # If a user is signed in, put the preferred language.\n I18n.locale = current_user.lang\n else\n # If there isn't a logged in user, use the default value\n # defined in config.\n I18n.locale = I18n.default_locale\n end\n return\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def default_locale?\n I18n.default_locale == I18n.locale\n end",
"def locale\n current_site.locale || I18n.default_locale.to_s\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\nend",
"def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end",
"def configure(&block)\n block.call @locale\n end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def getLocaleCode\n # first default locale to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # next set locale to the locale in user record\n @locale_code = current_user.try(:locale) || @locale_code\n # next set locale to the locale passed as the locale param\n if (params.present? &&\n params['locale'].present? &&\n BaseRec::VALID_LOCALES.include?(params['locale'].to_s)\n )\n @locale_code = params['locale']\n end\n # set the locale in I18n\n I18n.locale = @locale_code\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def set_locale_from_options_inline\n <<-EOL\nif options[:locale]\n #{\"Mobility.enforce_available_locales!(options[:locale])\" if I18n.enforce_available_locales}\n locale = options[:locale].to_sym\n options[:locale] &&= !!locale\nelse\n locale = Mobility.locale\nend\nEOL\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end"
] |
[
"0.7460023",
"0.74554276",
"0.7307174",
"0.71970034",
"0.7192265",
"0.7185846",
"0.70501685",
"0.70155674",
"0.6964818",
"0.6962019",
"0.6868439",
"0.68397456",
"0.68173033",
"0.68173033",
"0.67999643",
"0.6784234",
"0.6784234",
"0.6738898",
"0.67383397",
"0.67383397",
"0.6713762",
"0.66972804",
"0.6670811",
"0.66404927",
"0.6637412",
"0.66346693",
"0.6628771",
"0.66183174",
"0.6614192",
"0.6611305",
"0.6611305",
"0.66000473",
"0.6595717",
"0.6591905",
"0.6591905",
"0.6591905",
"0.6591905",
"0.6580421",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.6561335",
"0.65575016",
"0.6550646",
"0.65424716",
"0.65393233",
"0.65391916",
"0.6537842",
"0.6528506",
"0.65145266",
"0.6511482",
"0.65093863",
"0.6508769",
"0.6508769",
"0.6503759",
"0.65019953",
"0.64930016",
"0.6490777",
"0.6489311",
"0.6481502",
"0.64789504",
"0.64383346",
"0.64340734",
"0.64313626",
"0.64300096",
"0.64256984",
"0.6421723",
"0.64166564",
"0.6416093",
"0.6410986",
"0.63979274",
"0.63979274",
"0.63959736",
"0.6394477",
"0.6390217",
"0.6385664",
"0.63854206",
"0.6384385",
"0.63842636",
"0.6382262",
"0.638122",
"0.63804984",
"0.63804984",
"0.637631",
"0.6376261",
"0.6371558",
"0.6370093",
"0.6365073",
"0.63649046",
"0.63493866",
"0.63493866"
] |
0.0
|
-1
|
Sets the current locale pseudoglobally, i.e. in the Thread.current hash. source://i18n//lib/i18n/config.rb14
|
def locale=(locale); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def locale=(locale)\n Thread.current[:locale] = locale.to_s\n end",
"def set_locale\n\t\tif current_user\n\t\t\tRails.logger.debug { \"Setting locale <#{current_user.country.locale.to_sym}> using current user: #{current_user}\" }\n\t\t\tI18n.locale = current_user.country.locale.to_sym\n\t\telse\n\t\t\tRails.logger.debug { \"Using default locale <#{I18n.default_locale}>, because no user is signed in.\" }\n\t\t\tI18n.locale = I18n.default_locale\n\t\tend\n\tend",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def set_locale\n I18n.locale = I18n.default_locale\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end",
"def set_locale\n I18n.locale = current_user.try(:locale) || I18n.default_locale\n end",
"def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = extract_locale || session[:locale] || I18n.default_locale\n session[:locale] = I18n.locale\n end",
"def set_locale\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\tLOG.debug(fname) {\">>>>\"}\n\t\t#puts \"set_locale:params[:locale]=#{params[:locale]}\"\n\t\tif params[:locale]\n\t\t\tI18n.locale = params[:locale]\n\t\t\tsession[:lng] = I18n.locale\n\t\telse\n\t\t\tunless @current_user.nil?\n\t\t\t\t#puts \"set_locale:@current_user=#{@current_user} lng=#{@current_user.language}\"\n\t\t\t\tI18n.locale = @current_user.language\n\t\t\telse\n\t\t\t\tif session[:lng]\n\t\t\t\t\tI18n.locale = session[:lng]\n\t\t\t\telse\n\t\t\t\t\tI18n.locale = PlmServices.get_property(:LOCAL_DEFAULT)\n\t\t\t\t\tsession[:lng] = I18n.locale\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tLOG.debug(fname) {\"<<<<session=#{session}\"}\n\tend",
"def set_locale\n puts \"========#{Rails.env}\"\n # puts '********'\n # puts \"#{Rails.application.secrets}*********\"\n I18n.locale = session[:locale] || I18n.default_locale\n end",
"def set_locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n locale = params[:locale] || session[:locale] ||\n # (current_user.site_language if user_signed_in?) ||\n I18n.default_locale\n locale = AVAILABLE_LOCALES.keys.include?(locale) ? locale : I18n.default_locale\n session[:locale] = I18n.locale = locale\n end",
"def default_locale=(locale); end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def track_locale\n I18n.locale = session[:current_locale] || I18n.default_locale\n end",
"def set_locale\n if params[:locale]\n I18n.locale = session[:locale] = params[:locale] || I18n.default_locale\n else\n I18n.locale = session[:locale] || I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n if logged_in?\n if !current_user.shainmaster.setting.nil?\n if !current_user.shainmaster.setting.local.nil? && current_user.shainmaster.setting.local != ''\n I18n.locale = current_user.shainmaster.setting.local\n end\n end\n end\n end",
"def set_locale\n if (user_signed_in? && I18n.available_locales.include?(current_user.lang))\n # If a user is signed in, put the preferred language.\n I18n.locale = current_user.lang\n else\n # If there isn't a logged in user, use the default value\n # defined in config.\n I18n.locale = I18n.default_locale\n end\n return\n end",
"def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end",
"def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end",
"def set_locale\n rxp = Regexp.new('[a-zA-Z]{2}')\n user_locale = cookies[:locale] || params[:locale]\n user_locale = user_locale.present? ? user_locale.scan(rxp) : 'en'\n # Check, is this locale available for using.\n # Please note: this needed for disable invalid locale warning.\n available = I18n.available_locales.include?(user_locale[0].to_sym)\n I18n.locale = available ? user_locale[0] : 'en'\n end",
"def set_locale\n I18n.locale = \"fr\"\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end",
"def set_locale\n locale = request.subdomains.first\n locale = (logged_in? ?\n current_user.profile.language :\n browser_language) if locale.blank? || !I18n.available_locales.include?(locale.to_sym)\n I18n.locale = locale\n end",
"def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end",
"def set_locale\n I18n.locale = if user_signed_in?\n current_user.language.to_sym\n else\n I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.select_locale( params[:locale], session[:locale], I18n.from_http_header(request) )\n logger.info \"Using language: #{I18n.locale}\"\n session[:locale] = I18n.locale\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end",
"def set_locale\n if user_signed_in?\n I18n.locale = current_user.language.to_sym\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def set_locale\n I18n.locale = cookies[:locale] || params[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale\n end",
"def set_locale\n # Get the current path and request method (useful in the layout for changing the language)\n @current_path = request.env['PATH_INFO']\n @request_method = request.env['REQUEST_METHOD']\n\n # Try to get the locale from the parameters, from the session, and then from the navigator\n if params[:user_locale]\n # Store the locale in the session\n Locale.code = params[:user_locale][:code]\n session[:locale] = Locale.code\n elsif session[:locale]\n Locale.code = session[:locale]\n else\n Locale.code = local_case(get_valid_lang_from_accept_header)\n end\n\n logger.debug \"[globalite] Locale set to #{Locale.code}\"\n # render the page\n yield\n\n # reset the locale to its default value\n Locale.reset!\n end",
"def set_locale\n I18n.locale = :es || I18n.default_locale\n end",
"def set_locale\n# logger.debug \"* Locale currently is '#{I18n.locale}', params[:locale] = '#{params[:locale] }'\"\n# logger.debug \"* cookies[:locale] = '#{cookies[:locale] }', HTTP_ACCEPT_LANGUAGE: '#{request.env[\"HTTP_ACCEPT_LANGUAGE\"] }'\"\n accept_locales = LOCALES.keys # See config/application.rb for accepted LOCALES\n\n locale = params[:locale] if accept_locales.include?( params[:locale] )\n if locale.nil? # Use the cookie only when set or enabled\n locale = cookies[:locale] if accept_locales.include?( cookies[:locale] )\n else # Store the chosen locale when it changes\n cookies[:locale] = locale\n end\n\n current_locale = locale || I18n.default_locale # This covers also the default case when cookies are not enabled\n unless current_locale.nil?\n I18n.locale = to_safe_sym( current_locale, accept_locales )\n logger.debug \"* Locale is now set to '#{I18n.locale}'\"\n end\n end",
"def set_locale\n# logger.debug \"* Locale currently is '#{I18n.locale}', params[:locale] = '#{params[:locale] }'\"\n# logger.debug \"* cookies[:locale] = '#{cookies[:locale] }', HTTP_ACCEPT_LANGUAGE: '#{request.env[\"HTTP_ACCEPT_LANGUAGE\"] }'\"\n accept_locales = LOCALES.keys # See config/application.rb for accepted LOCALES\n\n locale = params[:locale] if accept_locales.include?( params[:locale] )\n if locale.nil? # Use the cookie only when set or enabled\n locale = cookies[:locale] if accept_locales.include?( cookies[:locale] )\n else # Store the chosen locale when it changes\n cookies[:locale] = locale\n end\n\n current_locale = locale || I18n.default_locale # This covers also the default case when cookies are not enabled\n unless current_locale.nil?\n I18n.locale = to_safe_sym( current_locale, accept_locales )\n logger.debug \"* Locale is now set to '#{I18n.locale}'\"\n end\n end",
"def set_locale\n @current_user = User.find_user(session)\n puts \"set_locale:params[:locale]=#{params[:locale]}\"\n if params[:locale]\n I18n.locale = params[:locale]\n session[:lng] = I18n.locale\n else\n unless @current_user.nil?\n puts \"set_locale:@current_user=#{@current_user} lng=#{@current_user.language}\"\n I18n.locale = @current_user.language\n else\n if session[:lng]\n I18n.locale = session[:lng]\n else\n I18n.locale = PlmServices.get_property(:LOCAL_DEFAULT)\n session[:lng] = I18n.locale\n end\n end\n end\n puts \"fin de set_locale\"\n end",
"def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def locale=(locale)\n @@default_locale = locale\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end",
"def set_locale\n if cookies[:locale].nil?\n if signed_in?\n I18n.locale = cookies[:locale] = current_user.language\n end\n #if not signed in, the locale will be the default (en)\n else\n I18n.locale = cookies[:locale]\n end\n end",
"def set_locale_with_fallback(locale)\n # Loading the default (fallback) locale\n set_locale Locale.find_main_cached.short.to_sym\n\n # Loading the current locale\n current_locale = @loaded_locales.detect { |loc| loc.short.to_sym == locale }\n if current_locale && current_locale != Locale.find_main_cached\n set_locale current_locale.short.to_sym\n @current_locale = current_locale\n else\n @current_locale = Locale.find_main_cached\n end\n end",
"def set_locale\n available = %w{en de}\n I18n.locale = params[:locale] || request.compatible_language_from(available)\n end",
"def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend",
"def set_locale\n I18n.locale = 'en'\n return\n\n # working, but disabled until translations are done\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = extract_locale_from_accept_language_header\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end",
"def set_locale\n I18n.locale = :fi\n end",
"def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = 'en'\n\n # if params[:locale].present? || session[:locale].present?\n # session[:locale] = params[:locale] if params[:locale].present?\n # I18n.locale = session[:locale]\n # else\n # logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n # I18n.locale = extract_locale_from_accept_language_header\n # logger.debug \"* Locale set to '#{I18n.locale}'\"\n # end\n end",
"def set_locale\n if params[:locale].nil?\n if current_user && I18n.available_locales.include?(current_user.locale.to_sym)\n I18n.locale = current_user.locale\n else\n I18n.locale = I18n.default_locale\n end\n elsif I18n.available_locales.include? params[:locale].to_sym\n I18n.locale = params[:locale]\n else\n flash_now(:notice, I18n.t('locale_not_available', locale: params[:locale]))\n end\n end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def set_locale\n if params[:locale].nil?\n if session[:locale].nil?\n I18n.locale = :ar\n else\n I18n.locale = session[:locale]\n end\n else\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n end\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def set_locale\n session[:locale] = params[:locale]\n session[:locale] ||= extract_locale_from_header\n# return switch_locale_and_redirect_to_referer if params[:locale].present?\n @locale = Locale.new session[:locale]\n I18n.locale = @locale.current\n end",
"def add_current_locale\n locale = ::Mongoid::Fields::I18n.locale.to_s\n self.locales << locale unless self.locales.include?(locale)\n end",
"def set_locale\n\t\t\tif current_user.present? && current_user.locales.present? && current_user.locales.count == 1\n\t\t\t\tI18n.locale = params[:locale] || current_user.locales.first || I18n.default_locale\n\t\t\telse\n\t\t\t\tI18n.locale = params[:locale] || I18n.default_locale\n\t\t\tend\n\t\tend",
"def set_locale\n if params[:locale].nil?\n I18n.locale = session[:locale].nil? ? :ar : session[:locale]\n else\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n end\n end",
"def set_translation\n if params[:locale].blank? && session[:current_locale].present?\n ::I18n.locale = session[:current_locale]\n elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)\n session[:current_locale] = ::I18n.locale = params[:locale]\n elsif current_alchemy_user && current_alchemy_user.respond_to?(:language) && current_alchemy_user.language.present?\n ::I18n.locale = current_alchemy_user.language\n else\n ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale\n end\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n I18n.locale = params[:locale] \n end",
"def set_current_language(lang)\n GetText.locale, prev_value = sanitize_lang(lang), GetText.locale\n prev_value\n end",
"def set_locale\n if params[:locale]\n cookies[:locale] = params[:locale]\n redirect_to request.referer || root_url\n end\n I18n.locale = cookies[:locale] || I18n.default_locale\n end",
"def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end",
"def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end",
"def set_locale\n if params[:set_locale]\n if I18n.available_locales.include?(params[:set_locale].to_sym)\n I18n.locale = params[:set_locale]\n else\n flash.now[:notice] = \"#{params[:set_locale]} translations not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value)\n @locale = value\n end",
"def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end",
"def set_locale\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = params[:locale] || locale_from_header || I18n.default_locale\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end",
"def set_locale\n I18n.locale = :pl\n end"
] |
[
"0.79651",
"0.7778035",
"0.7643022",
"0.76200086",
"0.75704306",
"0.7561668",
"0.7561668",
"0.75455534",
"0.74885684",
"0.74237764",
"0.7416121",
"0.73989516",
"0.73667914",
"0.7357776",
"0.7331059",
"0.7329447",
"0.7324575",
"0.7303647",
"0.72868264",
"0.72778463",
"0.72057176",
"0.7204528",
"0.71900123",
"0.71900123",
"0.71900123",
"0.71900123",
"0.7173429",
"0.7169959",
"0.7163155",
"0.7148369",
"0.7128741",
"0.71187717",
"0.7103386",
"0.7092296",
"0.7090254",
"0.7090254",
"0.70747167",
"0.70573664",
"0.70536834",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.70467025",
"0.7034271",
"0.7034086",
"0.7034086",
"0.7029331",
"0.70247597",
"0.7019755",
"0.70111954",
"0.7001096",
"0.6996139",
"0.6996139",
"0.6978456",
"0.6971575",
"0.69552463",
"0.69529533",
"0.69529533",
"0.694844",
"0.6947142",
"0.69377035",
"0.69229496",
"0.6913668",
"0.69100827",
"0.6905502",
"0.6883629",
"0.6870227",
"0.6867129",
"0.68625945",
"0.6860951",
"0.6860483",
"0.6856171",
"0.68534124",
"0.68481386",
"0.68479425",
"0.68329513",
"0.68255657",
"0.68180996",
"0.6817891",
"0.68176585",
"0.68145764",
"0.679857",
"0.6792219",
"0.6791646",
"0.6787846",
"0.6753218",
"0.6753218",
"0.6737719",
"0.6725971",
"0.6719935"
] |
0.7084856
|
36
|
Returns the current handler for situations when interpolation argument is missing. MissingInterpolationArgument will be raised by default. source://i18n//lib/i18n/config.rb97
|
def missing_interpolation_argument_handler; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def string_interpolation?(value = @value)\n !value.index(INTERPOLATION).nil?\n end",
"def method_missing(meth, *args, &block)\n return 'Unknown config value: ' + meth.to_s\n end",
"def config\n Wrangler::ExceptionHandler.config\n end",
"def interpolation_patterns; end",
"def interpolation\n # Just return the interpolation type for pre-2012 setups\n return (@interpolation || :constant) unless has_2012_tangents?\n \n return :constant if curve_order.to_s == \"constant\"\n return :hermite if curve_order.to_s == \"cubic\" && (curve_mode.to_s == \"hermite\" || curve_mode.to_s == \"natural\")\n return :bezier if curve_order.to_s == \"cubic\" && curve_mode.to_s == \"bezier\"\n return :linear if curve_order.to_s == \"linear\"\n \n raise \"Cannot determine interpolation for #{inspect}\"\n end",
"def default_error_handler( state, node, exception )\n\t\tcase self.options[:on_render_error].to_s\n\t\twhen 'ignore'\n\t\t\tself.log.debug \" not rendering anything for the error\"\n\t\t\treturn ''\n\n\t\twhen 'comment'\n\t\t\tself.log.debug \" rendering error as a comment\"\n\t\t\tmsg = \"%s: %s\" % [ exception.class.name, exception.message ]\n\t\t\tif self.options[:debugging_comments]\n\t\t\t\texception.backtrace.each {|line| msg << \"\\n\" << line }\n\t\t\tend\n\t\t\treturn self.make_comment( msg )\n\n\t\twhen 'propagate'\n\t\t\tself.log.debug \" propagating error while rendering\"\n\t\t\traise( exception )\n\n\t\telse\n\t\t\traise Inversion::OptionsError,\n\t\t\t\t\"unknown exception-handling mode: %p\" % [ self.options[:on_render_error] ]\n\t\tend\n\tend",
"def method_missing symbol, *args, &block\n return config[symbol] if config.has_key? symbol\n super symbol, *args, &block\n end",
"def method_missing(meth, *args, &blk)\n configuration.key?(meth.to_s) ? configuration.fetch(meth.to_s) : super\n end",
"def method_missing(meth, *args, &blk)\n configuration.key?(meth.to_s) ? configuration.fetch(meth.to_s) : super\n end",
"def method_missing(sym)\n return @locals[sym] if @locals.key?(sym)\n return config[sym] if config.key?(sym)\n super\n end",
"def exception_handler\n @exception_handler ||= {}\n end",
"def method_missing(method_name, *args, &block)\n config = Loquacious::Configuration.for method_name, &block\n raise Adhearsion::Configuration::ConfigurationError.new \"Invalid plugin #{method_name}\" if config.nil?\n config\n end",
"def method_missing(method_name, *args, &block)\n config = Loquacious::Configuration.for method_name, &block\n raise Adhearsion::Configuration::ConfigurationError.new \"Invalid plugin #{method_name}\" if config.nil?\n config\n end",
"def current_handler\n @current_handler || @default_handler\n end",
"def i18n_options\n default_i18n_options.merge(event_interpolations).transform_values do |value|\n if value.is_a?(String)\n decidim_html_escape(value)\n else\n value\n end\n end\n end",
"def method_missing(sym, *args)\n Configuration.fetch(sym, '')\n end",
"def method_missing(method, *args, &block)\n val = settings[method] #instance_variable_get \"@#{method.to_s}\"\n val.nil? ? nil : val\n end",
"def method_missing(method, *args, &block)\n if method.to_s =~ /^_(.+)$/\n arg = @in_args[$1.to_sym] || @out_args[$1.to_sym]\n return arg if !arg.nil?\n end\n\n super\n end",
"def method_missing(method, *args)\n \"#{method.to_s} not a valid formatter!\"\n end",
"def ignore_interpolation? arg, suspect\n return unless string_interp? arg\n return true unless arg[1].chomp.empty? # plain string before interpolation\n\n first_interp = arg.find_nodes(:evstr).first\n return unless first_interp\n\n first_interp[1].deep_each do |e|\n if suspect == e\n return false\n end\n end\n\n true\n end",
"def method_missing(method_name, *args, &block)\n case method_name\n when /^(s3n?)_(.*)_prefix$/\n if pattern = @path_templates[$2.to_sym]\n Pathology.template(pattern).interpolate(\n @options.merge({protocol: $1})\n )\n else\n super\n end\n else\n super\n end\n end",
"def method_missing(meth, *args, &block)\n config[meth.to_s]\n end",
"def default_handler\n @default_handler\n end",
"def method_missing(key, *args)\n meth = key.to_s.gsub(/^get_/, \"\")\n if @configuration.has_key?(meth)\n @configuration[meth]\n else\n STDERR.puts \"No key #{meth} defined in #{@config_file}\"\n end\n end",
"def error_handler\n @error_handler || DEFAULT_ERROR_HANDLER\n end",
"def method_missing(sym, *args, &block)\n if configuration.respond_to?(sym)\n configuration.send(sym, *args, &block)\n else\n super\n end\n end",
"def method_missing(name, *args, &block)\n method_name = name.to_s\n return super if Settler.private_methods(false).map(&:to_s).include?(method_name)\n\n if config.nil?\n Settler.load!\n return send(method_name)\n end\n\n warn \"[Settler] Warning: setting missing: #{method_name}\" if report_missing\n raise \"[Settler] Error: setting missing: #{method_name}\" if raise_missing\n\n nil\n end",
"def greetings_interpolation(name)\n # code goes here\nend",
"def method_missing(name, *args, &blk)\n return self[name.to_s] if has_key?(name.to_s)\n return self['config'][name.to_s] if self['config'] && self['config'].has_key?(name.to_s)\n super(name, *args, &blk)\n end",
"def method_missing(name, *args, &blk)\n return self[name.to_s] if has_key?(name.to_s)\n return self['config'][name.to_s] if self['config'] && self['config'].has_key?(name.to_s)\n super(name, *args, &blk)\n end",
"def method_missing (name, *args)\n @config.has_key?(name.to_s) ? @config[name.to_s] : super\n end",
"def find_template_extension_from_handler_with_generic_paths(template_path, template_format = @template.template_format)\r\n extension = find_template_extension_from_handler_without_generic_paths(template_path, template_format)\r\n if extension.blank? and search_generic_view_paths?\r\n self.class.template_handler_extensions.each do |handler_extension|\r\n return handler_extension if controller.find_generic_base_path_for(template_path, handler_extension)\r\n end\r\n end\r\n extension\r\n end",
"def default_i18n_subject(interpolations = {})\n ''\n end",
"def method_missing(name, *args, &block)\n notify(name, args) if name.to_s.end_with?(\"=\")\n\n return config.send(name, *args, &block) if config.respond_to? name\n\n super\n end",
"def method_missing (name, *args)\n @config.has_key?(name.to_s) ? @config[name.to_s] : super\n end",
"def rescue_with_handler(exception)\n to_return = super\n if to_return\n verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?\n logger.info(\"[RESCUE STYLE] rescue_with_handler\") if verbose\n data = get_exception_data\n status_code = status_code_for_exception(exception)\n #We only send email if it has been configured in environment\n send_email = should_email_on_exception?(exception, status_code, verbose)\n #We only send web hooks if they've been configured in environment\n send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)\n the_blamed = ExceptionNotification::Notifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)\n rejected_sections = %w(request session)\n # Debugging output\n verbose_output(exception, status_code, \"rescued by handler\", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose\n # Send the exception notification email\n perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email\n # Send Web Hook requests\n ExceptionNotification::HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotification::Notifier.config, exception, self, request, data, the_blamed) if send_web_hooks\n pass_it_on(exception, ENV, verbose)\n end\n to_return\n end",
"def method_missing(sym)\n return config[sym] if config.key?(sym)\n\n super\n end",
"def get_handler\n handler = YAML.load(self.code)\n # If it could not be deserialized property try registering its class\n # Constantize supposedly only converts a string into the constant,\n # but somehow it is allowing YAML to create the correct instance.\n # Black magic, clearly, but it works, as black magic usually does.\n if handler.instance_of? YAML::Object\n handler.class.constantize\n handler = YAML.load(self.code)\n end\n\n handler\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def _handle_action_missing(*args); end",
"def method_missing(missing_method_name, *args, &block)\n if 'cfg' == missing_method_name.to_s\n self.config.settings\n else\n super\n end\n end",
"def method_missing(key, *args, &block)\n begin\n value = fetch(key.to_s)\n rescue IndexError\n raise MissingSetting, \"Missing setting '#{key}' in #{@section}\"\n end\n value.is_a?(Hash) ? self.class.new(value, \"'#{key}' section in #{@section}\") : value\n end",
"def respond_to_missing?(method_name)\n @original_handler.respond_to?(method_name)\n end",
"def interpoltype()\n return :linear\n end",
"def handler_config\n\t\treturn self.configured_handlers.where(\n\t\t\tsend_spec: self.conn.sub_addr,\n\t\t\trecv_spec: self.conn.pub_addr\n\t\t).first\n\tend",
"def method_missing(name, *args)\n @config.fetch(name.to_s, nil)\n end",
"def accept(evaluator)\n evaluator.string_interpolation(self)\n end",
"def custom_exception_handler(exception)\n custom_exception_handlers[exception.to_s]\n end",
"def handler_for(path)\n handler[ path.split('.').last ]\n end",
"def handle_exception(exception, options = {})\n request = options[:request]\n render_errors = options[:render_errors] || false\n proc_name = options[:proc_name] || config[:app_name]\n error_messages = options[:error_messages] || ['']\n\n error_messages = [error_messages] unless error_messages.is_a?(Array)\n\n if exception.respond_to?(:backtrace)\n backtrace = exception.backtrace\n else\n backtrace = caller\n end\n\n # extract the relevant request data and also filter out any params\n # that should NOT be logged/emailed (passwords etc.)\n request_data = request_data_from_request(request) unless request.nil?\n\n supplementary_info = nil\n\n unless config[:call_for_supplementary_info].nil?\n supplementary_info = config[:call_for_supplementary_info].call(request)\n supplementary_info = [supplementary_info] unless supplementary_info.is_a?(Array)\n end\n\n unless supplementary_info.blank?\n error_messages << \"Supplementary info:\"\n error_messages += supplementary_info\n end\n\n if exception.nil?\n exception_classname = nil\n status_code = nil\n log_error error_messages.inspect\n log_error backtrace\n log_error \"Request params were:\"\n log_error request_data.to_yaml\n error_string = error_messages.shift\n else\n status_code =\n Wrangler::ExceptionHandler.status_code_for_exception(exception)\n\n log_exception(exception, request_data, status_code, error_messages)\n\n if exception.is_a?(Class)\n exception_classname = exception.name\n else\n exception_classname = exception.class.name\n end\n\n if exception.respond_to?(:message)\n error_string = exception.message\n else\n error_string = exception.to_s\n end\n end\n\n if send_notification?(exception, request, status_code)\n if notify_with_delayed_job?\n # don't pass in request as it contains not-easily-serializable stuff\n log_error \"Wrangler sending email notification asynchronously\"\n Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,\n exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data)\n else\n log_error \"Wrangler sending email notification synchronously\"\n Wrangler::ExceptionNotifier.deliver_exception_notification(exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data,\n request)\n end\n end\n\n if render_errors\n render_error_template(exception, status_code)\n end\n\n rescue Exception => unhandled_exception\n # if it looks like a temporary error interacting with SMTP, then enqueue\n # the error using delayed job if possible\n # (testing by name this way in case the exception isn't loaded into\n # environment, which would cause a NameError and be counterproductive...)\n if unhandled_exception.class.name == 'Net::SMTPAuthenticationError' &&\n Wrangler::ExceptionNotifier.respond_to?(:send_later)\n\n log_error \"Wrangler failed to send error notification: #{unhandled_exception.class.name}:\"\n log_error \" #{unhandled_exception.to_s}\"\n\n # note: this is specific to an old-ish version of delayed job...should\n # make wrangler compatible with the old and the new...\n log_error \"Wrangler attempting to send via delayed job\"\n Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,\n exception_classname,\n error_string,\n error_messages,\n proc_name,\n backtrace,\n supplementary_info,\n status_code,\n request_data)\n else\n log_error \"/!\\\\ FAILSAFE /!\\\\ Wrangler encountered an unhandled exception \" +\n \"while trying to handle an error. The arguments it received \" +\n \"were:\"\n log_error \" exception: #{exception.inspect}\"\n log_error \" options: #{options.inspect}\"\n log_error \"The unhandled error encountered was #{unhandled_exception.class.name}:\"\n log_error \" #{unhandled_exception.to_s}\"\n end\n end",
"def handle(name)\n if name.is_a?(String)\n menu = menu_options.assoc(name)\n if menu\n name, *args = menu[1][1 .. -1]\n else\n self.flash = \"Invalid option\"\n end\n end\n if name.is_a?(Symbol) and self.respond_to?(name)\n self.send(name, *args)\n elsif name.is_a?(String)\n \"\"\n else\n raise Puerto::HandlerNotFound.new(self.class, name)\n end\n rescue Puerto::HandlerNotFound\n self.flash = \"Not implemented yet\"\n nil\n end",
"def interp_option(type)\n @configure_args << \"--enable-#{type}interp\"\n end",
"def method_missing(format, *args, &block)\n raise ArgumentError, \":#{format} format already set\" if formats.any? { |name, proc| name.eql?(format) }\n raise ArgumentError, 'Must not supply both argument and block' if !args.empty? && block_given?\n if !args.empty? && (!args.first.nil? || args.size > 1)\n raise ArgumentError, 'The only argument accepted is nil for disabling formats'\n end\n formats << [format, block || (args.empty? ? proc {} : nil)]\n end",
"def interpolate( dindex )\n return method( self.interpoltype ).call( dindex )\n end",
"def default_exception_renderer=(_arg0); end",
"def log_handler\n #'@log_handler || ' go to worker/global log_handler even if @log_handler is defined\n defined?(@log_handler) ? @log_handler : @worker.nil? ? Beanpicker::log_handler : @worker.log_handler\n end",
"def method_missing(method, *args)\n if method =~ /current_(.*)/\n return path_part( @parts[$1.to_sym] ) if @parts.has_key?($1.to_sym)\n end\n\n super\n end",
"def apply_config_interpolations(item, units:, **)\n if item.is_a?(Hash)\n item.transform_values { |v| send(__method__, v, units: units) }\n elsif item.is_a?(Array)\n item.map { |v| send(__method__, v, units: units) }\n elsif item.is_a?(String) && item.include?('%{')\n item.gsub(SPRINTF_NAMED_REFERENCE) { |s| units[$1&.to_sym] || s }\n else\n item\n end\n end",
"def message\n configuration.default_message || @exception.message\n end",
"def route_eval(&block)\n if options.auto_locale\n if params[:locale]\n I18n.locale = params[:locale].to_sym rescue options.locale\n end\n end\n super(&block)\n end",
"def method_missing(*args)\n default\n end",
"def method_missing(name, *args)\n @config.respond_to?(name) ? @config.send(name, *args) : super\n end",
"def interpolation_options\n { resource_name: @term.display_name }\n end",
"def method_missing(m, *a, &b)\n read_settings(m.to_s)\n end",
"def method_missing(m, *args, &block)\n if m == :static_transform || m == :dynamic_transform || m == :frames\n return Orocos.transformer.manager.conf.send(m, *args, &block)\n end\n super\n end",
"def handle_default_options\n # before mergin check if custom :message provided by developer\n message_provided = options[:message]\n\n # do merge\n @options = DEFAULT_OPTIONS.merge(options)\n\n # handle default message template based on condition if\n # custom message was provided by developer\n @options[:message] = options[:message] % options[:validator].upcase unless message_provided\n end",
"def method_missing(name, *args)\n if args.size==1\n args[0]\n elsif args.size==0\n Waw.logger.warn(\"No such resource #{name} on #{@__name}, (#{caller[0]})\")\n nil\n else\n super\n end\n end",
"def method_missing(method, *args)\n ## return self[method.to_sym] if @opts[:one_file]\n if method.to_s =~ /^_(.*)/\n _flush_cache\n return @suffixes.send($1, *args)\n elsif _valid_file?(method)\n value = with_file(method, *args)\n value\n elsif _root_file\n value = with_file(_root_file, method, *args)\n value\n elsif _config_file\n value = with_file(_config_file, method, *args)\n value\n else\n super\n end\n end",
"def method_missing(name, *args)\n @handler.send(name, *args)\n end",
"def default_handler anElement\r\n if log\r\n puts \"#{self.class} - default handling:#{anElement.name}\"\r\n end\r\n end",
"def method_missing(key, *args)\n return super unless CONFIG_SCHEMA.key?(key)\n raise(\n ConfigValidationError,\n \"#{key} is incorrectly defined\"\n ) if CONFIG_SCHEMA[key].class != args.first.class\n end",
"def method_missing( method, *args )\n return super unless args.empty?\n _value_for_key( method )\n end",
"def method_missing(method, *args, &block)\n klass = Scry.const_get(method.to_s.capitalize)\n if klass\n klass = klass.const_get('Notifier')\n if klass\n raise unless args\n klass.new(config[method])\n else\n super\n end\n else\n super\n end\n end",
"def method_missing(name, *args, &block)\n if name.to_s[-1] == '='\n config[name[0..-2].to_s.upcase] = args[0]\n else\n config.fetch(name.to_s.upcase) {nil}\n end\n end",
"def method_missing(m)\n get_options\n key = m.to_s.gsub(/\\_/, \"-\")\n @options[key].nil? ? super : @options[key]\n end",
"def error_message\n \"JPT - #{setting_name} received an invalid argument: #{source}\"\n end",
"def error_handler()\n return @error_handler unless @error_handler.nil?\n eh = find_task(:error)\n return eh unless eh.nil?\n @env.error_handler\n end",
"def method_missing(sym, *args)\n if args.empty? && !block_given? && respond_to?(sym.to_s)\n self[sym.to_s]\n else\n super\n end\n end",
"def method_missing(method, *args)\n\t\tif self.respond_to?(method)\n\t\t\tlocalized_method = \"#{method}_#{I18n.locale}\"\n\t\t\tself.send(localized_method)\n\t\telse\n\t\t\tsuper\n\t\tend\n\tend",
"def unimplemented\n i18n_setup(:elephas, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + \"/../../../locales/\")) if !@i18n\n raise ArgumentError.new(i18n.unimplemented)\n end",
"def method_missing(method_sym, *arguments, &block)\n return @options[method_sym] if @options.include?(method_sym)\n super\n end",
"def handle_messages(&handler)\n raise NotImplementedError\n end",
"def unknown_handling option\n unless option.in? [:process, :abort, :unknown_string]\n raise \"unknown option for unknown handling\"\n end\n @unknown_handling = option\n end",
"def method_missing(m, *args, &block)\n if has? m.to_s\n get(m.to_s)\n else\n nil\n end\n end",
"def handler_for_request(req)\n req.path =~ /^#{@url_prefix}\\/([^\\/]+)/\n\n return @entry_points[$1] || Borges::NotFoundHandler.new\n end",
"def interpolation_statement(prior_segments)\n chunks = prior_segments.collect { |s| s.interpolation_chunk }\n chunks << interpolation_chunk\n \"\\\"#{chunks * ''}\\\"#{all_optionals_available_condition(prior_segments)}\"\n end",
"def method_missing(meth, *args, &block)\n if meth.to_s =~ /^happy_inter_(.+)$/\n happy_format(:international, $1, *args)\n elsif meth.to_s =~ /^happy_mask_(.+)$/\n happy_format(:mask, $1, *args)\n elsif meth.to_s =~ /^happy_(.+)$/\n happy_format(:national, $1, *args)\n else\n super\n end\n end",
"def implicit_handler(message)\n instance_methods(false).include?(message.to_sym) && message\n end",
"def _handle_action_missing(*args)\n action_missing(@_action_name, *args)\n end",
"def method_missing(m, *args, **kwargs, &block)\n if values.key?(m) && args.size == 0\n values[m]\n else\n super\n end\n end",
"def method_missing(method, *args, &block)\n if method =~ /(.+)\\?$/\n options[$1.to_sym].present?\n else\n options[method]\n end\n end",
"def define_exception_handler(data)\n exception_handler.merge!(data)\n end",
"def contains_interpolation?(string)\n contains_connect_variables?(string) || contains_puppet_variables?(string)\n end",
"def method_missing(symbol, *args, &block)\n if @options.key?(symbol)\n @options[symbol]\n else\n super(symbol, *args, &block)\n end\n end",
"def handler(filename)\n Template.handlers.each do |pattern, klass|\n return klass if filename =~ pattern\n end\n warning { \"No template handler found for: #{filename}\" }\n Template::Runner::Base\n end",
"def []( name )\n if form and r18n\n value = opts[ name ]\n if value.is_a?( String ) or ( value.nil? and not UNLOCALIZED_OPTIONS.include?( name ) )\n text = pt( name )\n return text.to_s if text.translated?\n end\n end\n super\n end",
"def handlers=(_arg0); end",
"def method_missing(method, *args)\n if value = env(method)\n return value\n else\n super(method, *args)\n end\n end",
"def method_missing(method, *args)\n if value = env(method)\n return value\n else\n super(method, *args)\n end\n end"
] |
[
"0.5517022",
"0.5260013",
"0.5257614",
"0.51578754",
"0.4976981",
"0.4906172",
"0.48765105",
"0.48153022",
"0.4802552",
"0.4802552",
"0.47337902",
"0.46863475",
"0.46790642",
"0.46790642",
"0.46781546",
"0.46509776",
"0.46246645",
"0.46230543",
"0.46203578",
"0.46012974",
"0.45560583",
"0.45554456",
"0.45491523",
"0.4547247",
"0.4529803",
"0.45246896",
"0.45064983",
"0.44968787",
"0.4495415",
"0.4488544",
"0.4488544",
"0.44766656",
"0.44542536",
"0.4432083",
"0.44223225",
"0.44212714",
"0.4419419",
"0.44034746",
"0.43823728",
"0.43739653",
"0.43582526",
"0.43478212",
"0.43198615",
"0.4310369",
"0.4306817",
"0.42977518",
"0.42965117",
"0.42920092",
"0.42910603",
"0.4267538",
"0.42602125",
"0.4246071",
"0.42334256",
"0.42327136",
"0.42288297",
"0.42207617",
"0.4217902",
"0.42078567",
"0.41942063",
"0.4188908",
"0.41886666",
"0.4185473",
"0.41731855",
"0.4161048",
"0.41461906",
"0.41375333",
"0.41328645",
"0.41283616",
"0.41270784",
"0.41157797",
"0.4113928",
"0.4110953",
"0.4106431",
"0.4106333",
"0.40957317",
"0.40932533",
"0.40872332",
"0.4086582",
"0.40864897",
"0.40859592",
"0.40818527",
"0.4077079",
"0.40646255",
"0.40636757",
"0.40537882",
"0.40417716",
"0.40375692",
"0.4027421",
"0.40220448",
"0.4020453",
"0.40149677",
"0.40117404",
"0.4010718",
"0.4009632",
"0.4006824",
"0.40058762",
"0.40020728",
"0.39966166",
"0.39937776",
"0.39937776"
] |
0.68051827
|
0
|
returns an array of plural keys for the given locale or the whole hash of locale mappings to plural keys so that we can convert from gettext's integerindex based style TODO move this information to the pluralization module source://i18n//lib/i18n/gettext.rb17
|
def plural_keys(*args); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locales\n locale_counts.keys\n end",
"def get_count_keys(locale, key)\r\n empty_translations = {}\r\n store_empty_translations = false\r\n count_keys = I18n.t!('i18n.plural.keys', :locale => locale).inject({}) do |result, plural_key|\r\n full_key = \"#{key}.#{plural_key}\"\r\n value = get_translate(locale, full_key)\r\n if value\r\n store_empty_translations = true\r\n result.merge plural_key.to_s => value\r\n else\r\n empty_translations.merge! full_key => \"\"\r\n result\r\n end\r\n end\r\n if store_empty_translations && empty_translations.present?\r\n I18n.backend.store_translations locale, empty_translations, :escape => false\r\n end\r\n count_keys\r\n rescue\r\n {}\r\n end",
"def hash_is_for_pluralization?(hash, locale)\n plural_keys = I18n.t('i18n.plural.keys', locale: locale)\n raise missing_pluralisations_message(locale) unless plural_keys.is_a?(Array)\n ((hash.keys.map(&:to_s) - plural_keys.map(&:to_s)) - ['zero']).empty?\n end",
"def pluralized_array_from_hash(hash, singular_key, plural_key); end",
"def pluralize(locale, entry, count)\n\n # return the entry directly if it is a string\n return entry unless entry.is_a?(Hash)\n\n key = pluralizer(locale).call(count.nil? ? 1 : count)\n # fallback to other if :zero is not set\n key = :other if key == :zero && !entry.has_key?(:zero)\n\n # raise a pluralization error only if count is explicitely set and the entry is not available\n # else return the entry that may be a hash or the translated string\n if entry.has_key?(key)\n translation entry[key], :plural_key => key.to_s\n elsif count\n raise I18n::InvalidPluralizationData.new(entry, count)\n else\n translation entry, :plural_key => nil\n end\n end",
"def translated_locales\n self.i18n.keys\n end",
"def pluralize(locale, entry, count); end",
"def translated_locales\r\n all.distinct(\"locale\").sort{ |x,y| x.to_s <=> y.to_s }.map(&:to_sym)\r\n end",
"def index\n @translations = @locale.translations.all(:order => \"raw_key, pluralization_index\")\n end",
"def pluralize_key\n ActiveSupport::Inflector.pluralize(key)\n end",
"def locale_idx; end",
"def locales\n map(&:locale)\n end",
"def load_entry(locale, key)\n locale, key = locale.to_s, key.to_s\n data = self.find_all_by_locale_and_key(locale, key)\n result = {}\n data.each do |row|\n #only return the simple translation if one is set\n return row.text if row.pluralization_index.blank?\n result[row.pluralization_index.to_sym] = row.text\n end\n return result\n end",
"def locale_matches\n matches = {}\n I18n.available_locales.map(&:to_s).each do |locale|\n matches[locale] = locale\n matches[locale[0, 2]] = locale if locale.length > 2\n end\n matches\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def available_locales\n locales = self.keys.map { |k| k =~ /\\./; $` }\n locales.uniq!\n locales.compact!\n locales.map! { |k| k.to_sym }\n locales\n end",
"def select_translations(args = {})\n hash = grouped_translated_text(args[:locale])\n hash.each { |key, value| hash[key] = value.count }.sort_by { |_key, value| value }.reverse.to_h\n end",
"def normalize_keys(locale, key, scope, separator = nil)\n keys = [locale] + Array(scope) + Array(key)\n keys = keys.map {|k| I18n.translation_key_escaped?(k) ? I18n.unescape_translation_key(k) : k.to_s.split(separator || I18n.default_separator)}\n keys = (keys.flatten - ['']).reject {|k| !k}\n keys.map {|k| k.to_sym if k}\n end",
"def search_conditions_as_hash(locale)\n [\n { :value => I18n.t(\"advanced_searches.text_search_field.all_words\", locale: locale), :key => \"all_words\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.one_word\", locale: locale), :key => \"one_word\"},\n { :value => I18n.t(\"advanced_searches.text_search_field.exact\", locale: locale), :key => \"exact\"}\n ]\n end",
"def i18n_keys(attr = nil, model = nil)\n values = { type: self.class.type_name, value: to_s }\n list_from = :i18n_type_scopes\n\n if attr && model\n values[:attr] = attr\n values[:model] = model.model_name.i18n_key\n list_from = :i18n_scopes\n end\n\n Torque::PostgreSQL.config.enum.send(list_from).map do |key|\n (key % values).to_sym\n end\n end",
"def available_locales\n self.locales.map { |locale| locale.to_sym }\n end",
"def load_all_entries\n results = self.all :order=>\"locale, key\"\n data = {}\n\n results.each do |result|\n #create an empty hash for each locale initially\n data[result.locale] ||= {}\n\n # create the deep nested scopes from the dotted key\n scopes = result.key.split(\".\").map{|k| k.to_sym}\n key = scopes.pop\n scope = scopes.inject(data[result.locale]) do |scope, s|\n # a new scope is empty initially\n # if its a simple string override it with a empty hash\n scope[s] = {} unless scope[s] and scope[s].is_a?(Hash)\n scope[s]\n end\n\n # if we have a pluralization form and the translation key already exists add the specific pluralization form\n if scope[key] && scope[key].is_a?(Hash) && !result.pluralization_index.blank?\n scope[key][result.pluralization_index] = result.text\n\n # if we have a pluralization index add the initial hash\n elsif !result.pluralization_index.blank?\n scope[key] = { result.pluralization_index.to_sym => result.text.to_s }\n\n # else we just add the simple text\n else\n scope[key] = result.text\n end\n\n end\n return data\n end",
"def used_locales\r\n locales = globalize.stash.keys.concat(globalize.stash.keys).concat(translations.translated_locales)\r\n locales.uniq!\r\n locales\r\n end",
"def locales(locale_type)\n locs = Set.new\n\n each_bathing_water do |bw|\n l = bw[locale_type]\n locs << l if l.is_a?(LdaResource)\n end\n\n locs.to_a.sort_by(&:label)\n end",
"def descriptions\n I18n.available_locales.map {|l| [l, description(l)] }.to_h\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def export_locale(locale)\n @sections_hash.keys.reduce({}) do |memo, section|\n memo[section.name] = export_section_locale(section, locale)\n memo\n end\n end",
"def pluralize(word, locale = :en)\n Geode::FastInflector.pluralize(word, locale)\n end",
"def locales\n get(\"locales\")[\"locales\"]\n end",
"def locale_flag_map\n\t\t\t@locale_flag_map ||= keys_to_sym(locale_flag_hash) \n\t\tend",
"def name\n n = names\n return nil if n.nil?\n\n @locales.each do |locale|\n return n[locale] if n.key?(locale)\n end\n\n nil\n end",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def available_locales\n init_names unless init_names?\n names.keys\n end",
"def abbreviations\n answers_hash.keys\n end",
"def get(locale = Localization.default_locale)\n @locales[locale.to_s]\n end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def pluralization_rules\n if defined?(@pluralization_regex) && @pluralization_regex\n return [@pluralization_regex, @pluralization_hash]\n end\n @pluralization_regex = Regexp.new(\"(\" + @plural_rules.map {|s,p| s}.join(\"|\") + \")$\", \"i\")\n @pluralization_hash = Hash[*@plural_rules.flatten]\n [@pluralization_regex, @pluralization_hash]\n end",
"def t_hash(key)\n translations = {}\n %i[en fr].each do |locale|\n translations[locale] = I18n.t(key, locale: locale, default: key.to_s.titleize)\n end\n translations\n end",
"def lookup(locale, key, scope = [], separator = nil)\n return unless key\n keys = I18n.send(:normalize_translation_keys, locale, key, scope)\n @moneta[keys.join('.')]\n end",
"def lookup(locale, key, scope = [], options = {})\n\n init_translations unless initialized?\n result = nil\n _locale = ::Locale.first(:code => locale)\n key = pluralizer(_locale, key, options[:count])\n value = _locale.translations.first(:code => key)\n result = value.value unless value.nil?\n result = options[:default] if !value.nil? && value.value == key && options[:default]\n return result unless value.nil? || value.value == key\n \n # check devise messages for remaining keys\n result = _locale.translations.first(:code => \"devise.sessions.#{key}\")\n return result.value unless result.nil?\n\n # fall back on yaml file if no object is found in db\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n keys.inject(translations) do |result, _key|\n return nil unless result.is_a?(Hash) && result.has_key?(_key)\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result = options[:default] if options[:default] && result.nil?\n result\n end\n \n end",
"def translations_for route\n available_locales.map do |locale|\n translate_route(route, locale.dup) #we duplicate the locale string to ensure it's not frozen\n end\n end",
"def known_locales\n if @known_locales.empty?\n [\n [ 'ja', 'Japanese', 'nplurals=1; plural=0;' ],\n [ 'vi', 'Vietnamese', 'nplurals=1; plural=0;' ],\n [ 'ko', 'Korean', 'nplurals=1; plural=0;' ],\n [ 'en', 'English', 'nplurals=2; plural=(n != 1);' ],\n [ 'de', 'German', 'nplurals=2; plural=(n != 1);' ],\n [ 'nl', 'Dutch', 'nplurals=2; plural=(n != 1);' ],\n [ 'sv', 'Swedish', 'nplurals=2; plural=(n != 1);' ],\n [ 'da', 'Danish', 'nplurals=2; plural=(n != 1);' ],\n [ 'no', 'Norwegian', 'nplurals=2; plural=(n != 1);' ],\n [ 'nb', 'Norwegian Bokmal', 'nplurals=2; plural=(n != 1);' ],\n [ 'nn', 'Norwegian Nynorsk', 'nplurals=2; plural=(n != 1);' ],\n [ 'fo', 'Faroese', 'nplurals=2; plural=(n != 1);' ],\n [ 'es', 'Spanish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt', 'Portuguese', 'nplurals=2; plural=(n != 1);' ],\n [ 'it', 'Italian', 'nplurals=2; plural=(n != 1);' ],\n [ 'bg', 'Bulgarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'el', 'Greek', 'nplurals=2; plural=(n != 1);' ],\n [ 'fi', 'Finnish', 'nplurals=2; plural=(n != 1);' ],\n [ 'et', 'Estonian', 'nplurals=2; plural=(n != 1);' ],\n [ 'he', 'Hebrew', 'nplurals=2; plural=(n != 1);' ],\n [ 'eo', 'Esperanto', 'nplurals=2; plural=(n != 1);' ],\n [ 'hu', 'Hungarian', 'nplurals=2; plural=(n != 1);' ],\n [ 'tr', 'Turkish', 'nplurals=2; plural=(n != 1);' ],\n [ 'pt_BR', 'Brazilian', 'nplurals=2; plural=(n > 1);' ],\n [ 'fr', 'French', 'nplurals=2; plural=(n > 1);' ],\n [ 'lv', 'Latvian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);' ],\n [ 'ga', 'Irish', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;' ],\n [ 'ro', 'Romanian', 'nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;' ],\n [ 'lt', 'Lithuanian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'ru', 'Russian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'uk', 'Ukrainian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'be', 'Belarusian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sr', 'Serbian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'hr', 'Croatian', 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'cs', 'Czech', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'sk', 'Slovak', 'nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;' ],\n [ 'pl', 'Polish', 'nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);' ],\n [ 'sl', 'Slovenian', 'nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);' ]\n ].each do | array_item |\n key = array_item[0].to_sym\n lang = array_item[1]\n plural_form = array_item[2]\n @known_locales[key] = {}\n @known_locales[key][:lang] = lang\n @known_locales[key][:plural_form] = plural_form\n end\n end\n @known_locales\n end",
"def globalize_fallbacks(for_locale = I18n.locale)\n [for_locale, primary_locale.to_sym].uniq\n end",
"def slice(*keys) = Locale.new(deconstruct_keys(keys.map(&:to_sym)))",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def locales_to_try(locale)\n locales = []\n locale_scratchpad = locale.clone\n if (locale_scratchpad.index('.'))\n locales << locale_scratchpad\n locale_scratchpad = locale_scratchpad.split('.')[0]\n end\n\n locale_parts = locale_scratchpad.split('-')\n loop do\n locales << locale_parts.join('-')\n locale_parts.pop\n break if locale_parts.empty?\n end\n\n locales\n end",
"def pluralize(count, singular, plural_arg=nil, plural: plural_arg, locale: I18n.locale)\n self.class.pluralize(count, singular, plural_arg, plural: plural, locale: locale)\n end",
"def pluralize\n {'win' => 'wins', 'loss' => 'losses', 'fail' => 'fails'}\n end",
"def translations_for_select\n Alchemy::I18n.available_locales.map do |locale|\n [_t(locale, :scope => :translations), locale]\n end\n end",
"def hierarchy_locale_map\n { ar: 'ar-Arab', en: 'en' }\n end",
"def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end",
"def available_locales\n translation_model.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
"def locale_to_name\n \t\t{'fr' => 'Français',\n 'en' => 'English',\n 'po' => 'portugues',\n 'sp' => 'Spanish',\n 'de' => 'Deutsch',\n 'it' => 'Italiano'}\n\tend",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def enabled_locales\n self[:enabled_locales].split(\",\").map(&:to_sym)\n end",
"def locale_count(locale_code)\n locale_counts[locale_code]\n end",
"def lookup_chain = locale(true).lookup",
"def testlocale\n check_path = 'config/locales/'\n locale_list = %w(vi en ja)\n\n @missing_files = []\n @missing_keys = []\n # begin checking if all the necessary locale files exist\n folders = Dir.glob(\"#{check_path}**/*/\").push(check_path)\n for folder in folders do\n key_list = []\n for locale in locale_list do\n file = \"#{folder}#{locale}.yml\"\n if File.exist?(file)\n thing = YAML.load_file(file)\n key_list.push(flatten_keys(thing[locale]))\n else\n @missing_files.push(file)\n end\n end\n key_list.each_with_index do |key1,k1|\n for key2 in key_list do\n missing = key2 - key1\n if missing.any?\n missing.each { |key| @missing_keys.push(\"Missing #{key} in #{folder}#{locale_list[k1]}.yml\") }\n end\n\n end\n end\n end\n\n end",
"def for_language(locale)\n translations.select { |word| word.locale == locale }\n end",
"def pluralize_unit_with_locale(count, unit, locale)\n singular = locale.t(:\"units.#{unit}\")\n unit_word = count == 1 ? singular : singular.pluralize\n locale.t(:template, count: count, unit: unit_word)\n end",
"def keys\n values.map(&:to_sym)\n end",
"def normalized_key(name, serializer)\n serializer && serializer.localized? ? \"#{name}.#{::I18n.locale}\" : name\n end",
"def locale\n @locales = Ramaze::Tool::Localize.languages.map{ |lang|\n [\n Ramaze::Tool::Localize.localize('locale_menu_descrition', lang),\n Ramaze::Tool::Localize.localize('locale_name', lang),\n lang\n ]\n }\n end",
"def composite_keys \n Hash.new.tap do |hash|\n SPREE_MODULES.each do |mod|\n hash.merge! get_translation_keys(\"spree_#{mod}\")\n end\n end\n end",
"def plural\n\t\tEndings.each { |k, v|\n\t\t\tif name =~ '(.*)' + k + '$'\n\t\t\t\treturn $1.to_s + v\n\t\t\tend\n\t\t}\n\t\treturn \"#{name}s\"\n\tend",
"def index\n @locales = Tolk::Locale.secondary_locales.sort_by(&:language_name)\n end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance(locale)\n end\n end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance(locale)\n end\n end",
"def all_locales\n locales = slugged_attributes\n .map { |attr| send(\"#{attr}_translations\").keys if respond_to?(\"#{attr}_translations\") }\n .flatten.compact.uniq\n locales = I18n.available_locales if locales.empty?\n locales\n end",
"def available_locales\n init_translations unless initialized?\n translations.inject([]) do |locales, (locale, data)|\n locales << locale unless (data.keys - [:i18n]).empty?\n locales\n end\n end",
"def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance_or_fallback(locale)\n end\n end",
"def locale_translations\n @locale_scope ||= begin\n locale_path = \"#{@locale}.yml\"\n locale_path = File.join(@locales_dir, locale_path) if @locales_dir\n YAML.load_file(locale_path).fetch(@locale)\n end\n end",
"def normalized_key(name, serializer)\n # serializer && serializer.localized? ? \"#{name}.#{::I18n.locale}\" : name\n serializer&.localized? ? \"#{name}.#{::Mongoid::Fields::I18n.locale}\" : name\n end",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def i18n_name(locale = I18n.locale.to_s)\n ([self[Type.i18n_name_field(locale)], self.name].reject(&:blank?).first)\n end",
"def i18n(locale)\n selected_locale = self.i18ns.select{|i18n| i18n.locale_id == locale.id }\n return selected_locale.first if selected_locale.any?\n\n self.i18ns.first\n end",
"def comments_hash\n I18n.available_locales.map { |l| [l, comment(l).try(:comment)] }.to_h\n end",
"def translate(locale, key, options = {})\n @locale = locale_in_context(locale)\n\n options[:scope] = [options[:scope]] unless options[:scope].is_a?(Array) || options[:scope].blank?\n key = \"#{options[:scope].join('.')}.#{key}\".to_sym if options[:scope] && key.is_a?(Symbol)\n count = options[:count]\n # pull out values for interpolation\n values = options.reject { |name, value| [:scope, :default].include?(name) }\n\n entry = lookup(@locale, key)\n cache_lookup = true unless entry.nil?\n\n # if no entry exists for the current locale and the current locale is not the default locale then lookup translations for the default locale for this key\n unless entry || @locale.default_locale?\n entry = use_and_copy_default_locale_translations_if_they_exist(@locale, key)\n end\n\n # if we have no entry and some defaults ... start looking them up\n unless entry || key.is_a?(String) || options[:default].blank?\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # this needs to be folded into the above at some point.\n # this handles the case where the default of the string key is a space\n if !entry && key.is_a?(String) && options[:default] == \" \"\n default = options[:default].is_a?(Array) ? options[:default].shift : options.delete(:default)\n return translate(@locale.code, default, options.dup)\n end\n\n # The requested key might not be a parent node in a hierarchy of keys instead of a regular 'leaf' node\n # that would simply result in a string return. If so, check the database for possible children \n # and return them in a nested hash if we find them.\n # We can safely ignore pluralization indeces here since they should never apply to a hash return\n if !entry && (key.is_a?(String) || key.is_a?(Symbol))\n #We need to escape % and \\. Rails will handle the rest.\n escaped_key = key.to_s.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub(/%/, '\\%')\n children = @locale.translations.find(:all, :conditions => [\"raw_key like ?\", \"#{escaped_key}.%\"]).select{|child| child.raw_key =~ /^#{key}/}\n if children.size > 0\n entry = hashify_record_array(key.to_s, children)\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n return entry\n end\n end\n\n # we check the database before creating a translation as we can have translations with nil values\n # if we still have no blasted translation just go and create one for the current locale!\n unless entry \n pluralization_index = (options[:count].nil? || options[:count] == 1) ? 1 : 0\n translation = @locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) ||\n @locale.create_translation(key, key, pluralization_index)\n entry = translation.value_or_default\n end\n\n # write to cache unless we've already had a successful cache hit\n @cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true\n\n entry = pluralize(@locale, entry, count)\n entry = interpolate(@locale.code, entry, values)\n entry.is_a?(Array) ? entry.dup : entry # array's can get frozen with cache writes\n end",
"def roman_mappings\n {\n 1000 => 'M',\n 900 => 'CM',\n 500 => 'D',\n 400 => 'CD',\n 100 => 'C',\n 90 => 'XC',\n 50 => 'L',\n 40 => 'XL',\n 10 => 'X',\n 9 => 'IX',\n 5 => 'V',\n 4 => 'IV',\n 1 => 'I',\n }\n end",
"def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end",
"def project_used_keys(search_pattern=nil)\n regex = /(I18n.| |\\>|\\(|=|\\[|\\{|I18n::|,|\\+)t[( ]?([\\\"\\'][a-zA-Z0-9._]+[\\\"\\'])(, :count => [@a-zA-Z0-9.]+|)[)]?/\n search_pattern ||= 'app/**/*.{rb,erb}'\n\n keys = Hash.new\n Dir[search_pattern].each do |path|\n File.open( path ) do |f|\n f.grep(regex) do |line|\n i18n_call = line.scan(regex)\n i18n_call.each do |k|\n key = k[1]\n key.delete! \"\\\"\\'\"\n key.insert(0,locale.to_s+'.')\n if k[2].include? \":count\"\n keys[(key+'.'+'zero').to_sym] = 0\n keys[(key+'.'+'one').to_sym] = 0\n keys[(key+'.'+'two').to_sym] = 0\n keys[(key+'.'+'few').to_sym] = 0\n keys[(key+'.'+'many').to_sym] = 0\n keys[(key+'.'+'other').to_sym] = 0\n else\n keys[key.to_sym] = 0\n end\n end\n end\n end\n end\n keys\n end",
"def lookup(locale, key, scope = [], options = {})\n init_translations unless initialized?\n \n # only formal address: [:de, :de_formal]\n # only multi tenancy: [:de, :tenant_name_de]\n # formal address & multi tenancy: [:de, :tenant_name_de, :de_formal, :tenant_name_de_formal]\n \n locales = []\n \n base_locale = locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '')\n \n tenant = tenant_from_locale?(locale)\n base_locale.gsub!(/^#{tenant}_/, '') if tenant\n \n locales << base_locale.to_sym \n \n if locale.to_s.match(FORMAL_LOCALE_PATTERN) && tenant && locale.to_s.match(/^#{tenant}_/)\n locales << locale.to_s.gsub(FORMAL_LOCALE_PATTERN, '').to_sym\n locales << locale.to_s.gsub(/^#{tenant}_/, '').to_sym\n end\n \n locales << locale unless locales.include?(locale)\n \n entry, last_entry = nil, nil\n \n locales.each do |locale|\n keys = I18n.normalize_keys(locale, key, scope, options[:separator])\n \n entry = keys.inject(translations) do |result, _key|\n _key = _key.to_sym\n \n unless result.is_a?(Hash) && result.has_key?(_key)\n nil\n else\n result = result[_key]\n result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)\n result\n end\n end\n \n if entry.nil?\n entry = last_entry\n else\n last_entry = entry\n end\n end\n \n entry\n end",
"def localizations\n @@locales[Locale.code] || {}\n end",
"def create_pluralized_getter(key)\n define_singleton_method(BOOKWORM_KEYS[key]['plural'].to_sym) do\n self[key]\n end\n end",
"def all_published_locales\n translations.where(published: true).map{|x| x.locale}.uniq.sort\n end",
"def lookup(locale, key, scope = [], options = {})\n key = normalize_flat_keys(locale, key, scope, options[:separator])\n\n return if translations.missing?(locale, key)\n\n result = translations.lookup(locale, key, options)\n translations.missing(locale, key, options) if result.nil?\n\n result\n end",
"def normalize_translation_keys(locale, key, scope, separator = nil)\n normalize_keys(locale, key, scope, separator)\n end",
"def locales\n locale_sources.compact.downcase.map {|loc| WorldFlags.locale(loc) unless loc.blank? }\n end",
"def locale\r\n read_attribute(:locale).to_sym\r\n end",
"def all_forms\n plural_form.blank? ? [name] : [plural_form.name, name].sort\n end",
"def plural_name\n return ext_text(9001, @id) if Item.id_valid?(@id)\n\n return ext_text(9001, 0)\n end",
"def locales(website)\n if product_families.size > 0\n @locales ||= product_families.map do |pf|\n pf.find_ultimate_parent.locales(website)\n end.flatten.uniq - locales_where_hidden\n else\n @locales ||= website.list_of_all_locales - locales_where_hidden\n end\n end",
"def tag_names locale = :en\n tags.pluck(\"name_#{locale}\").uniq.join(', ')\n end",
"def query_context_values_for_locale(locale)\n case locale\n when \"US\"\n US_QUERY_CONTEXT_VALUES \n else\n US_QUERY_CONTEXT_VALUES\n end\n end",
"def weighted_locales(locales)\n locales = locales.to_s.gsub(/\\s/,'')\n found = [[]]\n locales.split(',').each do |part|\n if part =~ /;q=/ #contains language and weight ?\n found.last << part.split(/;q=/)\n found.last.flatten!\n found << []\n else\n found.last << part\n end\n end\n found\n end",
"def plural_resource_label(options = {})\n defaults = { count: Helpers::I18n::PLURAL_MANY_COUNT,\n default: resource_label.pluralize.titleize }\n resource_name.translate defaults.merge options\n end",
"def keys\n @data.keys.sort.collect { |k| k.to_sym }\n end",
"def item_statuses\n # The previous mapping wasn't always in order\n # I18n.t(:history_actions).map { |key, value| [ value ] } \n # Retrieve translations and sort\n items = I18n.t(:item_status)\n items.map { |key, value| [ value, key ] } \n end",
"def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)\n word = if count == 1 || count.to_s.match?(/^1(\\.0+)?$/)\n singular\n else\n plural || singular.pluralize(locale)\n end\n\n \"#{count || 0} #{word}\"\n end"
] |
[
"0.71368897",
"0.70412976",
"0.6803723",
"0.65343845",
"0.6320404",
"0.62752354",
"0.62734723",
"0.62097245",
"0.5986995",
"0.5933502",
"0.59183365",
"0.5905321",
"0.5882354",
"0.58422196",
"0.57963085",
"0.57963085",
"0.57725656",
"0.5732884",
"0.571899",
"0.57029855",
"0.56650484",
"0.5595317",
"0.5520166",
"0.55109334",
"0.55020756",
"0.5490594",
"0.548676",
"0.54821926",
"0.5480472",
"0.5466204",
"0.5459514",
"0.5458498",
"0.5441827",
"0.54077095",
"0.5403157",
"0.53947943",
"0.53947943",
"0.5386834",
"0.5383058",
"0.53796744",
"0.5373377",
"0.53613794",
"0.5355707",
"0.5337246",
"0.5291092",
"0.52899474",
"0.5289092",
"0.5279371",
"0.5267949",
"0.52616626",
"0.52324533",
"0.52192914",
"0.5205011",
"0.51999986",
"0.5186247",
"0.5186247",
"0.51840806",
"0.51822317",
"0.51767176",
"0.5173489",
"0.51655895",
"0.5160868",
"0.5153558",
"0.51506364",
"0.5120006",
"0.5109497",
"0.50844985",
"0.50838935",
"0.50838935",
"0.50832933",
"0.50805527",
"0.50745994",
"0.5063049",
"0.50587726",
"0.5057045",
"0.50516313",
"0.50429237",
"0.50401425",
"0.50391793",
"0.50279844",
"0.500783",
"0.50077707",
"0.50067943",
"0.50060403",
"0.5004437",
"0.49977073",
"0.49948788",
"0.49943972",
"0.49881917",
"0.4983932",
"0.4982138",
"0.49803135",
"0.49772218",
"0.49680617",
"0.49638084",
"0.49564335",
"0.49399278",
"0.49387425",
"0.4934523",
"0.49317712"
] |
0.6791306
|
3
|
Method signatures: npgettext('Fruits', 'apple', 'apples', 2) npgettext('Fruits', ['apple', 'apples'], 2) source://i18n//lib/i18n/gettext/helpers.rb61
|
def np_(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def t(*args); I18n.t(*args) end",
"def n_(*msgids)\n count = msgids.pop\n \n translations = FastGettext.current_repository.plural(*msgids)\n selected = FastGettext.current_repository.pluralisation_rule.call(count)\n translations[selected] || msgids[selected] || msgids.last\n end",
"def l(*args); I18n.l(*args) end",
"def ns_(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def t(...)\n I18n.t(...)\nend",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def plural(*args)\n TextHelper.pluralize(*args)\n end",
"def translate(*args, **opts); end",
"def t(*args)\n I18n.t(*args)\n end",
"def t(*args, **kwargs)\n proc { I18n.t(*args, **kwargs) }\n end",
"def plural_keys(*args); end",
"def N_(*args)\r\n LocalizeActiveScaffold.dont_translate(args[0].to_s)\r\n end",
"def rgettext(targetfiles = nil, out = STDOUT)\n RGetText.run(targetfiles, out)\n self\n end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def _(text)\n text\n end",
"def _t(key, *args)\n I18n.t(key, *args)\n end",
"def translations; end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def pluralize(locale, entry, count); end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def t(*args)\n proc { I18n.t(*args) }\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def ft( *args )\n fail \"You need to set the locale with R18n.set('en') or similar. No locale, no helper. Sorry.\" unless r18n\n translation = t.forms[ self.class.translation_name ]\n args.empty? ? translation : translation[ *args ]\n end",
"def pt( *args )\n translation = ft[ name ]\n args.empty? ? translation : translation[ *args, self ]\n end",
"def N_(translate)\n translate\n end",
"def N_(translate)\n translate\n end",
"def translate_label(text)\n I18n.t(\"backend.labels.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def pluralize(word); end",
"def label_translation; end",
"def lnbText _obj, _args\n \"_obj lnbText _args;\" \n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def pluralize(bottles, text)\n return text + 's' if bottles != 1\n text\nend",
"def t(*args)\n I18n.send :t, *args\n end",
"def n_(singular, plural, num)\n # no textdomain configured yet\n if !@my_textdomain\n # it's enough to log just the singular form\n Yast.y2warning(\"No textdomain configured, cannot translate text #{singular.inspect}\")\n Yast.y2warning(\"Called from: #{::Kernel.caller(1).first}\")\n return fallback_n_(singular, plural, num)\n end\n\n # Switching textdomain clears gettext caches so avoid it if possible.\n # difference between _ and n_ is hat we need special cache for plural forms\n found = true\n if !@my_textdomain.include?(FastGettext.text_domain) || !cached_plural_find(singular, plural)\n # Set domain where key is defined.\n found = @my_textdomain.any? do |domain|\n FastGettext.text_domain = domain\n cached_plural_find(singular, plural)\n end\n end\n found ? Translation.n_(singular, plural, num) : fallback_n_(singular, plural, num)\n end",
"def _(key,value=\"\")\n NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil)\n end",
"def t(*values)\n self.class::translate(self) % values\n end",
"def pluralize(text)\n \"#{text.to_s}s\"\n end",
"def lbText _obj, _args\n \"_obj lbText _args;\" \n end",
"def localize(*args)\n I18n.localize *args\n end",
"def localize(*args)\n I18n.localize *args\n end",
"def plural(palavra)\n \"#{palavra}s\"\nend",
"def translate(text,dictonary)\nend",
"def Nn_(singular,plural)\n [singular,plural]\n end",
"def translate_value(args)\n code = get_field_val(args)\n translate_lang_code(code)\n end",
"def composeText _args\n \"composeText _args;\" \n end",
"def pagy_t(path, vars={})\n value = I18N.dig(*path.to_s.split('.'.freeze))\n if value.is_a?(Hash)\n vars.has_key?(:count) or return value\n plural = (Opts.i18n_plurals ||= -> (c) {c==0 && 'zero' || c==1 && 'one' || 'other'}).call(vars[:count])\n value.has_key?(plural) or return %(invalid pluralization data: \"#{path}\" cannot be used with count: #{vars[:count]}; key \"#{plural}\" is missing.)\n value = value[plural]\n end\n value or return %(translation missing: \"#{path}\")\n sprintf value, Hash.new{|h,k| \"%{#{k}}\"}.merge!(vars) # interpolation\n end",
"def t(string, options = {})\n I18n.t(string, **options)\nend",
"def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend",
"def getText _args\n \"getText _args;\" \n end",
"def lnbSetText _args\n \"lnbSetText _args;\" \n end",
"def pluralize(number, text)\n if number != 1\n return number, text + \"s\"\n else\n return number, text\n \n end\n \nend",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def plural(n, item)\n n == 1 ? \"#{n} #{item}\" : \"#{n} #{item}s\"\nend",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def test_gettext_support\n ### FIXME: how to set \"en\" as gettext's default language?\n\n t = MyTestCell.new(@controller)\n c = render_cell_state(t, :view_with_explicit_english_translation)\n\n # the view \"view_with_explicit_english_translation_en\" exists, check if\n # gettext/rails found it:\n if Object.const_defined?(:GetText)\n assert_selekt c, \"#defaultTranslation\", 0\n assert_selekt c, \"#explicitEnglishTranslation\"\n else\n assert_selekt c, \"#defaultTranslation\"\n end\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def field_label *i18n_keys\n first, *rest = i18n_keys.compact\n\n t(first, default: rest)\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def apphelp_generic( message_name )\n t( \"uk.org.pond.canvass.generic_messages.#{ message_name }\" )\n end",
"def translate!(key, **options); end",
"def translate(item)\n @progress.setMainStatusAndLogIt('Translating')\n text = get_original_text(item)\n return nil if text.empty?\n\n translated = ms_translate(text)\n super(item, translated) unless translated.nil? || translated.empty?\n end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def list_title_for(text)\n I18n.t(\"backend.general.list\", :model => text.is_a?(String) ? text : text.send(:human_name))\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def list_item_number_label(**)\n end",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def use_i18n; end",
"def message(msg, *args)\n\t\tsprintf(@messages[msg], *args)\n\tend",
"def toast_english_muffin (toast = 2)\n \"My english muffins need #{toast} minutes in the toaster.\"\nend",
"def isLocalized _args\n \"isLocalized _args;\" \n end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def translate(*args)\n key = args.shift\n if xlated = @map[key]\n if xlated.is_a?(String)\n args.empty? ? xlated : sprintf(xlated, *args)\n else\n xlated.call(*args)\n end\n else\n return key\n end\n end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\nend",
"def get_text(to_translate)\n return send(*to_translate) if to_translate.is_a?(Array)\n return to_translate\n end"
] |
[
"0.7873009",
"0.77218634",
"0.6509395",
"0.6392087",
"0.63138026",
"0.61900556",
"0.60633945",
"0.59617865",
"0.594882",
"0.59190375",
"0.5905709",
"0.5855841",
"0.5769643",
"0.57496667",
"0.57415915",
"0.5694004",
"0.56891274",
"0.5641658",
"0.56279945",
"0.5614263",
"0.55347544",
"0.552993",
"0.55213875",
"0.5499603",
"0.5499229",
"0.5490884",
"0.5485641",
"0.5468052",
"0.5468052",
"0.54633707",
"0.54504365",
"0.5443557",
"0.5384339",
"0.5372924",
"0.5372924",
"0.5372924",
"0.53684306",
"0.5366101",
"0.53617865",
"0.5359318",
"0.5350003",
"0.534397",
"0.53376895",
"0.533186",
"0.533186",
"0.5300442",
"0.5266656",
"0.52606773",
"0.52439",
"0.5224577",
"0.5224264",
"0.5215411",
"0.5192511",
"0.51915205",
"0.5188088",
"0.5181661",
"0.5168914",
"0.5168914",
"0.5168914",
"0.5167158",
"0.5159799",
"0.5139855",
"0.51348627",
"0.5101715",
"0.51012695",
"0.5091495",
"0.5091495",
"0.5091495",
"0.5091495",
"0.5091495",
"0.5091495",
"0.5091495",
"0.5091495",
"0.5074535",
"0.5074421",
"0.50671405",
"0.50647974",
"0.50640804",
"0.50582",
"0.50453657",
"0.50428903",
"0.5038119",
"0.5024049",
"0.5021504",
"0.50160575",
"0.5012833",
"0.5012833",
"0.5012833",
"0.50103813",
"0.50103813",
"0.50040287",
"0.50040287",
"0.50040287",
"0.5000875",
"0.49955305",
"0.4991941",
"0.4991941",
"0.4991941",
"0.49680206",
"0.49646184"
] |
0.60368663
|
7
|
Method signatures: npgettext('Fruits', 'apple', 'apples', 2) npgettext('Fruits', ['apple', 'apples'], 2) source://i18n//lib/i18n/gettext/helpers.rb61
|
def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def t(*args); I18n.t(*args) end",
"def n_(*msgids)\n count = msgids.pop\n \n translations = FastGettext.current_repository.plural(*msgids)\n selected = FastGettext.current_repository.pluralisation_rule.call(count)\n translations[selected] || msgids[selected] || msgids.last\n end",
"def l(*args); I18n.l(*args) end",
"def ns_(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def t(...)\n I18n.t(...)\nend",
"def np_(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def plural(*args)\n TextHelper.pluralize(*args)\n end",
"def translate(*args, **opts); end",
"def t(*args)\n I18n.t(*args)\n end",
"def t(*args, **kwargs)\n proc { I18n.t(*args, **kwargs) }\n end",
"def plural_keys(*args); end",
"def N_(*args)\r\n LocalizeActiveScaffold.dont_translate(args[0].to_s)\r\n end",
"def rgettext(targetfiles = nil, out = STDOUT)\n RGetText.run(targetfiles, out)\n self\n end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def _(text)\n text\n end",
"def _t(key, *args)\n I18n.t(key, *args)\n end",
"def translations; end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def pluralize(locale, entry, count); end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def t(*args)\n proc { I18n.t(*args) }\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def ft( *args )\n fail \"You need to set the locale with R18n.set('en') or similar. No locale, no helper. Sorry.\" unless r18n\n translation = t.forms[ self.class.translation_name ]\n args.empty? ? translation : translation[ *args ]\n end",
"def pt( *args )\n translation = ft[ name ]\n args.empty? ? translation : translation[ *args, self ]\n end",
"def N_(translate)\n translate\n end",
"def N_(translate)\n translate\n end",
"def translate_label(text)\n I18n.t(\"backend.labels.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def pluralize(word); end",
"def label_translation; end",
"def lnbText _obj, _args\n \"_obj lnbText _args;\" \n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def localize(*args)\n I18n.localize(*args)\n end",
"def pluralize(bottles, text)\n return text + 's' if bottles != 1\n text\nend",
"def t(*args)\n I18n.send :t, *args\n end",
"def n_(singular, plural, num)\n # no textdomain configured yet\n if !@my_textdomain\n # it's enough to log just the singular form\n Yast.y2warning(\"No textdomain configured, cannot translate text #{singular.inspect}\")\n Yast.y2warning(\"Called from: #{::Kernel.caller(1).first}\")\n return fallback_n_(singular, plural, num)\n end\n\n # Switching textdomain clears gettext caches so avoid it if possible.\n # difference between _ and n_ is hat we need special cache for plural forms\n found = true\n if !@my_textdomain.include?(FastGettext.text_domain) || !cached_plural_find(singular, plural)\n # Set domain where key is defined.\n found = @my_textdomain.any? do |domain|\n FastGettext.text_domain = domain\n cached_plural_find(singular, plural)\n end\n end\n found ? Translation.n_(singular, plural, num) : fallback_n_(singular, plural, num)\n end",
"def _(key,value=\"\")\n NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil)\n end",
"def t(*values)\n self.class::translate(self) % values\n end",
"def pluralize(text)\n \"#{text.to_s}s\"\n end",
"def lbText _obj, _args\n \"_obj lbText _args;\" \n end",
"def localize(*args)\n I18n.localize *args\n end",
"def localize(*args)\n I18n.localize *args\n end",
"def plural(palavra)\n \"#{palavra}s\"\nend",
"def translate(text,dictonary)\nend",
"def Nn_(singular,plural)\n [singular,plural]\n end",
"def translate_value(args)\n code = get_field_val(args)\n translate_lang_code(code)\n end",
"def composeText _args\n \"composeText _args;\" \n end",
"def pagy_t(path, vars={})\n value = I18N.dig(*path.to_s.split('.'.freeze))\n if value.is_a?(Hash)\n vars.has_key?(:count) or return value\n plural = (Opts.i18n_plurals ||= -> (c) {c==0 && 'zero' || c==1 && 'one' || 'other'}).call(vars[:count])\n value.has_key?(plural) or return %(invalid pluralization data: \"#{path}\" cannot be used with count: #{vars[:count]}; key \"#{plural}\" is missing.)\n value = value[plural]\n end\n value or return %(translation missing: \"#{path}\")\n sprintf value, Hash.new{|h,k| \"%{#{k}}\"}.merge!(vars) # interpolation\n end",
"def t(string, options = {})\n I18n.t(string, **options)\nend",
"def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend",
"def getText _args\n \"getText _args;\" \n end",
"def lnbSetText _args\n \"lnbSetText _args;\" \n end",
"def pluralize(number, text)\n if number != 1\n return number, text + \"s\"\n else\n return number, text\n \n end\n \nend",
"def plural(n, item)\n n == 1 ? \"#{n} #{item}\" : \"#{n} #{item}s\"\nend",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def test_gettext_support\n ### FIXME: how to set \"en\" as gettext's default language?\n\n t = MyTestCell.new(@controller)\n c = render_cell_state(t, :view_with_explicit_english_translation)\n\n # the view \"view_with_explicit_english_translation_en\" exists, check if\n # gettext/rails found it:\n if Object.const_defined?(:GetText)\n assert_selekt c, \"#defaultTranslation\", 0\n assert_selekt c, \"#explicitEnglishTranslation\"\n else\n assert_selekt c, \"#defaultTranslation\"\n end\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def field_label *i18n_keys\n first, *rest = i18n_keys.compact\n\n t(first, default: rest)\n end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate!(key, **options); end",
"def apphelp_generic( message_name )\n t( \"uk.org.pond.canvass.generic_messages.#{ message_name }\" )\n end",
"def translate(item)\n @progress.setMainStatusAndLogIt('Translating')\n text = get_original_text(item)\n return nil if text.empty?\n\n translated = ms_translate(text)\n super(item, translated) unless translated.nil? || translated.empty?\n end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def list_title_for(text)\n I18n.t(\"backend.general.list\", :model => text.is_a?(String) ? text : text.send(:human_name))\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def list_item_number_label(**)\n end",
"def translate(args)\n Config.instance.translate(args.first)\n end",
"def use_i18n; end",
"def message(msg, *args)\n\t\tsprintf(@messages[msg], *args)\n\tend",
"def toast_english_muffin (toast = 2)\n \"My english muffins need #{toast} minutes in the toaster.\"\nend",
"def isLocalized _args\n \"isLocalized _args;\" \n end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def translate(key, **options); end",
"def translate(key, **options); end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def translate(locale, key, options = T.unsafe(nil)); end",
"def translate(*args)\n key = args.shift\n if xlated = @map[key]\n if xlated.is_a?(String)\n args.empty? ? xlated : sprintf(xlated, *args)\n else\n xlated.call(*args)\n end\n else\n return key\n end\n end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\nend",
"def get_text(to_translate)\n return send(*to_translate) if to_translate.is_a?(Array)\n return to_translate\n end"
] |
[
"0.7721742",
"0.6507781",
"0.63917255",
"0.6312333",
"0.6190085",
"0.6061964",
"0.60387564",
"0.5962843",
"0.5949399",
"0.59180874",
"0.5904026",
"0.58546674",
"0.5769935",
"0.5748329",
"0.57399404",
"0.569274",
"0.56877345",
"0.5640801",
"0.562679",
"0.5613142",
"0.55351084",
"0.5528989",
"0.5519649",
"0.54985297",
"0.5498417",
"0.5489636",
"0.5485715",
"0.54682434",
"0.54682434",
"0.5462754",
"0.54504865",
"0.54432213",
"0.53845775",
"0.5372274",
"0.5372274",
"0.5372274",
"0.5368239",
"0.5364863",
"0.5361032",
"0.535836",
"0.5349176",
"0.5344506",
"0.5337495",
"0.5331168",
"0.5331168",
"0.53014016",
"0.52657056",
"0.5261277",
"0.5244398",
"0.52246785",
"0.5223993",
"0.52133954",
"0.5192219",
"0.51911724",
"0.5188512",
"0.5181696",
"0.5167892",
"0.5167846",
"0.5167846",
"0.5167846",
"0.5158522",
"0.5138296",
"0.5134255",
"0.5100963",
"0.5100058",
"0.50906336",
"0.50906336",
"0.50906336",
"0.50906336",
"0.50906336",
"0.50906336",
"0.50906336",
"0.50906336",
"0.50739413",
"0.50738734",
"0.5066422",
"0.5064104",
"0.50633115",
"0.5057126",
"0.5047534",
"0.50425595",
"0.5035523",
"0.5024033",
"0.50209767",
"0.5014322",
"0.50115055",
"0.50115055",
"0.50115055",
"0.50101954",
"0.50101954",
"0.500244",
"0.500244",
"0.500244",
"0.5000386",
"0.49954957",
"0.49912006",
"0.49912006",
"0.49912006",
"0.49678662",
"0.4963966"
] |
0.78737795
|
0
|
Method signatures: nsgettext('Fruits|apple', 'apples', 2) nsgettext(['Fruits|apple', 'apples'], 2) source://i18n//lib/i18n/gettext/helpers.rb46
|
def ns_(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def l(*args); I18n.l(*args) end",
"def t(*args); I18n.t(*args) end",
"def n_(*msgids)\n count = msgids.pop\n \n translations = FastGettext.current_repository.plural(*msgids)\n selected = FastGettext.current_repository.pluralisation_rule.call(count)\n translations[selected] || msgids[selected] || msgids.last\n end",
"def _(text)\n text\n end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def rgettext(targetfiles = nil, out = STDOUT)\n RGetText.run(targetfiles, out)\n self\n end",
"def plural_keys(*args); end",
"def pluralize(word); end",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def translate(*args, **opts); end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def Nn_(singular,plural)\n [singular,plural]\n end",
"def plural(*args)\n TextHelper.pluralize(*args)\n end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def N_(translate)\n translate\n end",
"def N_(translate)\n translate\n end",
"def t(...)\n I18n.t(...)\nend",
"def pluralize(locale, entry, count); end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def t(*args)\n I18n.t(*args)\n end",
"def N_(*args)\r\n LocalizeActiveScaffold.dont_translate(args[0].to_s)\r\n end",
"def pluralize(bottles, text)\n return text + 's' if bottles != 1\n text\nend",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def np_(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def _(key,value=\"\")\n NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil)\n end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def lex_en_plain_words; end",
"def lex_en_plain_words; end",
"def lex_en_plain_words; end",
"def translations; end",
"def translate_label(text)\n I18n.t(\"backend.labels.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def t(*args, **kwargs)\n proc { I18n.t(*args, **kwargs) }\n end",
"def translate_and_join(separator = ', ', description = '', options = {})\n self.translate(description, options).join(separator).tml_translated\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def list_title_for(text)\n I18n.t(\"backend.general.list\", :model => text.is_a?(String) ? text : text.send(:human_name))\n end",
"def translate_with_namespace(namespace, arg = nil, default = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def pluralize(text)\n \"#{text.to_s}s\"\n end",
"def _t(key, *args)\n I18n.t(key, *args)\n end",
"def t(*values)\n self.class::translate(self) % values\n end",
"def t(*args)\n proc { I18n.t(*args) }\n end",
"def composeText _args\n \"composeText _args;\" \n end",
"def label_translation; end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def lbText _obj, _args\n \"_obj lbText _args;\" \n end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_plain_string=(_arg0); end",
"def lex_en_plain_string=(_arg0); end",
"def lex_en_plain_string=(_arg0); end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def solrize\n return [rdf_subject.to_s] unless label_present\n [rdf_subject.to_s, { label: \"#{preferred_label}$#{rdf_subject}\" }]\n end",
"def to_sentence(items)\n if items.size <= 2\n items.join(items.size == 2 ? \" and \" : \"\")\n else\n [items[0..-2].join(\", \"), items.last].join(\", and \")\n end\n end",
"def tc(prefix, collection)\n collection.map {|i| [t(\"#{prefix}.#{i}\"), i]}\n end",
"def lex_en_plain_string; end",
"def lex_en_plain_string; end",
"def lex_en_plain_string; end",
"def e_words(str)\r\n \r\nend",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend",
"def localize(*args)\n I18n.localize(*args)\n end",
"def translate_sentence(description = nil, options = {})\n return '' if empty?\n return first if size == 1\n\n elements = translate(description, options)\n\n options[:separator] ||= ', '\n options[:joiner] ||= 'and'\n\n result = elements[0..-2].join(options[:separator])\n result << ' ' << options[:joiner].translate(description || 'List elements joiner', {}, options) << ' '\n result << elements.last\n\n result.tml_translated\n end",
"def s_(translate,seperator=nil)\n if translation = FastGettext.current_repository[translate]\n translation\n else\n translate.split(seperator||NAMESPACE_SEPERATOR).last\n end\n end",
"def s_(translate,seperator=nil)\n if translation = FastGettext.current_repository[translate]\n translation\n else\n translate.split(seperator||NAMESPACE_SEPERATOR).last\n end\n end",
"def translatable_links(t)\n link = link_to(t.titleize.pluralize, [:cms, @available_locale, t.constantize])\n\n var_name = t.underscore.parameterize # (ie, \"brand\" or \"product\")\n if item = instance_variable_get(\"@#{var_name.singularize}\")\n content_tag(:li, link) + item_link(item)\n elsif instance_variable_get(\"@#{var_name.pluralize}\")\n content_tag(:li, link, class: 'current hide-for-small')\n end\n end",
"def translate(text,dictonary)\nend",
"def n_(singular, plural, num)\n # no textdomain configured yet\n if !@my_textdomain\n # it's enough to log just the singular form\n Yast.y2warning(\"No textdomain configured, cannot translate text #{singular.inspect}\")\n Yast.y2warning(\"Called from: #{::Kernel.caller(1).first}\")\n return fallback_n_(singular, plural, num)\n end\n\n # Switching textdomain clears gettext caches so avoid it if possible.\n # difference between _ and n_ is hat we need special cache for plural forms\n found = true\n if !@my_textdomain.include?(FastGettext.text_domain) || !cached_plural_find(singular, plural)\n # Set domain where key is defined.\n found = @my_textdomain.any? do |domain|\n FastGettext.text_domain = domain\n cached_plural_find(singular, plural)\n end\n end\n found ? Translation.n_(singular, plural, num) : fallback_n_(singular, plural, num)\n end",
"def getText _args\n \"getText _args;\" \n end",
"def add_suggestions(name, items)\n # unless alternatives = compute_alternatives(name, items)\n # return\n # end\n # append_message(sprintf(' Did you mean \"%s\"?', implode('\", \"', alternatives)))\n end",
"def unicode_names=(_arg0); end",
"def tr_request(chars, *_)\n tr1 = ''\n tr2 = ''\n chars.scan(/./).each_slice(2) do |c1, c2|\n c2 ||= ' '\n tr1 += c1\n tr2 += c2\n end\n @translation = [tr1, tr2]\n end",
"def texts_translated\n @texts_translated ||= tokens_translated.map do |group|\n group.map { |value, type| type == :text ? value : fix_ascii(value) }.join\n end\n end",
"def sw_subject_titles(sep = ' ')\n result = []\n mods_ng_xml.subject.titleInfo.each { |ti_el|\n parts = ti_el.element_children.map(&:text).reject(&:empty?)\n result << parts.join(sep).strip unless parts.empty?\n }\n result\n end",
"def lnbSetText _args\n \"lnbSetText _args;\" \n end",
"def dummy\r\n N_('Open')\r\n N_('Close')\r\n N_('close')\r\n N_('Edit')\r\n N_('Delete')\r\n N_('Show')\r\n N_('Search')\r\n N_('Search Terms')\r\n N_('No Entries')\r\n N_('Found')\r\n N_('Create New')\r\n N_('Are you sure?')\r\n N_('Cancel')\r\n end",
"def pluralize_collection collection, noun \n if collection.size == 1 \n \"1 #{noun}\"\n else \n \"#{collection.size} #{noun.pluralize}\"\n end\n end",
"def lnbText _obj, _args\n \"_obj lnbText _args;\" \n end",
"def to_phrase(items)\n *items, last_item = items\n return last_item if items.empty?\n\n items.join(', ') + ', and ' + last_item\n end",
"def sw_subject_names(sep = ', ')\n mods_ng_xml.subject.name_el\n .select { |n_el| n_el.namePart }\n .map { |name_el_w_np| name_el_w_np.namePart.map(&:text).reject(&:empty?) }\n .reject(&:empty?)\n .map { |parts| parts.join(sep).strip }\n end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def translate!(key, **options); end",
"def localized_search_text_in(field)\n options[:organization].available_locales.map do |l|\n \"#{field} ->> '#{l}' ILIKE :text\"\n end.join(\" OR \")\n end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\nend"
] |
[
"0.7581999",
"0.6791193",
"0.57829094",
"0.5727344",
"0.57247674",
"0.5641557",
"0.5438735",
"0.5438735",
"0.5438735",
"0.53590256",
"0.53401554",
"0.5300031",
"0.5284317",
"0.5276896",
"0.5264105",
"0.5264105",
"0.5264105",
"0.5250062",
"0.52473104",
"0.5198388",
"0.5198388",
"0.5198388",
"0.51931113",
"0.51931113",
"0.5174446",
"0.5151919",
"0.51269567",
"0.51113427",
"0.50785077",
"0.5062358",
"0.5050383",
"0.5043765",
"0.50398487",
"0.5039084",
"0.5039084",
"0.5039084",
"0.5038438",
"0.5025811",
"0.5025811",
"0.5025811",
"0.5025553",
"0.5007749",
"0.50059205",
"0.4986047",
"0.4971416",
"0.49713677",
"0.49713677",
"0.49713677",
"0.49520662",
"0.49467558",
"0.49248606",
"0.49047363",
"0.4902302",
"0.49013242",
"0.48964316",
"0.48766506",
"0.48704192",
"0.48324674",
"0.4825822",
"0.4825822",
"0.4825822",
"0.48170528",
"0.48170528",
"0.48170528",
"0.48144698",
"0.48129496",
"0.48108226",
"0.47978446",
"0.4789885",
"0.4789885",
"0.4789885",
"0.47894529",
"0.4767361",
"0.47602046",
"0.47595978",
"0.47454146",
"0.47298777",
"0.47295824",
"0.47289523",
"0.47280875",
"0.4723169",
"0.4716608",
"0.47108057",
"0.47070298",
"0.47019652",
"0.46933097",
"0.46920148",
"0.46891737",
"0.46806782",
"0.4674279",
"0.4672453",
"0.4665105",
"0.46648175",
"0.46633667",
"0.46633667",
"0.46633667",
"0.46633667",
"0.4658276",
"0.4651181",
"0.4647012"
] |
0.6674116
|
2
|
Method signatures: nsgettext('Fruits|apple', 'apples', 2) nsgettext(['Fruits|apple', 'apples'], 2) source://i18n//lib/i18n/gettext/helpers.rb46
|
def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def ns_(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end",
"def l(*args); I18n.l(*args) end",
"def t(*args); I18n.t(*args) end",
"def n_(*msgids)\n count = msgids.pop\n \n translations = FastGettext.current_repository.plural(*msgids)\n selected = FastGettext.current_repository.pluralisation_rule.call(count)\n translations[selected] || msgids[selected] || msgids.last\n end",
"def _(text)\n text\n end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def lex_en_interp_words=(_arg0); end",
"def rgettext(targetfiles = nil, out = STDOUT)\n RGetText.run(targetfiles, out)\n self\n end",
"def plural_keys(*args); end",
"def pluralize(word); end",
"def pluralize(count, singular, plural_arg = T.unsafe(nil), plural: T.unsafe(nil), locale: T.unsafe(nil)); end",
"def translate(*args, **opts); end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def lex_en_interp_words; end",
"def Nn_(singular,plural)\n [singular,plural]\n end",
"def plural(*args)\n TextHelper.pluralize(*args)\n end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def lex_en_plain_words=(_arg0); end",
"def N_(translate)\n translate\n end",
"def N_(translate)\n translate\n end",
"def t(...)\n I18n.t(...)\nend",
"def pluralize(locale, entry, count); end",
"def translate_text(text)\n I18n.t(\"backend.texts.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def t(*args)\n I18n.t(*args)\n end",
"def N_(*args)\r\n LocalizeActiveScaffold.dont_translate(args[0].to_s)\r\n end",
"def pluralize(bottles, text)\n return text + 's' if bottles != 1\n text\nend",
"def translated_text(args = {})\n objects = args[:locale].nil? ? translations : for_language(args[:locale])\n objects.collect(&:text)\n end",
"def np_(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end",
"def _(key,value=\"\")\n NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil)\n end",
"def translate(default = nil, arg = nil, namespace = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n # there is a namespace and found a scope default separator in the key,\n # so we need to escape the string to e.g. foo.\"Foo. And Bar.\"\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_plain_words; end",
"def lex_en_plain_words; end",
"def lex_en_plain_words; end",
"def translations; end",
"def translate_label(text)\n I18n.t(\"backend.labels.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def t(*args, **kwargs)\n proc { I18n.t(*args, **kwargs) }\n end",
"def translate_and_join(separator = ', ', description = '', options = {})\n self.translate(description, options).join(separator).tml_translated\n end",
"def localize_with_args(args={}, replacement_string = '__i18n_missing__') \n I18n.translate(self, {:default => \"#{replacement_string}(#{self})\"}.merge(args))\n end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def list_title_for(text)\n I18n.t(\"backend.general.list\", :model => text.is_a?(String) ? text : text.send(:human_name))\n end",
"def translate_with_namespace(namespace, arg = nil, default = nil)\n options = {:default => default, :count => arg, :scope => namespace}.reject! {|k,v| v.blank?}\n if self.index(I18n.default_separator)\n options.delete(:scope)\n I18n.t(I18n.escape_translation_key(self, namespace), options)\n else\n I18n.t(self, options)\n end\n end",
"def pluralize(text)\n \"#{text.to_s}s\"\n end",
"def _t(key, *args)\n I18n.t(key, *args)\n end",
"def t(*values)\n self.class::translate(self) % values\n end",
"def t(*args)\n proc { I18n.t(*args) }\n end",
"def composeText _args\n \"composeText _args;\" \n end",
"def label_translation; end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def lbText _obj, _args\n \"_obj lbText _args;\" \n end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def lex_en_interp_backslash_delimited_words=(_arg0); end",
"def request_translations(texts, options = T.unsafe(nil), http_options = T.unsafe(nil)); end",
"def lex_en_plain_string=(_arg0); end",
"def lex_en_plain_string=(_arg0); end",
"def lex_en_plain_string=(_arg0); end",
"def solrize\n return [rdf_subject.to_s] unless label_present\n [rdf_subject.to_s, { label: \"#{preferred_label}$#{rdf_subject}\" }]\n end",
"def to_sentence(items)\n if items.size <= 2\n items.join(items.size == 2 ? \" and \" : \"\")\n else\n [items[0..-2].join(\", \"), items.last].join(\", and \")\n end\n end",
"def tc(prefix, collection)\n collection.map {|i| [t(\"#{prefix}.#{i}\"), i]}\n end",
"def e_words(str)\r\n \r\nend",
"def lex_en_plain_string; end",
"def lex_en_plain_string; end",
"def lex_en_plain_string; end",
"def test_pluralization\r\n GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'\r\n GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'\r\n set_language :en\r\n\r\n assert_equal 'No men', lwr(:a, 0)\r\n assert_equal '1 man', lwr(:a, 1)\r\n assert_equal '3 men', lwr(:a, 3)\r\n assert_equal '20 men', lwr(:a, 20)\r\n\r\n assert_equal 'a few men (0)', lwr_(:asd, :a, 0)\r\n assert_equal 'a few men (1)', lwr_(:asd, :a, 1)\r\n assert_equal 'a few men (3)', lwr_(:asd, :a, 3)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 12)\r\n assert_equal 'soo many men', lwr_(:asd, :a, 20)\r\n \r\n end",
"def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend",
"def localize(*args)\n I18n.localize(*args)\n end",
"def translate_sentence(description = nil, options = {})\n return '' if empty?\n return first if size == 1\n\n elements = translate(description, options)\n\n options[:separator] ||= ', '\n options[:joiner] ||= 'and'\n\n result = elements[0..-2].join(options[:separator])\n result << ' ' << options[:joiner].translate(description || 'List elements joiner', {}, options) << ' '\n result << elements.last\n\n result.tml_translated\n end",
"def s_(translate,seperator=nil)\n if translation = FastGettext.current_repository[translate]\n translation\n else\n translate.split(seperator||NAMESPACE_SEPERATOR).last\n end\n end",
"def s_(translate,seperator=nil)\n if translation = FastGettext.current_repository[translate]\n translation\n else\n translate.split(seperator||NAMESPACE_SEPERATOR).last\n end\n end",
"def translatable_links(t)\n link = link_to(t.titleize.pluralize, [:cms, @available_locale, t.constantize])\n\n var_name = t.underscore.parameterize # (ie, \"brand\" or \"product\")\n if item = instance_variable_get(\"@#{var_name.singularize}\")\n content_tag(:li, link) + item_link(item)\n elsif instance_variable_get(\"@#{var_name.pluralize}\")\n content_tag(:li, link, class: 'current hide-for-small')\n end\n end",
"def translate(text,dictonary)\nend",
"def n_(singular, plural, num)\n # no textdomain configured yet\n if !@my_textdomain\n # it's enough to log just the singular form\n Yast.y2warning(\"No textdomain configured, cannot translate text #{singular.inspect}\")\n Yast.y2warning(\"Called from: #{::Kernel.caller(1).first}\")\n return fallback_n_(singular, plural, num)\n end\n\n # Switching textdomain clears gettext caches so avoid it if possible.\n # difference between _ and n_ is hat we need special cache for plural forms\n found = true\n if !@my_textdomain.include?(FastGettext.text_domain) || !cached_plural_find(singular, plural)\n # Set domain where key is defined.\n found = @my_textdomain.any? do |domain|\n FastGettext.text_domain = domain\n cached_plural_find(singular, plural)\n end\n end\n found ? Translation.n_(singular, plural, num) : fallback_n_(singular, plural, num)\n end",
"def getText _args\n \"getText _args;\" \n end",
"def add_suggestions(name, items)\n # unless alternatives = compute_alternatives(name, items)\n # return\n # end\n # append_message(sprintf(' Did you mean \"%s\"?', implode('\", \"', alternatives)))\n end",
"def unicode_names=(_arg0); end",
"def tr_request(chars, *_)\n tr1 = ''\n tr2 = ''\n chars.scan(/./).each_slice(2) do |c1, c2|\n c2 ||= ' '\n tr1 += c1\n tr2 += c2\n end\n @translation = [tr1, tr2]\n end",
"def texts_translated\n @texts_translated ||= tokens_translated.map do |group|\n group.map { |value, type| type == :text ? value : fix_ascii(value) }.join\n end\n end",
"def sw_subject_titles(sep = ' ')\n result = []\n mods_ng_xml.subject.titleInfo.each { |ti_el|\n parts = ti_el.element_children.map(&:text).reject(&:empty?)\n result << parts.join(sep).strip unless parts.empty?\n }\n result\n end",
"def lnbSetText _args\n \"lnbSetText _args;\" \n end",
"def dummy\r\n N_('Open')\r\n N_('Close')\r\n N_('close')\r\n N_('Edit')\r\n N_('Delete')\r\n N_('Show')\r\n N_('Search')\r\n N_('Search Terms')\r\n N_('No Entries')\r\n N_('Found')\r\n N_('Create New')\r\n N_('Are you sure?')\r\n N_('Cancel')\r\n end",
"def pluralize_collection collection, noun \n if collection.size == 1 \n \"1 #{noun}\"\n else \n \"#{collection.size} #{noun.pluralize}\"\n end\n end",
"def lnbText _obj, _args\n \"_obj lnbText _args;\" \n end",
"def sw_subject_names(sep = ', ')\n mods_ng_xml.subject.name_el\n .select { |n_el| n_el.namePart }\n .map { |name_el_w_np| name_el_w_np.namePart.map(&:text).reject(&:empty?) }\n .reject(&:empty?)\n .map { |parts| parts.join(sep).strip }\n end",
"def to_phrase(items)\n *items, last_item = items\n return last_item if items.empty?\n\n items.join(', ') + ', and ' + last_item\n end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def translate!(key, **options); end",
"def localized_search_text_in(field)\n options[:organization].available_locales.map do |l|\n \"#{field} ->> '#{l}' ILIKE :text\"\n end.join(\" OR \")\n end",
"def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\nend"
] |
[
"0.6792097",
"0.66764313",
"0.5781654",
"0.5726153",
"0.5725643",
"0.56406915",
"0.5438408",
"0.5438408",
"0.5438408",
"0.5358775",
"0.53412116",
"0.5301072",
"0.52857107",
"0.5277405",
"0.5263729",
"0.5263729",
"0.5263729",
"0.5251851",
"0.5247334",
"0.5197781",
"0.5197781",
"0.5197781",
"0.51952124",
"0.51952124",
"0.5173569",
"0.5152117",
"0.51273346",
"0.5110321",
"0.50791174",
"0.50618786",
"0.50487876",
"0.50449383",
"0.50398564",
"0.5039497",
"0.503825",
"0.503825",
"0.503825",
"0.50252706",
"0.50252706",
"0.50252706",
"0.50247437",
"0.5008393",
"0.5005339",
"0.49851638",
"0.4971743",
"0.49700993",
"0.49700993",
"0.49700993",
"0.49504578",
"0.4948372",
"0.49252418",
"0.49044585",
"0.49024558",
"0.49000108",
"0.4894773",
"0.48756447",
"0.48694777",
"0.48315257",
"0.48245284",
"0.48245284",
"0.48245284",
"0.48166078",
"0.48158866",
"0.48158866",
"0.48158866",
"0.48122212",
"0.481",
"0.47977838",
"0.47902015",
"0.47884518",
"0.47884518",
"0.47884518",
"0.47686574",
"0.47602335",
"0.47599065",
"0.47445187",
"0.4730142",
"0.472985",
"0.47287363",
"0.47283125",
"0.47262615",
"0.47153413",
"0.4710177",
"0.47079492",
"0.4702075",
"0.469154",
"0.4689799",
"0.46877646",
"0.4681247",
"0.46746576",
"0.46709713",
"0.4664065",
"0.4663583",
"0.46625367",
"0.46625367",
"0.46625367",
"0.46625367",
"0.4658598",
"0.4650574",
"0.4647502"
] |
0.75832784
|
0
|
Returns the value of attribute locale. source://i18n//lib/i18n/exceptions.rb33
|
def locale; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locale\r\n read_attribute(:locale).to_sym\r\n end",
"def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end",
"def locale\n return @locale\n end",
"def locale\n return @locale\n end",
"def locale\n if self.language\n LANGUAGE_CODE[self.language]\n end\n end",
"def get(locale = Localization.default_locale)\n @locales[locale.to_s]\n end",
"def read_locale\n raise \"Override me\"\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end",
"def locale_in_context(locale)\n return @locale if @locale && @locale.code == locale.to_s\n #Locale.find_by_code(locale.to_s) rescue nil && (raise InvalidLocale.new(locale))\n locale = Locale.find_by_code(locale.to_s)\n raise InvalidLocale.new(locale) unless locale\n locale\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n if !language.nil?\n language.abbreviation\n elsif !org.nil?\n org.locale\n end\n end",
"def locale\n self.padma.try :locale\n end",
"def get_native_locale_attribute attribute, locale = Globalize.locale\n return self.send(attribute) unless translatable?\n\n if globalize.stash.contains?(locale, attribute)\n globalize.stash.read(locale, attribute)\n else\n translation_for(locale).send(attribute)\n end\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end",
"def get_locale(locale = nil)\n locale || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value); end",
"def locale\n @values.fetch('ai.device.locale') { \n @values['ai.device.locale'] = nil\n }\n end",
"def locale\n frontmatter_locale = data['locale'] || data['lang']\n filename_locale = path_part('locale') || path_part('lang')\n\n raise \"The locale in #{path}'s filename (#{filename_locale.inspect}) doesn't match the lang in its frontmatter (#{frontmatter_locale.inspect})\" if frontmatter_locale && filename_locale && frontmatter_locale != filename_locale\n\n default_locale = I18n.default_locale if defined? ::I18n\n\n found_locale = frontmatter_locale || filename_locale || default_locale\n found_locale&.to_sym\n end",
"def locale_language(locale = nil)\n (locale || I18n.locale).to_s.match(/^(\\w{2})/) ? $1.to_sym : nil\n end",
"def locale\n @locale || YodleeApi.locale\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n elsif !self.org.nil?\n return self.org.get_locale\n else\n return nil\n end\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def locale_language(locale=nil)\n \"#{locale || I18n.locale}\"[0, 2].to_sym\n end",
"def locale\n @locale || { :country => \"US\", :language => \"en\", :variant => nil }\n end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def getLocaleCode\n # first default locale to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # next set locale to the locale in user record\n @locale_code = current_user.try(:locale) || @locale_code\n # next set locale to the locale passed as the locale param\n if (params.present? &&\n params['locale'].present? &&\n BaseRec::VALID_LOCALES.include?(params['locale'].to_s)\n )\n @locale_code = params['locale']\n end\n # set the locale in I18n\n I18n.locale = @locale_code\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n end",
"def locale\n @grpc.locale\n end",
"def locale\n @grpc.locale\n end",
"def locale=(locale); end",
"def po_locale\n @po_locale\n end",
"def locale=(_arg0); end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale_name\n YAML.load(translation || \"{}\").with_indifferent_access[locale] || survey.default_locale_name\n end",
"def extract_locale_from_request\r\n # locale defined in parameters\r\n return params[:locale] if params[:locale]\r\n # get locale from subdomains\r\n parsed_locale = request.subdomains.first\r\n return parsed_locale if I18n.available_locales.map(&:to_s).include?(parsed_locale)\r\n # get locale from http header\r\n return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\r\n # get default locale\r\n return I18n.default_locale\r\n end",
"def correct_locale\n (locales.select{|loc|loc.locale == I18n.locale.to_s}.first || locales.first)\n end",
"def locale\n favored_locale\n end",
"def extract_locale_from_request\r\n # locale defined in parameters\r\n return params[:locale] if params[:locale]\r\n # get locale from subdomains\r\n parsed_locale = request.subdomains.first\r\n return parsed_locale if I18n.available_locales.map(&:to_s).include?(parsed_locale)\r\n # get locale from http header\r\n return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\r\n # get default locale\r\n return I18n.default_locale\r\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def i18n(locale)\n selected_locale = self.i18ns.select{|i18n| i18n.locale_id == locale.id }\n return selected_locale.first if selected_locale.any?\n\n self.i18ns.first\n end",
"def locale=(locale)\r\n write_attribute(:locale, locale.to_s)\r\n end",
"def locale=(locale)\n Thread.current[:locale] = locale.to_s\n end",
"def translate(attribute, locale_tag)\n if locale = DataMapper::I18n::Locale.for(locale_tag)\n t = resource.translations.first(:locale => locale)\n t ? t.send(attribute) : nil\n else\n nil\n end\n end",
"def default_locale; end",
"def extract_locale_from_session\n session[:locale] || nil\n end",
"def locale\n lang = params.fetch(:language, I18n.default_locale).to_sym\n I18n.available_locales.include?(lang) ? lang : I18n.default_locale\n end",
"def find_locale\n locale = locales.all.detect(&:default)\n return locale.code if locale\n\n default_locale\n end",
"def locale_from_http_header\n language = request.env['HTTP_ACCEPT_LANGUAGE']\n unless language.blank?\n http_locale = language.scan(/^[a-z]{2}-[A-Z]{2}/)\n unless http_locale.blank?\n http_locale = http_locale.first\n else\n http_locale = language.scan(/^[a-z]{2}/).first\n end\n end\n end",
"def verify_locale(locale)\n (site_locales.include? locale.to_s) ? locale : preferred_default_locale\n end",
"def find_by_locale(locale)\r\n with_locale(locale.to_s).first\r\n end",
"def get_matching_ui_locale(locale)\n lang = locale[0,2].downcase\n\n # Check with exact matching\n if Globalite.ui_locales.values.include?(local_case(locale))\n local_case(locale)\n end\n\n # Check on the language only\n Globalite.ui_locales.values.each do |value|\n value.to_s =~ /#{lang}-*/ ? value : nil\n end\n end",
"def get_locale\n I18n.locale = session[:i18n] || I18n.default_locale || :en\n end",
"def locale_from_env\n locale = nil\n # At least one environment valiables should be set on *nix system.\n [ENV[\"LC_ALL\"], ENV[\"LC_MESSAGES\"], ENV[\"LANG\"]].each do |loc|\n\tif loc != nil and loc.size > 0\n\t locale = Locale::Object.new(loc)\n\t locale.charset ||= get_charset(locale)\n\t break\n\tend\n end\n locale\n end",
"def verify_locale(locale)\n site_locales.include?(locale.to_s) ? locale : preferred_default_locale\n end",
"def locale\n current_site.locale || I18n.default_locale.to_s\n end",
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def locale_backend; end",
"def header_locale\n options = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '').split(',')\n # clear out preference values; assume they'll be in order\n options.map! { |v| v.split(';')[0] }\n options.each do |v|\n return locale_matches[v] if locale_matches.keys.include?(v)\n end\n I18n.default_locale\n end",
"def language #:nodoc\n return '' if read_attribute(:language).nil?\n read_attribute(:language).to_sym\n end",
"def name\n n = names\n return nil if n.nil?\n\n @locales.each do |locale|\n return n[locale] if n.key?(locale)\n end\n\n nil\n end",
"def getLocaleCode\n locp = params['locale'].to_s\n locc = cookies['locale'].to_s\n if (\n locp.present? &&\n BaseRec::VALID_LOCALES.include?(locp)\n )\n # first set locale to the locale passed as the locale param\n @locale_code = locp\n elsif (\n locc.present? &&\n BaseRec::VALID_LOCALES.include?(locc)\n )\n # next default locale to cookie:\n @locale_code = locc\n else\n # next set it to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # # next set locale to the locale in user record\n # @locale_code = current_user.try(:locale) || @locale_code\n end\n # set the locale in I18n\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n I18n.locale = @locale_code\n cookies[:locale] = @locale_code\n end",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def locale=(value)\n super(value.blank? ? nil : value)\n end",
"def system\n locale_from_env || default_locale\n end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def get_locale_from_subdomain\n locale = @rh.match( /(.+)\\.demowatch\\.[a-z]{2,3}$/i)[1]\n return locale if ( I18N_ALL_LANGUAGES.include?( locale))\n return nil\n end",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def locale\n (self.country.blank? or self.country.indonesia?) ? :id : :en\n end",
"def get_locale_from_http_header\n return DEFAULT_LANGUAGE if request.env['HTTP_ACCEPT_LANGUAGE'].nil?\n locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first\n return locale if I18N_ALL_LANGUAGES.include?( locale)\n return DEFAULT_LANGUAGE\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def valid_language\n locale = extract_locale_from_accept_language_header\n logger.debug \"* Extracted Locale ID: #{locale}\"\n if !locale.blank? &&\n (locale == 'de' ||\n locale == 'en')\n locale\n else\n DEFAULT_LANGUAGE\n end\n end",
"def valid_language\n locale = extract_locale_from_accept_language_header\n logger.debug \"* Extracted Locale ID: #{locale}\"\n if !locale.blank? &&\n (locale == 'de' ||\n locale == 'en')\n locale\n else\n DEFAULT_LANGUAGE\n end\n end",
"def fetch_attribute(locale, name)\r\n translation = record.translation_for(locale)\r\n return translation && translation.send(name)\r\n end",
"def get_locale_from_session\n if (session && session[:language])\n logger.debug \"*** Language from Session '#{session[:language]}'\"\n lang = session[:language]\n else\n lang = default_language\n end\n lang\n end",
"def locale=(value)\n if value == @defaults['ai.device.locale']\n @values.delete 'ai.device.locale' if @values.key? 'ai.device.locale'\n else\n @values['ai.device.locale'] = value\n end\n end",
"def another_locale\n I18n.available_locales.map(&:to_sym).select {|locale| locale != I18n.locale.to_sym }.first\n end",
"def message_language\n return @message_language\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def i18n_name(locale = I18n.locale.to_s)\n ([self[Type.i18n_name_field(locale)], self.name].reject(&:blank?).first)\n end",
"def get_locale_from_params \n return nil unless params[:locale]\n I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil\n end",
"def get_locale_from_params \n return nil unless params[:locale]\n I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil\n end",
"def extract_locale_from_accept_language_header\n browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first.to_sym\n return nil unless I18n.available_locales.include? browser_locale\n browser_locale\n end",
"def read(locale, name)\r\n self[locale][name.to_s]\r\n end",
"def extract_locale_from_accept_language_header\n locale = \"en_US\"\n locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first \\\n if not request.env['HTTP_ACCEPT_LANGUAGE'].nil?\n return locale\n end",
"def detect_locale_from(source)\n case source\n when :params\n params[:locale]\n when :session\n logger.debug \"Session: #{session.inspect}\"\n session[:locale]\n when :cookie\n cookies[:locale]\n when :domain\n parse_host_and_port_for_locale[0]\n when :header\n request.env['HTTP_ACCEPT_LANGUAGE']\n when :default\n default_locale\n else\n raise \"unknown source\"\n end\n end",
"def payment_compatible_locale(locale)\n locale = locale.to_s.split(\"-\").first\n if [\"fr\", \"en\", \"es\", \"it\", \"pt\", \"de\", \"nl\", \"fi\"].include?(locale)\n return locale\n else\n return \"en\"\n end\n end",
"def apply_locale; end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def default_locale\n FastGettext.available_locales.first\n end"
] |
[
"0.754781",
"0.7252886",
"0.71678245",
"0.71678245",
"0.70410967",
"0.6866833",
"0.686631",
"0.68230784",
"0.6686969",
"0.6676696",
"0.66669863",
"0.66669863",
"0.66206306",
"0.6609035",
"0.65974677",
"0.65783453",
"0.651413",
"0.6511079",
"0.6511079",
"0.65004814",
"0.6461078",
"0.64435494",
"0.64173275",
"0.6408252",
"0.63261515",
"0.62864256",
"0.62488073",
"0.62179774",
"0.6215542",
"0.6170496",
"0.6169997",
"0.6166439",
"0.6166439",
"0.61456966",
"0.61158705",
"0.6107885",
"0.6080659",
"0.6080659",
"0.607284",
"0.60727423",
"0.6048517",
"0.6027848",
"0.6022537",
"0.6020405",
"0.6015259",
"0.6008169",
"0.60079515",
"0.59753835",
"0.5958914",
"0.59585536",
"0.59578955",
"0.59503776",
"0.5945318",
"0.59019065",
"0.5894552",
"0.58937234",
"0.58935523",
"0.584798",
"0.5845077",
"0.58437544",
"0.58362156",
"0.5796624",
"0.5793097",
"0.5789496",
"0.57676774",
"0.57649213",
"0.5758135",
"0.5738953",
"0.5737297",
"0.57347775",
"0.57314926",
"0.57170004",
"0.5714283",
"0.56946075",
"0.5689262",
"0.56830925",
"0.56829494",
"0.567447",
"0.5671883",
"0.566953",
"0.5663584",
"0.5658663",
"0.5654388",
"0.564139",
"0.56327367",
"0.56290877",
"0.5628564",
"0.5626847",
"0.5622365",
"0.5615209",
"0.56077266",
"0.560185",
"0.55961686",
"0.55906314"
] |
0.65631115
|
21
|
Returns the value of attribute filename. source://i18n//lib/i18n/exceptions.rb41
|
def filename; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filename\n raise\n end",
"def filename\n @properties[:filename]\n end",
"def getFilename\r\n\t\t\t\t\treturn @filename\r\n\t\t\t\tend",
"def filename\n @filename\n end",
"def filename\n @filename\n end",
"def filename\n @filename\n end",
"def file_name\n return @file_name\n end",
"def file_name\n return @file_name\n end",
"def filename\n @file.basename.to_s\n end",
"def filename\n get \"filename\"\n end",
"def filename\n @file\n end",
"def filename\n @data[:name]\n end",
"def file_name\n @file_name\n end",
"def filename\n self._filename\n end",
"def filename\n return _meta_data['filename'] if _meta_data.has_key? 'filename'\n name\n end",
"def full_filename_for(attribute)\n filename = attachment_for(attribute).path\n end",
"def filename\n unless @filename\n load_file_params\n end\n @filename\n end",
"def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end",
"def file_name\n self.file_file_name\n end",
"def filename\n @metadata[:filename] || uri.path.split('/')[-1]\n end",
"def original_filename\n instance_read(:file_name)\n end",
"def filename\n @adapter.attribute\n end",
"def filename(property: 'file')\n params.dig property, :filename\n end",
"def filename\n __advance!\n @_st_fileName\n end",
"def file_name\n return unless @file\n\n @file.absolute_name\n end",
"def filename\n model.respond_to?(:filename) ? model.filename : super\n end",
"def original_filename\n @file_representation[:filename]\n end",
"def filename\n @metadata[:filename] || \"attachment\"\n end",
"def access_file_name\n end",
"def filename\n original_filename\n end",
"def get_filename (file)\n\t\tif file.is_a? File\n\t\t\tfile = file.path\n\t\tend\n\t\treturn file\n\tend",
"def name() @filename end",
"def fileName\r\n\t\traise NoMethodError\r\n\tend",
"def filename(filename = nil)\n @filename = filename if filename\n @filename\n end",
"def filename\n @basename + PAGE_FILE_EXT\n end",
"def assignment_upload_file_name\n read_attribute(:file_name)\n end",
"def filename\n return @file_object.io.path if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def original_filename\n metadata[\"filename\"]\n end",
"def filename\n return @filename if @filename\n\n if self.uri\n @filename = File.basename(self.uri.path)\n else\n regexps = PRECOMPILED_FILE_TYPES.map { |ext| \"\\.#{ext}\" }.join('|')\n\n @filename = File.basename(self.filepath).gsub(/#{regexps}/, '')\n end\n end",
"def original_file # Accessor for probably protected value original_filename\r\n original_filename\r\n end",
"def filename=(_); end",
"def validate_filename(_item)\n nil\n end",
"def filename\n path && File.basename(path)\n end",
"def filename\n @original_filename\n end",
"def filename\n find_attachment\n end",
"def filename\n if original_filename\n \"#{model.name.parameterize}-#{secure_token(8)}.#{file.extension}\"\n end\n end",
"def filename\n @filename ||= metadata.fetch('PA_MD_CUST_FILENAME', '').to_s\n end",
"def path\n @filename\n end",
"def filename()\n #This is a stub, used for indexing\n end",
"def label_for(file)\n if file.is_a?(Hyrax::UploadedFile) # filename not present for uncached remote file!\n file.uploader.filename.presence || File.basename(Addressable::URI.unencode(file.file_url))\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.unencode(file.file_url))\n elsif file.respond_to?(:original_filename) # e.g. Rack::Test::UploadedFile\n file.original_filename\n else\n File.basename(file)\n end\n end",
"def FileName\n if(!FilePath)\n return nil\n end\n return FilePath.FileName\n end",
"def errored_files\n @attributes[:errored_files]\n end",
"def filename\n @parts[-1]\n end",
"def file_name\n @file_name ||= File.basename tree\n end",
"def filename\n @filename || @options[:filename]\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 filename\n \"#{original_filename_without_extension.parameterize}_#{model.filename_token}#{original_extension}\" if original_filename\n end",
"def filename\n return @filename if @filename\n name.downcase.gsub(/\\W/, '_').squeeze('_')\n end",
"def filename\n \"#{model.name.parameterize}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n return @args[:fname]\n end",
"def name\n filename\n end",
"def name\n filename\n end",
"def filename\n attachment.original_filename\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def filename\n return @filename unless @filename.nil?\n generate_file_name()\n @filename\n end",
"def name\n self.filename\n end",
"def full_filename (for_file = model.document.file)\n for_file\n end",
"def filename\n @filename ||= attached_file&.original_filename&.dup\n end",
"def file\n file_names[x]\n end",
"def filename\n @filename || (@options && @options[:filename])\n end",
"def filename\n @filename || (@options && @options[:filename])\n end",
"def file_name=(value)\n @file_name = value\n end",
"def file_name=(value)\n @file_name = value\n end",
"def filename=(value)\n @old_filename = filename unless filename.nil? || @old_filename\n write_attribute :filename, sanitize_filename(value)\n end",
"def file_name\n \"#{@file_name}.#{extension}\"\n end",
"def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n return @args[\"fname\"]\n end",
"def filename\n original_filename.try(:gsub, '+', '-')\n end",
"def uploaded_filename_without_extension\n attachment.try(:original_filename_without_extension)\n end",
"def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def file_name\n File.basename @path\n end",
"def filename\n super\n end"
] |
[
"0.7426389",
"0.7015572",
"0.6760014",
"0.6714185",
"0.6708332",
"0.6708332",
"0.6622393",
"0.6622393",
"0.660398",
"0.65890926",
"0.658782",
"0.656798",
"0.6562609",
"0.6536921",
"0.65184313",
"0.6511762",
"0.6464005",
"0.6380086",
"0.6368738",
"0.6332088",
"0.63253725",
"0.6310324",
"0.6273208",
"0.62674206",
"0.6257432",
"0.62460804",
"0.6232113",
"0.6222635",
"0.62097746",
"0.6185446",
"0.61338556",
"0.6128882",
"0.6117273",
"0.6111684",
"0.611108",
"0.60881776",
"0.60806555",
"0.60767543",
"0.60452837",
"0.60253775",
"0.6020416",
"0.6012397",
"0.601031",
"0.60054",
"0.6001609",
"0.59669745",
"0.59648967",
"0.5959769",
"0.59560776",
"0.59532124",
"0.5944322",
"0.5943805",
"0.59291977",
"0.5928512",
"0.5922129",
"0.59195024",
"0.59142137",
"0.5913393",
"0.59112763",
"0.59107405",
"0.590571",
"0.590571",
"0.5902246",
"0.58959436",
"0.58959436",
"0.5893191",
"0.58739847",
"0.58735317",
"0.5860516",
"0.58534193",
"0.58474183",
"0.58474183",
"0.5841176",
"0.5841176",
"0.5831518",
"0.58302647",
"0.58293873",
"0.58266485",
"0.5819105",
"0.58138335",
"0.5809102",
"0.5805413",
"0.578136",
"0.578136",
"0.578136",
"0.57594895",
"0.575379"
] |
0.5944656
|
62
|
Returns the value of attribute count. source://i18n//lib/i18n/exceptions.rb93
|
def count; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count\n @attributes['count']\n end",
"def count\n self[:count].to_i\n end",
"def count\n @obj['count'].to_i\n end",
"def size\n @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size }\n end",
"def size\n @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size }\n end",
"def size\n @errors.values.inject(0) { |error_count, attribute| error_count + attribute.size }\n end",
"def count\n @data['count']\n end",
"def Count()\n _getproperty(1, [], [])\n end",
"def value_count\n $capitals.values.length\nend",
"def count\n @alarms.objects.find { |o| o.name == \"count\" }.val\n end",
"def domain_count\n @attributes[:domain_count]\n end",
"def notices_count\n @notices_count ||= error.search('notices-count').first.text.to_i\n end",
"def errorcount\r\n\t\t\t`#{BITS::BITSADMIN} /geterrorcount {#{@id}}`\r\n\t\tend",
"def message_count\n to_i description['MessageCount']\n end",
"def get_count\n @count <= 0 ? DEFAULT_COUNT : @count;\n end",
"def users_count\n @attributes[:users_count]\n end",
"def count; @value.size; end",
"def size_of attr\n real_attr = attribute_for attr\n raise LookupFailure.new(self, attr) unless real_attr\n AX.attr_count_of_element @ref, real_attr\n end",
"def api_keys_count\n @attributes[:api_keys_count]\n end",
"def item_count\n @item_count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n properties[\"x-dura-meta-space-count\"].to_i\n end",
"def attribute_count\n product_family.product_attributes.size\n end",
"def size\n @components.values.inject(0) { |component_count, attribute| component_count + attribute.size }\n end",
"def count \n puts \"Tu as scrappé #{@result_scrap.count} élémént(s)\"\n return @result_scrap.count\n end",
"def item_count\n return @item_count\n end",
"def value_count\n values.count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n errors.count\n end",
"def errors_count\n @error_rows_codes.count\n end",
"def errors_count\n @error_rows_codes.count\n end",
"def errors_count\n @error_rows_codes.count\n end",
"def collect_values_with_count\n\t\tvalues = Hash.new {|h,k| h[k]=0}\n\t\tself.class.ecore.eAllAttributes.each do |a|\n\t\t\tv = self.send(:\"#{a.name}\")\n\t\t\tif v!=nil\n\t\t\t\tif a.many\n\t\t\t\t\tv.each {|el| values[el]+=1}\n\t\t\t\telse\n\t\t\t\t\tvalues[v]+=1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tvalues\t\t\t\n\tend",
"def count\n items.compact.count.to_d\n end",
"def item_count()\n @names.count\n end",
"def max_uses\n @attributes[:max_uses]\n end",
"def message_count\n\t s = status\n\t\t\ts[:message_count]\n\t end",
"def count\n values.inject(0){|m, v| m + v.length}\n end",
"def error_count\n return @error_count\n end",
"def count\n # implement in subclasses\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n\t\t@input_ary.each_with_index { |line,i|\n\t\t\tif line =~ /^COUNT=([0-9]*)\\s*/\n\t\t\t\t@fileinfo[:count] = $1.to_i \n\t\t\t\tat = i+1\n\t\t\tend\n\t\t}\n\t\traise DTA_ReaderErr, \"Cannot define number of elements!\" unless @fileinfo[:count]\n\t\traise DTA_ReaderErr, \"Error parsing elements count :: #{@input_file}:#{at} :: COUNT=\" + $1.inspect if @fileinfo[:count] == 0\n\tend",
"def count\n @valueset.length\n end",
"def size\n count = 0\n @properties.each do |gid, values|\n if ! values.empty?\n count += 1\n end\n end\n return count\n end",
"def count\n raise NotImplementedError\n end",
"def failed_count\n return @failed_count\n end",
"def tags_count\n self[:tags_count].to_i\n end",
"def tags_count\n self[:tags_count].to_i\n end",
"def not_applicable_count\n return @not_applicable_count\n end",
"def count\n @target.count.to_i\n end",
"def size\n attribute_prop(3)\n end",
"def length\n @count\n end",
"def negative_count\n read_attribute(:negative_count) || taggings.count(:conditions => \"classifier_tagging = 0 AND taggings.strength = 0\")\n end",
"def get_field_count\n\t\tend",
"def item_count\n item_values.values.compact.sum { |v| v.is_a?(Array) ? v.size : 1 }\n end",
"def item_count\n\t\tquery(\"* marked:'quantityText'\", :text)[0]\n\tend",
"def count\n to_a.size\n end",
"def count\n to_a.size\n end",
"def count_escrowed\n return @count_escrowed\n end",
"def count\n @count ||= get_count\n end",
"def number_of_attributes\n\t\treturn self.attributes.size\n\tend",
"def count(scope, attr)\n \"poro_count_#{attr}\"\n end",
"def error_count=(value)\n @error_count = value\n end",
"def count(resource)\n list(resource.to_s,1)[\"meta\"][\"total_count\"]\n end",
"def count(attr = nil)\n if attr.nil?\n super()\n else\n column(attr).count\n end\n end",
"def count_failing\n return self.failing_products.size\n end",
"def count\n to_a.size\n end",
"def count\n @tpl[:cnt]\n end",
"def count\n @count ||= 0\n end",
"def count\n self.CountAmt\n end",
"def count_description\n @count ? \"#{@count} times\" : \"\"\n end",
"def missingmodulecount\n $number_of_missing_modules = @missingmodules.count().to_s\nend",
"def ab_counts(_experiment, _alternative)\n raise \"Not implemented\"\n end",
"def count\n @data.size\n end",
"def count\n Integer(parsed_body['Meta']['TotalCount'] || parsed_body['Meta']['ResultCount'][self.class.count_field])\n end",
"def related_count(type)\n cyc.talk(\"(length (#{type.to_s.gsub(\"_\",\"-\")} #{self.to_cyc}))\").to_i\n end",
"def email_count\n return @email_count\n end",
"def count\n elements.count\n end",
"def count()\n return @i\n end",
"def size_of attr\n real_attr = attribute_for attr\n raise Accessibility::LookupFailure.new(self, attr) unless real_attr\n size_of real_attr, for: @ref\n end",
"def count\n { value: @count, color: \"gray\" }\n end",
"def failure_count(headers)\n if headers.nil? || headers['count'].nil?\n 0\n else\n headers['count']\n end\n end",
"def item_count\n titles.size\n end",
"def item_max\n return @enumeration.length\n end",
"def item_count\n @items.length \n end",
"def badges_count\n badges.count\n end"
] |
[
"0.7390349",
"0.6595475",
"0.65658665",
"0.6517863",
"0.6478921",
"0.6478921",
"0.64198375",
"0.63121897",
"0.630374",
"0.62723786",
"0.61698264",
"0.6154641",
"0.6109414",
"0.60031146",
"0.5980089",
"0.5979875",
"0.5953739",
"0.59236264",
"0.5923555",
"0.59062064",
"0.5887132",
"0.5887132",
"0.5887132",
"0.5866443",
"0.5857256",
"0.5841107",
"0.5835388",
"0.58337885",
"0.5798434",
"0.5794887",
"0.57757753",
"0.57757753",
"0.57757753",
"0.57540303",
"0.5752111",
"0.5752111",
"0.5752111",
"0.57344806",
"0.5726119",
"0.5720476",
"0.5714682",
"0.57144547",
"0.57086444",
"0.5707675",
"0.57055026",
"0.5693389",
"0.5693389",
"0.5693389",
"0.5693389",
"0.5693389",
"0.5693389",
"0.5693389",
"0.5693389",
"0.56767064",
"0.5673722",
"0.5666077",
"0.5665723",
"0.564961",
"0.5649607",
"0.5649607",
"0.56313366",
"0.5630164",
"0.5625258",
"0.5614857",
"0.5609792",
"0.5597146",
"0.5595206",
"0.55921143",
"0.5574941",
"0.5574941",
"0.5564233",
"0.55640566",
"0.55504453",
"0.5540615",
"0.55387",
"0.55368525",
"0.5527377",
"0.5525131",
"0.54988086",
"0.54928464",
"0.5471862",
"0.5465913",
"0.5464208",
"0.54639506",
"0.5461709",
"0.54522705",
"0.54244655",
"0.5415001",
"0.5412688",
"0.5406058",
"0.5403289",
"0.54008305",
"0.53926104",
"0.53923357",
"0.5391494",
"0.5390731",
"0.53901404",
"0.5369877"
] |
0.53897506
|
99
|
Returns the value of attribute entry. source://i18n//lib/i18n/exceptions.rb93
|
def entry; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def value\n raise\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def get_entry(entry); end",
"def get(value)\n if value.kind_of? Details::Attribute\n raise \"Invalid attribute! Must be an attribute named #{self.name}\" if value.name != self.name\n value = value.value\n end\n value.strip! if value.kind_of? String\n @values.find { |v| v.value == value }\n end",
"def get_value\n read_attribute('text_value')\n end",
"def ar_get_resource_value(resource, column)\n return \"Error: #{resource}, #{column}\" unless column && resource\n \n case column\n when String, Symbol\n \n if controller.ardata.foreing_models.include?(column.to_s)\n column.to_s.match(/^(.*)_id$/)\n record= resource.send($1)\n return record ? record.label : controller.ardata.labels[:nil_value_in_field]\n else\n return h(resource.send(column)) || controller.ardata.labels[:nil_value_in_field]\n end\n \n else\n ar_retrieve_field_value column, resource\n end\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def datatables_instance_get_value(instance, column)\n if column[:attribute]\n val = instance.send(column[:attribute].to_sym)\n return I18n.t(val.to_s.to_sym, :default => val.to_s) if not val.nil?\n return ''\n elsif column[:special]\n special = column[:special]\n \n if special[:method]\n return method(special[:method].to_sym).call(instance)\n elsif special[:eval]\n proc = lambda { obj = instance; binding }\n return Kernel.eval(special[:eval], proc.call)\n end\n end\n return \"value not found\"\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def user_get_value(element)\r\n begin\r\n key_processor(element)\r\n ****_get_text(@selector, @locator)\r\n rescue Exception => e\r\n raise e.message\r\n raise e.backtrace.inspect\r\n end\r\n end",
"def __value\n unless defined?(@value)\n __get_value\n end\n\n if @value.is_a?(WrappedException)\n ::Kernel.raise @value\n end\n\n @value\n end",
"def value\n attributes.fetch(:value)\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def exception_variable\n node_parts[1]\n end",
"def value\n raw_value.is_a?(StandardError) ? raise(raw_value) : raw_value\n end",
"def value\n @attributes[:value]\n end",
"def get_value(render_context)\n return @message.translate(render_context)\n end",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def entry\n return @text_entry\n end",
"def vash_value_exception(val,*args)\n name = vash_value_name(val,*args)\n msg = \"invalid value #{val.inspect}\"\n msg += \" at position #{args[0].inspect}\" unless args[0].nil?\n msg += \" for option #{args[1].to_s}\" unless args.length < 2\n [Puppet::Util::PTomulik::Vash::InvalidValueError, msg]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def fetch_attribute(locale, name)\r\n translation = record.translation_for(locale)\r\n return translation && translation.send(name)\r\n end",
"def attr_val(xpath)\n Utilities::attr_val(@entry, xpath)\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n value = nil\n quoted_string29 = nil\n number30 = nil\n\n begin\n # at line 125:35: ( quoted_string | number )\n # at line 125:35: ( quoted_string | number )\n alt_43 = 2\n look_43_0 = @input.peek( 1 )\n\n if ( look_43_0 == QUOTE )\n alt_43 = 1\n elsif ( look_43_0 == DIGIT )\n alt_43 = 2\n else\n raise NoViableAlternative( \"\", 43, 0 )\n end\n case alt_43\n when 1\n # at line 125:37: quoted_string\n @state.following.push( TOKENS_FOLLOWING_quoted_string_IN_attribute_value_1234 )\n quoted_string29 = quoted_string\n @state.following.pop\n # --> action\n value = quoted_string29 \n # <-- action\n\n when 2\n # at line 125:85: number\n @state.following.push( TOKENS_FOLLOWING_number_IN_attribute_value_1240 )\n number30 = number\n @state.following.pop\n # --> action\n value = ( number30 && @input.to_s( number30.start, number30.stop ) ).to_i \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return value\n end",
"def [](attribute)\n messages[attribute.to_sym]\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 business_info_value( attribute )\n return nil if business_info.nil?\n YAML.load(business_info)[attribute]\n end",
"def localized_dynamic_attribute_value(field)\n if field.is_a?(String)\n field = self.content_type.find_field(field)\n end\n\n return nil if field.nil?\n\n value = (self.dynamic_attributes || {})[field.name.to_sym]\n\n # DEBUG puts \"[#{field.name.inspect}] #{value.inspect} / #{field.localized.inspect} / #{value.is_a?(Hash).inspect}\"\n\n if !field.is_relationship? && field.localized && value.is_a?(Hash)\n # get the localized value for the current locale\n _value = value[Locomotive::Mounter.locale]\n\n # no value for the current locale, give a try to the main one\n if _value.nil? && Locomotive::Mounter.locale != self.main_locale\n _value = value[self.main_locale]\n end\n\n value = _value\n end\n\n value # DEBUG .tap { |v| puts \"[#{field.name}] returning #{v.inspect}\" }\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def error_message\n self[:error_message]\n end",
"def _read_attribute(key); end",
"def text\n self.entry\n end",
"def value element_name\n begin\n el_attribute = el element_name\n el_attribute.attribute('value')\n rescue Exception => e\n $LOG.error \"error in getting element value \\n element name : #{element_name} \"+e.message\n raise \"error in getting element value \\n element name : #{element_name} \"+e.message\n end\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def lookup_attribute (attname, workitem)\n\n attname\n end",
"def value\n attributes['FieldValue']\n end",
"def grab(entry, attribute)\n const_attribute = begin\n attribute.camelize.constantize\n rescue NameError\n attribute\n end\n\n case const_attribute\n when Hash\n dup_attribute = const_attribute.dup\n value = dup_attribute.delete(\"value\")\n sprintf value, Hash[dup_attribute.map { |k, v| [k, grab(entry, v)] }].symbolize_keys\n when String\n normalize_ldap_value(entry, attribute)\n when Class, Module\n if const_attribute.respond_to?(:run)\n const_attribute.run(entry)\n else\n normalize_ldap_value(entry, attribute)\n end\n end\n end",
"def get_string(attr); end",
"def field_value(field_name, specification_hash, line)\n field_name = field_name.to_s\n content_ar = line.split('')\n value_str = ''\n if !specification_hash.keys.include? field_name \n raise InvalidAttrName, \"The specified attr name was not found in the specification hash.\"\n else\n range = specification_hash[field_name]\n range.each do |n|\n value_str.concat content_ar[n]\n end\n value_str.strip\n end\n end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def entry\n id_line('ENTRY_NAME')\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n value = nil\n string30 = nil\n number31 = nil\n\n begin\n # at line 152:35: ( string | number )\n # at line 152:35: ( string | number )\n alt_38 = 2\n look_38_0 = @input.peek(1)\n\n if (look_38_0 == T__14)\n alt_38 = 1\n elsif (look_38_0 == EOF || look_38_0 == DIGIT || look_38_0 == T__11 || look_38_0 == T__33)\n alt_38 = 2\n else\n raise NoViableAlternative(\"\", 38, 0)\n end\n case alt_38\n when 1\n # at line 152:37: string\n @state.following.push(TOKENS_FOLLOWING_string_IN_attribute_value_1142)\n string30 = string\n @state.following.pop\n # --> action\n value = (string30 && @input.to_s(string30.start, string30.stop))\n # <-- action\n\n when 2\n # at line 152:71: number\n @state.following.push(TOKENS_FOLLOWING_number_IN_attribute_value_1148)\n number31 = number\n @state.following.pop\n # --> action\n value = (number31 && @input.to_s(number31.start, number31.stop)).to_i\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end\n\n return value\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def val(document, attribute)\n document.public_send(attribute) ||\n raise(\"#{ document.inspect } has no #{ attribute.inspect } value\")\n end",
"def error_message\n @data[\"message\"]\n end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def message\n @error['message']\n end",
"def get_attrib(attrib)\n Attrib.get(attrib, self) rescue nil\n end",
"def get_resource_string(entry_datatype, entry_data)\n result = @stringpool_main.values[entry_data]\n return result\n end",
"def message\n msg = \"Format error found in %s tuple: %s\" % [@identifier, @invalid_data.inspect]\n return msg\n end",
"def get attribute\n attributes[attribute]\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def extended_label\n ext_label.textentry rescue nil\n end",
"def field_value\n if check_version_of(\"mail\", \"> 2.7.0\")\n %w(unparsed_value)\n elsif check_version_of(\"mail\", \"= 2.7.0\")\n %w(instance_variable_get @unparsed_value)\n elsif check_version_of(\"mail\", \"< 2.7.0\")\n %w(instance_variable_get @value)\n end\n end",
"def attribute_value\n @attributes.each { | id, value | return value }\n end",
"def exceptions\n @values['exceptions']\n end",
"def value\n self['value']\n end",
"def get_entry\n raise NotImplementedError\n end",
"def exception_message\n @e_m ||= @exception.nil? ? '' : @exception.message\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def get_attr_value_from_ext_attr( m_name, args )\n \n if self.new_record?\n \n value = nil\n \n self.extended_attributes.each do |extended_attr|\n value = ( extended_attr.value.blank? ? nil : extended_attr.value ) if( extended_attr.attr_name == m_name )\n end\n value\n \n else\n extended_attribute = find_in_extended_attr( m_name )\n extended_attribute.value if extended_attribute\n end\n \n end",
"def text\n getvalue\n end",
"def error_message_for(attribute)\n case attribute\n when :email, :password, :password_confirmation\n @admin_registration.errors[attribute].join(', ')\n else\n raise \"Error messages not implmeneted for \\\"#{attribute}\\\"\"\n end\n end",
"def value\n data[1]\n end",
"def value\n self[@name]\n end",
"def error\n @data['error']\n end",
"def error\n @data['error']\n end",
"def text\n @value[:text].to_s\n end",
"def on(attribute)\n errors[attribute.to_sym]\n end",
"def value_name\n MapEntryType::VALUE_NAME\n end",
"def help_text_for(attribute)\n ::I18n.translate!(attribute[:name], scope: [:alchemy, :resource_help_texts, resource_name])\n rescue ::I18n::MissingTranslationData\n nil\n end",
"def get_attribute(name)\n str = name.to_s\n \n # try fetching an instance variable first\n value = instance_variable_get(\"@#{str}\")\n return value unless value.nil?\n \n # not an instance variable -- try fetching from @metadata\n load_metadata unless @metadata_loaded\n value = @metadata[str]\n return value unless value.nil?\n \n # not in metadata under that name -- is there another variant?\n alternate_name = nil\n self.class.md_key_map.each do |md_name, var_name|\n if str == md_name.to_s\n alternate_name = var_name.to_s\n break\n end\n end\n \n # if we couldn't find anything, return nil\n return nil if alternate_name.nil?\n \n # otherwise, try looking in metadata using the alternate name\n # if this doesn't work, we'll just let the method return nil\n @metadata[alternate_name]\n end",
"def get_value name\n get name\n end",
"def on(attribute)\n attribute = attribute.to_s\n return nil unless @errors.has_key?(attribute)\n errors = @errors[attribute].map(&:to_s)\n errors.size == 1 ? errors.first : errors\n end",
"def get(attribute)\n @attributes[attribute.to_s]\n end",
"def get_char(attr); end",
"def db_value(attribute,code)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n self.eh_params[:db_codes][context][attribute.to_s].key(code)\n end",
"def value(key)\n if self[key].present?\n self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_f\n elsif self[:parameters].present? && self[:parameters][key].present?\n return self[:parameters][key]\n elsif self[:extras].present? && self[:extras][key].present?\n return self[:extras][key]\n else\n return \"\"\n end\n end",
"def rowcell_value(object, item, item_count)\n this_value = object.this_value(item[:code], item[:lookup], item[:format],\n item[:placeholder])\n if item_count == 1 || item[:label] == false\n this_value\n else\n \"#{object.this_label(item[:code], item[:action_name], item[:label])} : #{this_value}\"\n end\n end",
"def rule_get_value(ref)\n if val = rule_table.get_value(self, setup_package_id(ref))\n return val\n else\n (raise UnboundError.new(ref))\n end\n end",
"def value\r\n \tbase_value = read_attribute('value')\r\n \t#\r\n \tif ! base_value.nil?\r\n \treturn YAML::load(base_value)\r\n end\r\n return nil\r\n\tend",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def read_attribute(key)\n @hash[key.to_s]\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def read_entry(key, options) # :nodoc:\n entry = with { |c| c.get(key, options) }\n # NB Backwards data compatibility, to be removed at some point\n entry.is_a?(ActiveSupport::Cache::Entry) ? entry.value : entry\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n nil\n end",
"def read_value(key)\n keys = key.split('.')\n result = @context\n keys.each do |k|\n return nil unless result\n result = result[k]\n end\n return result\n end",
"def attribute_value_for(resource, attribute_name, truncation = 50)\n value = resource.send(attribute_name).to_s.truncate(truncation)\n if attribute_name.to_s.match(/_id$/)\n model_name = attribute_name.gsub(/_id$/, '').classify\n begin\n value = eval(model_name).find(value).to_s\n rescue ActiveRecord::RecordNotFound\n value = \"\"\n end\n end\n value\n end",
"def value\n $stderr.puts \"WARNING, you probably don't want to read value, if you do, please use #raw_value. Called from: #{caller.first}\"\n raw_value\n end",
"def getText\n return getProperty('text').to_s\n end",
"def model_exception(e, a_label)\n\t puts e #DEBUG - ERRORS\n\t\tputs clean_backtrace(e) #DEBUG - ERRORS\n\t\ta_label.setStringValue(\"Database Error: \" + e.to_s) unless a_label.nil?\n\tend",
"def attribute attr\n @ref.attribute(TRANSLATOR.cocoaify(attr)).to_ruby\n end"
] |
[
"0.5892803",
"0.5808762",
"0.5786461",
"0.57092917",
"0.56783736",
"0.5650231",
"0.56321627",
"0.56321627",
"0.56076485",
"0.5597559",
"0.5581199",
"0.55504876",
"0.5535299",
"0.55233335",
"0.55131596",
"0.549386",
"0.54874265",
"0.54667634",
"0.5452716",
"0.54484504",
"0.5433506",
"0.5390597",
"0.538968",
"0.53845274",
"0.5377974",
"0.5368284",
"0.5361602",
"0.5331172",
"0.5312181",
"0.5307352",
"0.5299803",
"0.5292144",
"0.52905107",
"0.5274907",
"0.52695024",
"0.52647024",
"0.52590567",
"0.52558345",
"0.5251489",
"0.5249157",
"0.52433425",
"0.52422184",
"0.5241321",
"0.5231743",
"0.5224646",
"0.52204114",
"0.5219188",
"0.5218103",
"0.5208255",
"0.52026075",
"0.518331",
"0.5163346",
"0.5155573",
"0.51536417",
"0.51395935",
"0.5134652",
"0.51281154",
"0.5127152",
"0.51192856",
"0.5115303",
"0.5113262",
"0.5110327",
"0.5108318",
"0.5108318",
"0.5108076",
"0.5108076",
"0.5097164",
"0.5095114",
"0.50945055",
"0.50912005",
"0.5087731",
"0.507656",
"0.5071977",
"0.50677586",
"0.50677586",
"0.50674856",
"0.5058368",
"0.5056323",
"0.50498337",
"0.504707",
"0.5018151",
"0.50069416",
"0.5005952",
"0.5005215",
"0.5005059",
"0.49959266",
"0.49914807",
"0.4990213",
"0.49901345",
"0.49869633",
"0.49869633",
"0.49869633",
"0.4984278",
"0.49836284",
"0.49807474",
"0.4968838",
"0.49669555",
"0.4961892",
"0.49584666",
"0.49582687",
"0.49569038"
] |
0.0
|
-1
|
Returns the value of attribute key. source://i18n//lib/i18n/exceptions.rb93
|
def key; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key\n attributes['key'] or raise NoKeySpecified\n end",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"def _read_attribute(key); end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def read_attribute(key)\n @hash[key.to_s]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def read_attribute(key)\n @attributes[key.to_sym]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def [](key_name)\n read_attribute(key_name)\n rescue MissingAttribute\n nil\n end",
"def translate_property_value(key)\n return resource_translation_matrix.fetch(key) if resource_translation_matrix &&\n resource_translation_matrix.key?(key)\n\n key.to_s\n end",
"def [](key_)\n @attributes[key_.to_s]\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def [](key)\n @attributes.get(key)\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def key\n attributes[:key]\n end",
"def error_key\n self.class.error_key\n end",
"def get_value(key)\n self[key]\n end",
"def value_for_key(key)\n if respond_to?(key)\n send key\n elsif attributes.include? key\n attributes[key]\n else\n row.send key\n end\n end",
"def key\n @attributes[:key]\n end",
"def key\n @attributes[:key]\n end",
"def [](key)\n @attributes[key]\n end",
"def key\n @key or raise MissingKey\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n element=@xml.xpath(key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n element=@xml.elements[key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def get_attribute(dict_name, key, default_value = nil)\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def value(key)\n if self[key].present?\n self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_f\n elsif self[:parameters].present? && self[:parameters][key].present?\n return self[:parameters][key]\n elsif self[:extras].present? && self[:extras][key].present?\n return self[:extras][key]\n else\n return \"\"\n end\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def translate_property_key(value)\n return resource_translation_matrix.key(value) if resource_translation_matrix &&\n resource_translation_matrix.value?(value)\n\n value.to_s\n end",
"def [](k)\n raise \"key #{k} should be symbol but #{k.class}\" unless k.is_a?(Symbol)\n return @attributes[k]\n end",
"def get_property(key)\n @data[key]\n end",
"def [](key)\n @attrs[key]\n end",
"def [](key)\n @attrs[key]\n end",
"def [](attr_key)\n @attributes[attr_key.to_sym]\n end",
"def [](key)\n @attributes = Array.new if @attributes.nil?\n attributes_downcase =@attributes.map(&:downcase)\n key.downcase!\n if attributes_downcase.include? key\n return get(key)\n else\n raise 'El atributo no ha sido encontrado en el objecto '+ key\n end\nend",
"def []( key )\n _meta_data[key.to_s]\n end",
"def read_value(key)\n keys = key.split('.')\n result = @context\n keys.each do |k|\n return nil unless result\n result = result[k]\n end\n return result\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def field(key)\n pdf_field(key).getValueAsString\n rescue NoMethodError\n raise \"unknown key name `#{key}'\"\n end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def [](key)\n a = @attrs_hash[key.intern]\n if a\n a.value\n else\n nil\n end\n end",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def read_key(key)\n raise RuntimeError.new(\"read_key not implemented!\")\n end",
"def get(key)\n \n end",
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def [](key)\n data[key.to_s]\n end",
"def value_for(resource)\n resource.send(key)\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def [](key)\n @entry[key] || @entry[key.to_s.upcase]\n end",
"def getKey; argSetTextual.to_sym end",
"def value_for(key)\n return '' unless self.param_values && self.param_values[key]\n self.param_values[key]\n end",
"def get_attribute(attribute)\n\t\t@attributes[attribute.intern]\n\tend",
"def [](attribute_name)\n @attributes[@current_language][attribute_name.to_sym] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n end",
"def [](key); self.properties[key.to_s]; end",
"def method_name key\n \"value_for_#{key}\"\n end",
"def ensure_attribute(root_element, key, type = nil, prefix = nil)\n value = get_attribute(root_element, key, type, prefix)\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"Attribute '#{label}' is missing\" if value.nil?\n value\n end",
"def [](key)\n @data[key.to_s]\n end",
"def []( key )\n\t\tself.validate unless self.validated?\n\t\treturn @valid[ key.to_sym ]\n\tend",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def [](attr_name)\n attr_name = attr_name.to_sym\n unless @attributes.key?(attr_name)\n raise NameError, \"undefined attribute #{attr_name.inspect}\"\n end\n @attributes[attr_name]\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def dynamo_attribute_key\n @attr.dynamo_name\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def t(key)\n I18n.translate(key).html_safe\n end",
"def get(key)\n messages[key]\n end",
"def get(key)\n messages[key]\n end",
"def db_value(attribute,code)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n self.eh_params[:db_codes][context][attribute.to_s].key(code)\n end",
"def attr_get(key)\n key_count = 0\n @attrkeys.each do |attrkey|\n if(attrkey == key)\n @attrvals[key_count]\n end\n key_count = key_count + 1\n end\n nil\n end",
"def get_string(attr); end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def [] key\n @attributes[key.to_s]\n end",
"def human_attribute_name(attribute_key_name, options = {})\n defaults = self_and_descendants_from_active_resource.map do |klass|\n :\"#{klass.name.underscore}.#{attribute_key_name}\"\n end\n defaults << options[:default] if options[:default]\n defaults.flatten!\n defaults << attribute_key_name.to_s.humanize\n options[:count] ||= 1\n I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activeresource, :attributes]))\n end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def liner_get(key)\n key = key.to_sym\n with_valid_attribute(key) do\n instance_variable_get \"@#{key}\"\n end\n end",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key)\n @attrs[key].present? ? @attrs[key] : nil\n end",
"def get_item_value(key)\n @attributes[key] = get_item_record(key) unless @attributes.has_key?(key)\n @attributes[key]\n end",
"def const_missing (name)\n _, f, k = /(.+?)_(.+)$/.match(name.to_s).to_a\n if _ and instance_methods(false).include? \"enum_field_for_#{f.downcase}\"\n if key_value = send(\"#{f.downcase}_values\").select{|x| x[1].to_s.gsub(/[^\\w_]/, \"_\") == \"#{k.downcase}\"}.first\n return key_value[1]\n end\n end\n super\n end",
"def [](key)\n send(\"#{key}\") rescue nil\n end",
"def [](key)\n return nil unless key\n @data[key.to_s] || @data[key.to_sym]\n end",
"def [] key\n\t\t\t\t@attributes[key]\n\t\t\tend",
"def get_hash_value(hash, key, attribute)\n hash[key][attribute]\n end",
"def error_message\n self[:error_message]\n end"
] |
[
"0.6568146",
"0.65384245",
"0.6519964",
"0.6504203",
"0.6498144",
"0.6497692",
"0.64802617",
"0.6449955",
"0.63199526",
"0.63199526",
"0.6286971",
"0.61781454",
"0.61704075",
"0.61315423",
"0.6129793",
"0.6129793",
"0.61205995",
"0.6113616",
"0.60509425",
"0.5977679",
"0.5977679",
"0.5977679",
"0.59705853",
"0.5970326",
"0.5957984",
"0.5946846",
"0.59276557",
"0.59276557",
"0.59255534",
"0.58916444",
"0.58903325",
"0.58308464",
"0.58296525",
"0.58057326",
"0.57918984",
"0.57771796",
"0.57751346",
"0.5750001",
"0.5730157",
"0.5716605",
"0.5716605",
"0.57086605",
"0.5696256",
"0.5693953",
"0.5659382",
"0.56591034",
"0.56591034",
"0.5650402",
"0.56459045",
"0.5642937",
"0.56407255",
"0.56302",
"0.5622465",
"0.55989707",
"0.5595133",
"0.55838275",
"0.55838275",
"0.55627185",
"0.55591375",
"0.5555232",
"0.5551014",
"0.5549714",
"0.55469364",
"0.5546767",
"0.55451304",
"0.5544277",
"0.5542119",
"0.5531074",
"0.55254513",
"0.552287",
"0.5521586",
"0.55114836",
"0.5510714",
"0.5508559",
"0.5507102",
"0.5506131",
"0.55045277",
"0.5497578",
"0.54962045",
"0.54962045",
"0.54886997",
"0.5486922",
"0.5486719",
"0.5484907",
"0.5468695",
"0.5462394",
"0.5458131",
"0.5457464",
"0.54522616",
"0.5451862",
"0.5451862",
"0.5451862",
"0.5451862",
"0.54501426",
"0.54501367",
"0.5447958",
"0.5444587",
"0.54433924",
"0.5443174",
"0.5441467",
"0.54413784"
] |
0.0
|
-1
|
Returns the value of attribute defaults. source://i18n//lib/i18n/locale/fallbacks.rb58
|
def defaults; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_value\n self['default']\n end",
"def fallback_to_default(localization_key, localization)\n localization_key.localizations.where.not(default_value: nil). \\\n where.not(id: localization.id).first&.default_value\n end",
"def default_value\n match = if definition =~ /timestamp|datetime/i\n /default '?(.+[^'])'?/i.match(definition)\n else\n /default '?(\\w+)'?/i.match(definition)\n end\n\n return unless match\n\n match[1].downcase != 'null' ? match[1] : nil\n end",
"def default\n attributes.default\n end",
"def defaults\n @defaults\n end",
"def default_value\n config[:default]\n end",
"def defaults\n @ordered_elements.select{|s| s.default?}\n end",
"def default_value\n return unless default?\n\n node_parts[1]\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def default\n self['default']\n end",
"def default_value(name)\n @@default_value[name]\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def default_value\n { 'value' => '', 'other' => '' }\n end",
"def default_values\n # Convert the symbols for the available locales to strings, to be able to compare with the user locale\n # NOTE.- don't do the opposite (converting the user locale to a symbol before checking if it's included in the\n # array of available locales) because memory allocated for symbols is never released by ruby, which means an\n # attacker could cause a memory leak by creating users with weird unavailable locales.\n available_locales = I18n.available_locales.map {|l| l.to_s}\n if !available_locales.include? self.locale\n Rails.logger.info \"User #{self.email} has unsupported locale #{self.locale}. Defaulting to locale 'en' instead\"\n self.locale = 'en'\n end\n\n timezone_names = ActiveSupport::TimeZone.all.map{|tz| tz.name}\n if !timezone_names.include? self.timezone\n Rails.logger.info \"User #{self.email} has unsupported timezone #{self.timezone}. Defaulting to timezone 'UTC' instead\"\n self.timezone = 'UTC'\n end\n\n if self.admin == nil\n Rails.logger.info \"User #{self.email} has unsupported admin #{self.admin}. Defaulting to admin 'false' instead\"\n self.admin = false\n end\n\n if self.quick_reading == nil\n Rails.logger.info \"User #{self.email} has unsupported quick_reading #{self.quick_reading}. Defaulting to quick_reading 'false' instead\"\n self.quick_reading = false\n end\n\n if self.open_all_entries == nil\n Rails.logger.info \"User #{self.email} has unsupported open_all_entries #{self.open_all_entries}. Defaulting to open_all_entries 'false' instead\"\n self.open_all_entries = false\n end\n\n if self.show_main_tour == nil\n Rails.logger.info \"User #{self.email} has unsupported show_main_tour #{self.show_main_tour}. Defaulting to show_main_tour 'true' instead\"\n self.show_main_tour = true\n end\n\n if self.show_mobile_tour == nil\n Rails.logger.info \"User #{self.email} has unsupported show_mobile_tour #{self.show_mobile_tour}. Defaulting to show_mobile_tour 'true' instead\"\n self.show_mobile_tour = true\n end\n\n if self.show_feed_tour == nil\n Rails.logger.info \"User #{self.email} has unsupported show_feed_tour #{self.show_feed_tour}. Defaulting to show_feed_tour 'true' instead\"\n self.show_feed_tour = true\n end\n\n if self.show_entry_tour == nil\n Rails.logger.info \"User #{self.email} has unsupported show_entry_tour #{self.show_entry_tour}. Defaulting to show_entry_tour 'true' instead\"\n self.show_entry_tour = true\n end\n\n if self.show_kb_shortcuts_tour == nil\n Rails.logger.info \"User #{self.email} has unsupported show_kb_shortcuts_tour #{self.show_kb_shortcuts_tour}. Defaulting to show_entry_tour 'true' instead\"\n self.show_kb_shortcuts_tour = true\n end\n\n if self.name.blank?\n Rails.logger.info \"User #{self.email} has no name set. Using the email by default.\"\n self.name = self.email\n end\n\n if self.subscriptions_updated_at == nil\n Rails.logger.info \"User #{self.email} has unsupported subscriptions_updated_at value, using current datetime by default\"\n self.subscriptions_updated_at = Time.zone.now\n end\n\n if self.folders_updated_at == nil\n Rails.logger.info \"User #{self.email} has unsupported folders_updated_at value, using current datetime by default\"\n self.folders_updated_at = Time.zone.now\n end\n\n if self.refresh_feed_jobs_updated_at == nil\n Rails.logger.info \"User #{self.email} has unsupported refresh_feed_jobs_updated_at value, using current datetime by default\"\n self.refresh_feed_jobs_updated_at = Time.zone.now\n end\n\n if self.subscribe_jobs_updated_at == nil\n Rails.logger.info \"User #{self.email} has unsupported subscribe_jobs_updated_at value, using current datetime by default\"\n self.subscribe_jobs_updated_at = Time.zone.now\n end\n\n if self.config_updated_at == nil\n Rails.logger.info \"User #{self.email} has unsupported config_updated_at value, using current datetime by default\"\n self.config_updated_at = Time.zone.now\n end\n\n if self.user_data_updated_at == nil\n Rails.logger.info \"User #{self.email} has unsupported user_data_updated_at value, using current datetime by default\"\n self.user_data_updated_at = Time.zone.now\n end\n\n if self.first_confirmation_reminder_sent == nil\n Rails.logger.info \"User #{self.email} has unsupported first_confirmation_reminder_sent #{self.first_confirmation_reminder_sent}. Defaulting to 'false' instead\"\n self.first_confirmation_reminder_sent = false\n end\n\n if self.second_confirmation_reminder_sent == nil\n Rails.logger.info \"User #{self.email} has unsupported second_confirmation_reminder_sent #{self.second_confirmation_reminder_sent}. Defaulting to 'false' instead\"\n self.second_confirmation_reminder_sent = false\n end\n\n if self.kb_shortcuts_enabled == nil\n Rails.logger.info \"User #{self.email} has unsupported kb_shortcuts_enabled #{self.kb_shortcuts_enabled}. Defaulting to 'true' instead\"\n self.kb_shortcuts_enabled = true\n end\n\n return true\n end",
"def default_value\n return @default_value\n end",
"def fallbacks\n @fallbacks ||= {}\n end",
"def default(values, default_value)\n if values.present?\n values\n else\n default_value\n end\n end",
"def default_values\n @default_values || {}\n end",
"def default_value(attr)\n\t\t\t@defaults ||= {}\n\t\t\t@defaults[attr.to_sym]\n\t\tend",
"def default_value\n # generally, elements contain string (except containers)\n ''\n end",
"def default_value\n default_db_value ? default_db_value.to_s : \"null\"\n end",
"def get_default_value\n raise 'get_default_value must be implemented'\n end",
"def default_attributes\n cfg_get(:default_attributes)\n end",
"def default_value\n @value || recommended_value\n end",
"def default_value\n @value || recommended_value\n end",
"def languagefallback()\n merge(languagefallback: 'true')\n end",
"def default_values\n {name: \"default\", index: -1, experiment_id: nil}\n end",
"def default_value\n return @default_value if @default_value\n\n superclass.default_value if superclass.respond_to?(:default_value)\n end",
"def field_defaults\r\n return @field_defaults\r\n end",
"def default(key)\n @defaults[key]\n end",
"def defaults\n self.class.defaults #.merge(@defaults || {})\n end",
"def calculate_defaults\n # see http://www.ruby-forum.com/topic/185611#811055 for the source of\n # this obtuseness (basically, I wanted Hash.map, but it didn't work)\n opts_with_defaults = @options.select {|_, opt| opt.should_have_default_value? }\n opts_with_defaults.merge(opts_with_defaults) {|_, opt, _| opt.default_value }\n end",
"def supports_default_values?\n true\n end",
"def default_attributes\n cfg_get(:default_attributes)\n end",
"def defaults\n defaults = self[:defaults] || {}\n return defaults if defaults.any?\n options.fetch 'defaults', {}\n end",
"def default_or_inferred_for(key_name)\n @defaults[key_name] || send(\"default_value_for_#{key_name}\") || \\\n raise(\"No default value for: #{key_name}\")\n end",
"def default\n defaults = {}\n @rules.each {|rule| rule.complete_defaults(defaults)}\n defaults\n end",
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def get_defaults( name )\n @defaults[ name ] || {}\n end",
"def extract_value_from_default(default)\n super ||\n extract_escaped_string_from_default(default) ||\n extract_time_from_default(default) ||\n extract_empty_array_from_default(default) ||\n extract_decimal_from_default(default)\n end",
"def default_value\n self[:value] ||= {}\n self[:value][:default_value] ||= ''\n self[:value][:default_value].to_f unless self[:value][:default_value].empty?\n end",
"def default_value(value); value; end",
"def fallback\n @@fallback\n end",
"def defaults(id)\n @@defaults[id]\n end",
"def defaults\n self.class.defaults\n end",
"def defaults(arg=nil)\n arg.nil? ? @defaults : (@defaults = arg)\n end",
"def locale_defaults\n if by_subdomain?\n defaults.merge(subdomain: locale.to_s)\n else\n defaults.merge(locale: locale.to_s)\n end\n end",
"def default_accessor_locales\n if @default_accessor_locales.is_a?(Proc)\n @default_accessor_locales.call\n else\n @default_accessor_locales\n end\n end",
"def defaults(defaults = T.unsafe(nil)); end",
"def default\n return @default\n end",
"def configured_default\n @options[:default] || default_entry\n end",
"def default_values\n if self.new_record?\n self.email_at_notices ||= Errbit::Config.email_at_notices\n end\n end",
"def defaults_str\n \"\"\n end",
"def get_locales(defaults=[])\n if self.available_locales.present?\n self.available_locales\n else\n defaults\n end\n end",
"def default_value\n @default_value ||= (value_hash[{}] ||= Value.new(self, labels: labels))\n end",
"def set_defaults\n \tdefault_language = lexeme.try(:language) || Language.new\n \n \tself.language ||= default_language\n\tend",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def default_value_if_blank(value, default)\n # Stolen from: http://api.rubyonrails.org/classes/Object.html#method-i-blank-3F\n empty = value.respond_to?(:empty?) ? !!value.empty? : !value\n if empty\n return default\n else\n return value\n end\n end",
"def default_for(entry)\n enumerations.dig(entry.to_sym, :default)\n end",
"def default_locale; end",
"def default_language\n languages.find_by(default: true)\n end",
"def default_value\n if @default_value\n @default_value\n elsif @multiple\n []\n end\n end",
"def default\n d = opts[ :default ]\n d = type_default if d.nil? && ! allow_null\n d\n end",
"def default_value \n self[:value] ||= {}\n self[:value][:default_value] ||= []\n self[:value][:default_value].delete('-1')\n self[:value][:default_value]\n end",
"def default_attrs\n @default_attrs\n end",
"def fallback_data\n @fallback_data ||= {}\n end",
"def default?\n defaults.any?\n end",
"def fallback_locales=(value)\n @fallback_locales = Array(value).map { |l| Nii::Locale.parse(l) }\n @fallback_context = nil\n end",
"def assign_defaults!(attrs, defaults)\n defaults.each do |key, value|\n key = key.to_s\n\n if attrs[key].nil?\n attrs[key] = value\n end\n end\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def default\n #----------\n \n # the default field value; retrieve from the options\n default = options[ :default ]\n \n # is there are default value?\n unless default.nil?\n self.value_from( default.respond_to?( :call ) ? default.call : default )\n end\n \n end",
"def locale_fallback?\n evaluate_localization_option!(:fallback)\n end",
"def defaults\n parse({})\n end",
"def defaults_definition\n return @defaults if @defaults\n\n @defaults = ancestors_with(Default)\n .inject(Definition.empty) do |acc, elem|\n acc.merge(elem.module_defaults_definition)\n end\n end",
"def default\n options[:default]\n end",
"def default_values\n self.priority ||= 0\n rescue ActiveModel::MissingAttributeError\n # This can be safely ignored: error is thrown only when NavItem.exists?() is called, because the\n # priority field isn't fetched\n end",
"def default_values\n h = {}\n template.parameters.each do |p|\n h[p.name] = h.default\n end\n h\n end",
"def default(value)\n CommonsInstitutions.defaults[value.to_s.to_sym]\n end",
"def default_language\n @default_language || :en\n end",
"def default\n @default\n end",
"def fallbacks=(fallbacks); end",
"def preferred_locales\n read_attribute(\"preferred_locales\").map(&:to_sym)\n end",
"def default_text(default)\n case default\n when Symbol\n I18n.t(default, scope: :default_content_texts)\n else\n default\n end\n end",
"def is_default\n data[:is_default]\n end",
"def extract_value_from_default(default)\n case default\n # Quoted types\n when /\\A[\\(B]?'(.*)'.*::\"?([\\w. ]+)\"?(?:\\[\\])?\\z/m\n # The default 'now'::date is CURRENT_DATE\n if $1 == \"now\" && $2 == \"date\"\n nil\n else\n $1.gsub(\"''\", \"'\")\n end\n # Boolean types\n when 'true', 'false'\n default\n # Numeric types\n when /\\A\\(?(-?\\d+(\\.\\d*)?)\\)?(::bigint)?\\z/\n $1\n # Object identifier types\n when /\\A-?\\d+\\z/\n $1\n else\n # Anything else is blank, some user type, or some function\n # and we can't know the value of that, so return nil.\n nil\n end\n end",
"def default_values\n @parse[:gaston] || {}\n end",
"def default_attribute_values\n # GUID defaults to the url attribute\n self.guid = self.url if self.guid.blank?\n\n # title defaults to the url attribute\n self.title = self.url if self.title.blank?\n\n # if the url attr is not actually a valid URL but the guid is, url attr takes the value of the guid attr\n if !(UrlValidator.valid_entry_url?(self.url)) && UrlValidator.valid_entry_url?(self.guid)\n self.url = self.guid\n # If the url was blank before but now has taken the value of the guid, default the title to this value\n self.title = self.url if self.title.blank?\n end\n\n # published defaults to the current datetime\n self.published = Time.zone.now if self.published.blank?\n end",
"def default_locale\n AppConfig.default_locale\n end",
"def default_error_message\n default_error_message_key = \"error.#{schema_key}\"\n default_message = Rails\n .application\n .config\n .default_metadata[default_error_message_key]\n\n if default_message.present?\n default_message['value'] % error_message_hash\n else\n raise NoDefaultMessage, \"No default message found for key '#{default_error_message_key}'.\"\n end\n end",
"def default_value_expression\n @gapi.default_value_expression\n end",
"def default_values\n self.subtype ||= \"registered\"\n self.status ||= \"NEW\"\n end"
] |
[
"0.6742151",
"0.66488904",
"0.6500617",
"0.63341075",
"0.6249136",
"0.61659443",
"0.61448073",
"0.61326814",
"0.6073066",
"0.60408926",
"0.60327405",
"0.6030849",
"0.60234493",
"0.6019798",
"0.60092217",
"0.6008043",
"0.59888434",
"0.5984335",
"0.59819263",
"0.59415054",
"0.59283173",
"0.59185916",
"0.59170175",
"0.5913036",
"0.5913036",
"0.5894057",
"0.5883539",
"0.5878144",
"0.58735377",
"0.58577365",
"0.5857679",
"0.58565146",
"0.5850776",
"0.5840045",
"0.5838451",
"0.583556",
"0.5830701",
"0.58282787",
"0.58210117",
"0.5804197",
"0.5795618",
"0.57938075",
"0.5791302",
"0.578269",
"0.5780613",
"0.57789624",
"0.57775736",
"0.57621706",
"0.57516456",
"0.5744402",
"0.57436734",
"0.5740831",
"0.5735279",
"0.5731253",
"0.5730964",
"0.5720351",
"0.5718206",
"0.571762",
"0.57141256",
"0.5708921",
"0.5708883",
"0.5707102",
"0.57036537",
"0.57019573",
"0.57017523",
"0.56883776",
"0.56843203",
"0.56821364",
"0.5672781",
"0.5652963",
"0.56513166",
"0.56484926",
"0.5646258",
"0.56367445",
"0.5633206",
"0.56258476",
"0.56176466",
"0.56170774",
"0.56125224",
"0.5612487",
"0.5604862",
"0.5596421",
"0.55929494",
"0.55890393",
"0.55883425",
"0.5580604",
"0.5573139",
"0.557025",
"0.55662185",
"0.5565804",
"0.55639863"
] |
0.56252855
|
84
|
Sets the current locale tag implementation. Use this to set a different locale tag implementation. source://i18n//lib/i18n/locale/tag.rb17
|
def implementation=(implementation); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_tag(tag, value, span=nil)\n raise NotImplementedError\n end",
"def language_tag=(value)\n @language_tag = value\n end",
"def tag_text=(value)\n self.tag=(value)\n end",
"def tag=(tag)\n @tag = tag\n @tls_id ||= \"tag_logger_#{self.object_id}\"\n Thread.current[@tls_id] = @tag\n end",
"def tag_set(p_tag_sym, p_val) tag.send(\"#{p_tag_sym.to_s}=\", p_val) end",
"def langtag(locale)\n\t\tcase locale.to_s\n\t\twhen 'se' then 'se'\n\t\twhen 'us' then 'en'\n\t\twhen 'uk' then 'en'\n\t\twhen 'cn' then 'zh'\n\t\telse locale\n\t\tend\n\tend",
"def set_tag(tag, *values)\n tag.upcase!\n @selected_files.each { |file| file.set_values(tag, *values) }\n self\n end",
"def tag=(value)\n # Normalize\n super(Tag.normalize(value))\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def locale=(locale); end",
"def set_tag(key, value)\n tags[key] = value.to_s\n self\n end",
"def set_tag(key, value)\n tags[key] = value.to_s\n self\n end",
"def locale=(locale)\n Thread.current[:locale] = locale.to_s\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value)\n @locale = value\n end",
"def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end",
"def default_locale=(locale); end",
"def tag(tag)\n @tagname = tag\n end",
"def set_TagMode(value)\n set_input(\"TagMode\", value)\n end",
"def set_TagMode(value)\n set_input(\"TagMode\", value)\n end",
"def locale=(value); end",
"def set_locale\n end",
"def tag tag = nil\n @tag = tag if tag\n @tag\n end",
"def language=(value)\n raise InvalidComponentError, \"Primary subtag cannot be omitted.\" unless value\n sequence = value.to_str\n if LANGUAGE_REGEX !~ sequence\n raise InvalidComponentError,\n \"#{value.inspect} does not conform to the 'language' ABNF \" \\\n \"or to the associated rules.\"\n end\n @language = sequence\n @primary = nil\n @extlang = nil\n dirty\n validate\n end",
"def locale=(locale)\r\n write_attribute(:locale, locale.to_s)\r\n end",
"def tag=(value)\n @children['tag'][:value] = value\n end",
"def set_tag(key, value)\n sanitized_value = valid_tag_value?(value) ? value : value.to_s\n @tags = @tags.merge(key.to_s => sanitized_value)\n end",
"def tag=(value)\n @tag = value\n self.status = TAG_STATUS.fetch(value)\n @tag\n end",
"def tag(arg)\n @tag = arg.to_s\n self\n end",
"def setLocale(locale)\n @fields['locale'] = locale\n self\n end",
"def setLocale(locale)\n @fields['locale'] = locale\n self\n end",
"def tag= tag\n @tag = tag\n update!\n end",
"def set_locale\n I18n.locale = extract_locale_from_tld\n end",
"def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end",
"def set_tag\n @tag = if current_manager\n Tag.find_by!(id: params[:id], organization_id: current_manager.organization_id)\n else\n Tag.find(params[:id])\n end\n end",
"def type_of_tag=(new_type_of_tag)\n super new_type_of_tag.to_s\n end",
"def type_of_tag=(new_type_of_tag)\n super new_type_of_tag.to_s\n end",
"def set_language\n @lecture.update(locale: I18n.default_locale.to_s)\n end",
"def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end",
"def tag_name=(tag_name)\n self.tag = Tag.find_by_name!(tag_name)\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end",
"def set_tag\n @tag = ActsAsTaggableOn::Tag.find(params[:id])\n end",
"def set_tag\n @tag = ActsAsTaggableOn::Tag.find(params[:id])\n end",
"def locale=(value)\n if value == @defaults['ai.device.locale']\n @values.delete 'ai.device.locale' if @values.key? 'ai.device.locale'\n else\n @values['ai.device.locale'] = value\n end\n end",
"def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def replace_using(tag, string)\n Tags[tag][1] = string\n end",
"def set_engine_tag\n @engine_tag = EngineTag.find(params[:id])\n end",
"def set_locale\n I18n.select_locale( params[:locale], session[:locale], I18n.from_http_header(request) )\n logger.info \"Using language: #{I18n.locale}\"\n session[:locale] = I18n.locale\n end",
"def locale=(locale)\n @@default_locale = locale\n end",
"def set_tag_value(tag_path, tag_value, is_size_updated = false)\n\n $test_logger.log(\"Set tag value #{tag_path}, #{tag_value}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.root.elements[tag_path]\n\n #Raise exception if no tag is found\n raise \"XML path '#{tag_path}' not found!\" if !target_tag\n\n #Assign specified value to XML tag\n target_tag.text = tag_value\n\n if is_size_updated\n attr_obj = target_tag.attributes.get_attribute(SIZE_ATTR)\n target_tag.attributes.delete(attr_obj)\n end\n\n #Notify changes to load other formats like RAW and HEX\n notify_change(InputChannel::XML)\n end",
"def set_locale(locale = nil)\n current_user_language = current_user ? current_user.language : nil\n tlc = locale || current_user_language # || 'en'\n #logger.debug \"\\n===> #{tlc}\\n\"\n I18n.locale = tlc\n end",
"def product_tags=(values)\n self.tag_list = values\n end",
"def set_tag_for_search(tag)\n @page.all(input_elements[:entries])\n @page.find(input_elements[:tag_filter_field]).set(tag)\n @page.find(input_elements[:tag_selected]).click\n @used_tag = tag\n end",
"def tag( val = nil )\n default :tag, val\n end",
"def set_locale_meta_tags\n set_meta_tags(og: {locale: t('locale.short-code', default: 'en_US')} )\n # @todo When we support multiple locales, pull them in below\n #alternate: { \"fr\" => \"http://yoursite.fr/alternate/url\",\n # \"de\" => \"http://yoursite.de/alternate/url\" }\n end",
"def tag=( val )\n header[:tag] = val\n end",
"def set_locale\n # Get the current path and request method (useful in the layout for changing the language)\n @current_path = request.env['PATH_INFO']\n @request_method = request.env['REQUEST_METHOD']\n\n # Try to get the locale from the parameters, from the session, and then from the navigator\n if params[:user_locale]\n # Store the locale in the session\n Locale.code = params[:user_locale][:code]\n session[:locale] = Locale.code\n elsif session[:locale]\n Locale.code = session[:locale]\n else\n Locale.code = local_case(get_valid_lang_from_accept_header)\n end\n\n logger.debug \"[globalite] Locale set to #{Locale.code}\"\n # render the page\n yield\n\n # reset the locale to its default value\n Locale.reset!\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end",
"def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_locale\n I18n.locale = params[:locale]\n end",
"def set_tag\n @tag = current_user.tags.find(params[:id])\n end",
"def set_locale\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\tLOG.debug(fname) {\">>>>\"}\n\t\t#puts \"set_locale:params[:locale]=#{params[:locale]}\"\n\t\tif params[:locale]\n\t\t\tI18n.locale = params[:locale]\n\t\t\tsession[:lng] = I18n.locale\n\t\telse\n\t\t\tunless @current_user.nil?\n\t\t\t\t#puts \"set_locale:@current_user=#{@current_user} lng=#{@current_user.language}\"\n\t\t\t\tI18n.locale = @current_user.language\n\t\t\telse\n\t\t\t\tif session[:lng]\n\t\t\t\t\tI18n.locale = session[:lng]\n\t\t\t\telse\n\t\t\t\t\tI18n.locale = PlmServices.get_property(:LOCAL_DEFAULT)\n\t\t\t\t\tsession[:lng] = I18n.locale\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tLOG.debug(fname) {\"<<<<session=#{session}\"}\n\tend",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def update_tag_attribute(content, tag_name, attr_name, init_val); end",
"def set_current_language(lang)\n GetText.locale, prev_value = sanitize_lang(lang), GetText.locale\n prev_value\n end",
"def use_i18n=(value); end",
"def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end",
"def set_tags(tags)\n @tags.update(tags)\n end",
"def tag_language_code_with_content\n self.language_code || self.tag_language_code_without_content \n end",
"def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end",
"def locale=(new_locale)\n FastGettext.locale = new_locale\n end",
"def tag(tag); end",
"def tag(tag); end"
] |
[
"0.61636746",
"0.6154581",
"0.5762692",
"0.5741483",
"0.56934136",
"0.5678227",
"0.566441",
"0.5632511",
"0.5631688",
"0.5631688",
"0.5631688",
"0.5631688",
"0.5631688",
"0.5631688",
"0.5631688",
"0.5550988",
"0.5465668",
"0.5465668",
"0.53963137",
"0.5390357",
"0.5390357",
"0.53711015",
"0.5367968",
"0.5340211",
"0.5325917",
"0.5325917",
"0.5310915",
"0.53078866",
"0.53003484",
"0.52786964",
"0.52415085",
"0.52360016",
"0.5219953",
"0.52040327",
"0.5173872",
"0.51700777",
"0.51700777",
"0.5162156",
"0.5153607",
"0.5151044",
"0.51162666",
"0.5096249",
"0.5096249",
"0.50935584",
"0.5085043",
"0.5080084",
"0.50639606",
"0.50599134",
"0.50599134",
"0.5047201",
"0.50453144",
"0.5032352",
"0.5032352",
"0.50106925",
"0.49915004",
"0.498012",
"0.49638748",
"0.49631807",
"0.49620852",
"0.4944765",
"0.4929204",
"0.49275926",
"0.4923747",
"0.49136207",
"0.49134684",
"0.49116203",
"0.49116203",
"0.49026927",
"0.48996216",
"0.48902845",
"0.48848304",
"0.48844528",
"0.48821893",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.4881866",
"0.48772687",
"0.4875951",
"0.4872188",
"0.4856808",
"0.48470476",
"0.48342833",
"0.48336092",
"0.4827785",
"0.48241308",
"0.48241308"
] |
0.0
|
-1
|
Factory method for locale tags. Delegates to the current locale tag implementation. source://i18n//lib/i18n/locale/tag.rb22
|
def tag(tag); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def langtag(locale)\n\t\tcase locale.to_s\n\t\twhen 'se' then 'se'\n\t\twhen 'us' then 'en'\n\t\twhen 'uk' then 'en'\n\t\twhen 'cn' then 'zh'\n\t\telse locale\n\t\tend\n\tend",
"def factory_method_for(tag); end",
"def tag_names locale = :en\n tags.pluck(\"name_#{locale}\").uniq.join(', ')\n end",
"def language_tag\n return @language_tag\n end",
"def tag(new_tag); end",
"def _tag(*a, &block)\n tag = Tag.new(self, *a, &block)\n end",
"def tag_keywords locale = :en\n tags.map do |t|\n t.try(\"keywords_#{locale}\")\n end.reject(&:blank?).uniq.join(', ')\n end",
"def set_locale_metatags! tags, record\n tags['og:locale:alternate'] = []\n tags['hreflang'] = []\n\n fields = %i[locale]\n fields << :state if record.respond_to? :state\n fields << :published if record.respond_to? :published\n fields << :published_at if record.respond_to? :published_at\n translations = record.translations.unscope(where: :locale).select(*fields)\n\n translations.each do |translation|\n next if translation.respond_to?(:state) && translation.state != record.class.states[:published]\n next if translation.respond_to?(:published) && !translation.published\n next if translation.respond_to?(:published_at) && !translation.published_at.nil? && translation.published_at > DateTime.now\n\n tags['og:locale:alternate'] << translation.locale\n tags['hreflang'] << [translation.locale, wm_url_for(record, locale: translation.locale)]\n end\n end",
"def initialize_defaults(method_name)\n super\n @template = \"#{I18n.locale}_#{method_name}\"\n end",
"def tag(name); end",
"def initialize_defaults(method_name)\r\n super\r\n @template = \"#{I18n.locale}_#{method_name}\"\r\n end",
"def initialize_defaults(method_name)\r\n super\r\n @template = \"#{I18n.locale}_#{method_name}\"\r\n end",
"def generate_language_switcher_link(locale)\n cat_permalink = nil\n tag_permalink = nil\n \n if params[:category].present?\n cat_permalink = Category.get_differnt_locale_permalink(Category::TYPES[:category], locale, params[:category])\n end\n \n if params[:tag].present?\n tag_permalink = Category.get_differnt_locale_permalink(Category::TYPES[:tag], locale, params[:tag])\n end\n \n if cat_permalink && tag_permalink\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => cat_permalink, :tag => tag_permalink)\n elsif cat_permalink\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => cat_permalink, :tag => nil)\n elsif tag_permalink\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => nil, :tag => tag_permalink)\n else\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => nil, :tag => nil)\n end\n \n end",
"def initialize_defaults(method_name)\r\n super\r\n @template = \"#{I18n.locale}_#{method_name}\"\r\n end",
"def initialize(*tags)\n @tags = tags.map{|tag| \"/tag/#{tag}\" }\n @wrap_tag = \"html\"\n end",
"def create_tag(tag) \n tag_type = parser.get_tag_type(tag)\n tag_attributes = parser.get_tag_attributes(tag)\n tag = Tag.new(tag_type, tag_attributes)\n end",
"def create_linked_tag_infos(tag, language_code)\n return_tag = {}\n\n unless tag.nil?\n return_tag[:id] = tag.id\n return_tag[:tag_identifier] = tag.tag_identifier\n\n if language_code.nil? and !tag.original_name.nil?\n return_tag[:name] = tag.original_name.text.to_s\n return_tag[:lang] = tag.original_name.lang_code.to_s\n elsif !language_code.nil?\n return_tag[:name] = tag.get_name_translation(language_code)\n return_tag[:lang] = language_code\n end\n end\n\n return_tag\n end",
"def translate(attribute, locale_tag)\n if locale = DataMapper::I18n::Locale.for(locale_tag)\n t = resource.translations.first(:locale => locale)\n t ? t.send(attribute) : nil\n else\n nil\n end\n end",
"def tag!(tag)\n H[tag, attr, convert_children]\n end",
"def template_tag\n if @tag\n @tag\n else\n TEMPLATE_TAG\n end\n end",
"def get_tag(tag_class); end",
"def create_tag_methods\n # Iterate around the items of the tags and create the necessary access methods\n if defined?(tags.item)\n tags.item.each do |name, value|\n method_name = format(\"%s_tag\", name)\n define_singleton_method method_name do\n value\n end\n end\n end\n end",
"def tag(arg)\n @tag = arg.to_s\n self\n end",
"def is_lang_tag? m\n I18n::Locale::Tag::Rfc4646.tag m rescue false\n end",
"def is_lang_tag? m\n I18n::Locale::Tag::Rfc4646.tag m rescue false\n end",
"def tagger_format tag\n \"<a href='/tags/#{tag}'>#{tag}</a>\"\n end",
"def create_tag_infos(tag, language_code)\n return_tag = {}\n\n # tag infos\n unless tag.nil?\n return_tag[:id] = tag.id\n return_tag[:tag_identifier] = tag.tag_identifier\n\n unless tag.description.nil? or tag.description.empty?\n return_tag[:description] = tag.description\n end\n\n unless tag.place.nil?\n return_tag[:places] = tag.place.id\n end\n\n # name\n # show original name if no lang_code is set\n if language_code.nil? and !tag.original_name.nil?\n return_tag[:name] = { :text => tag.original_name.text, :lang => tag.original_name.lang_code }\n elsif !language_code.nil? and tag.name_translations.count > 0\n return_tag[:name] = { :text => tag.get_name_translation(language_code), :lang => language_code }\n end\n\n # text_record infos\n unless tag.text_record.nil?\n unless tag.text_record.gender.nil?\n return_tag[:gender] = tag.text_record.gender\n end\n\n unless tag.text_record.image_url.empty?\n return_tag[:image_url] = tag.text_record.image_url\n end\n\n unless tag.text_record.text_url.empty?\n return_tag[:text_url] = tag.text_record.text_url\n end\n\n # show original text if no lang_code is set\n if language_code.nil? and !tag.text_record.original_text.nil?\n text = tag.text_record.original_text.text.to_s\n lang_code = tag.text_record.original_text.lang_code.to_s\n elsif !language_code.nil? and tag.text_record.translations.count > 0\n text = tag.text_record.get_translation(language_code)\n lang_code = language_code\n\n # convert to string\n text = text.to_s\n end\n\n unless text.nil?\n unless text.empty?\n return_tag[:translation] = { :text => text, :lang => lang_code }\n end\n end\n end\n\n # linked tags\n if tag.has_children?\n linked_tags = []\n tag.children.all.each { |t| linked_tags << create_linked_tag_infos(t, language_code) }\n return_tag[:linked_tags] = linked_tags\n end\n\n # parent tag\n unless tag.is_root?\n return_tag[:parent_tag] = create_linked_tag_infos(tag.parent, language_code)\n end\n\n # hardware\n unless tag.hardwares.nil? or tag.hardwares.count < 1\n hw_items = []\n tag.hardwares.each do |item|\n hw = {}\n\n hw[:type] = item.hardware_type\n hw[:identifier] = item.identifier\n\n if location = item.current_location\n hw[:latitude] = location.latitude\n hw[:longitude] = location.longitude\n end\n\n unless item.major.nil? and item.minor.nil?\n hw[:major] = item.major\n hw[:minor] = item.minor\n end\n\n hw_items << hw\n end\n return_tag[:hardware] = hw_items\n end\n end\n\n return_tag\n end",
"def create_tag(tag_name, tag_buf, raw_buf)\n if tag_buf =~ /\\A\\s*(?:(\\S+)\\s+)?\\(\\s*see\\s+(\\S+)\\s*\\)\\s*\\Z/\n return create_ref_tag(tag_name, $1, $2)\n end\n \n tag_method = \"#{tag_name}_tag\"\n if tag_name && @tag_factory.respond_to?(tag_method)\n if @tag_factory.method(tag_method).arity == 2\n @tags.push *@tag_factory.send(tag_method, tag_buf, raw_buf.join(\"\\n\"))\n else\n @tags.push *@tag_factory.send(tag_method, tag_buf) \n end\n else\n log.warn \"Unknown tag @#{tag_name}\" + (object ? \" in file `#{object.file}` near line #{object.line}\" : \"\")\n end\n rescue Tags::TagFormatError\n log.warn \"Invalid tag format for @#{tag_name}\" + (object ? \" in file `#{object.file}` near line #{object.line}\" : \"\")\n end",
"def language_tag=(value)\n @language_tag = value\n end",
"def initialize(tag)\n @tag = tag\n end",
"def tag\n raise NotImplementedError\n end",
"def tag\n raise NotImplementedError\n end",
"def from_i18n_locale(locale)\n I18n.with_locale(locale) { Locale.new(locale, I18n.t('.display_name'), I18n.t('.database_encoding')) }\n end",
"def abstract_tag(text); end",
"def tag( val = nil )\n default :tag, val\n end",
"def tag(tags)\n context = Thread.current[:lumberjack_context]\n context&.tag(tags)\n end",
"def tag_language_code_with_content\n self.language_code || self.tag_language_code_without_content \n end",
"def translation_for(locale, **)\n translation = translations.in_locale(locale)\n translation ||= translations.build(locale: locale)\n translation\n end",
"def apply_locale; end",
"def set_locale_meta_tags\n set_meta_tags(og: {locale: t('locale.short-code', default: 'en_US')} )\n # @todo When we support multiple locales, pull them in below\n #alternate: { \"fr\" => \"http://yoursite.fr/alternate/url\",\n # \"de\" => \"http://yoursite.de/alternate/url\" }\n end",
"def __with_locale__(locale, &block)\n yield\n end",
"def tag_name; end",
"def tag_name; end",
"def tag_name; end",
"def tag(string); end",
"def add_new_tag_with_label(tag_label)\n \traise \"error\" unless tag_label.is_a?(String)\n tag = Dtag.create(:label => DomainEnumerated.standardize_tag(tag_label), :domain_id => id)\n tag_ids << tag.id\n update_attribute(:descriptor, descriptor)\n tag\n end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def tag(tag_name, *args)\n tag_names = tag_name.split(args.first)\n\n tag_names.each do |tag_name|\n if !(self.tag_ids.include?(tag_name))\n tags << Tag.find_or_create_by(name: tag_name)\n end\n end\n self\n end",
"def use_tag(tag_name)\n raw \"_#{tag_name}\"\n end",
"def locale_scope\n I18n::Scope.new(locale_translations)\n end",
"def method_missing(method_name, *args)\n if m = method_name.to_s.match(/^cms_tag_(\\w+)$/)\n send(m[1], *args) if respond_to?(m[1])\n else\n super\n end\n end",
"def make_tags(tag, word)\n \"<#{tag}>#{word}</#{tag}>\"\n end",
"def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end",
"def tag(value)\n\t\t\tTag.new(value)\n\t\tend",
"def initialize(tag_name, markup, tokens)\n super\n options = markup.split(\" \")\n @lang = options.shift.downcase\n @highlight_options = parse_options(options)\n end",
"def method_missing(method, *_args)\n return tags[tag_map[method]] if tag_map.key?(method)\n\n super\n end",
"def tag(name)\n tags[name.to_s] if tags\n end",
"def yaml_tag_class_name\n self.name\n end",
"def tag; end",
"def tag; end",
"def to_label\n tag\n end",
"def to_label locale=I18n.default_locale\n self.subject locale\n end",
"def add_tag(tag)\n t = Tagging.new()\n t.translation = self\n t.tag = tag\n begin\n self.taggings << t\n rescue # Already tagged\n false\n end\n end",
"def tags\n EnvironmentTagMethodsFactory.new(self)\n end",
"def create(tag)\n update_tag_file do |tag_array|\n old_tags = ::MachineTag::Set.new(tag_array)[::MachineTag::Tag.new(tag).namespace_and_predicate]\n old_tags.each { |old_tag| tag_array.delete(old_tag) }\n tag_array << tag unless tag_array.include?(tag)\n end\n end",
"def tag\n end",
"def tag\n end",
"def locale_backend; end",
"def create_tagging(tag)\n # refuse to create taggings with a 0 split\n split_amount = TagParser.calculate_split(tag.name_with_split, self.amount)\n return nil if split_amount == 0\n usd_split_amount = CurrencyExchangeRate.convert_to_usd(split_amount, self.currency, self.date_posted) if split_amount\n\n taggings.create(\n :tag => tag,\n :name => tag.name_with_split,\n :split_amount => split_amount,\n :usd_split_amount => usd_split_amount)\n end",
"def add_tag(tag)\r\n self.tags.new(:name => tag.name)\r\n end",
"def wrap_tag_with_label(tag)\n wrap(:labeler, tag)\n end",
"def with_locale(tmp_locale = T.unsafe(nil)); end",
"def tag_state(tag)\n if current_user.globally_excluded?(tag)\n t(\"winnow.tags.general.globally_excluded\")\n elsif current_user.subscribed?(tag)\n t(\"winnow.tags.general.subscribed\")\n elsif (current_user.id == tag.user_id) && tag.public\n t(\"winnow.tags.general.public\")\n end\n end",
"def tag_name=(_arg0); end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def auto_create_tag\n\t\n\tget_tags.each do |tag|\n\t\t@items << Nanoc3::Item.new(\n\t\t\"<%= render 'tag', :tag => '#{tag}' %>\",\n\t { :title => \"Category: #{tag}\", :is_hidden => true, :tag => \"#{tag}\"}, # do not include in sitemap.xml\n\t \"/tags/#{tag}/\", # identifier\n\t :binary => false\n\t)\n\n\tend\n\tnil\nend",
"def _tag_name\n @tag_name\n end",
"def tag_page_resource(tag, articles)\n Sitemap::ProxyResource.new(@sitemap, link(tag), @tag_template).tap do |p|\n # Detect \"formatted\" tag in first article - trying to guess the correct format to show\n # tagname = articles.first.tags.detect { |article_tag| safe_parameterize(article_tag) == tag }\n\n # Add metadata in local variables so it's accessible to later extensions\n p.add_metadata locals: {\n 'page_type' => 'tag',\n 'tagname' => tag,\n 'articles' => articles,\n 'blog_controller' => @blog_controller\n }\n end\n end",
"def create_tag(node)\n tag = @factory.new_tag\n tag.text = node.text\n tag.count = node.attributes['count'].to_i if node.attributes['count']\n return tag\n end",
"def local_task_tag(name)\n Roby::Models::TaskServiceModel::DRoby.anon_tag_factory(name)\n end",
"def make_tags(item)\n\ttags_for(item, { :base_url => @site.config()[:base_url] + \"/tags/\" })\nend",
"def translation_for(locale, _options = {})\n translation = translations.find { |t| t.key == attribute && t.locale == locale.to_s }\n translation ||= translations.build(locale: locale, key: attribute)\n translation\n end",
"def create_local\n template \"config/locales/en.rb\", \"config/locales/#{class_name.underscore}.en.yml\"\n end",
"def create(tag)\n klass = Class.new self\n klass.tag tag\n klass\n end",
"def factory(locale = :en)\n if block_given?\n yield Factory.instance(locale)\n else\n Factory.instance(locale)\n end\n end",
"def with_locale(tmp_locale = T.unsafe(nil), &block); end",
"def locale(locale, &block)\n scope :locale => locale, &block\n end",
"def translation_for(locale, **)\n translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }\n translation ||= class_name.new(locale: locale, key_column => attribute)\n translation\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def event_tag(tag)\n case tag\n when \"NAME\" then tag\n else super(tag)\n end\n end",
"def tag(*a)\n Tag.tag(*a)\n end",
"def each\n each_locale { |locale| yield Translation.new(self, locale) }\n end",
"def translate_tag(untranslated_tag)\n return [] if untranslated_tag.blank?\n\n translated_tag_names = WikiPage.active.other_names_include(untranslated_tag).uniq.pluck(:title)\n translated_tag_names = TagAlias.to_aliased(translated_tag_names)\n translated_tags = Tag.where(name: translated_tag_names)\n\n if translated_tags.empty?\n normalized_name = TagAlias.to_aliased([Tag.normalize_name(untranslated_tag)])\n translated_tags = Tag.nonempty.where(name: normalized_name)\n end\n\n translated_tags\n end"
] |
[
"0.6808841",
"0.5990548",
"0.58918536",
"0.57097554",
"0.55515933",
"0.5514053",
"0.5505078",
"0.54841197",
"0.5483733",
"0.547594",
"0.54700255",
"0.54700255",
"0.5469505",
"0.54685724",
"0.5443215",
"0.5413555",
"0.53936845",
"0.53820074",
"0.5370707",
"0.53667915",
"0.5353651",
"0.53456455",
"0.53362066",
"0.533286",
"0.533286",
"0.5329503",
"0.5313951",
"0.5301565",
"0.52707314",
"0.52662766",
"0.5244024",
"0.5244024",
"0.5243887",
"0.52169347",
"0.52118236",
"0.52011675",
"0.5178336",
"0.51728773",
"0.5167413",
"0.5165768",
"0.5155374",
"0.51540446",
"0.51540446",
"0.51540446",
"0.51527643",
"0.515164",
"0.5142222",
"0.51226884",
"0.51036",
"0.5100907",
"0.50923014",
"0.5092281",
"0.50769067",
"0.50610167",
"0.50524294",
"0.5051879",
"0.50493866",
"0.5031344",
"0.5022331",
"0.5022331",
"0.5019291",
"0.5014501",
"0.500839",
"0.4994693",
"0.49935615",
"0.49904206",
"0.49904206",
"0.49896982",
"0.49879625",
"0.49726474",
"0.4972597",
"0.49698827",
"0.4964991",
"0.4962559",
"0.49603808",
"0.49603808",
"0.49603808",
"0.49603808",
"0.49603808",
"0.49603808",
"0.49603808",
"0.4958793",
"0.49428266",
"0.49396628",
"0.49378183",
"0.49344343",
"0.49324676",
"0.4932144",
"0.49310875",
"0.49252743",
"0.49231225",
"0.49205568",
"0.49200475",
"0.49160242",
"0.4914437",
"0.49006253",
"0.48890707",
"0.4887684",
"0.48820826"
] |
0.56099695
|
5
|
Parses the given tag and returns a Tag instance if it is valid. Returns false if the given tag is not valid according to RFC 4646. source://i18n//lib/i18n/locale/tag/rfc4646.rb18
|
def tag(tag); end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_tag(tag)\n parser = REXML::Parsers::UltraLightParser.new( tag)\n parser.parse[0]\n end",
"def is_lang_tag? m\n I18n::Locale::Tag::Rfc4646.tag m rescue false\n end",
"def is_lang_tag? m\n I18n::Locale::Tag::Rfc4646.tag m rescue false\n end",
"def parse_tag\n a_ord = ?a\n z_ord = ?z\n special_ords = [?:, ?-] # for xml:lang and http-equiv\n \n tag_name = ''\n pos = 1\n is_start_tag = (@html[pos,1] != '/')\n pos += 1 unless is_start_tag\n \n # get tag name\n while (@html[pos,1])\n char = @html.downcase[pos,1]\n pos_ord = char[0]\n if ((pos_ord >= a_ord && pos_ord <= z_ord) || (!tag_name.empty? && is_numeric?(char)))\n tag_name << char\n pos += 1\n else\n pos -= 1\n break\n end\n end # end while\n \n tag_name.downcase!\n if (tag_name.empty? || !BLOCK_ELEMENTS.include?(tag_name))\n # something went wrong, invalid tag\n invalid_tag\n return false\n end\n \n if (@no_tags_in_code && @open_tags.last == 'code' && !(tag_name == 'code' && !is_start_tag))\n # supress all HTML tags inside code tags\n invalid_tag\n return false\n end\n \n # get tag attributes\n # TODO: in HTML 4 attributes dont need to be quoted\n is_empty_tag = false\n attributes = {}\n curr_attribute = ''\n while (@html[pos+1,1])\n pos += 1\n # close tag\n if (@html[pos,1] == '>' || @html[pos,2] == '/>')\n if (@html[pos,1] == '/')\n is_empty_tag = true\n pos += 1\n end\n break \n end\n\n char = @html.downcase[pos,1]\n pos_ord = char[0]\n if (pos_ord >= a_ord && pos_ord <= z_ord)\n # attribute name\n curr_attribute << char\n elsif ([' ', \"\\t\", \"\\n\"].include?(char))\n # drop whitespace\n elsif\n # get attribute value\n pos += 1\n await = @html[pos,1] # single or double quote\n pos += 1\n value = ''\n while (@html[pos,1] && @html[pos,1] != await)\n value << @html[pos,1]\n pos += 1\n end # end while\n attributes[curr_attribute] = value\n curr_attribute = ''\n else\n invalid_tag\n return false\n end\n end # end while\n \n if (@html[pos, 1] != '>')\n invalid_tag\n return false\n end\n \n if (!curr_attribute.empty?)\n # html4 allows something like <option selected> instead of <option selected=\"selected\">\n attributes[curr_attribute] = curr_attribute\n end\n \n unless (is_start_tag)\n if (!attributes.empty? || (tag_name != @open_tags.last))\n # end tags must not contain any attributes\n # or maybe we did not expect a different tag to be closed\n invalid_tag\n return false\n end\n @open_tags.pop\n if (PREFORMATTED_TAGS.include?(tag_name))\n @keep_whitespace -= 1\n end\n end \n pos += 1\n @node = @html[0,pos]\n @html = @html[pos, @html.size-pos]\n @tag_name = tag_name\n @tag_attributes = attributes\n @is_start_tag = is_start_tag\n @is_empty_tag = is_empty_tag || EMPTY_TAGS.include?(tag_name)\n if (@is_empty_tag)\n # might not be well formed\n @node.gsub!(/ *\\/? *>$/, ' />')\n end\n @node_type = 'tag'\n @is_block_element = BLOCK_ELEMENTS[tag_name]\n return true\n end",
"def is_valid_tag(tag)\n return (not tag.empty? and tag =~ /v\\d{1,2}\\.\\d{1,3}/)\nend",
"def parse_tag\n tag = Tag.new\n cur = @tokens.first || raise\n\n case cur.ty\n when :dot\n tag.name = \"div\"\n tag.add_attr(\"class\", parse_css_class())\n when :hash\n tag.name = \"div\"\n tag.add_attr(\"id\", parse_elem_id())\n when :id \n tag.name = cur.value\n @tokens.shift\n else\n raise\n end\n\n # parse all attributes\n loop do\n if attr = try_parse_attr()\n tag.add_attr(*attr)\n else\n break\n end\n end\n\n cur = @tokens.first || (return tag)\n\n case cur.ty\n when :open\n @tokens.shift\n tag.elements = parse_statements()\n cur = @tokens.shift || raise\n raise unless cur.ty == :close\n when :dstr, :str, :eval\n tag.elements = [parse_expr()]\n when :nl, :semi\n # ok\n else\n raise \"invalid type #{ cur.ty }\"\n end\n\n return tag\n end",
"def tag?(t)\n return false if t.nil?\n if t =~ /^[a-zA-Z][\\w\\_\\-]+[a-zA-Z]$/\n return true\n end\n false\n end",
"def valid?(tag)\n prevalidated = prevalidated?(tag)\n @extra_validator ? @extra_validator.call(tag) && prevalidated : prevalidated\n end",
"def date_tag?(tag)\n validate_tag(tag) { |v| (v.size == 0) || (v.first.to_s =~ /^\\d\\d\\d\\d$/) }\n end",
"def can_parse?(str)\n str.match(/^#{tag}\\=[^\\x01]*\\x01/)\n end",
"def check_tag_format\n errors.add(:name, 'is not a valid tag') unless name =~ Tag.validation_regex\n end",
"def numeric_tag?(tag)\n validate_tag(tag) { |v| (v.size == 0) || (v.first.to_s =~ /^[1-9][0-9]*$/) }\n end",
"def tagged?(tag)\n !! self.tag(tag)\n end",
"def open_tag?(char)\n unless char == nil\n char =~ /\\A<[^>]+>/\n else\n false\n end\n end",
"def is_valid_element?(element)\n VALID_TAGS.include?(element.get_tag_name)\n end",
"def parse_tag_with_types_and_name(tag_name, text); end",
"def has_tag?(name); end",
"def parse_tag_with_name(tag_name, text); end",
"def validate\n name = params[:tag].downcase\n\n tag = ActsAsTaggableOn::Tag.where(\"name= ?\", name)[0]\n if tag == nil\n tag = ActsAsTaggableOn::Tag.new\n tag.name = name\n if tag.valid?\n head :no_content\n else\n respond_with tag.errors, status: :unprocessable_entity\n end\n end\n head :no_content\n end",
"def parse_tag_with_types(tag_name, text); end",
"def parse_tag(aText)\n # Recognize the first character\n if aText =~ /^[\\?\\/]/\n matching = DisallowedSigns.match(aText[1..-1])\n else\n # Disallow punctuation and delimiter signs in tags.\n matching = DisallowedSigns.match(aText)\n end\n fail(InvalidCharError.new(aText, matching[0])) if matching\n \n result = Placeholder.new(aText)\n\n return result\n end",
"def tagged?\n defined?(@tag) && !!@tag\n end",
"def tag\n if @tag.is_a? String\n @tag\n end\n end",
"def parse_tag_with_types_and_title(tag_name, text); end",
"def has_tag?(tag)\n tags.include?(tag.to_s)\n end",
"def create_tag(tag) \n tag_type = parser.get_tag_type(tag)\n tag_attributes = parser.get_tag_attributes(tag)\n tag = Tag.new(tag_type, tag_attributes)\n end",
"def element_is_tag?\n self[:is_tag]\n end",
"def is_tag?( tag = '' )\n return false unless @is_tag\n\n return true if tag.blank?\n\n tag_obj = get_queried_object\n\n tag = [tag] unless tag.is_a?(Array)\n tag.map!(&:to_s)\n\n if tag.include?(tag_obj.term_id.to_s)\n return true\n elsif tag.include?(tag_obj.name)\n return true\n elsif tag.include?(tag_obj.slug)\n return true\n end\n false\n end",
"def hastag?(tag)\n @tags[tag] ? true : false\n end",
"def isPollTag(tag)\n \tid = unhashTag(tag)\n \treturn (id >= POLLSSTARTID)\n end",
"def open_tag?(tag)\n !close_tag?(tag)\n end",
"def readable?(tag)\n readable.include? tag.to_sym\n end",
"def readable?(tag)\n readable.include? tag.to_sym\n end",
"def tagged?(tag)\n @tags.include?(tag)\n end",
"def has_tag?(tag) # rubocop:disable Naming/PredicateName\n !get_tag(tag).nil? # nil is considered not present, thus we can't use `Hash#has_key?`\n end",
"def validate(tags)\n return tags if opts[:novalidate]\n\n tags.tap do |t|\n t.each_pair do |name, value|\n validate_method = \"validate_#{name}\".to_sym\n\n unless respond_to?(validate_method)\n raise Aur::Exception::InvalidTagName, \"cannot validate '#{name}'\"\n end\n\n t[name] = send(validate_method, value)\n end\n end\n end",
"def has_tag? tag\n @values.has_key?(Values.unify_tag(tag.to_s))\n end",
"def has_tag(tag_name)\n tag = USER_TAGS[tag_name: tag_name]\n return tag != nil\n end",
"def correct_tag_values?\n validate_tags(info.our_tags)\n validate_album_disc(info.album, file.dirname.basename.to_s)\n end",
"def has_tag? (tag)\n\n @tags.include?(tag)\n end",
"def decode_tag(ns, name, attrs, parent)\n raise NotImplementError.new('Method decode_tag must be defined in derived class.')\n end",
"def get_tag_id(tag_name)\n case tag_name.gsub(/\\s+/, '_').downcase.to_sym\n when :pending_art_proof\n '1000019458'\n else\n false\n end\n end",
"def parse_tag_with_types_and_name(tag_name, text)\n name, types, text = *extract_types_from_text(text)\n name, text = *extract_name_from_text(text) if name.nil?\n Tag.new(tag_name, text, types, name)\n end",
"def has_tag?(tag)\n self.tags.include?(tag)\n end",
"def extract_tag_name(tag)\n match = /\\A<\\/?(#{@@name})/.match(tag)\n return match[1] if match\n raise \"Cannot find tag name in tag: #{tag}\"\n end",
"def has_tag? tag\n selected.each do |view|\n return true if view.rmq_data.has_tag?(tag)\n end\n false # tag doesn't exist if we got here\n end",
"def tag\n try_opt(:tag)\n end",
"def is_unidad_type?\n tag_name.eql?(UNIDAD)\n end",
"def parse_tag(tag, subtags, feed)\n extracted_subtags = {}\n feed = ExtractData.extract_tag_text(feed, tag)\n\n subtags.each do |sub|\n # Should be exctract_subtag_text here, after the correction\n sub_text = ExtractData.extract_tag_text(feed, sub)\n extracted_subtags[sub] = TransformData.tag_to_plaintext(sub_text) unless sub_text.empty?\n end\n\n transform_dates_in extracted_subtags\n end",
"def has_tag\n return @has_tag unless @has_tag.nil?\n get_tag_information\n @has_tag\n end",
"def has_tag? tag\n out = false\n selected.each do |view|\n if view.rmq_data.has_tag?(tag)\n out = true # This is weird because of RM android bug\n break\n end\n end\n\n out\n end",
"def tag\n t = string(/[^ \\)~-][^ ]*/, skip_balanced_parens: true)\n error(\"Invalid tag name: #{t}\") if t.downcase.in?(%w[and or]) || t.include?(\"*\") || t.match?(/\\A#{metatag_regex}/)\n space\n AST.tag(t)\n end",
"def has_tag(tag)\n @tags.include?(\"@#{tag}\")\n end",
"def have_tag(tag, attributes)\n HasTag.new(tag, attributes)\n end",
"def close_tag?(tag)\n tag.include?(\"</\") ? true : false\n end",
"def invalid_param?\n self[:params][:tag_param].match(@definition[:tag_param]).nil?\n end",
"def check_tag_allowed(type = :tag, prefix = :html)\n raise \"#{prefix.to_s.humanize} tag (#{params[\"#{prefix}_tag\"]}) not allowed\" if params[\"#{prefix}_tag\"].present? && !html_tag_options_for_type(type).include?(params[\"#{prefix}_tag\"])\n end",
"def tag\n @tag ||= to_boolean_phrase.hash.abs.to_s(36)\n end",
"def from_tag(tag)\n matchdata = tag.match VERSION_FORMAT\n new(matchdata[:major], matchdata[:minor], matchdata[:patch], Prerelease.from_string(matchdata[:prerelease]), matchdata[:build])\n end",
"def get_tag_from_label(tag_label, reload = false)\n tag_label = DomainEnumerated.standardize_tag(tag_label)\n tag_id, tag = get_hash_tags(reload).detect { |id, tag| tag.label == tag_label }\n tag\n end",
"def parse_line(line)\n return nil unless valid?(line)\n\n # it isn't a tag if it doesnt begin with #\n return M3U8ParsedTag.new(nil, nil, line) unless line[0] == '#'\n\n # is it an idependent tag?\n return M3U8ParsedTag.new(line[1..-1]) if independent_tag?(line)\n return nil unless (pos = line.index(':'))\n\n # is it a VALUE tag?\n tag, attr_or_val = [line[1..pos - 1], line[pos + 1..-1]]\n return M3U8ParsedTag.new(tag, nil, attr_or_val) if value_tag?(line[0..pos - 1])\n return M3U8ParsedTag.new(tag, attr_or_val) if attribute_tag?(line[0..pos - 1])\n\n # I don't know wtf it is!\n nil\n end",
"def tag_from(str)\n letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n numbers = '0123456789'\n if str.length < 2\n nil\n else\n if (str[0]=='<') && (str[-1]=='>')\n text = str.gsub('<','').gsub('>','').gsub('/','')\n if (text.length == 0) || !letters.include?(text[0])\n nil\n else\n text.split(\" \").first.downcase\n end\n else\n nil\n end\n end\nend",
"def tagqa\n # Clean up the name by removing/collapsing whitespace\n logger.info \"Running 'tagqa'\"\n self.name = Tag.tidyName name\n # ...and setting the normalized name\n self.normalized_name = Tag.normalizeName name\n self.tagtype = 0 unless tagtype\n if clashing_tag?\n # Shouldn't be saved, because either 1) it will violate uniqueness, or 2) an existing untyped tag can be used\n errors.add :key, \"Tag can't be saved because of possible redundancy\"\n false\n else\n true\n end\n end",
"def has_tag?(t)\n tags.include?(t)\n end",
"def add_tag(tag)\n t = Tagging.new()\n t.translation = self\n t.tag = tag\n begin\n self.taggings << t\n rescue # Already tagged\n false\n end\n end",
"def validate_tags(tags)\n tags.reduce(true) { |result, tag| result && yield(tag) }\n end",
"def close_tag?(char)\n unless char == nil\n char =~ %r!\\A</[^>]+>!\n else\n false\n end\n end",
"def validate(engine)\r\n @block = engine[format]\r\n fail \"Unsupported tag = #{format.inspect}\" unless @block\r\n true\r\n end",
"def get_tag(tag_class); end",
"def can_parse?(str)\n str =~ /^#{counter_tag}\\=[^\\x01]+\\x01/\n end",
"def parse_tag(html_str)\n node = Struct.new(:type, :classes, :id, :name)\n parser = node.new\n parser.type = html_str.scan(/<[a-z0-9]+/).join[1..-1]\n parser.classes = html_str.scan(/class='(.*?)'/).join.split(\" \")\n parser.id = html_str.scan(/id='(.*?)'/).join\n parser.name = html_str.scan(/name='(.*?)'/).join\n parser\nend",
"def xfrm_pos_tag_to_human_tag(tag)\n cache_tag_data if $shared_cache[:pos_tag_human_readings].nil?\n if $shared_cache[:pos_tag_human_readings].has_key?(tag)\n return $shared_cache[:pos_tag_human_readings][tag][:humanised]\n else\n return tag\n end\n end",
"def assert_tag(tag, string)\n complete_tag = \"<#{tag}>\"\n partial_tag = \"<#{tag}(\"\n (string.include? complete_tag) || (string.include? partial_tag)\n end",
"def value_for_tag?(tag)\n @set_fields[tag] || false\n end",
"def close_tag?(tag)\n tag.match(CLOSE)\n end",
"def prepare_param_tag(name_or_tag, &block) # :yields: tag\n tag = case name_or_tag\n when WWW::Delicious::Tag\n name_or_tag\n else\n Tag.new(:name => name_or_tag.to_s)\n end\n\n yield(tag) if block_given?\n # TODO: validate tag with tag.validate!\n raise \"Invalid `tag` value supplied\" unless tag.api_valid?\n tag\n end",
"def tag tag = nil\n @tag = tag if tag\n @tag\n end",
"def parse_tag(string)\n att = {\n type: /<(\\w)/.match(string),\n classes: /class='(\\w{1, 20}).(\\w{1, 20})'/.match(string),\n id: /id='(\\w{1, 20})'/.match(string),\n name: /name='(\\w{1, 30})'/.match(string)\n }\nend",
"def convert tag, val\n return val unless val.kind_of?(String)\n case tag\n when 'partofset', 'track'\n return val\n end\n case val\n when REGEXP_TIMESTAMP\n year, month, day, hour, minute = $~.captures[0,5].map {|cap| cap.to_i}\n if month == 0 || day == 0\n return nil\n end\n second = $6.to_f\n zone = $7\n zone = '+00:00' if zone == 'Z'\n begin\n Time.new(year, month, day, hour, minute, second, zone)\n rescue ArgumentError\n val\n end\n when REGEXP_RATIONAL\n return val if $2.to_i == 0\n Rational($1, $2)\n else\n val\n end\n end",
"def tag(string); end",
"def tag_unused?(tag)\n self.tag_used_k_times?(tag, 0)\n end",
"def process_tag(tag)\n if html = process_image_tag(tag)\n html\n elsif html = process_file_link_tag(tag)\n html\n else\n process_page_link_tag(tag)\n end\n end",
"def xfrm_pos_tag_to_inhuman_tag(tag)\n cache_tag_data if $shared_cache[:pos_tag_inhuman_readings].nil?\n if $shared_cache[:pos_tag_inhuman_readings].has_key?(tag)\n return $shared_cache[:pos_tag_inhuman_readings][tag][:inhumanised]\n else\n return tag\n end\n end",
"def validate_tags(website)\n tfa = website['tfa']\n if tfa != true && tfa != false\n error(\"#{website['name']}: The YAML tag \\'#{tag}\\' should be either \\'Yes\\' or \\'No\\'. (#{tfa})\")\n end\n\n # Validate tags that are obligatory\n @obligatory_tags.each do |t|\n tag = website[t]\n next unless tag.nil?\n error(\"#{website['name']}: The required YAML tag \\'#{t}\\' tag is not present.\")\n end\n\n # Validate tags associated with TFA 'YES'\n @tfa_yes_tags.each do |tfa_form|\n check_tag(tfa_form, false, true, website)\n end\n\n # Validate TFA form tags'\n @tfa_forms.each do |tfa_form|\n check_tag(tfa_form, false, true, website, true)\n end\n\n # Validate tags associated with TFA 'NO'\n @tfa_no_tags.each do |tfa_form|\n check_tag(tfa_form, false, false, website)\n end\n end",
"def tt?(tag)\n tag.bit == @tt_bit\n end",
"def validate_tag(tag)\n values = @selected_files.map { |file| file[tag] }\n values.reduce(true) { |r, v| r && yield(v) }\n end",
"def valid?\n @specification.check_tag(self) && @attributes.all? { | _k, v | v.valid? }\n end",
"def has_tag?(tag)\r\n self.tags.count(:name => tag.name)> 0\r\n end",
"def parse_tag_ver(tag_ver)\n parts = tag_ver.split('_')\n if parts[2]\n parts[2][1..-1] # Strip off 'g' prefix.\n else\n parts[0]\n end\nend",
"def parse_tag(line)\n raise SyntaxError.new(\"Invalid tag: \\\"#{line}\\\".\") unless match = line.scan(/%([-:\\w]+)([-\\w\\.\\#]*)(.*)/)[0]\n tag_name, attributes, rest = match\n new_attributes_hash = old_attributes_hash = last_line = object_ref = nil\n attributes_hashes = []\n while rest\n case rest[0]\n when ?{\n break if old_attributes_hash\n old_attributes_hash, rest, last_line = parse_old_attributes(rest)\n attributes_hashes << [:old, old_attributes_hash]\n when ?(\n break if new_attributes_hash\n new_attributes_hash, rest, last_line = parse_new_attributes(rest)\n attributes_hashes << [:new, new_attributes_hash]\n when ?[\n break if object_ref\n object_ref, rest = balance(rest, ?[, ?])\n else; break\n end\n end\n\n if rest\n nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\\/\\~&!])?(.*)?/)[0]\n nuke_whitespace ||= ''\n nuke_outer_whitespace = nuke_whitespace.include? '>'\n nuke_inner_whitespace = nuke_whitespace.include? '<'\n end\n\n value = value.to_s.strip\n [tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,\n nuke_inner_whitespace, action, value, last_line || @index]\n end",
"def validate_tags(params)\n db = connect_to_db()\n db.results_as_hash = true\n\n result = db.execute('SELECT id FROM tags where id=?', params[\"id\"].to_i)\n\n if !result.empty?()\n return true\n else\n return false\n end\n end",
"def allowed_child?(tag); end",
"def parse_tag_name( tag )\n match_name = /[^=]*/\n m = tag.match(match_name)\n return m[0]\n end",
"def clashing_tag?\n Tag.clashes(self).exists?\n end",
"def correct_tags?\n missing_tags?\n unwanted_tags?\n duplicate_tags?\n end",
"def parse_tags(tags, type)\n return tags[\"#{type}\"] unless tags[\"#{type}\"].nil?\n return \"N/A\"\nend",
"def check_tag_present\n entries = get_entries\n entries.each do |entry|\n if entry[\"data-mention-id\"].eql?(@stream_post_id)\n tags = entry.all(input_elements[:tag_link_on_stream])\n tags.each do |tag_on_stream|\n return true if tag_on_stream.text.include?(@used_tag)\n end\n return false\n end\n end\n return false\n end",
"def [](tag)\n unified_tag = Values.unify_tag(tag)\n convert(unified_tag, @values[unified_tag])\n end",
"def has_tag?(item, tag)\n return false if item[:tags].nil?\n item[:tags].include? tag\n end"
] |
[
"0.71589494",
"0.65725255",
"0.65725255",
"0.6411111",
"0.6313324",
"0.62935996",
"0.62114143",
"0.6185384",
"0.6144448",
"0.60811335",
"0.5932906",
"0.5924055",
"0.58369875",
"0.58241624",
"0.5820324",
"0.56992096",
"0.5663235",
"0.56374204",
"0.56203073",
"0.55995494",
"0.55986863",
"0.5579407",
"0.55651116",
"0.5520732",
"0.54676765",
"0.54604703",
"0.5453697",
"0.5450998",
"0.5448282",
"0.5407075",
"0.53990144",
"0.5352915",
"0.5352915",
"0.5351432",
"0.5346194",
"0.53208053",
"0.531527",
"0.5260307",
"0.52287316",
"0.5211227",
"0.52103025",
"0.5196235",
"0.5186315",
"0.5181509",
"0.5161498",
"0.5142255",
"0.5133238",
"0.5132801",
"0.51219547",
"0.5117903",
"0.5102568",
"0.5093959",
"0.5081958",
"0.50729036",
"0.5072397",
"0.50593185",
"0.50423414",
"0.5041802",
"0.50408745",
"0.50406253",
"0.50380266",
"0.5013086",
"0.4995953",
"0.49878728",
"0.49844518",
"0.49843076",
"0.49788243",
"0.49783853",
"0.49635506",
"0.49382365",
"0.49371472",
"0.49310365",
"0.4913489",
"0.49071214",
"0.49030897",
"0.48944166",
"0.48924738",
"0.48881695",
"0.48877937",
"0.48791516",
"0.4878754",
"0.48778597",
"0.48767182",
"0.48661909",
"0.48621103",
"0.48544168",
"0.4853786",
"0.48533383",
"0.4845847",
"0.48428452",
"0.4837118",
"0.48282105",
"0.48225477",
"0.48145095",
"0.48124197",
"0.479809",
"0.47952697",
"0.4792816",
"0.47880375"
] |
0.52961195
|
37
|
Returns the value of attribute tag. source://i18n//lib/i18n/locale/tag/simple.rb15
|
def tag; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def value_for_tag(tag)\n self.__send__(fields[tag].name)\n end",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def first_value(tag)\n tag_summary(tag).first[1].first\n end",
"def [](tag)\n unified_tag = Values.unify_tag(tag)\n convert(unified_tag, @values[unified_tag])\n end",
"def attr_tag(text); end",
"def value\n @attributes[:value]\n end",
"def value\n `#{@el}.value`\n end",
"def value\n attributes.fetch(:value)\n end",
"def get_value(element)\n\t\t\tif ['input','select','textarea'].include? element.tag_name.downcase\n\t\t\t\telement.attribute('value')\n\t\t\telse\n\t\t\t\telement.text\n\t\t\tend\n\t\tend",
"def get_tag_value (tag_path, fetch_datatype=false)\n\n $test_logger.log(\"Get tag value #{tag_path}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.root.elements[tag_path]\n\n #Fetch target value\n val = \"\"\n val = target_tag.get_text.value if target_tag && target_tag.get_text\n\n #Get data type for element\n if fetch_datatype\n data_type = ILVMessage.get_type_for_ele(target_tag)\n return val, data_type\n else\n return val\n end\n end",
"def get_attribute_or_element_value(xml, attr, default = nil, &f)\n val = default\n begin\n snip = xml.elements[attr]\n if snip.elements.size > 0\n if snip.elements.size == 1 && snip.elements['object']\n # must be an otml reference to a different OTObject\n # return the refid\n val = snip.elements['object'].attributes['refid'].to_s\n else\n # otherwise just return the whole snippet\n val = snip.to_s\n end\n else\n val = snip.get_text.to_s\n end\n rescue\n begin\n val = xml.attributes[attr].to_s\n rescue\n # logger.warn(\"Couldn't find attribute or element: #{attr}\")\n end\n end\n begin\n if f\n val = yield(val)\n end\n rescue\n val = default\n end\n return val\n end",
"def get_value\n read_attribute('text_value')\n end",
"def attribute_value(element,attribute_name)\n element.attribute_value(element,attribute_name)\n end",
"def translate(attribute, locale_tag)\n if locale = DataMapper::I18n::Locale.for(locale_tag)\n t = resource.translations.first(:locale => locale)\n t ? t.send(attribute) : nil\n else\n nil\n end\n end",
"def value element_name\n begin\n el_attribute = el element_name\n el_attribute.attribute('value')\n rescue Exception => e\n $LOG.error \"error in getting element value \\n element name : #{element_name} \"+e.message\n raise \"error in getting element value \\n element name : #{element_name} \"+e.message\n end\n end",
"def value sym\r\n @@tag_methods.has_key?(sym) ? value(@@tag_methods[sym]) : @values[sym]\r\n end",
"def html_value\n \"TODO: html_value for #{name}\"\n end",
"def get_value(attribute,xml)\n xml.xpath(\".//#{attribute}\").first.content\n end",
"def get_string(attr); end",
"def tag\n if @tag.is_a? String\n @tag\n end\n end",
"def first_subfield_value(tag)\n sf = @field.subfields.select { |sf| sf.code == tag}\n return '' if sf.empty?\n sf.first.value\n end",
"def value(name)\n element.value_for(name)\n end",
"def [](name)\n attr_name = name.to_s\n if attr_name == 'value'\n value\n elsif (tag_name == 'input') && (native[:type] == 'checkbox') && (attr_name == 'checked')\n native['checked'] == 'checked'\n else\n native[attr_name]\n end\n end",
"def [](name)\n `#{@el}.getAttribute(#{name})`\n end",
"def [](key)\n if key.to_s[0] == ?@\n tag = key.to_s[1..-1].to_sym\n c = child(tag)\n if c\n c.text\n else\n nil\n end\n else\n @attrs[key]\n end\n end",
"def tag_text()\n return self.tag(true)\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def tag\n return @tag\n end",
"def attribute attr\n @ref.attribute(TRANSLATOR.cocoaify(attr)).to_ruby\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def value_html\n options[:catalog] ? '' : attribute_value_to_html(Array.wrap(values).first)\n end",
"def markup\n if tag?\n @value.raw\n elsif @value.instance_variable_defined?(:@markup)\n @value.instance_variable_get(:@markup)\n end\n end",
"def attribute_value\n @attributes.each { | id, value | return value }\n end",
"def dom_attribute(name); end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def tag(value)\n merge(rvtag: value.to_s)\n end",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n element=@xml.xpath(key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n element=@xml.elements[key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def get_attribute( name )\n @attr_nodes.each do |attr|\n if attr.name == name then\n #//////////////////////////\n # 変更する\n #//////////////////////////\n return attr.value\n end\n end\n return \"\"\n end",
"def get_tagvalue(object, tagkey)\n value = \"\"\n if object[:tag_set]\n object[:tag_set].each do |tag|\n if tag[:key] == tagkey\n value = tag[:value]\n break\n end\n end\n end\n \n value\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n @attributes[:label]\n end",
"def to_label\n tag\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def tag_name\n return @tag_name\n end",
"def tag(value)\n merge(uctag: value.to_s)\n end",
"def attr(node,name_attribute='Name')\n node.attributes[name_attribute].value\n end",
"def tag\n @tag\n end",
"def element_for_attribute(name, namespace = '')\n val = Axlsx.instance_values_for(self)[name]\n return \"\" if val.nil?\n\n format(\"<%s:%s val='%s'/>\", namespace, Axlsx.camel(name, false), val)\n end",
"def text\n @tag_data[:text]\n end",
"def label\n if respond_to?(\"#{@attribute}_label\".to_sym)\n send(\"#{@attribute}_label\".to_sym)\n else\n @attribute.to_s.titleize\n end\n end",
"def get_value(element)\n element.value\n end",
"def tagname\n @tagname.id2name\n end",
"def tag( val = nil )\n default :tag, val\n end",
"def element\n \"Attribute\"\n end",
"def raw_attribute(name)\n\t\t\t@node.attribute(name).contents.to_s rescue nil\n\t\tend",
"def getTag\n\t\treturn @tag\n\tend",
"def value\n $tracer.trace(\"\\tAction: #{format_method(__method__)}\")\n label = \"\"\n for i in (0 .. @tag.length - 1)\n if @tag[i].checked == \"true\"\n label =@tag[i].value\n break\n end\n end\n return label\n end",
"def value\n $tracer.trace(\"\\tAction: #{format_method(__method__)}\")\n label = \"\"\n for i in (0 .. @tag.length - 1)\n if @tag[i].checked == \"true\"\n label =@tag[i].value\n break\n end\n end\n return label\n end",
"def label\n attribute :label\n end",
"def tag(value)\n merge(letag: value.to_s)\n end",
"def get_tag_attr (tag_path, attr_name)\n\n $test_logger.log(\"Get XML tag attribute #{tag_path}, #{attr_name}\")\n\n raise \"XML doc not loaded\" if @xml_ilv_node == nil\n\n #Get target tag\n target_tag = @xml_ilv_node.elements[tag_path]\n\n #Raise exception if no tag is found\n raise \"XML path '#{tag_path}' not found!\" if !target_tag\n\n #Get value from attribute, if exists\n attr_value = nil\n if target_tag.has_attributes?\n attr_obj = target_tag.attributes.get_attribute(attr_name)\n attr_value = attr_obj.value if attr_obj != nil\n end\n\n attr_value\n end",
"def custom_label(key, value)\n return if value == false\n return Allure::ResultUtils.tag_label(value.to_s) if value.is_a?(String) || value.is_a?(Symbol)\n\n Allure::ResultUtils.tag_label(key.to_s)\n end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def value(node, attribute); end",
"def value(node, attribute); end",
"def tag\n @tag ||= to_boolean_phrase.hash.abs.to_s(36)\n end",
"def attribute_user_tag; object_type.tag rescue \"\"; end",
"def get_tag_value_ascii (tag_path)\n\n $test_logger.log(\"Get tag value in ASCII #{tag_path}\")\n\n #Get tag text and data type\n tag_val, data_type = get_tag_value tag_path, true\n\n #Parse int value\n ascii_val = \"\"\n if data_type == DataType::HEX\n ascii_val = ILVMessage.hex_to_raw(tag_val.gsub(HEX_PREFIX, \"\")).reverse\n else\n ascii_val = tag_val\n end\n\n #Return ASCII value\n ascii_val\n end",
"def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end",
"def fetch_attribute(locale, name)\r\n translation = record.translation_for(locale)\r\n return translation && translation.send(name)\r\n end",
"def [](tag)\n to_h[tag.to_sym]\n end",
"def language_tag\n return @language_tag\n end",
"def name\n tag.name\n end",
"def tag_name; end",
"def tag_name; end",
"def tag_name; end",
"def label_from_attribute(attribute)\n attribute.to_s.humanize\n end",
"def list_item_attribute attribute, value, url=nil, url_options={}\n unless url.nil?\n value = link_to value, url, url_options\n end\n return \"<p class=\\\"list_item_attribute\\\"><b>#{attribute}</b>: #{value}</p>\"\n end",
"def tagattr(name, expr, value=nil, escape=true)\n if !expr\n return ''\n elsif escape\n return \" #{name}=\\\"#{escape_xml((value || expr).to_s)}\\\"\"\n else\n return \" #{name}=\\\"#{value || expr}\\\"\"\n end\n end",
"def tag_value(type)\n pattern = reserved_patterns[type]\n tag = tags.detect { |t| t.match?(pattern) }\n return unless tag\n\n tag.match(pattern)[type]\n end",
"def tag_value(prefix)\n tag = nil\n tag = @startup_tags && @startup_tags.detect { |t| t =~ /^#{prefix}/ }\n value = tag[prefix.size + 1..-1] if tag\n value\n end",
"def get_tag_value tag_key_name\n tag = self.tags.joins(:tag_key).where('tagging_tag_keys.name = ?', tag_key_name).includes(:tag_value).first\n tag.try(:tag_value).try(:value)\n end",
"def get(tag)\n @orig[tag]\n end",
"def name\n @attribute.name\n end",
"def attribute(name)\n return attributes[name]\n end",
"def [](attribute_name)\n @attributes[@current_language][attribute_name.to_sym] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n end",
"def label\n read_attr :label\n end",
"def to_sym\n self.tag\n end",
"def value\n attributes['FieldValue']\n end",
"def tag tag_name\n find_element :tag_name, tag_name\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def get(value)\n if value.kind_of? Details::Attribute\n raise \"Invalid attribute! Must be an attribute named #{self.name}\" if value.name != self.name\n value = value.value\n end\n value.strip! if value.kind_of? String\n @values.find { |v| v.value == value }\n end",
"def attr\n @attr || header.downcase\n end",
"def attr\n @attr || header.downcase\n end",
"def on_html_attr(name, value)\n if value[0] == :slim && value[1] == :attrvalue && !options[:merge_attrs][name]\n # We handle the attribute as a boolean attribute\n escape, code = value[2], value[3]\n case code\n when 'true'\n [:html, :attr, name, [:multi]]\n when 'false', 'nil'\n [:multi]\n else\n tmp = unique_name\n [:multi,\n [:code, \"#{tmp} = #{code}\"],\n [:if, tmp,\n [:if, \"#{tmp} == true\",\n [:html, :attr, name, [:multi]],\n [:html, :attr, name, [:escape, escape, [:dynamic, tmp]]]]]]\n end\n else\n # Attribute with merging\n @attr = name\n super\n end\n end"
] |
[
"0.6936106",
"0.6442283",
"0.64139587",
"0.6313943",
"0.62984896",
"0.62946063",
"0.6169126",
"0.61559546",
"0.61121285",
"0.61073935",
"0.61013216",
"0.6090771",
"0.6084936",
"0.6053683",
"0.60321325",
"0.6011387",
"0.6006891",
"0.5995697",
"0.59869564",
"0.5985908",
"0.5947614",
"0.5946754",
"0.5946557",
"0.59366846",
"0.5932102",
"0.5906188",
"0.5905341",
"0.58940625",
"0.5885044",
"0.5881602",
"0.58784264",
"0.5875162",
"0.58642805",
"0.5818608",
"0.5799604",
"0.5799604",
"0.5778647",
"0.57706153",
"0.57663435",
"0.57647496",
"0.57633907",
"0.57633907",
"0.57633907",
"0.57633907",
"0.57633907",
"0.57633907",
"0.57466066",
"0.5739964",
"0.5713684",
"0.57125014",
"0.57026654",
"0.5701348",
"0.5692903",
"0.56915206",
"0.569126",
"0.5689208",
"0.56887716",
"0.5677236",
"0.56673574",
"0.56661874",
"0.56634843",
"0.56430215",
"0.5638417",
"0.5638417",
"0.56322616",
"0.56278414",
"0.5620686",
"0.5617909",
"0.56162566",
"0.5614821",
"0.5614821",
"0.5608435",
"0.55964065",
"0.5581416",
"0.5578433",
"0.5572124",
"0.5567937",
"0.5560978",
"0.555955",
"0.55529886",
"0.55529886",
"0.55529886",
"0.5548654",
"0.5547954",
"0.55469346",
"0.554587",
"0.5530086",
"0.5524321",
"0.5517814",
"0.5508625",
"0.5498064",
"0.54923606",
"0.54903376",
"0.5486891",
"0.5478317",
"0.5469574",
"0.54430324",
"0.5424974",
"0.5417141",
"0.5417141",
"0.54121286"
] |
0.0
|
-1
|
Returns the value of attribute key. source://i18n//lib/i18n/exceptions.rb101
|
def key; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def key\n attributes['key'] or raise NoKeySpecified\n end",
"def _read_attribute(key); end",
"def read_attribute(key)\n @hash[key.to_s]\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def read_attribute(key)\n @attributes[key.to_sym]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def [](key_name)\n read_attribute(key_name)\n rescue MissingAttribute\n nil\n end",
"def translate_property_value(key)\n return resource_translation_matrix.fetch(key) if resource_translation_matrix &&\n resource_translation_matrix.key?(key)\n\n key.to_s\n end",
"def [](key_)\n @attributes[key_.to_s]\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n @attributes.get(key)\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def key\n attributes[:key]\n end",
"def [](key)\n @attributes[key]\n end",
"def get_value(key)\n self[key]\n end",
"def error_key\n self.class.error_key\n end",
"def value_for_key(key)\n if respond_to?(key)\n send key\n elsif attributes.include? key\n attributes[key]\n else\n row.send key\n end\n end",
"def key\n @attributes[:key]\n end",
"def key\n @attributes[:key]\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def get_attribute(dict_name, key, default_value = nil)\n end",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n element=@xml.xpath(key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n element=@xml.elements[key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def key\n @key or raise MissingKey\n end",
"def translate_property_key(value)\n return resource_translation_matrix.key(value) if resource_translation_matrix &&\n resource_translation_matrix.value?(value)\n\n value.to_s\n end",
"def value(key)\n if self[key].present?\n self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_f\n elsif self[:parameters].present? && self[:parameters][key].present?\n return self[:parameters][key]\n elsif self[:extras].present? && self[:extras][key].present?\n return self[:extras][key]\n else\n return \"\"\n end\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def [](key)\n @attributes = Array.new if @attributes.nil?\n attributes_downcase =@attributes.map(&:downcase)\n key.downcase!\n if attributes_downcase.include? key\n return get(key)\n else\n raise 'El atributo no ha sido encontrado en el objecto '+ key\n end\nend",
"def [](k)\n raise \"key #{k} should be symbol but #{k.class}\" unless k.is_a?(Symbol)\n return @attributes[k]\n end",
"def get_property(key)\n @data[key]\n end",
"def [](key)\n @attrs[key]\n end",
"def [](key)\n @attrs[key]\n end",
"def []( key )\n _meta_data[key.to_s]\n end",
"def [](attr_key)\n @attributes[attr_key.to_sym]\n end",
"def read_value(key)\n keys = key.split('.')\n result = @context\n keys.each do |k|\n return nil unless result\n result = result[k]\n end\n return result\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def field(key)\n pdf_field(key).getValueAsString\n rescue NoMethodError\n raise \"unknown key name `#{key}'\"\n end",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def [](key)\n a = @attrs_hash[key.intern]\n if a\n a.value\n else\n nil\n end\n end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def read_key(key)\n raise RuntimeError.new(\"read_key not implemented!\")\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def get(key)\n \n end",
"def [](key)\n @entry[key] || @entry[key.to_s.upcase]\n end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def value_for(key)\n return '' unless self.param_values && self.param_values[key]\n self.param_values[key]\n end",
"def ensure_attribute(root_element, key, type = nil, prefix = nil)\n value = get_attribute(root_element, key, type, prefix)\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"Attribute '#{label}' is missing\" if value.nil?\n value\n end",
"def [](key); self.properties[key.to_s]; end",
"def value_for(resource)\n resource.send(key)\n end",
"def getKey; argSetTextual.to_sym end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def [](attribute_name)\n @attributes[@current_language][attribute_name.to_sym] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def []( key )\n\t\tself.validate unless self.validated?\n\t\treturn @valid[ key.to_sym ]\n\tend",
"def [](key)\n data[key.to_s]\n end",
"def get_attribute(attribute)\n\t\t@attributes[attribute.intern]\n\tend",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def method_name key\n \"value_for_#{key}\"\n end",
"def t(key)\n I18n.translate(key).html_safe\n end",
"def get_string(attr); end",
"def get(key)\n messages[key]\n end",
"def get(key)\n messages[key]\n end",
"def human_attribute_name(attribute_key_name, options = {})\n defaults = self_and_descendants_from_active_resource.map do |klass|\n :\"#{klass.name.underscore}.#{attribute_key_name}\"\n end\n defaults << options[:default] if options[:default]\n defaults.flatten!\n defaults << attribute_key_name.to_s.humanize\n options[:count] ||= 1\n I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activeresource, :attributes]))\n end",
"def [](key)\n @data[key.to_s]\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def [](attr_name)\n attr_name = attr_name.to_sym\n unless @attributes.key?(attr_name)\n raise NameError, \"undefined attribute #{attr_name.inspect}\"\n end\n @attributes[attr_name]\n end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def attr_get(key)\n key_count = 0\n @attrkeys.each do |attrkey|\n if(attrkey == key)\n @attrvals[key_count]\n end\n key_count = key_count + 1\n end\n nil\n end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def [] key\n @attributes[key.to_s]\n end",
"def const_missing (name)\n _, f, k = /(.+?)_(.+)$/.match(name.to_s).to_a\n if _ and instance_methods(false).include? \"enum_field_for_#{f.downcase}\"\n if key_value = send(\"#{f.downcase}_values\").select{|x| x[1].to_s.gsub(/[^\\w_]/, \"_\") == \"#{k.downcase}\"}.first\n return key_value[1]\n end\n end\n super\n end",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def db_value(attribute,code)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n self.eh_params[:db_codes][context][attribute.to_s].key(code)\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def liner_get(key)\n key = key.to_sym\n with_valid_attribute(key) do\n instance_variable_get \"@#{key}\"\n end\n end",
"def get(key)\n @attrs[key].present? ? @attrs[key] : nil\n end",
"def dynamo_attribute_key\n @attr.dynamo_name\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def [] key\n\t\t\t\t@attributes[key]\n\t\t\tend",
"def get_hash_value(hash, key, attribute)\n hash[key][attribute]\n end",
"def [](key)\n\n lookup(key.to_s)\n end",
"def [](key)\n send(\"#{key}\") rescue nil\n end",
"def [](key)\n return nil unless key\n @data[key.to_s] || @data[key.to_sym]\n end"
] |
[
"0.6537088",
"0.6531893",
"0.6525233",
"0.6521474",
"0.6490372",
"0.6469063",
"0.6463172",
"0.6429756",
"0.6308918",
"0.6308918",
"0.6267189",
"0.6199822",
"0.6159743",
"0.6142727",
"0.61229026",
"0.61229026",
"0.6122393",
"0.61192036",
"0.6039653",
"0.5970389",
"0.5970389",
"0.5970389",
"0.5934528",
"0.5928251",
"0.5925474",
"0.5920314",
"0.59130996",
"0.589163",
"0.589163",
"0.58771676",
"0.5844633",
"0.5838267",
"0.58359987",
"0.579175",
"0.57899046",
"0.57846195",
"0.57604635",
"0.5729072",
"0.5725166",
"0.5723832",
"0.570864",
"0.570864",
"0.5704551",
"0.57004607",
"0.56688803",
"0.5656932",
"0.5656932",
"0.56502634",
"0.5641841",
"0.5630118",
"0.56191194",
"0.56147957",
"0.56116444",
"0.5603146",
"0.5581571",
"0.5581524",
"0.557685",
"0.5568097",
"0.5564945",
"0.55603075",
"0.55578184",
"0.55565375",
"0.5556421",
"0.5554377",
"0.5554377",
"0.5553298",
"0.5548257",
"0.5543607",
"0.5539826",
"0.5534651",
"0.5533916",
"0.55332506",
"0.5532927",
"0.5528847",
"0.5517839",
"0.55157685",
"0.55157685",
"0.5508897",
"0.55086935",
"0.5502219",
"0.5496128",
"0.5491016",
"0.5489341",
"0.54652673",
"0.5463978",
"0.546179",
"0.54598397",
"0.5459349",
"0.5456442",
"0.5456442",
"0.5456442",
"0.5456442",
"0.54547507",
"0.5448299",
"0.54457796",
"0.54427016",
"0.5436866",
"0.5436391",
"0.5434606",
"0.54282635",
"0.5427886"
] |
0.0
|
-1
|
Returns the value of attribute string. source://i18n//lib/i18n/exceptions.rb101
|
def string; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_string(attr); end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def get_string_value\n\t\tend",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def error_string\n # This method should be overridden\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def unknown_string\n t('Unknown')\n end",
"def string_value(value)\r\n value\r\n end",
"def error_message\n self[:error_message]\n end",
"def exception_message\n @e_m ||= @exception.nil? ? '' : @exception.message\n end",
"def get_string(field)\n field['stringValue']\n end",
"def error_message_for(attribute)\n case attribute\n when :email, :password, :password_confirmation\n @admin_registration.errors[attribute].join(', ')\n else\n raise \"Error messages not implmeneted for \\\"#{attribute}\\\"\"\n end\n end",
"def error_message(attribute)\n unless @object.errors.on(attribute).blank?\n content_tag(:p, :class => 'notice') do\n concat ERB::Util.html_escape(@object.errors.on(attribute).mb_chars.capitalize)\n end\n else\n ''\n end\n end",
"def get_string_value(field_name)\n\t\tend",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def format_string(record, attribute, val)\n val\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def error_message\n @data[\"message\"]\n end",
"def get(value)\n if value.kind_of? Details::Attribute\n raise \"Invalid attribute! Must be an attribute named #{self.name}\" if value.name != self.name\n value = value.value\n end\n value.strip! if value.kind_of? String\n @values.find { |v| v.value == value }\n end",
"def value\n #BaseData::PlainString.clean_value(self.strings.map(&:value).join)\n string = self.strings.map(&:value).join\n #string.metaclass.instance_eval do\n def string.clean_value\n BaseData::String.clean_value(self)\n end\n #end\n #debugger\n string\n end",
"def message\n msg = \"Format error found in %s tuple: %s\" % [@identifier, @invalid_data.inspect]\n return msg\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def translation(string, attributes)\n string\n end",
"def lookup_string_attribute (attname, workitem, options={})\n\n result = lookup_attribute(attname, workitem, options)\n result = result.to_s if result\n result\n end",
"def value\n raw_value.is_a?(StandardError) ? raise(raw_value) : raw_value\n end",
"def ar_get_resource_value(resource, column)\n return \"Error: #{resource}, #{column}\" unless column && resource\n \n case column\n when String, Symbol\n \n if controller.ardata.foreing_models.include?(column.to_s)\n column.to_s.match(/^(.*)_id$/)\n record= resource.send($1)\n return record ? record.label : controller.ardata.labels[:nil_value_in_field]\n else\n return h(resource.send(column)) || controller.ardata.labels[:nil_value_in_field]\n end\n \n else\n ar_retrieve_field_value column, resource\n end\n end",
"def fault_string\n @fault_string ||= XmlRpc::API::Message.parse_value(\n @document.root.elements[\"fault/value/struct/member[name='faultString']/value\"]) if @document && @document.root \n end",
"def message\n @error['message']\n end",
"def error_msg\n name\n end",
"def value\n @string || to_s\n end",
"def get_value\n read_attribute('text_value')\n end",
"def error_message_from_model(model, attribute, message, extra = {})\n ::ActiveModel::Errors.new(model).generate_message(attribute, message, extra)\n end",
"def value_field\n \"string\"\n end",
"def error_message\n return @error_message\n end",
"def error_msg\n ERROR_MSG[upcase_class_sym]\n end",
"def view_error_text(object, error_key, options = {})\n raise Exception.new(\"Parameter string_name may not be blank\") if error_key.blank?\n \n controller ||= options[:controller] ||= self.controller_name\n\n # If you are on the production server, you can only see strings set to live\n # mode. If you are on a development or staging server, you can see draft or ready status\n language_id = get_current_language_id(options)\n\n # First, try to look up the string in the specified controller\n # Note: we get the one with the highest version number\n translation = I18n::SingletonTranslationKey.translate( :klass => object, \n :language => language_id,\n :key => error_key )\n \n # Model errors are bound directly to an error we do not want to look for this key on the global level \n \n # if we found something, we're good\n return translation.text if translation && translation.text\n\n # if not, we can optionally return an empty string\n if options[:missing_ok] == true\n return \"\"\n else\n # Rather than fail if we can not find the translation, put the key in place of\n # the translation and log a tranlsation error in the i18n.log which is defined in\n # config/initializers/i18n_logger.rb\n language = Language.find(language_id)\n I18N_LOGGER.error \"view_text_lookup: Unable to locate string '#{error_key}' \" +\n \"for language #{language.language} that belongs to object #{object}\"\n return \"trasnlation-missing: #{error_key} - lang: #{language_id}\"\n end\n end",
"def failure_message\n @message\n end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def value\n raise\n end",
"def help_text_for(attribute)\n ::I18n.translate!(attribute[:name], scope: [:alchemy, :resource_help_texts, resource_name])\n rescue ::I18n::MissingTranslationData\n nil\n end",
"def error_message\n error.message\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def get_value(render_context)\n return @message.translate(render_context)\n end",
"def get_exception_with_string\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/error/stringInException'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 444\r\n raise ExceptionWithStringException.new(\r\n 'exception with string',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def exception_variable\n node_parts[1]\n end",
"def attribute_value(string)\n\n attribute_value = ''\n position = 0\n length = string.length\n\n while position < length\n \n # x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then advance position to the next byte, then, repeat this step.\n if string[position] =~ /[\\u{09}\\u{0A}\\u{0C}\\u{0D}\\u{20}]/\n \n position += 1\n\n elsif string[position] =~ /['\"]/\n\n attribute_value, position = quoted_value(string[position, length])\n break\n\n elsif string[position] == '>'\n position += 1\n break\n\n else\n attribute_value, position = unquoted_value(string[position, length])\n break\n end\n end\n\n [attribute_value, position]\n end",
"def string\n @string\n end",
"def string\n @string\n end",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def __value\n unless defined?(@value)\n __get_value\n end\n\n if @value.is_a?(WrappedException)\n ::Kernel.raise @value\n end\n\n @value\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n value = nil\n quoted_string29 = nil\n number30 = nil\n\n begin\n # at line 125:35: ( quoted_string | number )\n # at line 125:35: ( quoted_string | number )\n alt_43 = 2\n look_43_0 = @input.peek( 1 )\n\n if ( look_43_0 == QUOTE )\n alt_43 = 1\n elsif ( look_43_0 == DIGIT )\n alt_43 = 2\n else\n raise NoViableAlternative( \"\", 43, 0 )\n end\n case alt_43\n when 1\n # at line 125:37: quoted_string\n @state.following.push( TOKENS_FOLLOWING_quoted_string_IN_attribute_value_1234 )\n quoted_string29 = quoted_string\n @state.following.pop\n # --> action\n value = quoted_string29 \n # <-- action\n\n when 2\n # at line 125:85: number\n @state.following.push( TOKENS_FOLLOWING_number_IN_attribute_value_1240 )\n number30 = number\n @state.following.pop\n # --> action\n value = ( number30 && @input.to_s( number30.start, number30.stop ) ).to_i \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return value\n end",
"def text\n @value[:text].to_s\n end",
"def get_string\n get_item ? get_item.alert.id : ''\n end",
"def error_message; end",
"def message\n @props.fetch(:message, \"must be valid\")\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def error_message(e)\n fail e\n end",
"def label_from_attribute(attribute)\n attribute.to_s.humanize\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n value = nil\n string30 = nil\n number31 = nil\n\n begin\n # at line 152:35: ( string | number )\n # at line 152:35: ( string | number )\n alt_38 = 2\n look_38_0 = @input.peek(1)\n\n if (look_38_0 == T__14)\n alt_38 = 1\n elsif (look_38_0 == EOF || look_38_0 == DIGIT || look_38_0 == T__11 || look_38_0 == T__33)\n alt_38 = 2\n else\n raise NoViableAlternative(\"\", 38, 0)\n end\n case alt_38\n when 1\n # at line 152:37: string\n @state.following.push(TOKENS_FOLLOWING_string_IN_attribute_value_1142)\n string30 = string\n @state.following.pop\n # --> action\n value = (string30 && @input.to_s(string30.start, string30.stop))\n # <-- action\n\n when 2\n # at line 152:71: number\n @state.following.push(TOKENS_FOLLOWING_number_IN_attribute_value_1148)\n number31 = number\n @state.following.pop\n # --> action\n value = (number31 && @input.to_s(number31.start, number31.stop)).to_i\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end\n\n return value\n end",
"def describe_error\n message = \"\"\n if self.account_number == nil\n message = message + I18n.t(:wrong_or_missing_account_number, :scope => [:model, :index]) + \" \"\n end\n if self.account_bank_number == nil\n message = message + I18n.t(:wrong_or_missing_account_bank_number, :scope => [:model, :index]) + \" \"\n end\n if self.student.uic == nil\n message = message + I18n.t(:missing_uic, :scope => [:model, :index]) + \" \"\n end\n if self.sident == -666\n message = message + I18n.t(:missing_sident_666, :scope => [:model, :index]) + \" \"\n end\n if self.sident == nil\n message = message + I18n.t(:missing_sident, :scope => [:model, :index]) + \" \"\n end\n return message\n\n end",
"def make_valuestring\n\t\treturn self.value\n\tend",
"def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def attribute_get(attribute)\n check_attribute!(attribute)\n send(attribute.to_s)\n end",
"def attribute_get(attribute)\n check_attribute!(attribute)\n send(attribute.to_s)\n end",
"def get_char(attr); end",
"def attr\n @attr || header.downcase\n end",
"def attr\n @attr || header.downcase\n end",
"def value_for(field)\n value = instance_variable_get(:\"@#{field}\")\n value.nil? ? nil : value.to_s\n end",
"def error_text(error_code)\n ERRORS[error_code.to_i]\n end",
"def error(attr, text)\n errors[attr] ||= []\n errors[attr] << text\n end",
"def error_message(value)\n set_dsl(:error_message, value)\n end",
"def datatables_instance_get_value(instance, column)\n if column[:attribute]\n val = instance.send(column[:attribute].to_sym)\n return I18n.t(val.to_s.to_sym, :default => val.to_s) if not val.nil?\n return ''\n elsif column[:special]\n special = column[:special]\n \n if special[:method]\n return method(special[:method].to_sym).call(instance)\n elsif special[:eval]\n proc = lambda { obj = instance; binding }\n return Kernel.eval(special[:eval], proc.call)\n end\n end\n return \"value not found\"\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def error_message\n @response.reason_phrase\n end",
"def message\n configuration.default_message || @exception.message\n end",
"def getText\n return getProperty('text').to_s\n end",
"def get_string_field(field_name)\n\t\tend",
"def get(string)\n @strings[string]\n end",
"def message\n @errormsg\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def error_name\n self.class.error_name\n end",
"def error_name\n self.class.error_name\n end",
"def full_error(attribute_name, options = T.unsafe(nil)); end",
"def GetValAsString(field_name)\n _invoke(2, [field_name], [VT_BSTR])\n end",
"def meaningful_error_message callback, model, attributes\n rv = \"Unable to #{callback} a #{model.name}\"\n if attributes and !attributes.empty?\n rv << \" with #{attributes.inspect}\"\n end\n end",
"def message\n attributes.fetch(:message)\n end",
"def label\n if respond_to?(\"#{@attribute}_label\".to_sym)\n send(\"#{@attribute}_label\".to_sym)\n else\n @attribute.to_s.titleize\n end\n end",
"def error(string); end",
"def error(string); end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.gsub('.', '_').humanize\n attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)\n I18n.t(:\"hints.format\", \n :default => \"%{attribute} %{message}\",\n :attribute => attr_name,\n :message => message\n )\n end",
"def message # :nodoc:\n @properties['errorMessage'].dup\n end",
"def message\n attributes[:message]\n end"
] |
[
"0.6990498",
"0.63566935",
"0.6330076",
"0.6227711",
"0.6198186",
"0.6198186",
"0.6159626",
"0.6018299",
"0.60011744",
"0.5947088",
"0.5926198",
"0.5907302",
"0.58926356",
"0.5874215",
"0.58702123",
"0.584288",
"0.5828314",
"0.5736146",
"0.57326406",
"0.5714403",
"0.5712049",
"0.57077205",
"0.5701032",
"0.56883353",
"0.5687912",
"0.56538194",
"0.56362724",
"0.56289434",
"0.5609243",
"0.5599921",
"0.5598556",
"0.55925107",
"0.55684733",
"0.55676913",
"0.5560414",
"0.55447656",
"0.5535545",
"0.55346245",
"0.55231375",
"0.5511312",
"0.55104244",
"0.5507633",
"0.5492895",
"0.5490065",
"0.54843944",
"0.5480877",
"0.54652494",
"0.5458045",
"0.54304934",
"0.5426453",
"0.5426453",
"0.54211056",
"0.54211056",
"0.54211056",
"0.54195505",
"0.53911155",
"0.5389147",
"0.536778",
"0.5365007",
"0.53582627",
"0.5353977",
"0.5350563",
"0.5347879",
"0.53466815",
"0.53354985",
"0.532287",
"0.5313517",
"0.53087056",
"0.5308176",
"0.52993715",
"0.52993715",
"0.52963",
"0.5295111",
"0.5295111",
"0.52863216",
"0.5272824",
"0.52726066",
"0.52436686",
"0.5240982",
"0.5229517",
"0.5229517",
"0.52292204",
"0.52286696",
"0.5225227",
"0.52235276",
"0.5223347",
"0.5214759",
"0.5210143",
"0.5200424",
"0.51987803",
"0.51987803",
"0.5198491",
"0.5198154",
"0.5191301",
"0.5191206",
"0.5184367",
"0.5183101",
"0.5183101",
"0.51826257",
"0.5176801",
"0.51744777"
] |
0.0
|
-1
|
Returns the value of attribute values. source://i18n//lib/i18n/exceptions.rb101
|
def values; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def exceptions\n @values['exceptions']\n end",
"def attribute_errors\n errors = []\n self.class.all_attrs.values.each do |attr|\n attr.error_messages(attributes[attr.name]).each do |message|\n errors << \"#{to_s} #{message}\"\n end\n end\n errors\n end",
"def attribute_value\n @attributes.each { | id, value | return value }\n end",
"def user_exceptions\n rightsMetadata.individuals.map {|k, v| k if v == 'exceptions'}.compact \n end",
"def attribute_errors\n {}\n end",
"def user_exceptions\n individuals.map {|k, v| k if v == 'exceptions'}.compact \n end",
"def value\n raise\n end",
"def get_attribute_values() \n @attribute_values_flat\n end",
"def values(language = DEFAULT_LANGUAGE)\n @attributes[language].values.map {|attribute| attribute.value}\n end",
"def values\n @attributes.reject { |k, _| tag_names.include?(k.to_s) }\n end",
"def attribute_values\n attributes.values\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @value.nil?\n invalid_properties.push(\"invalid value for 'value', value cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def [](attribute)\n errors[attribute.to_sym] || []\n end",
"def [](attribute)\n errors[attribute.to_sym] || []\n end",
"def value\n attributes.fetch(:value)\n end",
"def invalid_attributes(model) #:nodoc:\n model.valid? ? [] : model.errors.instance_variable_get(\"@errors\").keys.map(&:to_sym)\n end",
"def enumeration_values\n enumeration = @xml.xpath('./xs:restriction/xs:enumeration', {'xs' => 'http://www.w3.org/2001/XMLSchema'})\n if enumeration.length > 0\n return enumeration.map {|elem| [elem.attributes['value'].value, elem.xpath('./xs:annotation/xs:documentation', {'xs' => 'http://www.w3.org/2001/XMLSchema'}).text]}\n else\n raise \"Not an enumeration\"\n end \n end",
"def values\n @attrs.values\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n value = nil\n string30 = nil\n number31 = nil\n\n begin\n # at line 152:35: ( string | number )\n # at line 152:35: ( string | number )\n alt_38 = 2\n look_38_0 = @input.peek(1)\n\n if (look_38_0 == T__14)\n alt_38 = 1\n elsif (look_38_0 == EOF || look_38_0 == DIGIT || look_38_0 == T__11 || look_38_0 == T__33)\n alt_38 = 2\n else\n raise NoViableAlternative(\"\", 38, 0)\n end\n case alt_38\n when 1\n # at line 152:37: string\n @state.following.push(TOKENS_FOLLOWING_string_IN_attribute_value_1142)\n string30 = string\n @state.following.pop\n # --> action\n value = (string30 && @input.to_s(string30.start, string30.stop))\n # <-- action\n\n when 2\n # at line 152:71: number\n @state.following.push(TOKENS_FOLLOWING_number_IN_attribute_value_1148)\n number31 = number\n @state.following.pop\n # --> action\n value = (number31 && @input.to_s(number31.start, number31.stop)).to_i\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end\n\n return value\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @beez_up_order_item_id.nil?\n invalid_properties.push(\"invalid value for 'beez_up_order_item_id', beez_up_order_item_id cannot be nil.\")\n end\n\n if @order_item_order_item_type.nil?\n invalid_properties.push(\"invalid value for 'order_item_order_item_type', order_item_order_item_type cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def validate_attribute_syntax\n\t\t@values.each do |attribute, values|\n\t\t\t[ values ].flatten.each do |value|\n\t\t\t\tbegin\n\t\t\t\t\tself.get_converted_attribute( attribute.to_sym, value )\n\t\t\t\trescue => err\n\t\t\t\t\tself.log.error \"validation for %p failed: %s: %s\" %\n\t\t\t\t\t\t[ attribute, err.class.name, err.message ]\n\t\t\t\t\tattrtype = self.find_attribute_type( attribute )\n\t\t\t\t\tself.errors.add( attribute, \"isn't a valid %s value\" %\n\t\t\t\t\t\t[ attrtype.syntax ? attrtype.syntax.desc : attrtype.syntax_oid ] )\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def get(value)\n if value.kind_of? Details::Attribute\n raise \"Invalid attribute! Must be an attribute named #{self.name}\" if value.name != self.name\n value = value.value\n end\n value.strip! if value.kind_of? String\n @values.find { |v| v.value == value }\n end",
"def exception_set\n return @children['exception-set'][:value]\n end",
"def values\n messages.values\n end",
"def values\n messages.values\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n value = nil\n quoted_string29 = nil\n number30 = nil\n\n begin\n # at line 125:35: ( quoted_string | number )\n # at line 125:35: ( quoted_string | number )\n alt_43 = 2\n look_43_0 = @input.peek( 1 )\n\n if ( look_43_0 == QUOTE )\n alt_43 = 1\n elsif ( look_43_0 == DIGIT )\n alt_43 = 2\n else\n raise NoViableAlternative( \"\", 43, 0 )\n end\n case alt_43\n when 1\n # at line 125:37: quoted_string\n @state.following.push( TOKENS_FOLLOWING_quoted_string_IN_attribute_value_1234 )\n quoted_string29 = quoted_string\n @state.following.pop\n # --> action\n value = quoted_string29 \n # <-- action\n\n when 2\n # at line 125:85: number\n @state.following.push( TOKENS_FOLLOWING_number_IN_attribute_value_1240 )\n number30 = number\n @state.following.pop\n # --> action\n value = ( number30 && @input.to_s( number30.start, number30.stop ) ).to_i \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return value\n end",
"def format_model_validation_errors(resource)\n resource.errors&.messages&.each_with_object([]) do |(attribute, errors), messages|\n next unless VALIDATION.key?(attribute) || attribute == :base\n\n # NOTE: If the value is a date, the typecast value may not correspond to original user input, so get value_before_type_cast\n unless attribute == :base\n value = VALIDATION.dig(attribute, :checks)&.include?(:date) ? resource.public_send(\"#{attribute}_before_type_cast\") : resource[attribute]\n msg_header = (value ? \"Value '#{value}' for \" : '') + \"'#{VALIDATION[attribute][:label]}'\"\n end\n errors.each do |error_message|\n # Exclude the actual value in logging to avoid PII/PHI\n Rails.logger.info \"Validation Error on: #{attribute}\"\n messages << \"#{msg_header} #{error_message}\".strip\n end\n end\n end",
"def attribute_values\n @columns.map do |column|\n @attributes[column.to_sym]\n end\n end",
"def values\n attribute_nodes.map(&:value)\n end",
"def errors\n @attributes[:errors]\n end",
"def exceptions=(value)\n @values['exceptions'] = value\n end",
"def _get_values\n _fields_map = get_flexi_fields_map\n\n @attributes.map do |k, v|\n field = _fields_map[k]\n raise \"Field - #{k} not defined\" if field.nil?\n VALUE.new(:field => field, value: self.send(:\"#{k}\"))\n end\n end",
"def attr_strings\n @attr_strings\n end",
"def value\n Array.wrap(\n if respond_to?(\"#{@attribute}_value\".to_sym)\n send(\"#{@attribute}_value\".to_sym)\n else\n @value\n end\n )\n end",
"def value\n @attributes[:value]\n end",
"def attribute_values(attributes)\n attributes.map { |attribute| self.send(attribute) }\n end",
"def __value\n unless defined?(@value)\n __get_value\n end\n\n if @value.is_a?(WrappedException)\n ::Kernel.raise @value\n end\n\n @value\n end",
"def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end",
"def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end",
"def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end",
"def error_message_for(attribute)\n case attribute\n when :email, :password, :password_confirmation\n @admin_registration.errors[attribute].join(', ')\n else\n raise \"Error messages not implmeneted for \\\"#{attribute}\\\"\"\n end\n end",
"def exceptions\n @exceptions ||= key[:exceptions]\n end",
"def value\n raw_value.is_a?(StandardError) ? raise(raw_value) : raw_value\n end",
"def values\n valid_criteria[attribute_name].nil? ? {} : valid_criteria[attribute_name][\"values\"]\n end",
"def parse_values(attribute, values)\n values = [amended_previous_value(attribute), values[1]] if opinion&.emendation?\n values = values.map { |value| normalize_line_endings(value) } if attribute == :body\n values\n end",
"def kwattr_values(attribute_name); end",
"def exceptions\n association.options[:except].to_a.collect(&:to_s)\n end",
"def values_at( *attributes )\n\t\treturn attributes.collect do |attribute|\n\t\t\tself[ attribute ]\n\t\tend\n\tend",
"def error_fields\n\t\treturn self.missing | self.invalid.keys\n\tend",
"def error_fields\n\t\treturn self.missing | self.invalid.keys\n\tend",
"def attribute_values\n self.class.attributes.map{ |attr| self.send(attr) }\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @event_time.nil?\n invalid_properties.push(\"invalid value for 'event_time', event_time cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def enum_values\n object.send(\"column_for_attribute\", @method_name).values\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @name.nil?\n invalid_properties.push(\"invalid value for 'name', name cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def attribute_values\n self.class.columns.map { |column| send(column) }\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @currency_code.nil?\n invalid_properties.push(\"invalid value for 'currency_code', currency_code cannot be nil.\")\n end\n\n if @description.nil?\n invalid_properties.push(\"invalid value for 'description', description cannot be nil.\")\n end\n\n if @original_price.nil?\n invalid_properties.push(\"invalid value for 'original_price', original_price cannot be nil.\")\n end\n\n if @sku.nil?\n invalid_properties.push(\"invalid value for 'sku', sku cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @state.nil?\n invalid_properties.push(\"invalid value for 'state', state cannot be nil.\")\n end\n\n if @organization_id.nil?\n invalid_properties.push(\"invalid value for 'organization_id', organization_id cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def attribute_values\n self.class.columns.map { |col| self.send(col) }\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @quantity.nil?\n invalid_properties.push('invalid value for \"quantity\", quantity cannot be nil.')\n end\n\n if @unit_price.nil?\n invalid_properties.push('invalid value for \"unit_price\", unit_price cannot be nil.')\n end\n\n invalid_properties\n end",
"def semantic_values\n [semantic_value]\n end",
"def get_value\n read_attribute('text_value')\n end",
"def attribute_values\n @attribute_values ||= {}\n end",
"def errors\n \"Missing value for <#{name}> field\" if required && !@value\n end",
"def value element_name\n begin\n el_attribute = el element_name\n el_attribute.attribute('value')\n rescue Exception => e\n $LOG.error \"error in getting element value \\n element name : #{element_name} \"+e.message\n raise \"error in getting element value \\n element name : #{element_name} \"+e.message\n end\n end",
"def exceptions\n return @exceptions\n end",
"def exceptions\n return @exceptions\n end",
"def get_values(attribute)\n obj = @map[attribute]\n if obj\n if obj.respond_to?(:each)\n return obj\n end\n end\n\n raise IllegalStateException, \"Tha attribute #{attribute} doesn't have a paired string array.\"\n end",
"def customise_error_values(values)\n values[:collection] = @collection_desc || 'items'\n\n if @relativity == :between\n values[:lower] = @expected.first\n values[:upper] = @expected.last\n end\n\n values\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def attribute_values\n self.class.columns.map { |attr| self.send(attr) }\n end",
"def customise_error_values(values)\n values[:expected] = Ward::Errors.format_exclusive_list(@expected)\n values\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @audit.nil?\n invalid_properties.push('invalid value for \"audit\", audit cannot be nil.')\n end\n\n if @comp.nil?\n invalid_properties.push('invalid value for \"comp\", comp cannot be nil.')\n end\n\n if @subcomp.nil?\n invalid_properties.push('invalid value for \"subcomp\", subcomp cannot be nil.')\n end\n\n invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @title_code.nil?\n invalid_properties.push(\"invalid value for 'title_code', title_code cannot be nil.\")\n end\n\n if @_class.nil?\n invalid_properties.push(\"invalid value for '_class', _class cannot be nil.\")\n end\n\n if @tenure.nil?\n invalid_properties.push(\"invalid value for 'tenure', tenure cannot be nil.\")\n end\n\n if @commonhold.nil?\n invalid_properties.push(\"invalid value for 'commonhold', commonhold cannot be nil.\")\n end\n\n if @addresses.nil?\n invalid_properties.push(\"invalid value for 'addresses', addresses cannot be nil.\")\n end\n\n if @is_not_main_title.nil?\n invalid_properties.push(\"invalid value for 'is_not_main_title', is_not_main_title cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @account_id.nil?\n invalid_properties.push(\"invalid value for 'account_id', account_id cannot be nil.\")\n end\n\n if @product.nil?\n invalid_properties.push(\"invalid value for 'product', product cannot be nil.\")\n end\n\n if @product_rate_plan.nil?\n invalid_properties.push(\"invalid value for 'product_rate_plan', product_rate_plan cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def value\n values.map { |v| v.value }\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @input_currency.nil?\n invalid_properties.push('invalid value for \"input_currency\", input_currency cannot be nil.')\n end\n\n if @sender.nil?\n invalid_properties.push('invalid value for \"sender\", sender cannot be nil.')\n end\n\n if @recipients.nil?\n invalid_properties.push('invalid value for \"recipients\", recipients cannot be nil.')\n end\n\n invalid_properties\n end",
"def value\n attributes['FieldValue']\n end",
"def attribute_changed_value_message=(_arg0); end",
"def items\n self.attrs[:value].items\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @type.nil?\n invalid_properties.push(\"invalid value for 'type', type cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @type.nil?\n invalid_properties.push(\"invalid value for 'type', type cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def values\n enumerations.dig(type, :values)\n end",
"def get_value(render_context)\n return @message.translate(render_context)\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if @containers.nil?\n invalid_properties.push(\"invalid value for 'containers', containers cannot be nil.\")\n end\n\n return invalid_properties\n end",
"def error_fields\n errors.messages.keys.map(&:to_s).join(', ')\n end",
"def list_invalid_properties\r\n invalid_properties = Array.new\r\n return invalid_properties\r\n end",
"def value\n #BaseData::PlainString.clean_value(self.strings.map(&:value).join)\n string = self.strings.map(&:value).join\n #string.metaclass.instance_eval do\n def string.clean_value\n BaseData::String.clean_value(self)\n end\n #end\n #debugger\n string\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def check_schema_values(resource)\n bad_vals = {}\n resource.each do |key, value|\n next unless attributes[key]\n type = @data_type_cache[attributes[key][:type]]\n is_sensitive = (attributes[key].key?(:sensitive) && (attributes[key][:sensitive] == true))\n error_message = Puppet::ResourceApi::DataTypeHandling.try_validate(\n type,\n value,\n '',\n )\n if is_sensitive\n bad_vals[key] = '<< redacted value >> ' + error_message unless error_message.nil?\n else\n bad_vals[key] = \"#{value} (#{error_message})\" unless error_message.nil?\n end\n end\n bad_vals\n end",
"def exceptions\n exceptions_node = node_parts[0]\n if exceptions_node.nil?\n []\n elsif exceptions_node.array_type?\n exceptions_node.values\n else\n [exceptions_node]\n end\n end",
"def parse_attribute_values\n values = []\n each_property do |name, value|\n values << AttributeValue.new(name, value)\n end\n\n DEFAULTS.each do |default|\n if values.find { |v| v.attribute.name == default.attribute.name }.nil?\n values << default\n end\n end\n\n values\n end",
"def values_for(entry)\n enumerations.dig(entry.to_sym, :values)\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def investigate_invalid_values!\n invalids = @pattern.split(/,|\\/|\\-/).uniq.collect do |value|\n value unless self.class.allowed_values.to_a.include?(value.upcase)\n end.compact\n invalids.delete(\"*\")\n\n err = nil\n if invalids.include?('') || invalids.include?(' ')\n err = \"#{field_name} field's pattern is invalid, please run:\n '#{self.class}.allowed_values' to know valid values\".squish\n elsif invalids.any?\n err = \"value: '#{invalids.join(', ')}' not allowed for '#{field_name}'\n field, run: '#{self.class}.allowed_values' to know valid values\".squish\n end\n raise self.invalid_field_error_class.new(err) if err\n end",
"def result_attrs\n main_result[\"@attr\"] rescue {}\n end",
"def values\n to_enum(:each_value).to_a\n end"
] |
[
"0.68621975",
"0.6014565",
"0.5986756",
"0.5940006",
"0.590028",
"0.58686674",
"0.58294743",
"0.57989454",
"0.5791069",
"0.5759251",
"0.57191104",
"0.5704403",
"0.5681387",
"0.5681387",
"0.5680825",
"0.5674279",
"0.5648006",
"0.56090575",
"0.5607465",
"0.5607465",
"0.56039923",
"0.5573682",
"0.55664223",
"0.5560124",
"0.5536478",
"0.55309135",
"0.55309135",
"0.5514915",
"0.55044335",
"0.5492966",
"0.5488838",
"0.5480194",
"0.54703325",
"0.54700416",
"0.54616797",
"0.5448466",
"0.5443801",
"0.54424685",
"0.54415166",
"0.5440407",
"0.5412844",
"0.5412844",
"0.5412844",
"0.54049814",
"0.54046965",
"0.5363701",
"0.53555053",
"0.5353009",
"0.53486264",
"0.5342388",
"0.53369415",
"0.53219694",
"0.53219694",
"0.53162014",
"0.5314471",
"0.53100073",
"0.530757",
"0.52986103",
"0.529779",
"0.5269149",
"0.526625",
"0.52630025",
"0.5261379",
"0.52573985",
"0.5253738",
"0.52464247",
"0.52445436",
"0.52407134",
"0.52407134",
"0.524056",
"0.52396834",
"0.5238223",
"0.52176255",
"0.52166176",
"0.5211205",
"0.520276",
"0.5202222",
"0.5189828",
"0.5183181",
"0.51812834",
"0.51723206",
"0.51676744",
"0.5163854",
"0.5162103",
"0.5162103",
"0.51601505",
"0.5153606",
"0.5150895",
"0.51485306",
"0.5143678",
"0.5142489",
"0.51399845",
"0.5136526",
"0.51312923",
"0.5129732",
"0.51240015",
"0.51231116",
"0.51197094",
"0.51195383",
"0.5119407",
"0.51176727"
] |
0.0
|
-1
|
Returns the value of attribute key. source://i18n//lib/i18n/exceptions.rb52
|
def key; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key\n attributes['key'] or raise NoKeySpecified\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"def _read_attribute(key); end",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def read_attribute(key)\n @hash[key.to_s]\n end",
"def read_attribute(key)\n @attributes[key.to_sym]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def [](key_name)\n read_attribute(key_name)\n rescue MissingAttribute\n nil\n end",
"def [](key_)\n @attributes[key_.to_s]\n end",
"def translate_property_value(key)\n return resource_translation_matrix.fetch(key) if resource_translation_matrix &&\n resource_translation_matrix.key?(key)\n\n key.to_s\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def [](key)\n @attributes.get(key)\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def error_key\n self.class.error_key\n end",
"def key\n attributes[:key]\n end",
"def value_for_key(key)\n if respond_to?(key)\n send key\n elsif attributes.include? key\n attributes[key]\n else\n row.send key\n end\n end",
"def key\n @attributes[:key]\n end",
"def key\n @attributes[:key]\n end",
"def [](key)\n @attributes[key]\n end",
"def get_value(key)\n self[key]\n end",
"def key\n @key or raise MissingKey\n end",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n element=@xml.xpath(key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n element=@xml.elements[key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def get_attribute(dict_name, key, default_value = nil)\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def value(key)\n if self[key].present?\n self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_f\n elsif self[:parameters].present? && self[:parameters][key].present?\n return self[:parameters][key]\n elsif self[:extras].present? && self[:extras][key].present?\n return self[:extras][key]\n else\n return \"\"\n end\n end",
"def [](k)\n raise \"key #{k} should be symbol but #{k.class}\" unless k.is_a?(Symbol)\n return @attributes[k]\n end",
"def translate_property_key(value)\n return resource_translation_matrix.key(value) if resource_translation_matrix &&\n resource_translation_matrix.value?(value)\n\n value.to_s\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def [](attr_key)\n @attributes[attr_key.to_sym]\n end",
"def [](key)\n @attrs[key]\n end",
"def [](key)\n @attrs[key]\n end",
"def []( key )\n _meta_data[key.to_s]\n end",
"def get_property(key)\n @data[key]\n end",
"def [](key)\n @attributes = Array.new if @attributes.nil?\n attributes_downcase =@attributes.map(&:downcase)\n key.downcase!\n if attributes_downcase.include? key\n return get(key)\n else\n raise 'El atributo no ha sido encontrado en el objecto '+ key\n end\nend",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def [](key)\n a = @attrs_hash[key.intern]\n if a\n a.value\n else\n nil\n end\n end",
"def read_value(key)\n keys = key.split('.')\n result = @context\n keys.each do |k|\n return nil unless result\n result = result[k]\n end\n return result\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def field(key)\n pdf_field(key).getValueAsString\n rescue NoMethodError\n raise \"unknown key name `#{key}'\"\n end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def read_key(key)\n raise RuntimeError.new(\"read_key not implemented!\")\n end",
"def ensure_attribute(root_element, key, type = nil, prefix = nil)\n value = get_attribute(root_element, key, type, prefix)\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"Attribute '#{label}' is missing\" if value.nil?\n value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def get(key)\n \n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def value_for(key)\n return '' unless self.param_values && self.param_values[key]\n self.param_values[key]\n end",
"def [](attribute_name)\n @attributes[@current_language][attribute_name.to_sym] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n end",
"def getKey; argSetTextual.to_sym end",
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def value_for(resource)\n resource.send(key)\n end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def []( key )\n\t\tself.validate unless self.validated?\n\t\treturn @valid[ key.to_sym ]\n\tend",
"def get_attribute(attribute)\n\t\t@attributes[attribute.intern]\n\tend",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def method_name key\n \"value_for_#{key}\"\n end",
"def [](key)\n data[key.to_s]\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def [](attr_name)\n attr_name = attr_name.to_sym\n unless @attributes.key?(attr_name)\n raise NameError, \"undefined attribute #{attr_name.inspect}\"\n end\n @attributes[attr_name]\n end",
"def [](key)\n @entry[key] || @entry[key.to_s.upcase]\n end",
"def [](key); self.properties[key.to_s]; end",
"def dynamo_attribute_key\n @attr.dynamo_name\n end",
"def human_attribute_name(attribute_key_name, options = {})\n defaults = self_and_descendants_from_active_resource.map do |klass|\n :\"#{klass.name.underscore}.#{attribute_key_name}\"\n end\n defaults << options[:default] if options[:default]\n defaults.flatten!\n defaults << attribute_key_name.to_s.humanize\n options[:count] ||= 1\n I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activeresource, :attributes]))\n end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def attr_get(key)\n key_count = 0\n @attrkeys.each do |attrkey|\n if(attrkey == key)\n @attrvals[key_count]\n end\n key_count = key_count + 1\n end\n nil\n end",
"def t(key)\n I18n.translate(key).html_safe\n end",
"def get_string(attr); end",
"def [](key)\n @data[key.to_s]\n end",
"def [] key\n @attributes[key.to_s]\n end",
"def get(key)\n messages[key]\n end",
"def get(key)\n messages[key]\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def get(key)\n @attrs[key].present? ? @attrs[key] : nil\n end",
"def db_value(attribute,code)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n self.eh_params[:db_codes][context][attribute.to_s].key(code)\n end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def const_missing (name)\n _, f, k = /(.+?)_(.+)$/.match(name.to_s).to_a\n if _ and instance_methods(false).include? \"enum_field_for_#{f.downcase}\"\n if key_value = send(\"#{f.downcase}_values\").select{|x| x[1].to_s.gsub(/[^\\w_]/, \"_\") == \"#{k.downcase}\"}.first\n return key_value[1]\n end\n end\n super\n end",
"def [] key\n\t\t\t\t@attributes[key]\n\t\t\tend",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def error_message\n self[:error_message]\n end",
"def get_item_value(key)\n @attributes[key] = get_item_record(key) unless @attributes.has_key?(key)\n @attributes[key]\n end",
"def liner_get(key)\n key = key.to_sym\n with_valid_attribute(key) do\n instance_variable_get \"@#{key}\"\n end\n end",
"def symbolyze_key(key)\n key.to_sym rescue key\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get_hash_value(hash, key, attribute)\n hash[key][attribute]\n end",
"def [](key)\n return nil unless key\n @data[key.to_s] || @data[key.to_sym]\n end"
] |
[
"0.6566014",
"0.65287936",
"0.6526084",
"0.6514951",
"0.65076464",
"0.64971024",
"0.64884686",
"0.6451801",
"0.6315732",
"0.6315732",
"0.6285044",
"0.6172765",
"0.6160449",
"0.6133987",
"0.6130529",
"0.6130529",
"0.61150324",
"0.6101438",
"0.60496014",
"0.59742546",
"0.59742546",
"0.59742546",
"0.5968921",
"0.5968689",
"0.59253263",
"0.5924986",
"0.5924986",
"0.59187835",
"0.59165245",
"0.58683246",
"0.5837581",
"0.58371204",
"0.5837055",
"0.5802089",
"0.57862836",
"0.5777117",
"0.5766891",
"0.57630455",
"0.5713538",
"0.57117814",
"0.57117814",
"0.5700016",
"0.5686824",
"0.56787807",
"0.56593657",
"0.56593657",
"0.56539786",
"0.56530297",
"0.56352806",
"0.56274515",
"0.5613723",
"0.5606612",
"0.5601955",
"0.5586077",
"0.557928",
"0.557928",
"0.5565624",
"0.55553705",
"0.55505365",
"0.55467373",
"0.554231",
"0.554131",
"0.55384785",
"0.55363464",
"0.5534339",
"0.55280864",
"0.55272734",
"0.55262744",
"0.55200064",
"0.55170745",
"0.5515284",
"0.5514386",
"0.55125874",
"0.55089813",
"0.55037755",
"0.5494616",
"0.54913497",
"0.54903924",
"0.5489067",
"0.54834443",
"0.5480158",
"0.54707515",
"0.54702467",
"0.54702467",
"0.5465783",
"0.5457409",
"0.54565907",
"0.54559195",
"0.54511744",
"0.5445117",
"0.54416335",
"0.544069",
"0.54307467",
"0.54271424",
"0.5416614",
"0.5415355",
"0.5415355",
"0.5415355",
"0.5415355",
"0.54140466",
"0.5412415"
] |
0.0
|
-1
|
Returns the value of attribute locale. source://i18n//lib/i18n/exceptions.rb52
|
def locale; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locale\r\n read_attribute(:locale).to_sym\r\n end",
"def locale\n return nil if errors\n\n locale = YAML.safe_load(@text).keys.first\n locale.to_sym\n end",
"def locale\n return @locale\n end",
"def locale\n return @locale\n end",
"def locale\n if self.language\n LANGUAGE_CODE[self.language]\n end\n end",
"def get(locale = Localization.default_locale)\n @locales[locale.to_s]\n end",
"def read_locale\n raise \"Override me\"\n end",
"def translation(locale=nil)\n return translation_for(:value, locale)\n end",
"def lang locale\n if translations.find_by(locale: locale).try(:automated?)\n \"#{locale}-x-mtfrom-de\"\n else\n locale.to_s\n end\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale_in_context(locale)\n return @locale if @locale && @locale.code == locale.to_s\n #Locale.find_by_code(locale.to_s) rescue nil && (raise InvalidLocale.new(locale))\n locale = Locale.find_by_code(locale.to_s)\n raise InvalidLocale.new(locale) unless locale\n locale\n end",
"def locale\n if !language.nil?\n language.abbreviation\n elsif !org.nil?\n org.locale\n end\n end",
"def locale\n self.padma.try :locale\n end",
"def get_native_locale_attribute attribute, locale = Globalize.locale\n return self.send(attribute) unless translatable?\n\n if globalize.stash.contains?(locale, attribute)\n globalize.stash.read(locale, attribute)\n else\n translation_for(locale).send(attribute)\n end\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end",
"def locale=(value)\n @locale = value\n end",
"def locale=(value)\n @locale = value\n end",
"def get_locale(locale = nil)\n locale || @_deco_locale || (h.cama_get_i18n_frontend rescue nil) || I18n.locale\n end",
"def locale=(value); end",
"def locale\n @values.fetch('ai.device.locale') { \n @values['ai.device.locale'] = nil\n }\n end",
"def locale\n frontmatter_locale = data['locale'] || data['lang']\n filename_locale = path_part('locale') || path_part('lang')\n\n raise \"The locale in #{path}'s filename (#{filename_locale.inspect}) doesn't match the lang in its frontmatter (#{frontmatter_locale.inspect})\" if frontmatter_locale && filename_locale && frontmatter_locale != filename_locale\n\n default_locale = I18n.default_locale if defined? ::I18n\n\n found_locale = frontmatter_locale || filename_locale || default_locale\n found_locale&.to_sym\n end",
"def locale\n @locale || YodleeApi.locale\n end",
"def locale_language(locale = nil)\n (locale || I18n.locale).to_s.match(/^(\\w{2})/) ? $1.to_sym : nil\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n elsif !self.org.nil?\n return self.org.get_locale\n else\n return nil\n end\n end",
"def locale\n defined?(I18n) ? I18n.locale : default_locale\n end",
"def locale\n @locale || { :country => \"US\", :language => \"en\", :variant => nil }\n end",
"def locale_language(locale=nil)\n \"#{locale || I18n.locale}\"[0, 2].to_sym\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def locale(locale)\n if default?\n locale.to_s\n else\n \"#{self.name}_#{locale.to_s}\"\n end\n end",
"def getLocaleCode\n # first default locale to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # next set locale to the locale in user record\n @locale_code = current_user.try(:locale) || @locale_code\n # next set locale to the locale passed as the locale param\n if (params.present? &&\n params['locale'].present? &&\n BaseRec::VALID_LOCALES.include?(params['locale'].to_s)\n )\n @locale_code = params['locale']\n end\n # set the locale in I18n\n I18n.locale = @locale_code\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n end",
"def locale\n @grpc.locale\n end",
"def locale\n @grpc.locale\n end",
"def locale=(locale); end",
"def po_locale\n @po_locale\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale\n sys && sys[:locale] ? sys[:locale] : default_locale\n end",
"def locale=(_arg0); end",
"def extract_locale_from_request\r\n # locale defined in parameters\r\n return params[:locale] if params[:locale]\r\n # get locale from subdomains\r\n parsed_locale = request.subdomains.first\r\n return parsed_locale if I18n.available_locales.map(&:to_s).include?(parsed_locale)\r\n # get locale from http header\r\n return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\r\n # get default locale\r\n return I18n.default_locale\r\n end",
"def locale=(locale)\r\n write_attribute(:locale, locale.to_s)\r\n end",
"def locale_name\n YAML.load(translation || \"{}\").with_indifferent_access[locale] || survey.default_locale_name\n end",
"def locale=(locale)\n Thread.current[:locale] = locale.to_s\n end",
"def locale\n favored_locale\n end",
"def extract_locale_from_request\r\n # locale defined in parameters\r\n return params[:locale] if params[:locale]\r\n # get locale from subdomains\r\n parsed_locale = request.subdomains.first\r\n return parsed_locale if I18n.available_locales.map(&:to_s).include?(parsed_locale)\r\n # get locale from http header\r\n return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\r\n # get default locale\r\n return I18n.default_locale\r\n end",
"def correct_locale\n (locales.select{|loc|loc.locale == I18n.locale.to_s}.first || locales.first)\n end",
"def fallback_localization(locale, key_without_locale)\n value = nil\n return nil unless fallbacks = ::Rails.application.config.i18n.fallbacks\n keys = fallbacks == true ? @locale_cache.keys : fallbacks\n keys.map(&:to_s).each do |lc|\n if lc != locale.locale && value.nil?\n nk = \"#{lc}.#{key_without_locale}\"\n v = localizations[nk]\n value = v if v.present? && value.nil?\n end\n end\n value\n end",
"def extract_locale_from_session\n session[:locale] || nil\n end",
"def i18n(locale)\n selected_locale = self.i18ns.select{|i18n| i18n.locale_id == locale.id }\n return selected_locale.first if selected_locale.any?\n\n self.i18ns.first\n end",
"def locale_from_http_header\n language = request.env['HTTP_ACCEPT_LANGUAGE']\n unless language.blank?\n http_locale = language.scan(/^[a-z]{2}-[A-Z]{2}/)\n unless http_locale.blank?\n http_locale = http_locale.first\n else\n http_locale = language.scan(/^[a-z]{2}/).first\n end\n end\n end",
"def default_locale; end",
"def translate(attribute, locale_tag)\n if locale = DataMapper::I18n::Locale.for(locale_tag)\n t = resource.translations.first(:locale => locale)\n t ? t.send(attribute) : nil\n else\n nil\n end\n end",
"def locale\n lang = params.fetch(:language, I18n.default_locale).to_sym\n I18n.available_locales.include?(lang) ? lang : I18n.default_locale\n end",
"def find_locale\n locale = locales.all.detect(&:default)\n return locale.code if locale\n\n default_locale\n end",
"def verify_locale(locale)\n (site_locales.include? locale.to_s) ? locale : preferred_default_locale\n end",
"def get_locale\n I18n.locale = session[:i18n] || I18n.default_locale || :en\n end",
"def get_matching_ui_locale(locale)\n lang = locale[0,2].downcase\n\n # Check with exact matching\n if Globalite.ui_locales.values.include?(local_case(locale))\n local_case(locale)\n end\n\n # Check on the language only\n Globalite.ui_locales.values.each do |value|\n value.to_s =~ /#{lang}-*/ ? value : nil\n end\n end",
"def locale\n current_site.locale || I18n.default_locale.to_s\n end",
"def locale_from_env\n locale = nil\n # At least one environment valiables should be set on *nix system.\n [ENV[\"LC_ALL\"], ENV[\"LC_MESSAGES\"], ENV[\"LANG\"]].each do |loc|\n\tif loc != nil and loc.size > 0\n\t locale = Locale::Object.new(loc)\n\t locale.charset ||= get_charset(locale)\n\t break\n\tend\n end\n locale\n end",
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def verify_locale(locale)\n site_locales.include?(locale.to_s) ? locale : preferred_default_locale\n end",
"def find_by_locale(locale)\r\n with_locale(locale.to_s).first\r\n end",
"def header_locale\n options = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '').split(',')\n # clear out preference values; assume they'll be in order\n options.map! { |v| v.split(';')[0] }\n options.each do |v|\n return locale_matches[v] if locale_matches.keys.include?(v)\n end\n I18n.default_locale\n end",
"def locale_backend; end",
"def language #:nodoc\n return '' if read_attribute(:language).nil?\n read_attribute(:language).to_sym\n end",
"def locale=(value)\n super(value.blank? ? nil : value)\n end",
"def getLocaleCode\n locp = params['locale'].to_s\n locc = cookies['locale'].to_s\n if (\n locp.present? &&\n BaseRec::VALID_LOCALES.include?(locp)\n )\n # first set locale to the locale passed as the locale param\n @locale_code = locp\n elsif (\n locc.present? &&\n BaseRec::VALID_LOCALES.include?(locc)\n )\n # next default locale to cookie:\n @locale_code = locc\n else\n # next set it to default locale\n @locale_code = Rails.application.config.i18n.default_locale\n # # next set locale to the locale in user record\n # @locale_code = current_user.try(:locale) || @locale_code\n end\n # set the locale in I18n\n Rails.logger.debug \"@locale_code: #{@locale_code.inspect}\"\n I18n.locale = @locale_code\n cookies[:locale] = @locale_code\n end",
"def system\n locale_from_env || default_locale\n end",
"def name\n n = names\n return nil if n.nil?\n\n @locales.each do |locale|\n return n[locale] if n.key?(locale)\n end\n\n nil\n end",
"def get_locale_from_subdomain\n locale = @rh.match( /(.+)\\.demowatch\\.[a-z]{2,3}$/i)[1]\n return locale if ( I18N_ALL_LANGUAGES.include?( locale))\n return nil\n end",
"def locale=(value)\n if value == @defaults['ai.device.locale']\n @values.delete 'ai.device.locale' if @values.key? 'ai.device.locale'\n else\n @values['ai.device.locale'] = value\n end\n end",
"def default_locale\n (self.locales.first || Locomotive::Mounter.locale).to_sym\n end",
"def current_locale\n Thread.current[:\"localite:locale\"] || base\n end",
"def locale\n (self.country.blank? or self.country.indonesia?) ? :id : :en\n end",
"def get_locale_from_http_header\n return DEFAULT_LANGUAGE if request.env['HTTP_ACCEPT_LANGUAGE'].nil?\n locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first\n return locale if I18N_ALL_LANGUAGES.include?( locale)\n return DEFAULT_LANGUAGE\n end",
"def lookup(locale, key)\n cache_key = Translation.ck(locale, key)\n if @cache_store.exist?(cache_key) && value = @cache_store.read(cache_key)\n return value\n else\n translations = locale.translations.find_all_by_key(Translation.hk(key))\n case translations.size\n when 0\n value = nil\n when 1\n value = translations.first.value_or_default\n else\n value = translations.inject([]) do |values, t| \n values[t.pluralization_index] = t.value_or_default\n values\n end\n end\n\n @cache_store.write(cache_key, (value.nil? ? nil : value))\n return value\n end\n end",
"def current_locale\n I18n.locale.to_sym || I18n.default_locale.to_sym || I18n.available_locales.first.to_sym\n end",
"def valid_language\n locale = extract_locale_from_accept_language_header\n logger.debug \"* Extracted Locale ID: #{locale}\"\n if !locale.blank? &&\n (locale == 'de' ||\n locale == 'en')\n locale\n else\n DEFAULT_LANGUAGE\n end\n end",
"def valid_language\n locale = extract_locale_from_accept_language_header\n logger.debug \"* Extracted Locale ID: #{locale}\"\n if !locale.blank? &&\n (locale == 'de' ||\n locale == 'en')\n locale\n else\n DEFAULT_LANGUAGE\n end\n end",
"def get_locale_from_session\n if (session && session[:language])\n logger.debug \"*** Language from Session '#{session[:language]}'\"\n lang = session[:language]\n else\n lang = default_language\n end\n lang\n end",
"def extract_locale_from_accept_language_header\n browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first.to_sym\n return nil unless I18n.available_locales.include? browser_locale\n browser_locale\n end",
"def fetch_attribute(locale, name)\r\n translation = record.translation_for(locale)\r\n return translation && translation.send(name)\r\n end",
"def extract_locale_from_accept_language_header\n locale = \"en_US\"\n locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first \\\n if not request.env['HTTP_ACCEPT_LANGUAGE'].nil?\n return locale\n end",
"def payment_compatible_locale(locale)\n locale = locale.to_s.split(\"-\").first\n if [\"fr\", \"en\", \"es\", \"it\", \"pt\", \"de\", \"nl\", \"fi\"].include?(locale)\n return locale\n else\n return \"en\"\n end\n end",
"def another_locale\n I18n.available_locales.map(&:to_sym).select {|locale| locale != I18n.locale.to_sym }.first\n end",
"def get_locale_from_params \n return nil unless params[:locale]\n I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil\n end",
"def message_language\n return @message_language\n end",
"def i18n_name(locale = I18n.locale.to_s)\n ([self[Type.i18n_name_field(locale)], self.name].reject(&:blank?).first)\n end",
"def get_locale_from_params \n return nil unless params[:locale]\n I18n.available_locales.include?(params[:locale].to_sym) ? params[:locale] : nil\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : available_locales[0]\n end",
"def detect_locale_from(source)\n case source\n when :params\n params[:locale]\n when :session\n logger.debug \"Session: #{session.inspect}\"\n session[:locale]\n when :cookie\n cookies[:locale]\n when :domain\n parse_host_and_port_for_locale[0]\n when :header\n request.env['HTTP_ACCEPT_LANGUAGE']\n when :default\n default_locale\n else\n raise \"unknown source\"\n end\n end",
"def to_deepl_compatible_locale(locale)\n locale.to_s.split('-', 2).first.upcase\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def apply_locale; end",
"def read(locale, name)\r\n self[locale][name.to_s]\r\n end"
] |
[
"0.7582414",
"0.72378975",
"0.7186267",
"0.7186267",
"0.7050338",
"0.68463755",
"0.68450034",
"0.68023676",
"0.6683615",
"0.66830313",
"0.66830313",
"0.6653649",
"0.66487956",
"0.6629406",
"0.6610411",
"0.6580387",
"0.6554843",
"0.6554843",
"0.65383667",
"0.6520241",
"0.650237",
"0.6441375",
"0.6436192",
"0.64320254",
"0.6332313",
"0.62851053",
"0.6242478",
"0.6236851",
"0.62078875",
"0.61828256",
"0.6170767",
"0.61676574",
"0.61676574",
"0.6153152",
"0.6122074",
"0.6120906",
"0.6120906",
"0.6102111",
"0.608908",
"0.60602295",
"0.6058505",
"0.6045807",
"0.603929",
"0.60385627",
"0.6019443",
"0.59887904",
"0.5976429",
"0.5976276",
"0.5954631",
"0.59492403",
"0.59489095",
"0.5946949",
"0.594551",
"0.590869",
"0.5899609",
"0.58662325",
"0.58654755",
"0.5860868",
"0.58590597",
"0.5851098",
"0.58463365",
"0.5821381",
"0.579207",
"0.5780246",
"0.5772011",
"0.5764387",
"0.57473505",
"0.5743529",
"0.5732776",
"0.57266945",
"0.57232136",
"0.57210547",
"0.57118976",
"0.5702565",
"0.5701806",
"0.5693186",
"0.56841356",
"0.568406",
"0.5660347",
"0.56547356",
"0.5645762",
"0.5644585",
"0.56324995",
"0.562714",
"0.5620047",
"0.56199867",
"0.5618231",
"0.56163865",
"0.5607132",
"0.5600728",
"0.55972385",
"0.5595368",
"0.55772495",
"0.5572681"
] |
0.65556216
|
20
|
Returns the value of attribute options. source://i18n//lib/i18n/exceptions.rb52
|
def options; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s\n \"Option :#{@option_name} is not a recognised option.\"\n end",
"def options\n attributes.fetch(:options)\n end",
"def value\r\n assert_exists\r\n option_value\r\n end",
"def options_text\n options.map{ |opt| opt.text}\n end",
"def error(attribute_name, options = T.unsafe(nil)); end",
"def full_error(attribute_name, options = T.unsafe(nil)); end",
"def options\n self.read_attribute(:options).split(\"\\n\") unless self.read_attribute(:options).nil?\n end",
"def invalid_option\n\t\t\t\talert_menu \"Invalid option!\"\n\t\t\tend",
"def message\n @options[:message] || \"failed validation\"\n end",
"def options; enum_value_descriptor_proto.options; end",
"def options\n data[:options]\n end",
"def []( name )\n if form and r18n\n value = opts[ name ]\n if value.is_a?( String ) or ( value.nil? and not UNLOCALIZED_OPTIONS.include?( name ) )\n text = pt( name )\n return text.to_s if text.translated?\n end\n end\n super\n end",
"def options_text\n versioned_definition.options_text\n end",
"def variant_options(v, options={})\n v.options_text\n end",
"def options_text(alt_option_config_attr = nil)\n alt_option_config_attr ||= self.class.option_configs_attr\n return unless alt_option_config_attr\n\n send(alt_option_config_attr).dup\n end",
"def valid_options\n self::OPTIONS.map(&:to_s).join(', ')\n end",
"def text_from_normalize_help_tag_options(options={})\n options = normalize_help_tag_options(options)\n options['text'] ? options['text'] : nil\n end",
"def exceptions\n @values['exceptions']\n end",
"def unrecognized_option(err); end",
"def check_option!(name, definition)\n case name\n when :values\n raise AttributorException, \"Allowed set of values requires an array. Got (#{definition})\" unless definition.is_a? ::Array\n when :default\n raise AttributorException, \"Default value doesn't have the correct attribute type. Got (#{definition.inspect})\" unless type.valid_type?(definition) || definition.is_a?(Proc)\n options[:default] = load(definition) unless definition.is_a?(Proc)\n when :description\n raise AttributorException, \"Description value must be a string. Got (#{definition})\" unless definition.is_a? ::String\n when :required\n raise AttributorException, 'Required must be a boolean' unless definition == true || definition == false\n raise AttributorException, 'Required cannot be enabled in combination with :default' if definition == true && options.key?(:default)\n when :required_if\n raise AttributorException, 'Required_if must be a String, a Hash definition or a Proc' unless definition.is_a?(::String) || definition.is_a?(::Hash) || definition.is_a?(::Proc)\n raise AttributorException, 'Required_if cannot be specified together with :required' if options[:required]\n when :example\n unless definition.is_a?(::Regexp) || definition.is_a?(::String) || definition.is_a?(::Array) || definition.is_a?(::Proc) || definition.nil? || type.valid_type?(definition)\n raise AttributorException, \"Invalid example type (got: #{definition.class.name}). It must always match the type of the attribute (except if passing Regex that is allowed for some types)\"\n end\n when :custom_data\n raise AttributorException, \"custom_data must be a Hash. Got (#{definition})\" unless definition.is_a?(::Hash)\n else\n return :unknown # unknown option\n end\n\n :ok # passes\n end",
"def value\n options_hash[option_id]\n end",
"def option_type; end",
"def option_attributes\n @option_attributes || {}\n end",
"def label\n option ? option.text : read_attribute(:label)\n end",
"def extract_data_from_error\n OPTIONS.each do |option|\n data = error.instance_variable_get \"@_error_handler_#{option}\"\n\n unless instance_variable_get \"@#{option}\"\n instance_variable_set \"@#{option}\", data\n end\n end\n\n @backtrace ||= error.backtrace\n @method_name ||= error.name if error.respond_to? :name\n @text ||= error.message\n end",
"def option_details\n @@option_details\n end",
"def options_values\n options.map{ |opt| opt.value}\n end",
"def options_for(field)\n @options[field]\n end",
"def options\n validate_or_get_results :options\n end",
"def html_options\n @options\n end",
"def method_missing(method_name, *args)\n if method_name.to_s.match?(OPTION_ATTRIBUTE_RE)\n nil\n else\n super\n end\n end",
"def error_message\n self[:error_message]\n end",
"def method_missing(sym, *args)\n return @options[sym]\n end",
"def _get_option(name)\n\n # Start with nothing\n value = nil\n\n # First, get the default value by cycling through the allowed options\n method = self.class.metadata[:allowed_options].each do |allowed_option|\n value = allowed_option[:default] if allowed_option[:name] == name\n end\n\n # Then, cycle through the user-provided options\n @user_options.each do |user_option|\n value = user_option[name] if user_option.key?(name)\n end\n\n value\n end",
"def vash_value_exception(val,*args)\n name = vash_value_name(val,*args)\n msg = \"invalid value #{val.inspect}\"\n msg += \" at position #{args[0].inspect}\" unless args[0].nil?\n msg += \" for option #{args[1].to_s}\" unless args.length < 2\n [Puppet::Util::PTomulik::Vash::InvalidValueError, msg]\n end",
"def value_text\n raise \"value_text is only valid for select items\" unless self.tag_name == \"select\"\n\n values = self.value\n if values.is_a?(Array)\n values.map do |value|\n self.find(\"option[value=\\\"#{value}\\\"]\", visible: false).text\n end\n else\n self.find(\"option[value=\\\"#{values}\\\"]\", visible: false).text\n end\n end",
"def options\n return @data.options\n end",
"def method_missing(name, *_args)\n fail \"Unknown option #{name.to_s.gsub!('=', '')}\"\n end",
"def text\r\n assert_exists\r\n option_text\r\n end",
"def message_tag\n options.delete(:message_tag) || CaseForm.complex_error_message_tag\n end",
"def option(name)\n @options[name.to_s]\n end",
"def to_s\n option.to_s\n end",
"def exceptions\n association.options[:except].to_a.collect(&:to_s)\n end",
"def field_value\n opts = selected_options\n opts.count == 1 ? opts.first.text : opts.map(&:text)\n end",
"def error_message\n # :nocov:\n options.fetch(:messages, :valid)\n # :nocov:\n end",
"def error_on(attr, options)\n errors = @object.errors[attr]\n return nil unless errors\n\n errors = errors.to_sentence if errors.respond_to?(:to_sentence)\n\n @template.content_tag 'div',\n \"#{options[:label] || attr.to_s.humanize} #{errors}.\",\n :class => 'field_error'\n end",
"def option(opt)\n @options[opt]\n end",
"def options(opt)\n end",
"def get_options; end",
"def get_options\n @options\n end",
"def get_option_value(name=nil)\n if name.class == String && !block_given?\n return ::Vertx::Util::Utils.from_object(@j_del.java_method(:getOptionValue, [Java::java.lang.String.java_class]).call(name))\n end\n raise ArgumentError, \"Invalid arguments when calling get_option_value(name)\"\n end",
"def help_text\n @attributes[:help_text]\n end",
"def options_string\n self.form_field_options.map {|ffo| ffo.label}.join(', ')\n end",
"def cli_option(key)\n return @cli_options[key]\n end",
"def options\n\t\t\tVALID_OPTIONS_KEYS.inject({}) do |option,key|\n\t\t\t\toption.merge!(key => send(key))\n\t\t\tend\n\t\tend",
"def option_names\n standard_option_names\nend",
"def duration_options\n Task.durations.map do |key, val|\n [I18n.t(\"activerecord.attributes.task.duration-text.#{key}\"), val]\n end\n end",
"def options\n @options || parse_and_return(:@options)\n end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def attribute_errors\n {}\n end",
"def [](key)\n @options[key]\n end",
"def option(key)\n option_set[key]\n end",
"def errors\n @errors ||= EntityTypePropertyOptionErrors.new(self)\n end",
"def options\n element.options.map { |e| PageObject::Elements::Option.new(e) }\n end",
"def attrs\n @options[:attrs]\n end",
"def handle_failed_option param, value\n @options_ok = false\n end",
"def value(op)\n raise \"Option '#{op}' not accepted\" if !accepts? op\n raise \"Option '#{op}' not specified\" if !has? op\n return @options[op].value\n end",
"def values\n @options['values']\n end",
"def option_text_and_value(option)\n # Options are [text, value] pairs or strings used for both.\n if !option.is_a?(String) && option.respond_to?(:first) && option.respond_to?(:last)\n option = option.reject { |e| Hash === e } if Array === option\n [option.first, option.last]\n else\n [option, option]\n end\n end",
"def option_text_and_value(option)\n # Options are [text, value] pairs or strings used for both.\n if !option.is_a?(String) && option.respond_to?(:first) && option.respond_to?(:last)\n option = option.reject { |e| Hash === e } if Array === option\n [option.first, option.last]\n else\n [option, option]\n end\n end",
"def option\n return @manager.configurable.class.configuration.options[key]\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def resource_attributes\n self.class.attributes.names - [:options]\n end",
"def options(opt); end",
"def options\n return @options\n end",
"def options(opt); end",
"def validation_options\n @validation_options ||= options.reject do |k, v|\n %i{declared_in name instance_variable_name desired_state identity default name_property coerce required nillable sensitive description introduced deprecated default_description skip_docs}.include?(k)\n end\n end",
"def message\n options.delete(:message) || translated_message\n end",
"def options_conflicts_with\n data.options_conflicts_with\n end",
"def get_raw_value_for_option(option=nil)\n if option.class == Hash && !block_given?\n return @j_del.java_method(:getRawValueForOption, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option)))\n end\n raise ArgumentError, \"Invalid arguments when calling get_raw_value_for_option(option)\"\n end",
"def []( name )\n @options[ name ]\n end",
"def option_tag(text); end",
"def options\n I18n.t(\"filter_labels.#{param}\").with_indifferent_access\n end",
"def options\n @options\n end",
"def options\n @options\n end",
"def validate\n errors = Array.new\n\n [value].flatten.each do |value_with_modifier|\n value = value_with_modifier[:value]\n modifier = value_with_modifier[:modifier]\n\n if !option.allowed_values.nil? and !option.allowed_values.include?(value)\n errors << \"The value '#{value}' for the '#{option.key}' setting isn't present in the list of allowed values.\"\n end\n\n if !option.allowed_format.nil?\n case option.allowed_format\n when 'string'\n if !value.is_a?(String)\n errors << \"The value '#{value}' for the '#{option.key}' setting is not a String.\"\n end\n when 'fixnum'\n if !value.is_a?(Fixnum)\n errors << \"The value '#{value}' for the '#{option.key}' setting is not a Fixnum.\"\n end\n when 'float'\n if !value.is_a?(Float) and !value.is_a?(Fixnum)\n errors << \"The value '#{value}' for the '#{option.key}' setting is not a Float.\"\n end\n when 'boolean'\n if !value.is_a?(TrueClass) and !value.is_a?(FalseClass)\n errors << \"The value '#{value}' for the '#{option.key}' setting is not a Boolean.\"\n end\n when 'email'\n if !value[/^[A-Z0-9_\\.%\\+\\-\\']+@(?:[A-Z0-9\\-]+\\.)+(?:[A-Z]{2,4}|museum|travel)$/i]\n errors << \"The value '#{value}' for the '#{option.key}' setting is not an Email Address.\"\n end\n when 'url'\n if !value[URI.regexp]\n errors << \"The value '#{value}' for the '#{option.key}' setting is not a URL.\"\n end\n end\n\n if option.allowed_format.is_a?(Regexp) and !value[option.allowed_format]\n errors << \"The value '#{value}' for the '#{option.key}' setting is not in the correct format.\"\n end\n end\n\n if !modifier.nil? and !option.allowed_modifiers.nil? and !option.allowed_modifiers.include?(modifier)\n errors << \"The modifier '#{modifier}' for the '#{option.key}' setting isn't present in the list of allowed modifiers.\"\n end\n end\n\n errors.each do |error|\n @manager.configurable.errors.add(:settings, error)\n end\n end",
"def options\n @options\n end",
"def option_method(key)\n key.to_sym if key && respond_to?(key)\n end",
"def options\n return @options\n end",
"def validate_options; end",
"def err_extra_kv (args, usage)\n message= \"Extra options:\\n\"\n args.each() {|k,v| message = message + \" --#{k}=#{v}\\n\"}\n message = message + usage\n raise message\n end",
"def options\n @options\n end",
"def options\n @options\n end"
] |
[
"0.61152637",
"0.6095615",
"0.6036085",
"0.60175234",
"0.6016837",
"0.5911173",
"0.5905528",
"0.5888331",
"0.5834185",
"0.5815595",
"0.57814837",
"0.5735032",
"0.5728902",
"0.5703877",
"0.56964666",
"0.568494",
"0.5623765",
"0.558237",
"0.55760247",
"0.5574",
"0.5513959",
"0.5507324",
"0.5491219",
"0.5465513",
"0.54556036",
"0.5445672",
"0.54455614",
"0.54426223",
"0.5432925",
"0.54234034",
"0.54164845",
"0.54031676",
"0.5387916",
"0.538673",
"0.5373906",
"0.5366727",
"0.5353459",
"0.53490615",
"0.5319995",
"0.5318075",
"0.5315023",
"0.5310326",
"0.5305622",
"0.53025305",
"0.5295699",
"0.52868325",
"0.52801156",
"0.5275337",
"0.5264406",
"0.5260692",
"0.52534264",
"0.52347255",
"0.52292585",
"0.5228646",
"0.5213292",
"0.521023",
"0.52049375",
"0.5192105",
"0.518215",
"0.518215",
"0.518215",
"0.518215",
"0.518215",
"0.518215",
"0.518215",
"0.518215",
"0.518215",
"0.5179689",
"0.5179577",
"0.51793265",
"0.51785195",
"0.51760453",
"0.51740974",
"0.5171751",
"0.51700467",
"0.51693505",
"0.51653504",
"0.51653504",
"0.5163991",
"0.5163224",
"0.51629317",
"0.51599145",
"0.5159346",
"0.51591724",
"0.515804",
"0.5154855",
"0.51512796",
"0.5150406",
"0.51485837",
"0.5145867",
"0.5143331",
"0.51424414",
"0.51424414",
"0.5137367",
"0.5135568",
"0.5124407",
"0.51206845",
"0.5107626",
"0.5094848",
"0.50930387",
"0.50930387"
] |
0.0
|
-1
|
Returns the value of attribute key. source://i18n//lib/i18n/exceptions.rb109
|
def key; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key\n attributes['key'] or raise NoKeySpecified\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"def _read_attribute(key); end",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def read_attribute(key)\n @hash[key.to_s]\n end",
"def read_attribute(key)\n @attributes[key.to_sym]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def [](key_name)\n read_attribute(key_name)\n rescue MissingAttribute\n nil\n end",
"def translate_property_value(key)\n return resource_translation_matrix.fetch(key) if resource_translation_matrix &&\n resource_translation_matrix.key?(key)\n\n key.to_s\n end",
"def [](key_)\n @attributes[key_.to_s]\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def [](key)\n attributes[key]\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def [](key)\n @attributes.get(key)\n end",
"def key\n attributes[:key]\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def error_key\n self.class.error_key\n end",
"def value_for_key(key)\n if respond_to?(key)\n send key\n elsif attributes.include? key\n attributes[key]\n else\n row.send key\n end\n end",
"def key\n @attributes[:key]\n end",
"def key\n @attributes[:key]\n end",
"def get_value(key)\n self[key]\n end",
"def [](key)\n @attributes[key]\n end",
"def key\n @key or raise MissingKey\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n element=@xml.xpath(key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n element=@xml.elements[key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def get_attribute(dict_name, key, default_value = nil)\n end",
"def value(key)\n if self[key].present?\n self[key].class != ActiveSupport::TimeWithZone ? self[key] : self[key].to_f\n elsif self[:parameters].present? && self[:parameters][key].present?\n return self[:parameters][key]\n elsif self[:extras].present? && self[:extras][key].present?\n return self[:extras][key]\n else\n return \"\"\n end\n end",
"def translate_property_key(value)\n return resource_translation_matrix.key(value) if resource_translation_matrix &&\n resource_translation_matrix.value?(value)\n\n value.to_s\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def [](k)\n raise \"key #{k} should be symbol but #{k.class}\" unless k.is_a?(Symbol)\n return @attributes[k]\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def [](key)\n @attrs[key]\n end",
"def [](key)\n @attrs[key]\n end",
"def [](attr_key)\n @attributes[attr_key.to_sym]\n end",
"def get_property(key)\n @data[key]\n end",
"def []( key )\n _meta_data[key.to_s]\n end",
"def [](key)\n @attributes = Array.new if @attributes.nil?\n attributes_downcase =@attributes.map(&:downcase)\n key.downcase!\n if attributes_downcase.include? key\n return get(key)\n else\n raise 'El atributo no ha sido encontrado en el objecto '+ key\n end\nend",
"def read_value(key)\n keys = key.split('.')\n result = @context\n keys.each do |k|\n return nil unless result\n result = result[k]\n end\n return result\n end",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def [](key)\n a = @attrs_hash[key.intern]\n if a\n a.value\n else\n nil\n end\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def field(key)\n pdf_field(key).getValueAsString\n rescue NoMethodError\n raise \"unknown key name `#{key}'\"\n end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def key_value\n @key_value.nil? ? self.key.to_s : @key_value\n end",
"def read_key(key)\n raise RuntimeError.new(\"read_key not implemented!\")\n end",
"def [](attribute_name)\n @attributes[@current_language][attribute_name.to_sym] || \n @attributes[@current_language][attribute_name.to_s.singularize.to_sym]\n end",
"def get(key)\n \n end",
"def getKey; argSetTextual.to_sym end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def ensure_attribute(root_element, key, type = nil, prefix = nil)\n value = get_attribute(root_element, key, type, prefix)\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"Attribute '#{label}' is missing\" if value.nil?\n value\n end",
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def value_for(key)\n return '' unless self.param_values && self.param_values[key]\n self.param_values[key]\n end",
"def value_for(resource)\n resource.send(key)\n end",
"def [](key)\n @entry[key] || @entry[key.to_s.upcase]\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def get_attribute(attribute)\n\t\t@attributes[attribute.intern]\n\tend",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def [](key)\n data[key.to_s]\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def [](key); self.properties[key.to_s]; end",
"def t(key)\n I18n.translate(key).html_safe\n end",
"def method_name key\n \"value_for_#{key}\"\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def []( key )\n\t\tself.validate unless self.validated?\n\t\treturn @valid[ key.to_sym ]\n\tend",
"def human_attribute_name(attribute_key_name, options = {})\n defaults = self_and_descendants_from_active_resource.map do |klass|\n :\"#{klass.name.underscore}.#{attribute_key_name}\"\n end\n defaults << options[:default] if options[:default]\n defaults.flatten!\n defaults << attribute_key_name.to_s.humanize\n options[:count] ||= 1\n I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activeresource, :attributes]))\n end",
"def get_string(attr); end",
"def get(key)\n messages[key]\n end",
"def get(key)\n messages[key]\n end",
"def dynamo_attribute_key\n @attr.dynamo_name\n end",
"def [](attr_name)\n attr_name = attr_name.to_sym\n unless @attributes.key?(attr_name)\n raise NameError, \"undefined attribute #{attr_name.inspect}\"\n end\n @attributes[attr_name]\n end",
"def attr_get(key)\n key_count = 0\n @attrkeys.each do |attrkey|\n if(attrkey == key)\n @attrvals[key_count]\n end\n key_count = key_count + 1\n end\n nil\n end",
"def [](key)\n @data[key.to_s]\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def db_value(attribute,code)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n self.eh_params[:db_codes][context][attribute.to_s].key(code)\n end",
"def [] key\n @attributes[key.to_s]\n end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def get(key)\n @attrs[key].present? ? @attrs[key] : nil\n end",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def get_item_value(key)\n @attributes[key] = get_item_record(key) unless @attributes.has_key?(key)\n @attributes[key]\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def [] key\n\t\t\t\t@attributes[key]\n\t\t\tend",
"def const_missing (name)\n _, f, k = /(.+?)_(.+)$/.match(name.to_s).to_a\n if _ and instance_methods(false).include? \"enum_field_for_#{f.downcase}\"\n if key_value = send(\"#{f.downcase}_values\").select{|x| x[1].to_s.gsub(/[^\\w_]/, \"_\") == \"#{k.downcase}\"}.first\n return key_value[1]\n end\n end\n super\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def liner_get(key)\n key = key.to_sym\n with_valid_attribute(key) do\n instance_variable_get \"@#{key}\"\n end\n end",
"def get_hash_value(hash, key, attribute)\n hash[key][attribute]\n end",
"def [](key)\n if key.to_s[0] == ?@\n tag = key.to_s[1..-1].to_sym\n c = child(tag)\n if c\n c.text\n else\n nil\n end\n else\n @attrs[key]\n end\n end",
"def error_message\n self[:error_message]\n end"
] |
[
"0.6561134",
"0.6527371",
"0.65238667",
"0.6515823",
"0.6510158",
"0.6481626",
"0.64718825",
"0.6430067",
"0.62943554",
"0.62943554",
"0.6255954",
"0.61909246",
"0.6172352",
"0.61207014",
"0.6112885",
"0.6112885",
"0.61048526",
"0.60806817",
"0.603959",
"0.5967862",
"0.5962219",
"0.5962219",
"0.5962219",
"0.5955738",
"0.59406054",
"0.5931129",
"0.5931129",
"0.5929004",
"0.5905142",
"0.5854062",
"0.5849408",
"0.5844449",
"0.5839039",
"0.5789372",
"0.5786953",
"0.5779431",
"0.5759642",
"0.5758129",
"0.57027656",
"0.57027656",
"0.57027435",
"0.5700072",
"0.5698657",
"0.56621325",
"0.56534225",
"0.5641456",
"0.5637806",
"0.5628436",
"0.5628436",
"0.56282985",
"0.5620086",
"0.5618137",
"0.55896354",
"0.55896354",
"0.55862904",
"0.55852437",
"0.5577196",
"0.5576543",
"0.55544347",
"0.55536616",
"0.55534893",
"0.55529565",
"0.5547017",
"0.5535217",
"0.5534018",
"0.5531902",
"0.5530726",
"0.55265397",
"0.55245847",
"0.55204296",
"0.5516499",
"0.55149484",
"0.5514784",
"0.55145204",
"0.5502754",
"0.5501779",
"0.54968554",
"0.54968554",
"0.54951817",
"0.54922855",
"0.5491199",
"0.5487932",
"0.54799896",
"0.5474213",
"0.54639316",
"0.5456956",
"0.54543436",
"0.54522014",
"0.5451129",
"0.545096",
"0.54506016",
"0.5442316",
"0.5439915",
"0.5439032",
"0.5439032",
"0.5439032",
"0.5439032",
"0.5434874",
"0.54318476",
"0.54304117",
"0.54241824"
] |
0.0
|
-1
|
Returns the value of attribute string. source://i18n//lib/i18n/exceptions.rb109
|
def string; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_string(attr); end",
"def get_string_value\n\t\tend",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def error_string\n # This method should be overridden\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def unknown_string\n t('Unknown')\n end",
"def error_message\n self[:error_message]\n end",
"def exception_message\n @e_m ||= @exception.nil? ? '' : @exception.message\n end",
"def string_value(value)\r\n value\r\n end",
"def error_message_for(attribute)\n case attribute\n when :email, :password, :password_confirmation\n @admin_registration.errors[attribute].join(', ')\n else\n raise \"Error messages not implmeneted for \\\"#{attribute}\\\"\"\n end\n end",
"def error_message(attribute)\n unless @object.errors.on(attribute).blank?\n content_tag(:p, :class => 'notice') do\n concat ERB::Util.html_escape(@object.errors.on(attribute).mb_chars.capitalize)\n end\n else\n ''\n end\n end",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def get_string(field)\n field['stringValue']\n end",
"def get_string_value(field_name)\n\t\tend",
"def error_message\n @data[\"message\"]\n end",
"def message\n msg = \"Format error found in %s tuple: %s\" % [@identifier, @invalid_data.inspect]\n return msg\n end",
"def format_string(record, attribute, val)\n val\n end",
"def value\n #BaseData::PlainString.clean_value(self.strings.map(&:value).join)\n string = self.strings.map(&:value).join\n #string.metaclass.instance_eval do\n def string.clean_value\n BaseData::String.clean_value(self)\n end\n #end\n #debugger\n string\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def get(value)\n if value.kind_of? Details::Attribute\n raise \"Invalid attribute! Must be an attribute named #{self.name}\" if value.name != self.name\n value = value.value\n end\n value.strip! if value.kind_of? String\n @values.find { |v| v.value == value }\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def lookup_string_attribute (attname, workitem, options={})\n\n result = lookup_attribute(attname, workitem, options)\n result = result.to_s if result\n result\n end",
"def translation(string, attributes)\n string\n end",
"def fault_string\n @fault_string ||= XmlRpc::API::Message.parse_value(\n @document.root.elements[\"fault/value/struct/member[name='faultString']/value\"]) if @document && @document.root \n end",
"def value\n raw_value.is_a?(StandardError) ? raise(raw_value) : raw_value\n end",
"def message\n @error['message']\n end",
"def error_msg\n name\n end",
"def error_message\n return @error_message\n end",
"def ar_get_resource_value(resource, column)\n return \"Error: #{resource}, #{column}\" unless column && resource\n \n case column\n when String, Symbol\n \n if controller.ardata.foreing_models.include?(column.to_s)\n column.to_s.match(/^(.*)_id$/)\n record= resource.send($1)\n return record ? record.label : controller.ardata.labels[:nil_value_in_field]\n else\n return h(resource.send(column)) || controller.ardata.labels[:nil_value_in_field]\n end\n \n else\n ar_retrieve_field_value column, resource\n end\n end",
"def value\n @string || to_s\n end",
"def error_msg\n ERROR_MSG[upcase_class_sym]\n end",
"def get_value\n read_attribute('text_value')\n end",
"def view_error_text(object, error_key, options = {})\n raise Exception.new(\"Parameter string_name may not be blank\") if error_key.blank?\n \n controller ||= options[:controller] ||= self.controller_name\n\n # If you are on the production server, you can only see strings set to live\n # mode. If you are on a development or staging server, you can see draft or ready status\n language_id = get_current_language_id(options)\n\n # First, try to look up the string in the specified controller\n # Note: we get the one with the highest version number\n translation = I18n::SingletonTranslationKey.translate( :klass => object, \n :language => language_id,\n :key => error_key )\n \n # Model errors are bound directly to an error we do not want to look for this key on the global level \n \n # if we found something, we're good\n return translation.text if translation && translation.text\n\n # if not, we can optionally return an empty string\n if options[:missing_ok] == true\n return \"\"\n else\n # Rather than fail if we can not find the translation, put the key in place of\n # the translation and log a tranlsation error in the i18n.log which is defined in\n # config/initializers/i18n_logger.rb\n language = Language.find(language_id)\n I18N_LOGGER.error \"view_text_lookup: Unable to locate string '#{error_key}' \" +\n \"for language #{language.language} that belongs to object #{object}\"\n return \"trasnlation-missing: #{error_key} - lang: #{language_id}\"\n end\n end",
"def error_message_from_model(model, attribute, message, extra = {})\n ::ActiveModel::Errors.new(model).generate_message(attribute, message, extra)\n end",
"def get_value(render_context)\n return @message.translate(render_context)\n end",
"def error_message\n error.message\n end",
"def help_text_for(attribute)\n ::I18n.translate!(attribute[:name], scope: [:alchemy, :resource_help_texts, resource_name])\n rescue ::I18n::MissingTranslationData\n nil\n end",
"def value_field\n \"string\"\n end",
"def exception_variable\n node_parts[1]\n end",
"def failure_message\n @message\n end",
"def value\n raise\n end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def __value\n unless defined?(@value)\n __get_value\n end\n\n if @value.is_a?(WrappedException)\n ::Kernel.raise @value\n end\n\n @value\n end",
"def [](attribute)\n messages_for(attribute)\n end",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def get_exception_with_string\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/error/stringInException'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 444\r\n raise ExceptionWithStringException.new(\r\n 'exception with string',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def string\n @string\n end",
"def string\n @string\n end",
"def attribute_value(string)\n\n attribute_value = ''\n position = 0\n length = string.length\n\n while position < length\n \n # x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then advance position to the next byte, then, repeat this step.\n if string[position] =~ /[\\u{09}\\u{0A}\\u{0C}\\u{0D}\\u{20}]/\n \n position += 1\n\n elsif string[position] =~ /['\"]/\n\n attribute_value, position = quoted_value(string[position, length])\n break\n\n elsif string[position] == '>'\n position += 1\n break\n\n else\n attribute_value, position = unquoted_value(string[position, length])\n break\n end\n end\n\n [attribute_value, position]\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n value = nil\n quoted_string29 = nil\n number30 = nil\n\n begin\n # at line 125:35: ( quoted_string | number )\n # at line 125:35: ( quoted_string | number )\n alt_43 = 2\n look_43_0 = @input.peek( 1 )\n\n if ( look_43_0 == QUOTE )\n alt_43 = 1\n elsif ( look_43_0 == DIGIT )\n alt_43 = 2\n else\n raise NoViableAlternative( \"\", 43, 0 )\n end\n case alt_43\n when 1\n # at line 125:37: quoted_string\n @state.following.push( TOKENS_FOLLOWING_quoted_string_IN_attribute_value_1234 )\n quoted_string29 = quoted_string\n @state.following.pop\n # --> action\n value = quoted_string29 \n # <-- action\n\n when 2\n # at line 125:85: number\n @state.following.push( TOKENS_FOLLOWING_number_IN_attribute_value_1240 )\n number30 = number\n @state.following.pop\n # --> action\n value = ( number30 && @input.to_s( number30.start, number30.stop ) ).to_i \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return value\n end",
"def error_message; end",
"def get_string\n get_item ? get_item.alert.id : ''\n end",
"def text\n @value[:text].to_s\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def attribute_value(key, node = @current_node)\n\t\tif is_valid(node) && node.key?(key) then\n\t\t\treturn node.attribute(key).to_s\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def error_message(e)\n fail e\n end",
"def make_valuestring\n\t\treturn self.value\n\tend",
"def attr\n @attr || header.downcase\n end",
"def attr\n @attr || header.downcase\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n value = nil\n string30 = nil\n number31 = nil\n\n begin\n # at line 152:35: ( string | number )\n # at line 152:35: ( string | number )\n alt_38 = 2\n look_38_0 = @input.peek(1)\n\n if (look_38_0 == T__14)\n alt_38 = 1\n elsif (look_38_0 == EOF || look_38_0 == DIGIT || look_38_0 == T__11 || look_38_0 == T__33)\n alt_38 = 2\n else\n raise NoViableAlternative(\"\", 38, 0)\n end\n case alt_38\n when 1\n # at line 152:37: string\n @state.following.push(TOKENS_FOLLOWING_string_IN_attribute_value_1142)\n string30 = string\n @state.following.pop\n # --> action\n value = (string30 && @input.to_s(string30.start, string30.stop))\n # <-- action\n\n when 2\n # at line 152:71: number\n @state.following.push(TOKENS_FOLLOWING_number_IN_attribute_value_1148)\n number31 = number\n @state.following.pop\n # --> action\n value = (number31 && @input.to_s(number31.start, number31.stop)).to_i\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end\n\n return value\n end",
"def label_from_attribute(attribute)\n attribute.to_s.humanize\n end",
"def describe_error\n message = \"\"\n if self.account_number == nil\n message = message + I18n.t(:wrong_or_missing_account_number, :scope => [:model, :index]) + \" \"\n end\n if self.account_bank_number == nil\n message = message + I18n.t(:wrong_or_missing_account_bank_number, :scope => [:model, :index]) + \" \"\n end\n if self.student.uic == nil\n message = message + I18n.t(:missing_uic, :scope => [:model, :index]) + \" \"\n end\n if self.sident == -666\n message = message + I18n.t(:missing_sident_666, :scope => [:model, :index]) + \" \"\n end\n if self.sident == nil\n message = message + I18n.t(:missing_sident, :scope => [:model, :index]) + \" \"\n end\n return message\n\n end",
"def message\n @props.fetch(:message, \"must be valid\")\n end",
"def error_text(error_code)\n ERRORS[error_code.to_i]\n end",
"def get_char(attr); end",
"def attribute(value, default_value=nil)\n str = value.to_s\n not(str.empty?) ? str : default_value\n end",
"def value_for(field)\n value = instance_variable_get(:\"@#{field}\")\n value.nil? ? nil : value.to_s\n end",
"def attribute_get(attribute)\n check_attribute!(attribute)\n send(attribute.to_s)\n end",
"def attribute_get(attribute)\n check_attribute!(attribute)\n send(attribute.to_s)\n end",
"def error_message(value)\n set_dsl(:error_message, value)\n end",
"def datatables_instance_get_value(instance, column)\n if column[:attribute]\n val = instance.send(column[:attribute].to_sym)\n return I18n.t(val.to_s.to_sym, :default => val.to_s) if not val.nil?\n return ''\n elsif column[:special]\n special = column[:special]\n \n if special[:method]\n return method(special[:method].to_sym).call(instance)\n elsif special[:eval]\n proc = lambda { obj = instance; binding }\n return Kernel.eval(special[:eval], proc.call)\n end\n end\n return \"value not found\"\n end",
"def message\n configuration.default_message || @exception.message\n end",
"def error(attr, text)\n errors[attr] ||= []\n errors[attr] << text\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def error_name\n self.class.error_name\n end",
"def error_name\n self.class.error_name\n end",
"def error_message\n @response.reason_phrase\n end",
"def full_error(attribute_name, options = T.unsafe(nil)); end",
"def message # :nodoc:\n @properties['errorMessage'].dup\n end",
"def message\n attributes.fetch(:message)\n end",
"def message\n @errormsg\n end",
"def getText\n return getProperty('text').to_s\n end",
"def get_string_field(field_name)\n\t\tend",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def value element_name\n begin\n el_attribute = el element_name\n el_attribute.attribute('value')\n rescue Exception => e\n $LOG.error \"error in getting element value \\n element name : #{element_name} \"+e.message\n raise \"error in getting element value \\n element name : #{element_name} \"+e.message\n end\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def label\n if respond_to?(\"#{@attribute}_label\".to_sym)\n send(\"#{@attribute}_label\".to_sym)\n else\n @attribute.to_s.titleize\n end\n end",
"def message\n attributes[:message]\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.gsub('.', '_').humanize\n attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)\n I18n.t(:\"hints.format\", \n :default => \"%{attribute} %{message}\",\n :attribute => attr_name,\n :message => message\n )\n end",
"def get(string)\n @strings[string]\n end",
"def meaningful_error_message callback, model, attributes\n rv = \"Unable to #{callback} a #{model.name}\"\n if attributes and !attributes.empty?\n rv << \" with #{attributes.inspect}\"\n end\n end",
"def attribute attr\n @ref.attribute(TRANSLATOR.cocoaify(attr)).to_ruby\n end",
"def error(attribute_name, options = T.unsafe(nil)); end"
] |
[
"0.69891775",
"0.63351744",
"0.6315944",
"0.62282073",
"0.6220859",
"0.61755294",
"0.61755294",
"0.60254234",
"0.5971157",
"0.5960759",
"0.5945387",
"0.589549",
"0.58895236",
"0.58698446",
"0.5842314",
"0.58374757",
"0.5820371",
"0.5733058",
"0.57262313",
"0.57200474",
"0.5719632",
"0.57182366",
"0.5714854",
"0.57118535",
"0.5689852",
"0.5640529",
"0.5638972",
"0.56347424",
"0.56215936",
"0.56213593",
"0.56133187",
"0.5602652",
"0.56000507",
"0.55785745",
"0.55693996",
"0.5566551",
"0.5559515",
"0.55468684",
"0.5537398",
"0.552869",
"0.5521521",
"0.55207163",
"0.5516723",
"0.55165124",
"0.5512447",
"0.55088395",
"0.5445725",
"0.5442591",
"0.54294705",
"0.54294705",
"0.54294705",
"0.54219663",
"0.541106",
"0.541106",
"0.5398364",
"0.53965306",
"0.53962743",
"0.5386895",
"0.53842944",
"0.537983",
"0.5350308",
"0.5344927",
"0.5343037",
"0.53274",
"0.5324147",
"0.5324147",
"0.5320878",
"0.5320205",
"0.5319632",
"0.53133863",
"0.530909",
"0.53023714",
"0.52901655",
"0.52788603",
"0.52714676",
"0.52714676",
"0.5267093",
"0.5264083",
"0.5260203",
"0.5254022",
"0.5250669",
"0.5250669",
"0.52498996",
"0.52498996",
"0.5245798",
"0.5243869",
"0.5229875",
"0.5217686",
"0.52172923",
"0.5206096",
"0.52029717",
"0.519689",
"0.51967925",
"0.51962006",
"0.5191754",
"0.5191127",
"0.51846135",
"0.51805305",
"0.51793253",
"0.51758504",
"0.5166532"
] |
0.0
|
-1
|
Returns the value of attribute filename. source://i18n//lib/i18n/exceptions.rb117
|
def filename; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filename\n raise\n end",
"def filename\n @properties[:filename]\n end",
"def getFilename\r\n\t\t\t\t\treturn @filename\r\n\t\t\t\tend",
"def filename\n @filename\n end",
"def filename\n @filename\n end",
"def filename\n @filename\n end",
"def file_name\n return @file_name\n end",
"def file_name\n return @file_name\n end",
"def filename\n @file.basename.to_s\n end",
"def filename\n @file\n end",
"def filename\n @data[:name]\n end",
"def filename\n get \"filename\"\n end",
"def file_name\n @file_name\n end",
"def filename\n self._filename\n end",
"def filename\n return _meta_data['filename'] if _meta_data.has_key? 'filename'\n name\n end",
"def full_filename_for(attribute)\n filename = attachment_for(attribute).path\n end",
"def filename\n unless @filename\n load_file_params\n end\n @filename\n end",
"def file_name\n self.file_file_name\n end",
"def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end",
"def filename\n @metadata[:filename] || uri.path.split('/')[-1]\n end",
"def original_filename\n instance_read(:file_name)\n end",
"def filename\n @adapter.attribute\n end",
"def filename(property: 'file')\n params.dig property, :filename\n end",
"def file_name\n return unless @file\n\n @file.absolute_name\n end",
"def filename\n __advance!\n @_st_fileName\n end",
"def original_filename\n @file_representation[:filename]\n end",
"def filename\n model.respond_to?(:filename) ? model.filename : super\n end",
"def filename\n @metadata[:filename] || \"attachment\"\n end",
"def access_file_name\n end",
"def filename\n original_filename\n end",
"def get_filename (file)\n\t\tif file.is_a? File\n\t\t\tfile = file.path\n\t\tend\n\t\treturn file\n\tend",
"def name() @filename end",
"def filename\n @basename + PAGE_FILE_EXT\n end",
"def assignment_upload_file_name\n read_attribute(:file_name)\n end",
"def filename(filename = nil)\n @filename = filename if filename\n @filename\n end",
"def original_filename\n metadata[\"filename\"]\n end",
"def fileName\r\n\t\traise NoMethodError\r\n\tend",
"def filename\n return @file_object.io.path if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def filename\n return @filename if @filename\n\n if self.uri\n @filename = File.basename(self.uri.path)\n else\n regexps = PRECOMPILED_FILE_TYPES.map { |ext| \"\\.#{ext}\" }.join('|')\n\n @filename = File.basename(self.filepath).gsub(/#{regexps}/, '')\n end\n end",
"def original_file # Accessor for probably protected value original_filename\r\n original_filename\r\n end",
"def filename=(_); end",
"def filename\n find_attachment\n end",
"def filename\n path && File.basename(path)\n end",
"def filename\n @original_filename\n end",
"def validate_filename(_item)\n nil\n end",
"def filename\n @filename ||= metadata.fetch('PA_MD_CUST_FILENAME', '').to_s\n end",
"def label_for(file)\n if file.is_a?(Hyrax::UploadedFile) # filename not present for uncached remote file!\n file.uploader.filename.presence || File.basename(Addressable::URI.unencode(file.file_url))\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.unencode(file.file_url))\n elsif file.respond_to?(:original_filename) # e.g. Rack::Test::UploadedFile\n file.original_filename\n else\n File.basename(file)\n end\n end",
"def path\n @filename\n end",
"def filename()\n #This is a stub, used for indexing\n end",
"def filename\n if original_filename\n \"#{model.name.parameterize}-#{secure_token(8)}.#{file.extension}\"\n end\n end",
"def file_name\n @file_name ||= File.basename tree\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 FileName\n if(!FilePath)\n return nil\n end\n return FilePath.FileName\n end",
"def filename\n return @args[:fname]\n end",
"def filename\n @parts[-1]\n end",
"def filename\n @filename || @options[:filename]\n end",
"def filename\n \"#{original_filename_without_extension.parameterize}_#{model.filename_token}#{original_extension}\" if original_filename\n end",
"def filename\n return @filename if @filename\n name.downcase.gsub(/\\W/, '_').squeeze('_')\n end",
"def filename\n attachment.original_filename\n end",
"def filename\n \"#{model.name.parameterize}.#{file.extension}\" if original_filename.present?\n end",
"def full_filename (for_file = model.document.file)\n for_file\n end",
"def name\n filename\n end",
"def name\n filename\n end",
"def errored_files\n @attributes[:errored_files]\n end",
"def filename\n return @filename unless @filename.nil?\n generate_file_name()\n @filename\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def name\n self.filename\n end",
"def filename\n @filename ||= attached_file&.original_filename&.dup\n end",
"def file\n file_names[x]\n end",
"def file_name=(value)\n @file_name = value\n end",
"def file_name=(value)\n @file_name = value\n end",
"def filename\n @filename || (@options && @options[:filename])\n end",
"def filename\n @filename || (@options && @options[:filename])\n end",
"def filename\n return @args[\"fname\"]\n end",
"def filename=(value)\n @old_filename = filename unless filename.nil? || @old_filename\n write_attribute :filename, sanitize_filename(value)\n end",
"def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end",
"def file_name\n \"#{@file_name}.#{extension}\"\n end",
"def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end",
"def uploaded_filename_without_extension\n attachment.try(:original_filename_without_extension)\n end",
"def filename\n original_filename.try(:gsub, '+', '-')\n end",
"def filename\n @filename = \"#{secure_token}_#{split_extension(original_filename)}.#{file.extension}\" if original_filename.present?\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_name\n File.basename @path\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end",
"def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end"
] |
[
"0.7384743",
"0.70630807",
"0.680468",
"0.6748212",
"0.67416143",
"0.67416143",
"0.66735876",
"0.66735876",
"0.664797",
"0.66358054",
"0.6629167",
"0.66220355",
"0.6609552",
"0.65783286",
"0.65663797",
"0.6563168",
"0.6502247",
"0.6419557",
"0.6419504",
"0.63743913",
"0.6368853",
"0.6354121",
"0.6315408",
"0.6305615",
"0.63045436",
"0.62918776",
"0.62873673",
"0.62658095",
"0.6251065",
"0.62175536",
"0.6171663",
"0.6168776",
"0.6156575",
"0.61493385",
"0.61430895",
"0.6130359",
"0.6111845",
"0.6110466",
"0.60817724",
"0.6074723",
"0.60677326",
"0.6054996",
"0.60517013",
"0.6039329",
"0.602884",
"0.6024209",
"0.60116637",
"0.6001698",
"0.59955764",
"0.5994554",
"0.59846437",
"0.597812",
"0.5971101",
"0.5962557",
"0.59566134",
"0.5954093",
"0.594628",
"0.59436417",
"0.5941639",
"0.59359664",
"0.5935023",
"0.59326434",
"0.59326434",
"0.59310955",
"0.5923671",
"0.59180117",
"0.59180117",
"0.5910399",
"0.5908404",
"0.59032667",
"0.5888186",
"0.5888186",
"0.5880714",
"0.5880714",
"0.58687806",
"0.5865394",
"0.58557737",
"0.5855743",
"0.5846161",
"0.5833905",
"0.58278793",
"0.58265674",
"0.5817344",
"0.5805503",
"0.5798688",
"0.5798688",
"0.5798688"
] |
0.59795827
|
62
|
Returns the value of attribute type. source://i18n//lib/i18n/exceptions.rb117
|
def type; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n attr_val('./@typeCode')\n end",
"def failure_type\n @attributes[:failure_type]\n end",
"def attribute_type\n (float? || integer? || text? || boolean? ? field_type : 'string').to_sym\n end",
"def type\n @attributes.fetch('type', nil)\n end",
"def attribute_type(x)\n self.class.attribute_type qualified_name(x)\n end",
"def type\n @error['type']\n end",
"def value_type\n @type.value_type\n end",
"def dynamo_attribute_definition_type\n dynamo_attribute_value_type_key.to_s.upcase\n end",
"def type\n read_attr :type, :to_sym\n end",
"def attr_type_for(attribute)\n fields = self.class._module.fields\n field = fields[attribute]\n raise UninitializedModule, \"#{self.class.session.namespace_const}Module #{self.class._module.name} was not initialized properly (fields.length == 0)\" if fields.length == 0\n raise InvalidAttribute, \"#{self.class}._module.fields does not contain an entry for #{attribute} (of type: #{attribute.class})\\nValid fields: #{self.class._module.fields.keys.sort.join(\", \")}\" if field.nil?\n raise InvalidAttributeType, \"#{self.class}._module.fields[#{attribute}] does not have a key for \\'type\\'\" if field[\"type\"].nil?\n field[\"type\"].to_sym\n end",
"def type\n self.attributes[:type]\n end",
"def type\n if validator_hash[:numericality] == true ||\n validator_hash[:numericality] == { allow_nil: true }\n 'Decimal'\n elsif validator_hash.dig(:numericality, :only_integer)\n 'Integer'\n elsif validator_hash[:ingested_date]\n 'Date'\n elsif validator_hash.dig(:case_insensitive_inclusion, :in) == %w[Y N]\n 'YesNo'\n elsif inclusion_list_with_lookup_values?(validator_hash.dig(:case_insensitive_inclusion, :in))\n attr.name.tr(' ', '')\n else\n 'String'\n end\n end",
"def type\n @exception.class.to_s\n end",
"def attachment_detail_type_value_name\n\t\t\ttype_values[3]\n\t\tend",
"def parse_attribute(value, type)\n case type\n when 'INTEGER'\n value.to_i\n when 'BOOLEAN'\n value.to_i == 1\n when 'TEXT'\n value.strip\n else\n raise 'Invalid data type'\n end\n end",
"def attr_type(attr_name)\n raise NotImplementedError\n end",
"def type_code\n type.try(:code)\n end",
"def value_type\n return @value_type\n end",
"def expected_type\n @data[\"expected_type\"]\n end",
"def type_for_attribute(attr_name)\n attr_name = attr_name.to_s\n attribute_types[attr_name]\n end",
"def type_for_attribute(attr_name)\n attr_name = attr_name.to_s\n attribute_types[attr_name]\n end",
"def type_for_attribute(attr_name)\n attr_name = attr_name.to_s\n attribute_types[attr_name]\n end",
"def type_name\n self['type_name']\n end",
"def type_for_attribute(_attribute)\n ActiveModel::Type.lookup(:string, limit: 200)\n end",
"def type\n self['type']\n end",
"def type\n @data['type']\n end",
"def value(instance = nil)\n if nil == instance\n return attribute_type\n end\n attribute_type.new(instance, @options.merge({\n :cls => model,\n :type => type,\n :name => name\n }))\n end",
"def valid_attribute_type( attroid )\n\t\treturn self.valid_attribute_types.find {|attr_type| attr_type.valid_name?(attroid) }\n\tend",
"def type\n @data['type']\n end",
"def title_attachment_type_value_id\n\t\t\tTypeValue.find_by_name(type_values[4]).code rescue '0'\n\t\tend",
"def record_type\n attributes['item_type']\n end",
"def value_type\n 'UNKNOWN'\n end",
"def _type\n special_attribute('@type'.freeze)\n end",
"def find_attribute_type( name )\n\t\tattrtype = nil\n\n\t\t# Try both the name as-is, and the camelCased version of it\n\t\tcamelcased_sym = name.to_s.gsub( /_(\\w)/ ) { $1.upcase }.to_sym\n\t\tattrtype = self.valid_attribute_type( name ) ||\n\t\t self.valid_attribute_type( camelcased_sym )\n\n\t\treturn attrtype\n\tend",
"def title_attachment_type_value_name\n\t\t\ttype_values[4]\n\t\tend",
"def type\n self['type']['type']\n end",
"def type\n @type.to_s\n end",
"def type\n _type rescue nil\n end",
"def type\n self[:type]\n end",
"def attribute_user_tag; object_type.tag rescue \"\"; end",
"def type\n data['type'].to_sym\n end",
"def type\n\t\t\t@data[\"type\"]\n\t\tend",
"def type_for_attribute(attr_name, &block)\n attr_name = attr_name.to_s\n if block\n attribute_types.fetch(attr_name, &block)\n else\n attribute_types[attr_name]\n end\n end",
"def column_type_of(attribute)\n column = @ar_class.columns_hash[attribute.to_s]\n return :string unless column\n return :numeric if column.number? or [:datetime,:time,:date,:timestamp].include?(column.type)\n return :string\n end",
"def type(value)\n _type(value) or fail ArgumentError, \"Unknown value for type: #{value}\"\n end",
"def type(value)\n _type(value) or fail ArgumentError, \"Unknown value for type: #{value}\"\n end",
"def type_from_database(attribute)\n col = @object.column_for_attribute(attribute)\n\n unless col.nil?\n col.type.to_s.downcase\n else\n nil\n end\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def type\n return @type if @type != \"unknown\"\n info\n @type\n end",
"def event_type\n @attributes[:event_type]\n end",
"def type\n self[:type]\n end",
"def value\n send property.type_field\n end",
"def type\n self['TYPE'].to_i\n end",
"def wrong_type_error(value, data_name, expected_type)\n \"#{data_name} was of wrong type, expected #{expected_type} and the value was #{value}\"\n end",
"def human_type\n self[:type].to_human\n end",
"def typecast_attribute(type, value)\n raise ArgumentError, \"a Class must be given\" unless type\n return value if value.nil?\n typecast_value(type, value)\n end",
"def type_name\n @values['typeName']\n end",
"def type\n return attributes['type'] if attributes['type']\n \n # Lookups are in order of preference so if, for example, you set the uri but display_name and id are also\n # set, we'd rather go with the canonical representation.\n if display_name && id\n 'CanonicalUser'\n elsif email_address\n 'AmazonCustomerByEmail'\n elsif uri\n 'Group'\n end\n end",
"def simple_value_type_code\n value_type_code\nend",
"def get_datatype(name, attribute)\n Object.const_get(name).new.get_datatype(attribute)\n end",
"def type\n @props[:type]\n end",
"def error_type\n @error_type ||=\n if (c = self_class)\n type = c.safe_const_get(:ERROR_TYPE)\n type ||= c.name&.demodulize&.to_s&.underscore&.remove(/_error$/)\n type&.to_sym\n end\n end",
"def target_type_localized\n target_type.downcase.to_sym.l\n rescue StandardError\n \"\"\n end",
"def type_str\n self.class.const_get(:TYPE_STR)\n end",
"def query_failure_type\n @attributes[:query_failure_type]\n end",
"def attribute_type(attribute)\n adapter.attribute_type(Ldaptic.encode(attribute))\n end",
"def type\n @type.name\n end",
"def type_name\n @type_name ||= StringHelpers.underscore(StringHelpers.demodulize(@value.class.name)).to_sym\n end",
"def expected_type\n @property.expected_type\n end",
"def attribute_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 30 )\n value = nil\n string30 = nil\n number31 = nil\n\n begin\n # at line 152:35: ( string | number )\n # at line 152:35: ( string | number )\n alt_38 = 2\n look_38_0 = @input.peek(1)\n\n if (look_38_0 == T__14)\n alt_38 = 1\n elsif (look_38_0 == EOF || look_38_0 == DIGIT || look_38_0 == T__11 || look_38_0 == T__33)\n alt_38 = 2\n else\n raise NoViableAlternative(\"\", 38, 0)\n end\n case alt_38\n when 1\n # at line 152:37: string\n @state.following.push(TOKENS_FOLLOWING_string_IN_attribute_value_1142)\n string30 = string\n @state.following.pop\n # --> action\n value = (string30 && @input.to_s(string30.start, string30.stop))\n # <-- action\n\n when 2\n # at line 152:71: number\n @state.following.push(TOKENS_FOLLOWING_number_IN_attribute_value_1148)\n number31 = number\n @state.following.pop\n # --> action\n value = (number31 && @input.to_s(number31.start, number31.stop)).to_i\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 30 )\n\n end\n\n return value\n end",
"def type\n field[:type]\n end",
"def of_kind?(attribute, type = :invalid)\n attribute, type = normalize_arguments(attribute, type)\n\n if type.is_a? Symbol\n !where(attribute, type).empty?\n else\n messages_for(attribute).include?(type)\n end\n end",
"def material_type\n attributes['material_type']\n end",
"def material_type\n attributes['material_type']\n end",
"def type\n \"AttributeDefinition\"\n end",
"def attr_name_from_type_param(type)\n #ap \"type #{type}\"\n type\n .split(\":\")\n .last\n .gsub(/\\[.*:/, '')\n .gsub(/\\]/, '')\n .to_sym\n end",
"def type\n raw_data['type']\n end",
"def type\n data.type\n end",
"def get_type\n\n end",
"def reflection_or_attribute_name; end",
"def type\n @type\n end",
"def get_attribute(root_element, key, type = nil, prefix = nil)\n key_parts = key.split('.')\n output_entry = key_parts[0...-1].inject(root_element.to_hash) { |element, k| element.nil? ? nil : element[k] }\n return nil unless output_entry\n value = output_entry[key_parts.last]\n return nil if value.nil?\n label = prefix ? \"#{prefix}.#{key}\" : key\n raise \"The value of attribute '#{label}' is '#{value.inspect}' and this is not of the expected type #{type.inspect}\" if type && !(type.is_a?(Array) ? type : [type]).any? { |t| value.is_a?(t) }\n value\n end",
"def datatype(value)\n _datatype(value) or fail ArgumentError, \"Unknown value for datatype: #{value}\"\n end",
"def check_attribute_type(ast_class_name, attribute, class_lut)\n\tif not (class_lut.include? attribute.type or attribute.type == \"SELF_TYPE\")\n\t\tline_number = attribute.type_line\n\t\tmessage = \"class #{ast_class_name} has attribute #{attribute.name} with unknown type #{attribute.type}\"\n\t\ttype_error(line_number, message)\t\t\t\n\tend\nend",
"def check_attribute_type(ast_class_name, attribute, class_lut)\n\tif not (class_lut.include? attribute.type or attribute.type == \"SELF_TYPE\")\n\t\tline_number = attribute.type_line\n\t\tmessage = \"class #{ast_class_name} has attribute #{attribute.name} with unknown type #{attribute.type}\"\n\t\ttype_error(line_number, message)\t\t\t\n\tend\nend",
"def get_type; raise NotImplementedError end",
"def type_name\n MESSAGE_TYPE[self.type_id-1][0]\n end",
"def cast_eav_value value, attribute # :nodoc:\n attributes = self.class_eav_attributes.stringify_keys\n return value unless attributes.keys.include?(attribute)\n return value if attributes[attribute] == String # no need for casting\n\n\n begin\n # for core types [eg: Integer '12']\n eval(\"#{attributes[attribute]} '#{value}'\")\n\n rescue\n begin\n # for BigDecimal [eg: BigDecimal.new(\"123.45\")]\n eval(\"#{attributes[attribute]}.new('#{value}')\")\n\n rescue\n begin\n # for date/time classes [eg: Date.parse(\"2011-03-20\")]\n eval(\"#{attributes[attribute]}.parse('#{value}')\")\n rescue\n value\n end\n\n end\n end\n end",
"def get_string(attr); end",
"def text_type\n return @text_type\n end",
"def validateType\n unless Relationship_Type.include?(@type)\n raise \"value #{@type} is not a valid relationship type value\"\n end\n end",
"def type\n @type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Paragraph\", \"Character\", \"Table\", \"List\"])\n if type.to_i == 0\n unless validator.valid?(type)\n raise ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n else\n @type = validator.allowable_values[type.to_i]\n end\n end",
"def property(name)\n return type if name == :type\n Builtin::Error.new(\"PropertyUnknownError: '#{name}' not recognized by #{type}\")\n end",
"def type(column); self[column]['type']; end",
"def value_type= value_type\n self.type = value_type.gsub(\"-\", \"_\").camelize\n end",
"def type\n @type\n end"
] |
[
"0.67965454",
"0.6758143",
"0.6758143",
"0.6758143",
"0.66248244",
"0.66092944",
"0.6570114",
"0.64820665",
"0.64709496",
"0.6451648",
"0.6443759",
"0.6443188",
"0.6399244",
"0.63964474",
"0.63953704",
"0.63598096",
"0.6338912",
"0.629534",
"0.626897",
"0.61901724",
"0.6188766",
"0.61825025",
"0.61318177",
"0.61143243",
"0.61143243",
"0.61143243",
"0.61057985",
"0.61014193",
"0.6091783",
"0.6090304",
"0.60430884",
"0.6042932",
"0.60370976",
"0.6006178",
"0.6004496",
"0.59976774",
"0.59919375",
"0.5981838",
"0.5971789",
"0.5969939",
"0.59453154",
"0.5935033",
"0.59341043",
"0.5927387",
"0.592201",
"0.5920716",
"0.5918802",
"0.5913963",
"0.5892531",
"0.5892531",
"0.5875453",
"0.5873464",
"0.5872701",
"0.5865245",
"0.58487797",
"0.5808956",
"0.5805862",
"0.5799642",
"0.5798691",
"0.57978135",
"0.5795371",
"0.5788083",
"0.5787158",
"0.5785383",
"0.57840925",
"0.57767564",
"0.57739455",
"0.5773715",
"0.57655114",
"0.57593465",
"0.574297",
"0.57284707",
"0.5726952",
"0.5709466",
"0.57084304",
"0.5696419",
"0.56916714",
"0.56916714",
"0.5668732",
"0.56669384",
"0.56577",
"0.56544745",
"0.5637576",
"0.5633923",
"0.56290436",
"0.5623557",
"0.56233466",
"0.5621528",
"0.5621528",
"0.5619587",
"0.56182915",
"0.5613309",
"0.5609738",
"0.5603036",
"0.5602955",
"0.55956745",
"0.5592498",
"0.5585978",
"0.5585368",
"0.55804706",
"0.55784106"
] |
0.0
|
-1
|
Returns the value of attribute backend_klass. source://i18n//lib/i18n/exceptions.rb125
|
def backend_klass; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def inspect\n \"Inspec::Backend::Class @transport=#{backend.class}\"\n end",
"def klass\n class_name = self[\"_type\"]\n class_name ? class_name.constantize : nil\n end",
"def klass\n @klass ||= begin\n @klass_name.split('::').inject(Object){|n,i| n.const_get(i)}\n rescue NameError => e\n end\n end",
"def backend(value = nil)\n if value.is_a?(Symbol)\n require \"down/#{value}\"\n @backend = Down.const_get(value.to_s.split(\"_\").map(&:capitalize).join)\n elsif value\n @backend = value\n else\n @backend\n end\n end",
"def to_s\n \"Inspec::Backend::Class\"\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def platform_klass\n @platform.name.to_s.classify.constantize\n\n rescue NameError\n raise Platforms::ClassDoesNotExist\n end",
"def backend_name\n self.class.name.split(\"::\")[-1].split(\"Store\")[0].downcase\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def implementation_class\n full_implementation_class_name.ns_constantize\n rescue StandardError => e\n msg = \"Failed to get the implementation_class for #{full_implementation_class_name} in #{self.class} #{self&.id} : #{e}\"\n Rails.logger.warn msg\n Rails.logger.warn e.backtrace.join(\"\\n\")\n raise e, msg\n end",
"def default_backend\n attributes_class.defaults[:backend]\n end",
"def klass\n info.klass\n end",
"def service_exception\n if current_module.const_defined?('ServiceException')\n current_module.const_get('ServiceException')\n else\n current_module.const_set('ServiceException', Class.new(Common::Exceptions::BackendServiceException))\n end\n end",
"def klass\n raise NotImplementedError\n end",
"def klass\n @klass || raise(\"klass not set - see bind method\")\n end",
"def klass\n @klass ||=\n if klass_name\n klass_name.constantize\n else\n nil\n end\n end",
"def klass\n @klass ||= @options[:klass] || __get_class_value(:klass)\n end",
"def klass\n type.to_s.classify.constantize\n end",
"def entry_class\n @entry_class ||= settings(\"components.#{params[:component]}.klass\", fatal_exception: true).classify.constantize\n end",
"def klass\n if @klass.is_a?(Class)\n @klass\n else\n unless /\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z/ =~ @klass.to_s\n raise NameError, \"#{@klass.inspect} is not a valid constant name!\"\n end\n \n Object.module_eval(\"::#{$1}\", __FILE__, __LINE__)\n end\n end",
"def backend_name\n config['backend']\n end",
"def klass\n (@klass ||= self.mounting_point.content_types[self.class_name]).tap do |klass|\n if klass.nil?\n raise UnknownContentTypeException.new(\"unknow content type #{self.class_name}\")\n end\n end\n end",
"def class_for(code_object)\n class_name = code_object.class.to_s.split('::').last\n const_get(class_name)\n end",
"def current_class_name\n @klass.to_s\n end",
"def klass\n @options[:class].presence\n end",
"def translation_class\n const_get translation_class_name\n end",
"def component_class\n raise NotImplementedError, 'Specify component class in settings model.'\n end",
"def backend\n @backend ||= self.class.backend\n end",
"def klass\n self.class\n end",
"def klass\n @object.name if (defined? @object.class.name)\n end",
"def klass\n reflection.klass\n end",
"def klass\n reflection.klass\n end",
"def scm_provider_klass\n @scm_provider_klass ||= eval(danger.scm_provider.to_s)\n end",
"def object_class(klass)\n @object_classes[klass.to_s.tr('-', '_').downcase]\n end",
"def _class\n special_attribute('@class'.freeze) || self.class.name.demodulize\n end",
"def type_klass; end",
"def klass\n @klass ||= klasses.select{|k| k.to_s.demodulize == klass_name}.compact.first\n raise EndpointNotDefinedError, \"To call /endpoints/#{params[:klass_name]} you must define 'class #{params[:klass_name].classify} < FfcrmEndpoint::Endpoint'\" if !@klass.present?\n @klass\n end",
"def klass\n object_name.classify.constantize\n end",
"def klass\n nil\n end",
"def klass(class_name)\n Atlas.const_get(class_name)\n end",
"def error_type\n @error_type ||=\n if (c = self_class)\n type = c.safe_const_get(:ERROR_TYPE)\n type ||= c.name&.demodulize&.to_s&.underscore&.remove(/_error$/)\n type&.to_sym\n end\n end",
"def class_name\n self.class.to_s.split('::').last\n end",
"def class_for assoc_name\n raise NotImplementedError\n end",
"def class_for assoc_name\n raise NotImplementedError\n end",
"def worker_class_constantize(worker_class)\n if worker_class.is_a?(String)\n if worker_class.respond_to?(:constantize)\n worker_class.constantize\n else\n # duplicated logic from Rails 3.2.13 ActiveSupport::Inflector\n # https://github.com/rails/rails/blob/9e0b3fc7cfba43af55377488f991348e2de24515/activesupport/lib/active_support/inflector/methods.rb#L213\n names = worker_class.split('::')\n names.shift if names.empty? || names.first.empty?\n constant = Object\n names.each do |name|\n constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)\n end\n constant\n end\n else\n worker_class\n end\n rescue\n worker_class\n end",
"def data_klass\n klass_type = self.class.name\n .gsub!('Spree::Wombat::Handler::', '')\n .gsub!('Handler', '')\n \"Integrations::#{sync_type.camelize}::#{klass_type}\"\n end",
"def engine_class_name(e)\n e.class.name.deconstantize # remove the ::Engine part\n end",
"def klass_name\n \"#{params[:klass_name].classify}\"\n end",
"def determine_operator_class\n\n if operator_for(:has_many) || operator_for(:belongs_to) || operator_for(:has_one)\n\n result = klass.reflect_on_association(operator)\n\n return result.klass if result\n\n result = MapperUtils.class_from_string(operator.classify)\n\n if result.nil?\n begin\n first = klass.to_s.split('::').first\n logger.debug \"Trying to find operator class with Parent Namespace #{first}\"\n\n result = MapperUtils.const_get_from_string(\"#{first}::#{operator.classify}\")\n rescue StandardError => e\n logger.error(\"Failed to derive Class for #{operator} (#{@operator_type} - #{e.inspect}\")\n end\n end\n\n result\n\n elsif connection_adapter_column\n begin\n Kernel.const_get(connection_adapter_column.type.to_s.classify)\n rescue StandardError\n nil\n end\n end\n end",
"def klass_for(controller)\n if registered?(controller) && klass_defined?(controller)\n storage[controller][:klass]\n\n else\n raise Vedeu::Error::MissingRequired,\n \"Cannot route to #{controller} as no class defined.\"\n\n end\n end",
"def type\n self.class.to_s.split('::').last.downcase.to_sym\n end",
"def ruby_class_name\n @ruby_class_name\n end",
"def type\n @exception.class.to_s\n end",
"def name\n @klass\n end",
"def __ext_class\n self_class.name || '???'\n end",
"def backend\n @backend ||= Configurator.new(self, :backend)\n end",
"def worker_class_constantize(worker_class)\n return worker_class unless worker_class.is_a?(String)\n Object.const_get(worker_class)\n rescue NameError => ex\n case ex.message\n when /uninitialized constant/\n worker_class\n else\n raise\n end\n end",
"def typecast_to_class(value)\n value.to_s.constantize\n rescue NameError\n nil\n end",
"def locale_klass_name\n @locale_klass_name ||= self.class.name.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr('-', '_').\n downcase\n end",
"def worker_class_constantize(worker_class)\n if worker_class.is_a?(String)\n worker_class.constantize rescue worker_class\n else\n worker_class\n end\n end",
"def worker_class_constantize(worker_class)\n if worker_class.is_a?(String)\n worker_class.constantize rescue worker_class\n else\n worker_class\n end\n end",
"def component(klass)\n if @replacements && @replacements.has_key?(klass)\n @replacements[klass]\n\n else\n klass\n end\n end",
"def type; self.class.name.split('::').last.to_sym; end",
"def hashback_backend\n self.class.__send__(:class_variable_get, :@@_backend) \n end",
"def class_name\n (self.type.to_s || self.class.name).demodulize\n end",
"def error_name(klass)\n underscore(klass.class.name).split(/\\//).last \n end",
"def klass\n @klass ||= BSON.const_get(description)\n end",
"def className\r\n self.class.to_s\r\n end",
"def job_class\n discrete? ? attributes['job_class'] : serialized_params['job_class']\n end",
"def worker_class_constantize(worker_class)\n return worker_class unless worker_class.is_a?(String)\n worker_class.constantize\n rescue NameError\n worker_class\n end",
"def __adapter_for_klass(klass)\n Adapter.adapters.select { |name, checker| checker.call(klass) }.keys.first\n end",
"def type\n klass = self.class.name\n if sep = klass.rindex('::')\n klass[(sep+2)..-1]\n else\n klass\n end.underscore.to_sym\n end",
"def class_name\n self.class.name.split(\"::\").last.downcase\n end",
"def className\n\t\tself.class.to_s\n\tend",
"def className\n\t\tself.class.to_s\n\tend",
"def exception_class; end",
"def className\r\n\t\tself.class.to_s\r\n\tend",
"def klass; end",
"def klass; end",
"def associated_class\n cached_fetch(:class) do\n begin\n constantize(self[:class_name])\n rescue NameError => e\n raise NameError, \"#{e.message} (this happened when attempting to find the associated class for #{inspect})\", e.backtrace\n end\n end\n end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def convert_to_class(klass)\n @class_cache[klass] ||= Object.const_get(camelize(klass))\n rescue NameError\n raise Traitor::Error.new(\"Tried to create a #{camelize(klass)}, but it does not exist!\")\n end",
"def error_class_constant(error_code); end",
"def codebase()\n \"Hiera::Backend::Simp_compliance_enforcement_backend\"\n end",
"def name\n has_module?(klass) ? klass[(klass.index(\"::\")+2)..-1] : klass\n end",
"def resource_klass_name\n resource_name.classify\n end",
"def resource_klass\n Valkyrie.config.resource_class_resolver.call(internal_resource)\n end",
"def resource_klass\n Valkyrie.config.resource_class_resolver.call(internal_resource)\n end",
"def target_klass\n target_klass_name.constantize\n end",
"def class_name\n self.class.name.split(\"::\").last\n end",
"def type_name\n self.class.name.split('::').last.upcase\n end",
"def class_name\n name = @klass.name\n name.name\n end"
] |
[
"0.6439473",
"0.6364077",
"0.6353455",
"0.62631845",
"0.6179496",
"0.61606276",
"0.61606276",
"0.6159273",
"0.61586124",
"0.60690385",
"0.60690385",
"0.60690385",
"0.6047836",
"0.60435575",
"0.6043083",
"0.6015774",
"0.6010699",
"0.5976511",
"0.597107",
"0.5953714",
"0.5917207",
"0.5913224",
"0.5894191",
"0.5869618",
"0.586112",
"0.5856927",
"0.5841315",
"0.5837757",
"0.5836007",
"0.5820599",
"0.58133584",
"0.5801516",
"0.57865685",
"0.576784",
"0.576784",
"0.576312",
"0.5740247",
"0.57364523",
"0.56808275",
"0.5661309",
"0.56545454",
"0.565449",
"0.5646342",
"0.56373733",
"0.56224144",
"0.561773",
"0.561773",
"0.5611691",
"0.5607757",
"0.56063306",
"0.55982953",
"0.5596179",
"0.5574372",
"0.5573416",
"0.5569497",
"0.55685997",
"0.5549597",
"0.55482465",
"0.55406755",
"0.55339515",
"0.55335045",
"0.5525822",
"0.551188",
"0.551188",
"0.55014753",
"0.550106",
"0.5496215",
"0.5489023",
"0.5482378",
"0.5463353",
"0.5454093",
"0.5450462",
"0.5447917",
"0.54465926",
"0.5441901",
"0.5436013",
"0.54329705",
"0.54329705",
"0.54281074",
"0.542747",
"0.5414629",
"0.5414629",
"0.54144144",
"0.54141945",
"0.54141945",
"0.54141945",
"0.54141945",
"0.54141945",
"0.54141945",
"0.5412403",
"0.53952354",
"0.53951",
"0.53867733",
"0.5380563",
"0.5380361",
"0.5380361",
"0.537673",
"0.53752124",
"0.5370219",
"0.5368718"
] |
0.72675484
|
0
|
Returns the value of attribute method. source://i18n//lib/i18n/exceptions.rb125
|
def method; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [](attribute)\n messages_for(attribute)\n end",
"def [](attribute)\n messages[attribute.to_sym]\n end",
"def attribute_get(attribute)\n check_attribute!(attribute)\n send(attribute.to_s)\n end",
"def attribute_get(attribute)\n check_attribute!(attribute)\n send(attribute.to_s)\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def get_string(attr); end",
"def value\n raise\n end",
"def datatables_instance_get_value(instance, column)\n if column[:attribute]\n val = instance.send(column[:attribute].to_sym)\n return I18n.t(val.to_s.to_sym, :default => val.to_s) if not val.nil?\n return ''\n elsif column[:special]\n special = column[:special]\n \n if special[:method]\n return method(special[:method].to_sym).call(instance)\n elsif special[:eval]\n proc = lambda { obj = instance; binding }\n return Kernel.eval(special[:eval], proc.call)\n end\n end\n return \"value not found\"\n end",
"def method_missing(method_name)\n attributes[method_name]\n end",
"def getter(attribute)\n willAccessValueForKey(attribute)\n value = send(\"primitive#{attribute.sub(/\\S/, &:upcase)}\")\n didAccessValueForKey(attribute)\n return value\n end",
"def method\n attributes.fetch(:method)\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def raw(attribute)\n errors[attribute.to_sym]\n end",
"def read_attribute_for_validation(attr)\r\n send(attr)\r\n end",
"def method_missing(method, *args, &block)\n key = method.to_s\n return @details[key] if @details.has_key?(key)\n\n raise Ncdc::Error.new(\"Could not read attribute '#{key}' - #{@details.inspect}\")\n end",
"def method\n @attributes[:method]\n end",
"def human_name_for(instance, method)\n I18n.t(\"activerecord.attributes.#{instance}.#{method}\", :default => method.to_s.humanize)\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def attribute(_name)\n raise Orocos::NotFound, \"#attribute is not implemented in #{self.class}\"\n end",
"def read_attribute_for_validation(attr)\n send(attr)\n end",
"def read_attribute_for_validation(attr)\n send(attr)\n end",
"def read_attribute_for_validation(attr)\n send(attr)\n end",
"def method_missing(sym, *args, &block)\n return attribute(sym.to_s) if not sym.to_s =~ /\\?$/\n super\n end",
"def get_attribute(object, attribute)\n attribute = attribute.to_sym\n object = localize(object) unless object.respond_to? :nii_attribute?\n return object.nii_attribute(attribute) if object.nii_attribute? attribute\n raise Errors::UnknownAttribute, \"unknown attribute\"\n end",
"def method_name key\n \"value_for_#{key}\"\n end",
"def val(document, attribute)\n document.public_send(attribute) ||\n raise(\"#{ document.inspect } has no #{ attribute.inspect } value\")\n end",
"def attribute_from_method( methodname )\n\n\t\tcase methodname.to_s\n\t\twhen /^(?:has_)?([a-z]\\w*)\\?$/i\n\t\t\treturn $1.to_sym, :predicate\n\t\twhen /^([a-z]\\w*)(=)?$/i\n\t\t\treturn $1.to_sym, ($2 ? :writer : :reader )\n\t\tend\n\tend",
"def method_missing(attribute_name, *)\n instance_variable_get(\"@#{attribute_name}\")\n rescue NameError\n raise NoMethodError, \"undefined method `#{attribute_name}' for #{inspect}\"\n end",
"def textMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend",
"def get attribute\n attributes[attribute]\n end",
"def localized_attribute_string(resource, attr_name)\n model_name = resource.class.name.underscore\n action_name = template.params[:action].to_s rescue ''\n attribute_name = attr_name.to_s\n\n i18n_scopes = ['{{model}}.{{action}}.{{attribute}}', '{{model}}.{{attribute}}', '{{attribute}}']\n defaults = i18n_scopes.collect do |i18n_scope|\n i18n_path = i18n_scope.dup\n i18n_path.gsub!('{{action}}', action_name)\n i18n_path.gsub!('{{model}}', model_name)\n i18n_path.gsub!('{{attribute}}', attribute_name)\n i18n_path.gsub!('..', '.')\n i18n_path.to_sym\n end\n defaults << ''\n\n i18n_value = ::I18n.t(defaults.shift, :default => defaults, :scope => \"formtastic.labels\")\n i18n_value.blank? ? nil : i18n_value\n end",
"def method_missing(method_name, *args, &block)\n ignore_list = [:to_hash]\n return if ignore_list.include? method_name\n\n respond_to?(method_name) ? attribute(method_name.to_s.tr('_', '-')) : super\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(method, *args)\n if opt = get(method)\n opt.value\n else\n raise NoMethodError, method\n end\n end",
"def attribute_changed_value_message=(_arg0); end",
"def on(attribute)\n errors[attribute.to_sym]\n end",
"def error_message_for(attribute)\n case attribute\n when :email, :password, :password_confirmation\n @admin_registration.errors[attribute].join(', ')\n else\n raise \"Error messages not implmeneted for \\\"#{attribute}\\\"\"\n end\n end",
"def call_field(field)\n field.to_s.split('__').inject(self) { |a, e| a&.send(e) }\n rescue NoMethodError\n ''\n end",
"def [](attribute)\n case attribute\n when Integer\n @attributes[attribute].value\n else\n @attribute_for.fetch(to_field(attribute)) do |header_name|\n raise UnknownAttributeError,\n \"the header '#{header_name.value}' is unknown\"\n end\n end\n end",
"def method_missing( attribute, *args )\n\t\treturn self.base.send( attribute, *args )\n\tend",
"def value_for (attribute)\n unless current_values.key?(attribute)\n raise ArgumentError, \"No such attribute: #{attribute.inspect}\"\n end\n current_values[attribute]\n end",
"def error(method)\n errors = @object.errors[method] if @object\n errors.to_sentence if errors.present?\n end",
"def method_missing(meth, *args, &block)\n return 'Unknown config value: ' + meth.to_s\n end",
"def method_missing(method_name, *arguments, &block)\n # not a bug here, we want =, not ==\n if /^(?<id>[^=]+)$/ =~ method_name.to_s && (attribute = self[id])\n attribute.value\n else\n nil\n end\n end",
"def __value\n unless defined?(@value)\n __get_value\n end\n\n if @value.is_a?(WrappedException)\n ::Kernel.raise @value\n end\n\n @value\n end",
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def attribute attr\n @ref.attribute(TRANSLATOR.cocoaify(attr)).to_ruby\n end",
"def _read_attribute(key); end",
"def reflection_or_attribute_name; end",
"def [](attribute)\n `c$Element.prototype.m$get_property.call(#{@element},attribute)`\n end",
"def error_message\n self[:error_message]\n end",
"def attribute_name\n notifier.attribute_name if notifier.respond_to?(:attribute_name)\n end",
"def ar_get_resource_value(resource, column)\n return \"Error: #{resource}, #{column}\" unless column && resource\n \n case column\n when String, Symbol\n \n if controller.ardata.foreing_models.include?(column.to_s)\n column.to_s.match(/^(.*)_id$/)\n record= resource.send($1)\n return record ? record.label : controller.ardata.labels[:nil_value_in_field]\n else\n return h(resource.send(column)) || controller.ardata.labels[:nil_value_in_field]\n end\n \n else\n ar_retrieve_field_value column, resource\n end\n end",
"def parse_translated_attribute_accessor(method_name)\n return unless method_name =~ /\\A([a-z_]+)_([a-z]{2})(=?)\\z/\n\n translated_attr_name = $1.to_sym\n return unless translated_attrs.include?(translated_attr_name)\n\n locale = $2.to_sym\n assigning = $3.present?\n\n [translated_attr_name, locale, assigning]\n end",
"def read_attribute_for_validation(name)\n send(name)\n end",
"def get_value\n read_attribute('text_value')\n end",
"def get_char(attr); end",
"def get_value(attribute)\n obj = @map[attribute]\n if obj\n if obj.is_a?(String)\n return obj.to_s\n end\n end\n\n raise IllegalStateException, \"The attribute #{attribute} doesn't have a paired string.\"\n end",
"def get_attribute(attribute)\n\t\t@attributes[attribute.intern]\n\tend",
"def method_missing(m)\n body[m.to_s] || 'Not available'\n end",
"def accessor_for(attribute)\n attribute = attribute.to_sym\n\n if table.has_key?(attribute)\n attribute\n\n elsif pair = pair_for(attribute)\n pair.first\n\n else\n send_to_translation(:accessor_for, attribute)\n end\n end",
"def define_active_enum_read_method(attribute, column)\n class_eval <<-DEF\n def active_enum_translate_#{attribute}(arg, value)\n enum = self.class.active_enum_for(:#{attribute})\n arg ||= #{ActiveEnum.use_name_as_value ? ':name' : ':id' }\n case arg\n when :id\n if enum[value] then value else 0 end\n when :name\n enum[value] || I18n.t('unknown', scope: :active_enum, default: 'Unknown')\n when :enum\n enum\n when Symbol\n (enum.meta(value) || {})[arg]\n end\n end\n \n def #{attribute}(arg=nil)\n value = self.#{column}\n active_enum_translate_#{attribute}(arg, value)\n end\n\n def human_#{attribute}\n enum = self.class.active_enum_for(:#{attribute})\n value = self.#{column}\n enum[value]\n end\n DEF\n end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def get_value_with_method_name(method_name)\n get_contact_detail_value(hash_from_method_name(method_name))\n end",
"def raw_getter field\n val = self.instance_variable_get(\"@#{field}\")\n return nil if val.nil? == true || val == false\n\n if BOOL_ATTRIBUTES.include? field\n return field.to_s.gsub '_', '-' \n end\n\n if STR_ATTRIBUTES.include? field \n return val \n end\n\n if ARR_STR_ATTRIBUTES.include? field && val.empty? == false \n return val.join ' '\n end\n\n if SUB_STR_ATTRIBUTES.include? field \n return SUB_STR_ATTRIBUTES[field].sub '%sub%', val \n end \n end",
"def get(attribute)\n @attributes[attribute.to_s]\n end",
"def method\n return @method\n end",
"def error_message_from_model(model, attribute, message, extra = {})\n ::ActiveModel::Errors.new(model).generate_message(attribute, message, extra)\n end",
"def method_missing( method, *args )\n return super unless args.empty?\n _value_for_key( method )\n end",
"def fetch_attribute(locale, name)\r\n translation = record.translation_for(locale)\r\n return translation && translation.send(name)\r\n end",
"def attr\n @attr || header.downcase\n end",
"def attr\n @attr || header.downcase\n end",
"def get_attribute_value(attribute)\n values = read_attr_val(attribute.id)\n return nil unless values\n if attribute.atype == ProductAttribute::Atype_String\n return values[0]\n elsif attribute.atype == ProductAttribute::Atype_Currency\n MoneyUtils.format(values[1])\n else\n return Integer(values[1])\n end\n end",
"def [](method)\n self.__send__(method)\n rescue NoMethodError\n nil\n end",
"def read_attribute\n record.public_send(attribute)\n end",
"def attribute(field)\n ->(resource) { resource.send(field) }\n end",
"def method_missing(method_id, *arguments, &block)\n return data['attributes'][method_id.to_s] if data['attributes'].key?(method_id.to_s) && arguments.none? && block.nil?\n\n super\n end",
"def [](attribute)\n errors[attribute.to_sym] || []\n end",
"def [](attribute)\n errors[attribute.to_sym] || []\n end",
"def [](method)\n self.send(method.to_sym)\n rescue NoMethodError\n nil\n end",
"def key_value\n @attrs[self.class.key_attribute.to_s]\nend",
"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_property\n @method_property\n end",
"def translation_for(field)\n object.class.human_attribute_name(field)\n end",
"def [](attr)\n send(attr)\n end",
"def value_for(resource)\n resource.send(key)\n end",
"def get_value()\n raise(IsoError, IsoError.tag_the_message(\"Operation not available in Composite\"))\n end",
"def attribute(show_attribute)\n case show_attribute\n when 'deadline'\n return self.deadline\n when 'renter_id'\n return self.renter.surname if self.renter_id > 0\n when 'property_id'\n return self.property.name if self.property_id > 0\n when 'object'\n return self.object.downcase\n when 'price'\n return self.price\n when 'category'\n return self.category\n when 'groupp'\n return self.groupp\n when 'paid'\n return self.paid\n else \n return ''\n end\n end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end",
"def attribute_name; end"
] |
[
"0.6290639",
"0.62029237",
"0.6152934",
"0.6152934",
"0.6089394",
"0.6089394",
"0.6059173",
"0.6057837",
"0.6054255",
"0.6027787",
"0.6012341",
"0.5954264",
"0.5933237",
"0.5933237",
"0.5892689",
"0.5892574",
"0.5868998",
"0.58081543",
"0.5806475",
"0.5799586",
"0.5787982",
"0.573838",
"0.573838",
"0.573838",
"0.57001495",
"0.5654291",
"0.5651236",
"0.56245255",
"0.56085455",
"0.56019807",
"0.55997705",
"0.55814457",
"0.5575824",
"0.5570855",
"0.55548555",
"0.55528283",
"0.5549941",
"0.5522422",
"0.55067235",
"0.5493733",
"0.54905075",
"0.54803",
"0.5471384",
"0.5470478",
"0.5465426",
"0.54642385",
"0.5455773",
"0.54535747",
"0.5452995",
"0.5434554",
"0.54222906",
"0.5418299",
"0.54146457",
"0.54019064",
"0.5400873",
"0.5396256",
"0.5385818",
"0.5377673",
"0.5376286",
"0.5364951",
"0.53513396",
"0.5347928",
"0.5342024",
"0.5341362",
"0.53354776",
"0.53354776",
"0.53354776",
"0.53354776",
"0.53354776",
"0.53354776",
"0.53354776",
"0.53222793",
"0.53152364",
"0.53144157",
"0.53102815",
"0.5309546",
"0.53065795",
"0.5273518",
"0.5266082",
"0.5260566",
"0.5260566",
"0.5247975",
"0.5246004",
"0.5241516",
"0.5239324",
"0.52381194",
"0.52319115",
"0.52319115",
"0.52293956",
"0.5224001",
"0.5222588",
"0.52188075",
"0.5211076",
"0.51955295",
"0.51954025",
"0.5195106",
"0.5189979",
"0.51876366",
"0.51876366",
"0.51876366",
"0.51876366"
] |
0.0
|
-1
|
Returns the value of attribute msg. source://i18n//lib/i18n/exceptions.rb125
|
def msg; end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_message(key)\n msg = error_messages[key]\n return msg.nil? ? 'An unspecified error occurred.' : msg\n end",
"def exception_message\n @e_m ||= @exception.nil? ? '' : @exception.message\n end",
"def message\n @error['message']\n end",
"def error_message\n self[:error_message]\n end",
"def error_message\n @data[\"message\"]\n end",
"def message\n configuration.default_message || @exception.message\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def message\n msg = \"Format error found in %s tuple: %s\" % [@identifier, @invalid_data.inspect]\n return msg\n end",
"def error_msg\n name\n end",
"def error_message\n return @error_message\n end",
"def message # :nodoc:\n @properties['errorMessage'].dup\n end",
"def error_msg\n ERROR_MSG[upcase_class_sym]\n end",
"def message\n @props.fetch(:message, \"must be valid\")\n end",
"def message\n @errormsg\n end",
"def error_message\n error.message\n end",
"def message\n message_hash || 'The item could not be found'.freeze\n end",
"def failure_message\n @message\n end",
"def exception_message(e, msg=nil)\n m = []\n m << msg if msg\n m << e.message\n m += e.backtrace\n m.join(\"\\n\")\n end",
"def error_message=(value)\n @error_message = value\n end",
"def error_message(e)\n fail e\n end",
"def error_message\n @response.reason_phrase\n end",
"def error_message\n @response_attributes['ErrorMessage'];\n end",
"def message\n @params['ErrorMessage']\n end",
"def message\n @values['message']\n end",
"def error_message_for(attribute)\n case attribute\n when :email, :password, :password_confirmation\n @admin_registration.errors[attribute].join(', ')\n else\n raise \"Error messages not implmeneted for \\\"#{attribute}\\\"\"\n end\n end",
"def translated_error_message(identifier)\n return default_translated_error_message(identifier) if utility.nil?\n I18n.t(\n \"errors.messages.#{utility_class_name}.#{identifier}\",\n default: default_translated_error_message(identifier)\n )\n end",
"def get_error_message(str)\n tmp=str.scan(/^ERROR MESSAGE --8<------\\n(.*?)ERROR MESSAGE ------>8--$/m)\n return \"Error message not available\" if !tmp[0]\n tmp[0][0].strip\n end",
"def custom_error_message\n message = component.dig('errors', schema_key, 'any')\n\n message % error_message_hash if message.present?\n end",
"def error_message(ex) #:nodoc:\n msg = \"error: #{ex.message}\"\n case ex\n when UnknownCommand\n msg += \". Use '#{program_name} help' for a list of commands\"\n when UnknownCommandArgument\n msg += \". Use '#{program_name} help #{ex.command.name}' for a list of command options\"\n when UnknownGlobalArgument\n msg += \". Use '#{program_name} help' for a list of global options\"\n end\n msg\n end",
"def getMessage()\n return @message\n end",
"def hubssolib_get_exception_message(id_data)\n hubssolib_get_exception_data(CGI::unescape(id_data))\n end",
"def message\n @attributes[:message]\n end",
"def message\n format(ERRORS.fetch(type), **params)\n end",
"def message\n format(ERRORS.fetch(type), **params)\n end",
"def error_message_from_model(model, attribute, message, extra = {})\n ::ActiveModel::Errors.new(model).generate_message(attribute, message, extra)\n end",
"def message\n MESSAGE\n end",
"def message\n MESSAGE\n end",
"def message\n MESSAGE\n end",
"def message\n MESSAGE\n end",
"def error_message; end",
"def message_for(key,options={})\n handwritten_message || I18n.translate(key, {:scope => 'activerecord.errors.messages'}.merge(options))\n end",
"def msg\n self['msg']||{}\n end",
"def error_message\n err = details[\"err\"] || details[\"errmsg\"] || details[\"$err\"]\n if code = details[\"code\"]\n \"failed with error #{code}: #{err.inspect}\\n\\n\" <<\n \"See #{ERROR_REFERENCE}\\nfor details about this error.\"\n elsif code = details[\"assertionCode\"]\n assertion = details[\"assertion\"]\n \"failed with error #{code}: #{assertion.inspect}\\n\\n\" <<\n \"See #{ERROR_REFERENCE}\\nfor details about this error.\"\n else\n \"failed with error #{err.inspect}\"\n end\n end",
"def error_message(value)\n set_dsl(:error_message, value)\n end",
"def errmsg e\n m, c, b = e.message, e.class, (e.backtrace||[])\n \"#{ m } (#{ c })\\n#{ b }\"\n end",
"def message\n message = errors[:message]\n if message.class == String\n message\n elsif message.class == Array\n message.join\n end\n end",
"def message\n attributes[:message]\n end",
"def invalid_message\r\n @invalid_message ||= 'Please enter Yes or No.'\r\n end",
"def message_from(response)\n if not response.has_key?(:ErrInfo)\n return 'Success'\n end\n\n # The ErrInfo key can contain a | separated string of multiple error\n # codes. By default we start at the end and work our way backwards to\n # try and find the highest-level one we can.\n if response[:ErrInfo].index('|')\n error_codes = response[:ErrInfo].split('|')\n else\n error_codes = [response[:ErrInfo]]\n end\n\n error_codes.reverse.each do |code|\n if ERROR_CODES.has_key?(code)\n return ERROR_CODES[code]\n end\n end\n\n \"Error #{error_codes[-1]}\"\n end",
"def not_valid_message; nil; end",
"def not_valid_message; nil; end",
"def message\n attributes.fetch(:message)\n end",
"def mensaje_error\n\t\tmensaje_error_element.text\n\tend",
"def error_msg\n IBM_DB.getErrormsg(@conn, IBM_DB::DB_CONN)\n end",
"def msg_ERROR(source, args)\n return args[0]\n end",
"def message\n @_message\n end",
"def message\n @_message\n end",
"def get_general_error_message\n find('#form-message-general').text\n end",
"def message\n \"Telphin returned an error #{@error_code}: '#{@error_msg}'\"\n end",
"def translated_header_message\n lookups = []\n lookups << :\"activemodel.errors.template.header_message\"\n lookups << :\"activerecord.errors.template.header_message\"\n lookups << :\"case_form.errors.template.header_message\"\n lookups << \"Some errors prohibited this object from being saved\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def schema_error_msg(prop)\n msg = schema.fetch('properties', {}).fetch(prop, {})['error']\n msg || begin\n schema.fetch('definitions', {}).values.map do |attrs|\n attrs.fetch('properties', {}).fetch(prop, {})['error']\n end.first\n end\n end",
"def get_message\n raise NotImplementedError.new(\"#{self.class.name}#get_message() is not implemented.\")\n end",
"def get_message\n raise NotImplementedError.new(\"#{self.class.name}#get_message() is not implemented.\")\n end",
"def error_for_message(msg)\n unless @errors\n with_reader do |conn|\n @errors = (0..127).inject({}) do |h, err|\n h[conn.err2string(err)] = err; h\n end\n end\n @errors.delete(\"Unknown error\")\n end\n @errors[msg]\n end",
"def error_message(attribute)\n unless @object.errors.on(attribute).blank?\n content_tag(:p, :class => 'notice') do\n concat ERB::Util.html_escape(@object.errors.on(attribute).mb_chars.capitalize)\n end\n else\n ''\n end\n end",
"def error_message_for(field)\n return nil unless has_errors?(field)\n \n errors = if RPH::FormAssistant::Rules.has_I18n_support?\n full_messages_for(field)\n else\n human_field_name = field.to_s.humanize\n errors = [*object.errors[field]].map do |error|\n \"#{human_field_name} #{error}\"\n end \n end\n \n RPH::FormAssistant::FieldErrors.new(errors)\n end",
"def error msg\n puts \"#{self.class} error: #{msg}\"\n end",
"def message\n message = \"Some of the request parameters are invalid:\" \n @messages.each { |param, identifiers| message << \"\\n * #{param}: #{identifiers.join(', ')}\" }\n message\n end",
"def exception_details(e, msg); end",
"def error_message(response)\n json = parse_as_json(response)\n json.dig('error', 'message')\n rescue UnexpectedResponseError\n summary = \"Status: #{response.code}; Body: #{response.body}\"\n \"Could not parse error message. #{summary}\"\n end",
"def error msg\n @error = msg\n end",
"def message\n props[ LOG_PROP_NAME ] if props\n end",
"def exception_variable\n node_parts[1]\n end",
"def errmsg(message); end",
"def exception_message(e)\n <<-EXCEPTION\nException happend\nType: #{@type.inspect}\nData: #{@data.inspect}\nError occurs: #{e.class.inspect}(#{e.message})\nBacktrace: #{e.backtrace.join(\"\\n\") rescue ''}\n EXCEPTION\n end",
"def get_message\n get_status[:message]\n end",
"def full_message(attribute, message)\n return message if attribute == :base\n attr_name = attribute.to_s.tr('.', '_').humanize\n #attr_name = @base.class.human_attribute_name(attribute, default: attr_name)\n I18n.t(:\"errors.format\", {\n default: \"%{attribute} %{message}\",\n attribute: attr_name,\n message: message\n })\n end",
"def error_text(error_code)\n ERRORS[error_code.to_i]\n end",
"def failure_message(*args)\n case args.size\n when 1\n @failure_message = args[0]\n when 2\n @exception_type, @failure_message = args[0], args[1]\n else\n raise ArgumentError, \"#{self.class}#failure_message takes 1 or 2 arguments, you gave #{args.inspect}\"\n end\n end",
"def get_error_message(str)\n tmp=str.split(/\\n/)\n return \"Unknown error\" if !tmp[0]\n tmp[0]\n end",
"def error_string\n # This method should be overridden\n end",
"def error(msg)\n puts red(bold(\"[!] #{msg}\"))\n end",
"def failed_message\n Online::OPERATION_FAILED_ADVICES[@data['error_code'].to_i || \"Errore sconosciuto (#{error_code})\"]\n end",
"def get_error_message(form_name, question_id)\n get_form(form_name)[:questions][question_id][:error_message]\n end",
"def error_message\n \"JPT - #{setting_name} received an invalid argument: #{source}\"\n end",
"def describe_error\n message = \"\"\n if self.account_number == nil\n message = message + I18n.t(:wrong_or_missing_account_number, :scope => [:model, :index]) + \" \"\n end\n if self.account_bank_number == nil\n message = message + I18n.t(:wrong_or_missing_account_bank_number, :scope => [:model, :index]) + \" \"\n end\n if self.student.uic == nil\n message = message + I18n.t(:missing_uic, :scope => [:model, :index]) + \" \"\n end\n if self.sident == -666\n message = message + I18n.t(:missing_sident_666, :scope => [:model, :index]) + \" \"\n end\n if self.sident == nil\n message = message + I18n.t(:missing_sident, :scope => [:model, :index]) + \" \"\n end\n return message\n\n end",
"def default_message\n \"Invalid Derelict instance\"\n end",
"def extact_error_message(body)\n error_response = JSON.parse(body)\n error_response[\"errorMessage\"][0][\"error\"][0][\"message\"][0] rescue \"Unexpected error occured!\"\n end",
"def error_message(obj, name = \"\")\n if name.present? && obj.get_operation_result.code.zero?\n \"Could not find user '#{name}'\"\n else\n \"#{obj.get_operation_result.message} (code #{obj.get_operation_result.code})\"\n end\n end",
"def error_message\n @@state[@server] ? @@state[@server][:message] : \"\"\n end",
"def error_message\n if @errors\n @errors.map { |(k,v)|\n \"#{k} #{v.join(',')}\"\n }.join(\"; \")\n end\n end",
"def error_message\n if error == 'on_reserve'\n 'another user has already reserved this item'\n elsif error == 'too_many'\n \"you cannot renew a loan more than 10 times\"\n elsif code == 'PatronNotFound'\n 'problem with user id - please contact an administrator for assistance'\n end\n end",
"def get_error_msg(value, id = \"id\")\n take_screenshot\n return $browser.span(:\"#{id}\" => \"#{value}\").text\n end",
"def default_error_message\n default_error_message_key = \"error.#{schema_key}\"\n default_message = Rails\n .application\n .config\n .default_metadata[default_error_message_key]\n\n if default_message.present?\n default_message['value'] % error_message_hash\n else\n raise NoDefaultMessage, \"No default message found for key '#{default_error_message_key}'.\"\n end\n end",
"def message\n backtrace = @config.backtrace_cleaner.clean(exception.backtrace)\n markdown = Markdown.new\n metadata.each { |key, value| markdown.bullet(\"#{key}: #{value}\") }\n max_block_size = MAX_MESSAGE_SIZE - markdown.result.length - 10\n markdown.code_block(backtrace.join(\"\\n\"), 'text', max_block_size)\n markdown.result\n end",
"def errmsg(message)\n error.print(\"*** #{message}\\n\")\n end",
"def message\n @options[:message] || \"failed validation\"\n end",
"def error_message(msg)\n STDERR.puts msg\n end",
"def message\n errors.join(\"\\n\")\n end",
"def message\n @cause.nil? ? super : \"#{super} (cause: #{@cause.message})\"\n end",
"def error\n params[\"ErrDesc\"]\n end"
] |
[
"0.7317678",
"0.7084888",
"0.70647895",
"0.69148684",
"0.6891388",
"0.68525314",
"0.6843268",
"0.68404174",
"0.6804894",
"0.6769956",
"0.67391574",
"0.66558814",
"0.6554872",
"0.65408057",
"0.65241593",
"0.6430584",
"0.6408233",
"0.6365566",
"0.63168323",
"0.62989503",
"0.6293189",
"0.62899005",
"0.6271467",
"0.62705576",
"0.62531954",
"0.6252161",
"0.6231654",
"0.62028325",
"0.61934286",
"0.6190944",
"0.61895394",
"0.6157349",
"0.61569697",
"0.61569697",
"0.61565983",
"0.6144752",
"0.6144752",
"0.6144752",
"0.6144752",
"0.6140832",
"0.6140692",
"0.6135758",
"0.61283875",
"0.6114175",
"0.61104083",
"0.6099246",
"0.60802",
"0.60639715",
"0.6045488",
"0.6036105",
"0.6036105",
"0.60311425",
"0.60268945",
"0.6025846",
"0.60197145",
"0.6006125",
"0.6006125",
"0.59812427",
"0.5980349",
"0.5953888",
"0.5936476",
"0.59347355",
"0.59347355",
"0.5933793",
"0.5927079",
"0.5917654",
"0.5907121",
"0.59064126",
"0.59052277",
"0.5899343",
"0.5890604",
"0.5873495",
"0.58709407",
"0.5862921",
"0.5858304",
"0.58549607",
"0.5850949",
"0.5848416",
"0.58470064",
"0.5842924",
"0.5838814",
"0.58381873",
"0.58279157",
"0.5817217",
"0.5814475",
"0.5799955",
"0.57914686",
"0.57857865",
"0.57851976",
"0.57850987",
"0.5782902",
"0.57824004",
"0.57806367",
"0.57754064",
"0.5764131",
"0.57412165",
"0.57380736",
"0.57365084",
"0.5732173",
"0.5725157",
"0.5721114"
] |
0.0
|
-1
|
Generates crontab for each scheduled Job using Whenever DSL.
|
def schedule_jobs(job_list)
Jobbr::Ohm.models(Jobbr::Scheduled).each do |job|
if job.every
job_list.every job.every[0], job.every[1] do
job_list.jobbr job.task_name
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def install_crontab\n # create a working crontab file\n # log \"Building crontab\\n\"\n f = File.open(CRONTAB, 'w')\n f.write \"MAIL='keburgett@gmail.com'\\n\"\n # for each sprinkle, write a crontab entry for OPEN and CLOSE times.\n p = Porter.first.localhost_with_port # provides host:port combination\n Sprinkle.all.each do |s|\n [OPEN, CLOSE].each do |action|\n crontab_line = \"#{s.to_crontab(action)} sh #{valve_actuator_path} #{s.valve.to_crontab(action)} #{p} #{s.id}\\n\" \n f.write crontab_line\n # log \"#{crontab_line}\\n\"\n end\n end\n f.close\n system(\"crontab #{CRONTAB}\")\n end",
"def install_crontab\n # create a working crontab file\n f = File.open(CRONTAB, 'w')\n f.write \"MAIL='keburgett@gmail.com'\\n\"\n # for each sprinkle, write a crontab entry for OPEN and CLOSE times.\n Sprinkle.all.each do |s|\n [AppConstants::OPEN, AppConstants::CLOSE].each do |action|\n crontab_line = \"#{s.to_crontab(action)} sh #{valve_actuator_path} #{s.valve.to_crontab(action)} #{host_with_port}\\n\" \n f.write crontab_line\n # #logger.info crontab_line\n end\n end\n f.close\n system(\"crontab #{CRONTAB}\")\n end",
"def cron_tasks\n end",
"def get_crontab_entry\n # Initialize\n newcron = []\n newcron << \"# Chef Name: #{new_resource.name}\"\n newcron << env_var_str unless env_var_str.empty?\n newcron << duration_str + time_out_str + cmd_str\n\n newcron.join(\"\\n\")\n end",
"def cron_schedule\n @cron_schedule ||= Fugit::Cron.parse(cron)\n end",
"def cron(*args)\n @cron = args\n end",
"def create_cron\n cron_edit = CronEdit.new\n command = cron_edit.add_command create_cron_command, Environment.ruby\n puts \"--> added command to cron\"\n puts \" #{command}\"\n end",
"def create\n @chore = @dwelling.chores.build(params[:chore])\n @chore.owner = current_user\n @chore.active = true\n\n # Make the actual cron-format string\n cron_cmd = \"/bin/bash -l -c 'cd #{Rails.root} && bundle exec rake chores:activate_chore CHORE_ID=\"\n case @chore.cron_str\n when \"Every M/W/F\"\n @chore.cron_str = \"0 0 * * MON,WED,FRI #{cron_cmd}\"\n when \"Every T/Th\"\n @chore.cron_str = \"0 0 * * TUE,THU #{cron_cmd}\"\n when \"Every Sunday\"\n @chore.cron_str = \"0 0 * * SUN #{cron_cmd}\"\n else\n @chore.cron_str = nil\n end\n\n # if @chore.cron_str\n # puts @chore.cron_str\n # puts (CronEdit::Crontab.Add \"chore_#{params[:id]}\", @chore.cron_str)\n # end\n\n respond_to do |format|\n if @chore.save\n if @chore.cron_str\n puts @chore.cron_str\n puts (CronEdit::Crontab.Add \"chore_#{@chore.id}\", \"#{@chore.cron_str}#{@chore.id}'\")\n end\n format.html { redirect_to @chore, notice: 'Chore was successfully created.' }\n format.json { render json: @chore, status: :created, location: @chore }\n else\n format.html { render :new }\n format.json { render json: @chore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def schedule(interval: CronSwanson.default_interval, roles: [], &block)\n @in_schedule_method = true\n @whenever_jobs = []\n\n raise ArgumentError, \"provide a block containing jobs to schedule.\" if !block_given?\n\n # execute the block in the context of CronSwanson::Whenever (rather than in the context\n # of the Whenever::JobList where it will be invoked) so that we can intercept\n # calls to `rake` and similar (via method_missing below).\n instance_eval(&block)\n\n # make a schedule based on the contents of the jobs which were defined in the block\n schedule_seed = @whenever_jobs.map do |job_config|\n m, args, _block = *job_config\n \"#{m} #{args.join}\"\n end\n schedule = CronSwanson.build_schedule(@seed + schedule_seed.join, interval: interval)\n\n # now that we know when to schedule the jobs, actually pass the block to Whenever\n if roles.size > 0\n @whenever_job_list.every(schedule, roles: roles, &block)\n else\n @whenever_job_list.every(schedule, &block)\n end\n\n @in_schedule_method = false\n end",
"def initialize\n klass = self.class\n create_hourly_cronjob(klass.hourly_method) if klass.hourly_method\n create_daily_cronjob(klass.daily_method, klass.daily_trigger_time) if klass.daily_method\n create_weekly_cronjob(klass.weekly_method, klass.weekly_trigger_time) if klass.weekly_method\n end",
"def weekly_time_generator(args = {:start_time => Time.now, :end_time => nil, :cron => ''})\n begin\n return [] if args[:cron].blank?\n\n # get cron as hash\n cron = cron_date args[:cron]\n\n # get the first value of the cron which is an integer and the pevious index\n # ex: cron = '41 * * * *' - we want to know that it starts every hour (prev index before the number) in the 41-st minute\n for k, v in cron do\n at = v\n break if v.class == 'Fixnum'\n # break in ruby continues the last iteration..\n every = k if v == '*'\n end\n\n changed_time = start_time = cron_generate_date args[:cron], args[:start_time]\n end_time = args[:end_time]\n\n # end_time is nil?\n end_time = Time.now.end_of_week if !end_time.respond_to? :year\n # end_time should not be longer than the end of this week\n end_time = end_time > start_time.end_of_week ? start_time.end_of_week : end_time\n\n all = []\n while changed_time <= end_time\n all << changed_time #changed_time.strftime(\"%d.%m.%Y %H:%M\")\n changed_time += 1.send(every)\n end\n\n all\n\n rescue => ex\n send_mail \"#{ex.class}: #{ex.message}. args: #{args}\" \n end\n\n end",
"def add_cron_job(job)\n client.create_cron_job(Kubeclient::Resource.new(job.cron_job_manifest))\n end",
"def schedule_jobs(jobs)\n scheduler = Rufus::Scheduler.start_new\n \n jobs.each do |job|\n Mongolicious.logger.info(\"Scheduled new job for #{job['db'].split('/').last} with interval #{job['interval']}\")\n scheduler.every job['interval'] do\n backup(job)\n end\n end \n \n scheduler.join\n end",
"def cron_open\n # jo = File.open #still need to write crontab protocol\n end",
"def current_cron_jobs\n client.get_cron_jobs(label_selector)\n end",
"def initialize(cron_def, &block)\n @cron_def = cron_def\n @block = block\n @next_run = cron_parser && cron_parser.next(Time.now)\n PeriodicTask.tasks << self\n end",
"def generate_schedule\n \tschedule = Array.new\n \tqueue = Array.new\n \tcurrent_job = nil\n \tcurrent_job_execution_time = 0\n\n \tfor time in 0...hyper_period\n \t\t# add released tasks to queue\n \t\tqueue += get_released_jobs time\n\n \t\t# give the current job credit for execution in last step\n \t\tcurrent_job_execution_time += 1 unless current_job.nil?\n\n \t\t#check if current task is finished\n \t\tif !!current_job and current_job[:task].worst_case_execution_time == current_job_execution_time\n \t\t\t#task is finished\n \t\t\tcurrent_job = nil\n \t\t\tcurrent_job_execution_time = 0\n \t\tend\n\n \t\t#find a task to execute\n \t\tif current_job.nil?\n \t\t\tcurrent_job = get_highest_priorty_task(queue)\n \t\t\tqueue.delete(current_job)\n \t\tend\n\n \t\t# if we are missing a deadline task set is not schedulable\n \t\tif !!current_job and time >= current_job[:deadline]\n \t\t\treturn nil\n \t\tend\n\n \t\t# add current job to schedule\n \t\tschedule.push(current_job.nil? ? 0 : current_job[:task].id)\n\n \t\t#log whats executing in this slot\n \t\t#puts \"Slot #{time + 1} \" + (current_job.nil? ? \"Idle\" : current_job[:task].name)\n \tend\n\n \t# if queue isn't empty, then return nil\n \treturn nil unless queue.empty?\n\n \t#return schedule\n \tschedule\n end",
"def crontab_list\n @logger.info('[SystemGateway][crontab_list] Calling CronEdit::Crontab.List...')\n list = CronEdit::Crontab.List\n @logger.info(\"[SystemGateway][crontab_list] Call ended. Output: #{list}\")\n list\n end",
"def scheduled_notification\n @scheduled_time = params[:time]\n @city_db_id = application_params[:city_db_id]\n\n @scheduled_time.each do |time|\n Delayed::Job.enqueue(NotifyCouriersJob.new(@city_db_id), :run_at => time)\n end\n end",
"def update_whenever \n begin\n ::Whenever::CommandLine.execute({:update => true, :file => \"#{Rails.root}/config/schedule.rb\"})\n rescue SystemExit # whenever quits after updating cron jobs, we need to stop him\n end\n end",
"def apply\n if desired.cron_exists\n action_create\n else\n action_delete\n end\n end",
"def to_crontab(action)\n # log \"Sprinkle.to_crontab(#{action})\\n\"\n if action == OPEN\n t = start_time\n # log \"start_time --> #{time_as_string(t)}\\n\"\n else\n t = start_time + duration*60\n # log \"stop_time --> #{time_as_string(t)}\\n\"\n end\n t.strftime(CRONTAB_STRFTIME)\n end",
"def cron(task_name)\n task = $bot[:tasks][task_name]\n unless task\n say \"Task \\\"#{task_name}\\\" does not exist. Use \\\"twittbot cron list\\\" for a list of available tasks.\"\n return\n end\n\n #check_config\n init_clients\n task[:block].call\n end",
"def auto_manage(cloud_type)\n\n cron_file = \"crontab-#{cloud_type}\"\n path = \"/etc/puppet/modules/#{cloud_type}/files/cron/#{cron_file}\"\n \n if File.exists?(path)\n file = File.open(path, 'r')\n line = file.read().chomp()\n file.close\n \n # Add the 'puppet apply manifest.pp' line to the crontab file\n mcc = MCollectiveCronClient.new(\"cronos\")\n mcc.add_line(CloudCron::CRON_FILE, line)\n mcc.disconnect\n else\n @err.call \"Impossible to find cron file at #{path}\"\n end\n \n end",
"def to_crontab_attributes(state)\n \"#{id} #{state}\"\n end",
"def create_cron_command\n command = @options.cron + \" sycbackup #{@options.backup_folder}\"\n command += ' -d ' + @options.database + \n ' -u' + @options.user + \n ' -p' + @options.password if @options.database\n command += ' -f ' + @options.files.join(',') if @options.files\n command += ' -m ' + @options.max_backups if @options.max_backups\n command += ' --no-compress' if @options.no_compress\n command += ' --override' if @options.override\n\n command\n end",
"def run_cron_on(host, action, user, entry=\"\", &block)\n platform = host['platform']\n if platform.include?('solaris') || platform.include?('aix') then\n case action\n when :list then args = '-l'\n when :remove then args = '-r'\n when :add\n on( host,\n \"echo '#{entry}' > /var/spool/cron/crontabs/#{user}\",\n &block )\n end\n\n else # default for GNU/Linux platforms\n case action\n when :list then args = '-l -u'\n when :remove then args = '-r -u'\n when :add\n on( host,\n \"echo '#{entry}' > /tmp/#{user}.cron && \" +\n \"crontab -u #{user} /tmp/#{user}.cron\",\n &block )\n end\n end\n\n if args\n case action\n when :list, :remove then on(host, \"crontab #{args} #{user}\", &block)\n end\n end\n end",
"def schedule_recurring_jobs\n EmbargoAutoExpiryJob.perform_later(account)\n LeaseAutoExpiryJob.perform_later(account)\n end",
"def cyclecron(cron)\n obj = Puppet::Type::Cron.cronobj(@me)\n\n text = obj.read\n name = cron.name\n comp = mk_catalog(name, cron)\n\n assert_events([:cron_created], comp)\n cron.provider.class.prefetch\n currentvalue = cron.retrieve\n\n assert(cron.insync?(currentvalue), \"Cron is not in sync\")\n\n assert_events([], comp)\n\n curtext = obj.read\n text.split(\"\\n\").each do |line|\n assert(curtext.include?(line), \"Missing '#{line}'\")\n end\n obj = Puppet::Type::Cron.cronobj(@me)\n\n cron[:ensure] = :absent\n\n assert_events([:cron_removed], comp)\n\n cron.provider.class.prefetch\n currentvalue = cron.retrieve\n\n assert(cron.insync?(currentvalue), \"Cron is not in sync\")\n assert_events([], comp)\n end",
"def schedule_info\n\n @cron_line.original\n end",
"def enable_cron\n require 'rufus/scheduler'\n set :scheduler, Rufus::Scheduler.new\n job = PuppetHerald::PurgeCronJob.new\n # Run every 30 minutes, by default\n cron = ENV['PUPPET_HERALD_PURGE_CRON'] || '*/30 * * * *'\n PuppetHerald.logger.info \"Stating scheduler with: `#{cron}`...\"\n scheduler.cron(cron) { job.run! }\n end",
"def schedule (cron_line, params={}, &block)\n\n params = prepare_params(params)\n\n #\n # is a job with the same id already scheduled ?\n\n cron_id = params[:cron_id] || params[:job_id]\n\n #@unschedule_queue << cron_id\n\n #\n # schedule\n\n b = to_block(params, &block)\n job = CronJob.new(self, cron_id, cron_line, params, &b)\n\n @schedule_queue << job\n\n job.job_id\n end",
"def run_cron_on(host, action, user, entry = \"\", &block)\n block_on host do |host|\n platform = host['platform']\n if platform.include?('solaris') || platform.include?('aix') then\n case action\n when :list then args = '-l'\n when :remove then args = '-r'\n when :add\n on(host,\n \"echo '#{entry}' > /var/spool/cron/crontabs/#{user}\",\n &block)\n end\n\n else # default for GNU/Linux platforms\n case action\n when :list then args = '-l -u'\n when :remove then args = '-r -u'\n when :add\n on(host,\n \"echo '#{entry}' > /tmp/#{user}.cron && \" +\n \"crontab -u #{user} /tmp/#{user}.cron\",\n &block)\n end\n end\n\n if args\n case action\n when :list, :remove then on(host, \"crontab #{args} #{user}\", &block)\n end\n end\n end\n end",
"def schedule_raids(array)\n array.each do |key, value1|\n value1['raids'].each do |value2|\n unless Time.parse(value2['0']).past?\n new_cron(\n value2['0'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting now!\"\n )\n end\n unless Time.parse(value2['15']).past?\n new_cron(\n value2['15'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 15 minutes!\"\n )\n end\n unless Time.parse(value2['30']).past?\n new_cron(\n value2['30'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 30 minutes!\"\n )\n end\n unless Time.parse(value2['45']).past?\n new_cron(\n value2['45'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 45 minutes!\"\n )\n end\n next if Time.parse(value2['60']).past?\n new_cron(\n value2['60'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 1 hour!\"\n )\n end\n end\nend",
"def cron_command\n cron_content = master.run_shell('crontab -l').stdout\n collector_line = cron_content.split(\"\\n\").select do |line|\n line =~ %r{splunk_hec_collect_api_events.rb}\n end\n collector_line.join.split[-3..-1].join(' ')\nend",
"def Clockwork\n puts \"testing clockwork!\"\n every(30.seconds, 'Send Messages') {\n rake 'scheduler:send_messages'\n mail(:to => \"swamy@ostryalabs.com\", subject: 'hello')\n }\n \nend",
"def wrap_in_schedule (raw_expression, options)\n\n oat = options[:at]\n oin = options[:in]\n ocron = options[:cron]\n oevery = options[:every]\n\n fei = new_fei(\n :workflow_instance_id => get_wfid_generator.generate(nil),\n :workflow_definition_name => 'schedlaunch',\n :expression_name => 'sequence')\n\n # not very happy with this code, it builds custom\n # wrapping processes manually, maybe there is\n # a more elegant way, but for now, it's ok.\n\n template = if oat or oin\n\n sleep_atts = if oat\n { 'until' => oat }\n else #oin\n { 'for' => oin }\n end\n sleep_atts['scheduler-tags'] = \"scheduled-launch, #{fei.wfid}\"\n\n raw_expression.new_environment\n raw_expression.store_itself\n\n [\n 'sequence', {}, [\n [ 'sleep', sleep_atts, [] ],\n raw_expression.fei\n ]\n ]\n\n elsif ocron or oevery\n\n fei.expression_name = 'cron'\n\n cron_atts = if ocron\n { 'tab' => ocron }\n else #oevery\n { 'every' => oevery }\n end\n cron_atts['name'] = \"//cron_launch__#{fei.wfid}\"\n cron_atts['scheduler-tags'] = \"scheduled-launch, #{fei.wfid}\"\n\n template = raw_expression.raw_representation\n remove(raw_expression)\n\n [ 'cron', cron_atts, [ template ] ]\n\n else\n\n nil # don't schedule at all\n end\n\n if template\n\n raw_exp = RawExpression.new_raw(\n fei, nil, nil, @application_context, template)\n\n #raw_exp.store_itself\n raw_exp.new_environment\n\n raw_exp\n else\n\n raw_expression\n end\n end",
"def rocket_job_cron_next_time(time = Time.now)\n RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)\n end",
"def rocket_job_cron_next_time(time = Time.now)\n RocketJob::Plugins::Rufus::CronLine.new(cron_schedule).next_time(time)\n end",
"def initialize(testing_frequency = \"60m\")\n # Set up the tasks\n @job_ids_by_task = {}\n @tasks_by_job_ids = {}\n # Start the scheduler\n @scheduler = Rufus::Scheduler.start_new\n # Create a logger\n @logger = Logger.new( 'scheduler.log', 'monthly' )\n @task_test_results_logger = Logger.new( 'task_test_results.log', 'monthly' )\n puts \"Schedule tests\"\n # Add the test runninng scheduler method\n @scheduler.every(testing_frequency) do\n test_results = execute_task_tests()\n test_results.each {|test_result|\n # the test is not nil then we have an error (print this error to the log)\n if(!test_result.nil?)\n @task_test_results_logger.error(test_result.inspect)\n end\n }\n end\n end",
"def add_to_crontab(commands,period,use_sudo=false)\n send_cmd = use_sudo ? :sudo : :run\n tmp_cron=\"/tmp/cron.tmp\"\n self.send(send_cmd, \"rm -f #{tmp_cron} && touch #{tmp_cron}\")\n run \"(#{use_sudo ? 'sudo ' : ''}crontab -l || true) > #{tmp_cron}\"\n cron_lines = [*commands].map{|cmd| \"#{period} #{cmd}\"}\n add_to_file(tmp_cron, cron_lines)\n self.send(send_cmd, \"crontab #{tmp_cron}\")\n sudo \"rm -f #{tmp_cron}\"\nend",
"def sudo_add_to_crontab(commands,period)\n add_to_crontab(commands, period, true)\nend",
"def mkcron(name, addargs = true)\n cron = nil\n command = \"date > #{tmpdir()}/crontest#{name}\"\n args = nil\n if addargs\n args = {\n :command => command,\n :name => name,\n :user => @me,\n :minute => rand(59),\n :month => \"1\",\n :monthday => \"1\",\n :hour => \"1\"\n }\n else\n args = {:command => command, :name => name}\n end\n assert_nothing_raised {\n cron = @crontype.new(args)\n }\n\n cron\n end",
"def new_load_schedule\n @worker_method_triggers = { }\n @my_schedule.each do |key,value|\n case value[:trigger_args]\n when String\n cron_args = value[:trigger_args] || \"0 0 0 0 0\"\n trigger = BackgrounDRb::CronTrigger.new(cron_args)\n @worker_method_triggers[key] = { :trigger => trigger,:data => value[:data],:runtime => trigger.fire_after_time(Time.now).to_i }\n when Hash\n trigger = BackgrounDRb::Trigger.new(value[:trigger_args])\n @worker_method_triggers[key] = { :trigger => trigger,:data => value[:trigger_args][:data],:runtime => trigger.fire_after_time(Time.now).to_i }\n end\n end\n end",
"def pm_counter_cron_main_with_team(team_array)\n \n start_time=Time.now\n\n return if team_array.nil? || team_array.size ==0\n \n\nteam_array.each do |team|\n logger=Logger.new(\"pm_counter_#{team}.log\",shift_age = 7, shift_size = 1048576)\n all_counters=pm_counter_get_defined_counter(logger)\n set_logger_level(logger)\n Bts.where(:team=>team).each do |bts|\n result=pm_counter_analysis_one_bts(all_counters,bts.s1_ip,bts.bts_username,bts.bts_password,logger)\n end\n\n Cron.create(:name=>\"PM counter_#{team}\",:scope=>\"#{team}\",:start=>start_time.to_s,:cost=>Time.now - start_time,:succ=>\"#{0}\",:fail=>\"#{0}\")\n ActiveRecord::Base.connection.close\nend\nend",
"def execute_tasks(starttime)\n now=Time.now\n starttime=Time.at(now.to_i-24*60*60) if starttime.nil? \n $stdin.each_line do |line|\n md= /^([^\\t|^\\#].*\\t){5}/.match(line)\n if (md)\n cron = Rufus::Scheduler::CronLine.new(md[0]) \n next_time = cron.next_time(starttime)\n if (next_time.day()==now.day())\n command=line[md[0].length .. line.length-1]\n system(command)\n end\n end\n end\nend",
"def run_cron_on(host, action, user, entry=\"\", &block)\n platform = host['platform']\n if platform.include?('solaris') || platform.include?('aix') then\n case action\n when :list then args = '-l'\n when :remove then args = '-r'\n when :add\n on(host, \"echo '#{entry}' > /var/spool/cron/crontabs/#{user}\", &block)\n end\n else # default for GNU/Linux platforms\n case action\n when :list then args = '-l -u'\n when :remove then args = '-r -u'\n when :add\n on(host, \"echo '#{entry}' > /tmp/#{user}.cron && crontab -u #{user} /tmp/#{user}.cron\", &block)\n end\n end\n\n if args\n case action\n when :list, :remove then on(host, \"crontab #{args} #{user}\", &block)\n end\n end\n end",
"def histcall\n HardWorker.perform_at(24.hours, 1)\n puts \"Cron job: Stocks being added to db\"\n end",
"def application_specific_tasks\n # system 'cap deploy:whenever:update_crontab'\n # system 'cap deploy:delayed_job:stop'\n # system 'cap deploy:delayed_job:start n=1'\n # system 'cap deploy:run_command command='ls -la''\nend",
"def schedule(*args, &block)\n @jobs << [block, args]\n end",
"def add_to_scheduler\n name = \"for_survey_#{@schedulable.company_survey.id}\"\n config = {}\n config[:every] = [\"#{@schedulable.repeat_every}#{@schedulable.repeat_mode}\",\n { first_at: calculate_next_delivery }]\n config[:class] = 'SendEmailsJob'\n config[:queue] = 'send_emails'\n config[:persist] = true\n config[:args] = @schedulable.company_survey.id\n Resque.set_schedule(name, config)\n end",
"def schedule(*args, &block)\n @jobs << [block, args]\n end",
"def schedule(*args, &block)\n @jobs << [block, args]\n end",
"def schedule(cron)\n if !cron.is_a?(String) || cron.blank?\n raise InvalidArgumentError,\n \"The cron passed to 'schedule' must be a non empty string\"\n end\n\n Engine.instance.schedule([self], cron)\n end",
"def schedule(*args, &block)\n @jobs << [block, args]\n end",
"def schedule\n Resque.set_schedule(schedule_name, {\n :cron => cron,\n :class => \"Myreplicator::Export\",\n :queue => \"myreplicator_export\",\n :args => id\n })\n end",
"def run\n super\n cron_poller.start\n end",
"def cron\n @cron_expression.original_expression\n end",
"def trigger (params)\n\n return if paused?\n\n ldebug { \"trigger() cron : #{@fei.to_debug_s}\" }\n\n #@raw_child.application_context = @application_context\n # done in expool.tlaunch_child()\n\n begin\n\n @counter += 1\n store_itself\n #\n # note : one variant would be to give Time.now.to_f as a sub_id...\n # then no need to store...\n #\n # but it's good to have a counter to keep track of the number of\n # executions\n\n child_fei = get_expression_pool.tlaunch_child(\n self,\n first_expression_child,\n @counter,\n @applied_workitem.dup,\n :register_child => false)\n #\n # register_child is set to false, cron doesn't keep\n # track of its spawned children\n\n rescue\n\n lerror do\n \"trigger() cron caught exception\\n#{OpenWFE::exception_to_s($!)}\"\n end\n end\n end",
"def calc_next_run\n RunAtPeriodicJob.new(:name => self.name, :job => self.job, :run_at_minutes => self.run_at_minutes)\n end",
"def chronic\n @chronic ||= statements.except(:order).order('entered_on ASC, entered_at ASC, id ASC').all\n end",
"def application_specific_tasks\n # system 'cap deploy:whenever:update_crontab'\n # system 'cap deploy:delayed_job:stop'\n # system 'cap deploy:delayed_job:start n=1'\n # system 'cap deploy:run_command command=\"ls -la\"'\nend",
"def application_specific_tasks\n # system 'cap deploy:whenever:update_crontab'\n # system 'cap deploy:delayed_job:stop'\n # system 'cap deploy:delayed_job:start n=1'\n # system 'cap deploy:run_command command=\"ls -la\"'\nend",
"def application_specific_tasks\n # system 'cap deploy:whenever:update_crontab'\n # system 'cap deploy:delayed_job:stop'\n # system 'cap deploy:delayed_job:start n=1'\n # system 'cap deploy:run_command command=\"ls -la\"'\nend",
"def schedule\n \"#{frequency_quantity} #{frequency_type.name.pluralize} at #{execution_time}\"\n end",
"def index\n @admin_cron_requests = Admin::CronRequest.all\n end",
"def cron_timer(minutes_from_now,time_object, script)\n raw_time = time_object + (minutes_from_now.to_i*60)\n cron_string = cron_converter(raw_time)\n end",
"def run_now!\n update_attributes(run_at: nil) if cron_schedule\n end",
"def check_schedule()\n create_daily_tests()\n create_weekly_tests()\n end",
"def remove_all_test_cronjobs\n CronEdit::Crontab.List.keys.each do |key|\n CronEdit::Crontab.Remove(key) if key =~ /test-/\n end\nend",
"def schedule_job_specs(job_specs)\n job_specs.each { |job_spec| schedule_job_spec(job_spec) }\n end",
"def schedule_for!\n unless self.parent_id\n starts_on = created_at\n course.lessons.all(order: :position).each do |lesson|\n unless scheduled_course.scheduled_lessons.where('lesson_id= ? and enrolment_id = ?',lesson.id, id ).first\n ScheduledLesson.create(student_user_id: self.student_user_id, enrolment_id: self.id, scheduled_course_id: scheduled_course.id, lesson_id: lesson.id )\n end\n end\n end\n end",
"def schedule(spec)\n @task.schedule = Cloud::Cycler::Schedule.parse(spec)\n end",
"def run time=nil\n\n puts \"[cron] run called #{Time.now}\" if @debug\n time = self.time if time.nil?\n self.each { |cron_job|\n ok,details = cron_job.runnable?(time)\n if ok then\n @queue.enq(cron_job)\n if cron_job.once? then\n cron_job[:delete] = true\n end\n end\n }\n self.reject! { |cron_job|\n cron_job[:delete]\n }\n end",
"def cron_generate_date(cron, date)\n begin\n date = Time.now if !date.respond_to? :year\n\n # if date < Time.now.beginning_of_week then date = Time.now\n date = Time.now if date < Time.now.beginning_of_week\n \n cron = cron_date cron\n\n #get the key of the last *\n every = cron.select{ |k,v| v == '*' }.keys.last\n\n # we are comparing cron to the current date so:\n # if v == * then v = date.k\n for k,v in cron do\n #puts \"date.#{k}\"\n cron[k] = eval(\"date.#{k}\") if v.class == String\n end\n \n # convert cron in date\n cron = Time.local(cron[:year], cron[:month], cron[:day], cron[:hour], cron[:minute])\n\n # if generated date is < date then increment it by 1 on the first *\n # i.e. cron = '41 18 * * *' and date = '2012-03-15 19:37'.\n # generated date will be 2012-03-15 18:41 which is past date - we want the next cron date which is 2012-03-16 18:41\n cron += 1.send(every) if cron < date\n\n return cron\n rescue => ex\n send_mail \"#{ex.class}: #{ex.message}. cron: #{cron}, date: #{date}\" \n end\n end",
"def execute_cron_job\n lambda do\n |request, jle|\n $db_lock.synchronize {\n jle.run_status = 'Running'\n jle.start_time = Time.now\n jle.save(:validate => false)\n }\n jlh = Hash.new\n jlh[:run_status] = \"Failure\"\n @@thread_count = @@thread_count + 1;\n Thread.current[:name] = \"JOB_THREAD \" + request.to_s + ' ' + @@thread_count.to_s;\n Thread.current[:watchdogged] = false\n begin\n jmd = JobMetadata.job_code(request)[0]\n @job_map[Thread.current] = jmd.max_execution_minutes.to_i.minutes.from_now\n\n jlh[:jmd] = jmd\n jlh[:jle] = jle\n commands = gather_commands(true,request)\n commands = commands[request]\n if (commands.nil? || commands.empty?)\n $logger.error(\"There are no commands for request #{request}. Exiting...\")\n return\n end\n $logger.debug(\"The size of commands is \" << commands.length.to_s)\n #total_result = nil\n commands.each do |command|\n command.chomp!\n $logger.debug(\"command = #{command}\")\n #$stderr.puts(\"executing #{command}\")\n #result = `#{command}` There seems to be a bug in ruby where backticks hang in multi threaded situations\n result = JobEngine.execute_command_to_temp(command)\n #$stderr.puts(\"executed #{command}\")\n result.chomp!\n\n if (jlh[:job_result].nil?)\n jlh[:job_result] = result\n else\n jlh[:job_result] << \"\\n\" << result\n end\n $logger.debug(\"the result is #{result}...\")\n #check to see if the command is in\n end\n # $stderr.puts(\"About to finish the jle\")\n # finish_job_log_entry(Time.now,total_result, jle, nil)\n jlh[:run_status] = \"Completed\"\n # $stderr.puts(\"finished the jle\")\n # email_job_result(total_result,jle,jmd) if jmd.email_result\n # $stderr.puts(\"emailed\") if jmd.email_result\n # $stderr.puts(\"not emailed\") unless jmd.email_result\n\n rescue =>ex\n error = \"An execution thread terminated while executing \" << request\n $logger.error(error)\n $logger.error(ex.to_s)\n jlh[:job_result] = '' if jlh[:job_result].nil?\n jlh[:job_result] << ex.to_s\n ensure\n unless jlh[:run_status].eql?(\"Completed\")\n jlh[:job_result] = '' if jlh[:job_result].nil?\n if (Thread.current[:watchdogged])\n jlh[:job_result] << \"\\nKilled by the job watch dog at \" + Thread.current[:watchdogged_time].to_s + \"!\"\n else\n jlh[:job_result] << \"\\nAn exceptional event occurred!\"\n end\n end\n finish_job_log_entry(jlh)\n end\n end\n end",
"def create_scheduled_notifications\n t = Time.now.utc\n x = self.notifications_created_since_recurrence_last_updated_count\n \n while (d = recurrence[x]) && t >= d\n create_notification_for_date(d)\n \n self.notifications_created_since_recurrence_last_updated_count += 1\n self.save!\n \n x += 1\n end \n end",
"def daily_midnight\n logger.info \" daily_midnight\"\n PersistStatsJob.create({})\n Gift.send_expiration_reminders(5)\n Gift.send_expiration_reminders(3)\n Gift.send_expiration_reminders(1)\n end",
"def to_crontab_time(state)\n # log \"Sprinkle.to_crontab(#{state})\\n\"\n if state == ACTIVE\n t = start_time\n # log \"start_time --> #{t}, #{t.strftime(CRONTAB_STRFTIME)}\\n\"\n else\n t = stop_time\n # log \"stop_time --> #{t}, #{t.strftime(CRONTAB_STRFTIME)}\\n\"\n end\n t.strftime(CRONTAB_STRFTIME)\n end",
"def schedule(hash)\n run_job = Proc.new do\n if hash['make_after'].to_i > 0\n EM::Timer.new(hash['make_after']) do\n self.storage.load(hash) { |hash| do_job(JR.make(hash)) }\n end\n else\n EM.next_tick do\n self.storage.load(hash) { |hash| do_job(JR.make(hash)) }\n end\n end\n end\n\n if hash['defer'] == 'true'\n EM.defer { run_job.call }\n else\n run_job.call\n end\n end",
"def enable_cron\n value = ActiveModel::Type::Boolean.new.cast(\n options[:enable_cron] ||\n rails_config[:enable_cron] ||\n env['GOOD_JOB_ENABLE_CRON'] ||\n false\n )\n value && cron.size.positive?\n end",
"def schedules\n workers.map(&:schedule)\n end",
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for the next month\n # TODO: make instance variable with schedule instance to avoid repeat instantiation\n schedule = IceCube::Schedule.new\n schedule.add_recurrence_rule(self.recurrence)\n schedule.occurrences(Time.current + 1.month).each do |o|\n Occurrence.create(event: self, date: o.to_date)\n end\n end\n end",
"def schedule_with_periodicity(jobs=parse_jobs())\n # see parse_input.rb\n #jobs = parse_jobs()\n jobs.each do |job|\n unless job.periodicity == 0 or jobs.map{ |j| j.id }.count(job.id) > 1\n # duplicate periodic job and fix arrival and relative_deadline\n periodic_job = job.dup\n periodic_job.arrival = job.periodicity + job.arrival\n periodic_job.relative_deadline = periodic_job.arrival + periodic_job.deadline\n # insert it at the good arrival place in the array of jobs\n i = 0\n jobs.map do |j|\n if periodic_job.arrival > jobs[i].arrival and\n (jobs[i+1].nil? or periodic_job.arrival < jobs[i+1].arrival)\n jobs.insert(i + 1, periodic_job)\n break\n end\n i += 1\n end\n end\n end\n return jobs\nend",
"def schedule_updates\n schedule_update_in(48.hours)\n end",
"def run_periodic_tasks!\n logger.info(\"Running periodic tasks...\")\n PeriodicTask.run_all_due!\n end",
"def schedule_line\n [ level_to_config, pool_to_config, month, day, \"at #{time}\"].join(\" \")\n end",
"def schedule_updates\n schedule_updates_in(24.hours, 48.hours)\n end",
"def stop_cron_jobs(cloud_type)\n\n mcc = MCollectiveCronClient.new(\"cronos\")\n string = \"init-#{cloud_type}\"\n mcc.delete_line(CloudCron::CRON_FILE, string)\n\n end",
"def run!\n logger.info(\"Running task #{self.class.to_s}\")\n @block.call\n @next_run = cron_parser && cron_parser.next(Time.now)\n end",
"def execute_continuous_task\n Rake::Task['cron_task:continuous:execute_task'].reenable\n Rake::Task['cron_task:continuous:execute_task'].invoke\n @lock_file_handle.close\n end",
"def scheduled\n jobs_index(Job.scheduled)\n end",
"def on_schedule\n return to_enum(:on_schedule) unless block_given?\n start = context.order.created_at\n finish = start + context.order.gateway.orders_expiration_period.seconds\n period = finish - start\n often = {\n base_interval: ENVied.ORDER_CHECK_BASE_INTERVAL.seconds,\n max_interval: ENVied.ORDER_CHECK_MAX_INTERVAL.seconds,\n rand_factor: ENVied.ORDER_CHECK_RAND_FACTOR,\n multiplier: ENVied.ORDER_CHECK_BACKOFF_MULT,\n max_period: period,\n }\n now = start\n with_intervals often do |interval|\n now += interval\n now = now.round(2)\n yield now, false\n end\n yield finish, true\n end",
"def next_time(*args)\n cron_schedule.next_time(*args)\n end",
"def all\n Array(@@job_scheduler_instance)\n end",
"def run\n if @options.cron\n create_cron\n elsif @options.database or @options.file\n create_backup\n end\n end",
"def make_constant_schedule(name, temperature)\n s = OpenStudio::Model::ScheduleRuleset.new(@model)\n s.setName(name)\n s.defaultDaySchedule.addValue(OpenStudio::Time.new(\"24:00:00\"), OpenStudio::convert(temperature, \"F\", \"C\").get)\n\ts\n end",
"def job_time(job)\n extract_job_schedule(job).split.each_with_index.map do |value, index|\n cron_time_value = @cron_time.split[index]\n\n if value == \"*\"\n cron_time_value\n elsif value.match(/\\*\\/\\d{1,2}/)\n increment = value.match(/\\*\\/\\d{1,2}/).to_s[2..-1].to_i\n\n case index\n when 0, 1\n increment_value(:time, cron_time_value, increment)\n when 2\n increment_value(:day_of_month, cron_time_value, increment)\n when 3\n increment_value(:month, cron_time_value, increment)\n when 4\n increment_value(:day_of_week, cron_time_value, increment)\n end\n else\n value\n end\n end.join(\" \")\n end",
"def scheduled\n response = get 'scheduled'\n response.map{|item| Hashie::Mash.new(item)}\n end",
"def do_schedule_at (at, params={}, &block)\n\n job = params.delete(:job)\n\n unless job\n\n jobClass = params[:every] ? EveryJob : AtJob\n\n b = to_block(params, &block)\n\n job = jobClass.new(self, at_to_f(at), params[:job_id], params, &b)\n end\n\n if jobClass == AtJob && job.at < (Time.new.to_f + @precision)\n\n job.trigger() unless params[:discard_past]\n\n @non_cron_jobs.delete job.job_id # just to be sure\n\n return nil\n end\n\n @non_cron_jobs[job.job_id] = job\n\n @schedule_queue << job\n\n job.job_id\n end"
] |
[
"0.71155566",
"0.70647675",
"0.6726734",
"0.66560173",
"0.6329746",
"0.6241412",
"0.61797154",
"0.61311436",
"0.6067103",
"0.60323566",
"0.6022563",
"0.5953872",
"0.58901006",
"0.58551264",
"0.5836398",
"0.58332103",
"0.579289",
"0.5760674",
"0.5750348",
"0.57358044",
"0.5721976",
"0.5667742",
"0.56323606",
"0.5584399",
"0.5557127",
"0.55406505",
"0.5525272",
"0.5525163",
"0.5519922",
"0.551562",
"0.5510468",
"0.54939246",
"0.54865855",
"0.54843044",
"0.54821545",
"0.54779994",
"0.5469095",
"0.5453817",
"0.5453817",
"0.5453129",
"0.5425887",
"0.5413868",
"0.5410042",
"0.5404777",
"0.54028636",
"0.53770465",
"0.53510445",
"0.52975166",
"0.5282764",
"0.5279451",
"0.52790594",
"0.52777576",
"0.52777576",
"0.52734506",
"0.52578914",
"0.5255127",
"0.5250037",
"0.5248127",
"0.52339923",
"0.5233635",
"0.5228362",
"0.5224185",
"0.5224185",
"0.5224185",
"0.5224086",
"0.52191496",
"0.52085835",
"0.52037054",
"0.52019936",
"0.5192626",
"0.51664674",
"0.51658785",
"0.5155973",
"0.51424944",
"0.5139981",
"0.5129623",
"0.51155084",
"0.5105124",
"0.50987697",
"0.5089462",
"0.50858295",
"0.50733113",
"0.50706166",
"0.5068457",
"0.5064531",
"0.50524986",
"0.50485265",
"0.5043873",
"0.50430197",
"0.5014849",
"0.5012124",
"0.49903294",
"0.49892014",
"0.49880642",
"0.49817723",
"0.49762937",
"0.49670735",
"0.49666008",
"0.49658662",
"0.49338147"
] |
0.622361
|
6
|
Write a method called 'in_array' which will take two parameteres: One as a string and one as an array of strings Return a boolean indicationg whether or not the string is found in the array. Test your solution with: ruby tests/05_in_array_test.rb Example: "hello", ["hi","howdy","hello"] should return true. Defining method to check validity of string being in array and string being
|
def in_array(needle, haystack)
(string_in_array(needle, haystack) == true and needle.is_a? String) ? true : false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def in_array(array, string)\n array.each do |object|\n if object == string\n return true\n else\n return false\n end\n end\nend",
"def is_it_in(array, string)\n array.include?(string) ? array.index(string) : nil\nend",
"def arr_in_phrase? (arr, string)\n\t#might be unefficient to recreate the reg each time, maybe better to return a regex?\n\treg = arr.map {|str| Regexp.escape(str)}\n\treg = /#{arr.join(\"|\")}/ \n\treturn reg === string\nend",
"def in_array(array1, array2)\r\n \r\nend",
"def is_item_in_array(array,item)\n return array.include?(item)\nend",
"def in_arr? (arr, text, exact)\n\tif exact\n\t\treturn arr.include? text\n\telse\n\t\treturn arr.any?{|s| s.include? text}\n\tend\nend",
"def contains_string(given, string_array)\n is_present = false\n string_array.each do |file_name|\n is_present = true if given.downcase.include? file_name.downcase\n end\n\n is_present\nend",
"def contains (array, string)\n# use select method to filter over array\n array.select do |value|\n# use include? to see if the array includes string\n value.include? string\n end\nend",
"def is_value_in_array(string,array)\n found = false\n array_size = array.length\n array_index = 0\n\n while (found == false && array_index<array_size)\n if array[array_index]==string\n found = true\n end\n array_index =array_index+1 \n end\n return found\nend",
"def in_array(array, check_value)\n\tarray.each do |value|\n\t\tif value == check_value\n\t\t\treturn true\n\t\tend\n\tend\n\treturn false\nend",
"def search_array(array_list, particular_string)\n array_list.each do |item|\n if item == particular_string\n return true\n end\n end\nend",
"def check_array(array,target)\n if array.include?(target)\n return true\n else\n return false\n end\nend",
"def in_array(array, check_value)\n\tarray.each do |value|\n\t\tif value == check_value\n\t\t\treturn true\n\t\tend\n\tend\n\n\treturn false\nend",
"def item_include?(array, string)\n match = false\n array.each do |el|\n if el == string\n match = true\n end\n end\n match\nend",
"def include_array?(array)\n array.any? { |member| array?(member) }\n end",
"def array_checker(array, string)\n array.each do |array|\n if array == string \n return string\n else return nil\n end\n end\nend",
"def item_included?(str, arr)\n arr.each do |item|\n return true if item == str\n end\n false\nend",
"def array_includes?(array, given_thing)\n answer = false\n\n array.each do |thing|\n if thing == given_thing\n answer = true\n end\n end\n\n return answer\nend",
"def strCheck(arr, str)\n arr.each do |i|\n if str == i\n return true\n end\n end\n return false\nend",
"def innit?(array, item_to_look_for)\n\tresult = false\n\tarray.each do |list_item|\n\t\tif list_item == item_to_look_for\n\t\t\tresult = true\t\n\t\tend\n\tend\n\treturn result\nend",
"def in_array(a1, a2)\n a1.find_all { |word| a2.select! { |word2| word2.include?(word) } }\nend",
"def assert_array_element(array_list, expected_in_array)\n\t\tassert_send([array_list, :member?, expected_in_array], message='Element'+expected_in_array+' not present in array list')\n\tend",
"def include?(array, search_element)\n array.each do |array_element|\n if array_element == search_element\n return true\n end\n end\n false\nend",
"def include?(array, search_element)\n array.each do |array_element|\n if array_element == search_element\n return true\n end\n false\n end\nend",
"def check_input(input, values)\n input_ok = false\n values.each do |value|\n input_ok = true if input.include?(value)\n end\n return input_ok\nend",
"def array_4or7\n array = Array.new\n puts \"Give me array of length 2\"\n array = gets.chomp.split(',')\n if (array.length==2)\n if (array.include?(\"4\") || array.include?(\"7\"))\n puts true\n else\n puts false\n end\n else\n puts \"Array has to have length of 2.\"\n end\nend",
"def wordInStrings(word, strings)\n for string in strings do\n\n if string.include? word\n return true\n end\n end\n\n return false\nend",
"def match_array(input)\n case input\n in [a, b, c]\n \"matching - #{a}, #{b}, #{c}\"\n else\n \"no match\"\n end\nend",
"def include?(array, value)\n # method A\n array.any? { |element| element == value }\n \n # method B\n # for item in array\n # return true if item == value\n # end\n \n # false\nend",
"def is_valid_text?(input, arr)\n result = false\n arr.each do |ele|\n result = true if input.downcase == ele.downcase\n end\n result\n end",
"def include?(array, value)\n array.each { |element| return true if value == element }\n false\nend",
"def include?(array, search)\n array.each do |value|\n return true if value == search\n end\n false\nend",
"def includ?(array, value)\n\tarray.each do |element|\n\t\tif element == value\n\t\t\treturn true\n\t\tend\n\tend\n\tfalse\nend",
"def in_all_strings?(long_strings, substring)\n new_arr = long_strings.select {|s| s.include?(substring)}\n return new_arr == long_strings\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all?{ |el| el.include?(substring)}\nend",
"def _is_in(token, list)\n return false unless list\n list.include?(token[1])\n end",
"def include?(array, value)\n array.each do |elem|\n return true if elem == value\n end\n false\nend",
"def include? array, item\n array.include?(item)\nend",
"def include?(array, search_value)\n array.any? { |element| element == search_value }\nend",
"def include?(array, arg)\n boolean_return = false\n array.each {|value| return boolean_return = true if value == arg}\n boolean_return\nend",
"def include?(array, target)\n matches = array.select { |element| element == target }\n !matches.empty?\nend",
"def contains?(trie, array)\n if !(array.nil? || trie.nil?)\n array.each { |item| return true if trie.include? item }\n end\n false\n end",
"def include?(arr, search)\n arr.each do |element|\n if element == search\n return true\n end\n end\n false\nend",
"def include?(array, search_value)\n !array.select{|element| element == search_value}.empty?\nend",
"def test1(array)\n\tputs \"Test1: Should take an array as argument -> \"\n\tarray.class == Array ? true : false\nend",
"def test1(array)\n\tputs \"Test1: Should take an array as argument -> \"\n\tarray.class == Array ? true : false\nend",
"def include?(array, value)\n array.any?(value)\nend",
"def exists?(number, array)\n array.include?(number)\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all?{|str|str.include?(substring)}\n\nend",
"def in? first, *rest\n (first.is_a?(Array) ? first : [first].concat(rest)).include? self\n end",
"def contains_subarray?(source, subarray)\n source = Array.wrap(source)\n subarray = Array.wrap(subarray)\n iteration_count = source.length - subarray.length\n 0.upto(iteration_count).any? do |i|\n source[i..(i+subarray.length-1)] == subarray\n end\n end",
"def validate_string_array(arry)\n if arry.is_a?(Array)\n arry.each do |choice|\n validate( { choice: choice }, { choice: { kind_of: String } } )\n end\n end\n end",
"def is_op?(input, accept_arr)\n input=input.downcase\n ok = 1 if accept_arr.include?(input)\n ok = 0 if !accept_arr.include?(input)\n return ok\nend",
"def in_all_strings?(long_strings, short_string)\n long_strings.all? do |long_string|\n long_string.include?(short_string)\n end\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.map do |str|\n str.split.any?(substring)\n end.all?(true)\nend",
"def include? (array, search)\n array.each { |item| return true if search == item }\n return false\nend",
"def in_all_strings?(long_strings, short_string)\nend",
"def is_array_of_strings(source)\n if source.is_a?(Array)\n arr = source - ['', nil]\n return arr.all?{ |value| value.is_a? String } unless arr.empty?\n end\n false\n end",
"def include?(array, search_value)\n if array.count(search_value) == 1\n return true\n else\n return false\n end\nend",
"def in_array(array1, array2)\n array1.select{|s| array2.any?{|w| w.include?(s) } }.sort\nend",
"def true_for_ravenclaw(array, item)\n for i in array\n status= i.include?(item)\n end\n return status\nend",
"def matches?(input_string)\n @word_list.include? input_string\n end",
"def match_array_with_values(input)\n case input\n in [1, b, 3]\n \"matching - #{input}, second element is #{b}\"\n else\n \"no match\"\n end\nend",
"def include?(array, search_value)\n array.select { |value| value == search_value }.empty? ? false : true\nend",
"def include?(arr, search)\n arr.any? { |i| i == search }\nend",
"def is_array_str?\n (@url.match(/^\\[/)) ? true : false\n end",
"def include?(arr, search)\n arr.any? { |elem| elem == search }\nend",
"def include_str_ary?(instr_ary)\n last_match = 0\n found = 0\n instr_ary.each do |instr|\n self[last_match..-1].each_with_index do |g_ins, idx|\n if g_ins.to_s.index instr\n found += 1\n last_match += idx + 1\n break\n end\n end\n end\n found == instr_ary.size\n end",
"def include?(array, value)\n array.each do |integer|\n return true if integer == value\n end\n return false\nend",
"def include?(array, search_value)\n # array.each do |element|\n # return true if element == search_value\n # end\n # false\n array.count(search_value) > 0\nend",
"def assert_in(first, second, message='', node=nil)\n assert Array === second && second.include?(first), \"expected #{second} to include '#{first}' #{message}\", node\n end",
"def include?(array, query)\n array.each do |el|\n return true if el == query\n end\n false\nend",
"def check_array( lines )\r\n status = false\r\n lines.each { |line| status = true if check_string(line) }\r\n return status\r\n end",
"def in_supplies?(string, supplies)\n supplies.each do |item|\n return true if item == string\n end\n false\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? { |string| string.include?(substring) }\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? { |string| string.include?(substring) }\nend",
"def check_string(string)\n\tzombie_apocalypse_supplies = [\"hatchet\", \"rations\", \"water jug\", \"binoculars\",\n \"shotgun\", \"compass\", \"CB radio\", \"batteries\"]\n\tzombie_apocalypse_supplies.each do |item|\n\t\tif string.downcase == item.downcase\n\t\t\treturn true\n\t\tend\n\tend\n false\nend",
"def include?(arr, val)\n arr.any? { |element| element == val }\nend",
"def number_in_array?(number, array)\n check = false\n array.each do |num| \n if num==number \n check = true\n end \n end\n return check\n end",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tabg_maker(array).any? {|x| x.class != Array} ? false : true\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? {|string| string.include?(substring)}\nend",
"def letter_checker(array, string)\n array.select do |value|\n value.include? string\n end\nend",
"def assert_contains(array, item)\n assert_equal true, array.include?( item )\n end",
"def includes?(array, target)\n return false if array.length <= 0\n return true if array[0] == target\n includes?(array[1..-1], target)\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? {|x| x.include?(substring) }\nend",
"def include?(arr, search_val)\n # arr.each { |e| return true if e == search_val }\n # false\n arr.count(search_val) > 0\n # or:\n # arr.any? { |i| i == val }\nend",
"def contain_a(array)\n array.select do |string|\n string.include?('a')\n end\nend",
"def vowels_with_array_no_equality_or_if(letter)\n if vowels.include? letter \n return true\n else \n return false\n end\nend",
"def subset?(arr, valid_arr)\n\t\tvalid_set = Set.new valid_arr\n\t\tset = Set.new arr\n\t\treturn set.subset?(valid_set)\n\tend",
"def has?(arr, e)\n end",
"def in_all_strings?(long_strings, substring)\n long_strings.all? {|word| word.include?(substring)}\nend",
"def existsinarray arr, number\n len = arr.length\n idx = 0\n while idx <= len - 1\n if number == arr[idx]\n return true\n end\n idx = idx + 1\n \n end\n return false \nend",
"def include?(arr, search_value)\n new_arr = arr.select { |element| element == search_value}\n !new_arr.empty?\nend",
"def test_xyz_not_in_arr\n refute_includes(list, 'ttt')\n end",
"def contain_a(array)\n has_a = []\n\n array.each do |word|\n has_a << word if word.include?('a')\n end\n has_a\nend",
"def invalid_interactions?(arr)\n valid_interactions = %w(inhibitor agonism antagonism other neutral agonist inducer antagonist)\n valid_targets = %w(protein dna rna drug)\n # If this is not an array is incorrect\n return false unless arr.class == Array\n # [OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}\n # (Regexp for UniProt id provided by UniProt)\n uniprot_regex = Regexp.new('[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}', Regexp::EXTENDED)\n arr.each do |value|\n # If value is not an array is incorrect\n return true unless value.class == Array\n return true unless valid_interactions.include?(value[1]) # Check interaction\n return true unless valid_targets.include?(value[2]) # Check molecule type\n return true unless uniprot_regex.match(value[4]) # Check uniprot uri\n end\n false\n end",
"def includes?(array, target)\n return false if array.empty?\n \n return true if array[0] == target\n\n includes?(array[1..-1], target)\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.each do |string|\n return false unless string.include?(substring)\n end\n\n return true\nend",
"def match?(given_names); end",
"def matches? string\n tag_string = string[%r|<key>Tags</key>\\s+<array>(.*?)</array>|m,1]\n\n # Edge case: no tags\n return true if @include.empty? && tag_string.nil?\n\n return (tag_string &&\n @include.all?{ |s| tag_string.include?(s) } &&\n @exclude.all?{ |s| !tag_string.include?(s) }\n )\n end"
] |
[
"0.7816119",
"0.74933344",
"0.74730855",
"0.74123037",
"0.7315693",
"0.7283202",
"0.72668666",
"0.7142964",
"0.7074229",
"0.7035094",
"0.70348394",
"0.70124453",
"0.70107067",
"0.6939859",
"0.6839054",
"0.6736855",
"0.67250067",
"0.6700291",
"0.66987336",
"0.6493552",
"0.6489193",
"0.64806014",
"0.64765877",
"0.6454238",
"0.6436171",
"0.6378491",
"0.6367827",
"0.63631374",
"0.6300603",
"0.6300455",
"0.6291452",
"0.62759143",
"0.6275482",
"0.62537324",
"0.62510693",
"0.624975",
"0.62484646",
"0.6241422",
"0.6239513",
"0.62341774",
"0.62250906",
"0.6206253",
"0.6181367",
"0.6176365",
"0.6175042",
"0.6175042",
"0.6159301",
"0.6156446",
"0.6149004",
"0.614004",
"0.61395645",
"0.612637",
"0.6125295",
"0.61125714",
"0.6109583",
"0.6097573",
"0.60741544",
"0.6071789",
"0.6063547",
"0.6061545",
"0.60577583",
"0.60506713",
"0.6046516",
"0.60460794",
"0.60381633",
"0.603702",
"0.60368603",
"0.60325944",
"0.6017634",
"0.6014237",
"0.6012317",
"0.601202",
"0.6000972",
"0.59815156",
"0.59798336",
"0.59797025",
"0.59777373",
"0.59758943",
"0.596506",
"0.595433",
"0.5942611",
"0.594224",
"0.5942008",
"0.59358233",
"0.5934016",
"0.5929997",
"0.5925422",
"0.5924967",
"0.5922587",
"0.5909757",
"0.59039414",
"0.5898823",
"0.5882939",
"0.5880984",
"0.5878385",
"0.58782876",
"0.58757037",
"0.58705544",
"0.5867112",
"0.5843668"
] |
0.8270633
|
0
|
For current implementation docs, see For upcoming XML implementation docs, see
|
def price
@required = [:zip, :country, :sender_zip, :weight]
@insured_value ||= 0
@country ||= 'US'
@sender_country ||= 'US'
@transaction_type ||= 'GND' # default to UPS ground
@data = "AppVersion=1.2&AcceptUPSLicenseAgreement=yes&ResponseType=application/x-ups-rss&ActionCode=3&RateChart=Customer+Counter&DCISInd=0&SNDestinationInd1=0&SNDestinationInd2=0&ResidentialInd=$r&PackagingType=00&ServiceLevelCode=#{@transaction_type}&ShipperPostalCode=#{@sender_zip}&ShipperCountry=#{@sender_country}&ConsigneePostalCode=#{@zip}&ConsigneeCountry=#{@country}&PackageActualWeight=#{@weight}&DeclaredValueInsurance=#{@insured_value}"
get_response "http://www.ups.com/using/services/rave/qcost_dss.cgi"
price = @response.split("%")
price = price[price.size-2]
return price.to_f
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def xml?; end",
"def xml?; end",
"def xml; end",
"def xml_decl; end",
"def parse_xml\n\n raise \"parse_xml method has not been implemented in this class\"\n \n end",
"def render_xml\n end",
"def build_xml\n raise NotImplementedError, \"Override build_xml in subclass\"\n end",
"def select_xml_nfe\n\t\t\t\n\tend",
"def rexml? ; false end",
"def xml!; @xml = true; end",
"def additional_information_xml(xml)\n\n end",
"def to_xml\n\t\tend",
"def to_xml\n\t\tend",
"def xpath; end",
"def xpath; end",
"def _to_xml(xml)\n end",
"def has_xml_content\n attr_accessor :xml_content\n end",
"def private; end",
"def toxml\n\t\tend",
"def document_root_element; end",
"def root_element\n root.xml \n end",
"def xml=(klass); end",
"def to_xml(*args)\n super\n end",
"def from_xml(xml)\n\t\tend",
"def xml_at_element_top( xml, name )\r\n xml.interface {\r\n xml.name name\r\n xml.unit { \r\n xml.name '0'\r\n return xml\r\n }\r\n } \r\n end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def test_access\n\tdoc = NQXML::TreeParser.new(@rsrc.xml).document\n\n\troot = doc.rootNode\n\tassert_nil(root.parent)\n\tassert_equal('outer', root.entity.name)\n \tassert_equal(8, root.children.length)\n\tassert_instance_of(NQXML::Text, root.firstChild().entity)\n\tassert_instance_of(NQXML::Text, root.lastChild().entity)\n\n\tnode = root.firstChild().nextSibling()\n\tassert_equal(node.parent, root)\n\tassert_equal('<simpleTag>', node.entity.source)\n\tassert_equal(1, node.children.length)\n\tassert_equal('text', node.firstChild().entity.text)\n end",
"def xml_statistics\n super\n end",
"def inner_xml\n child.to_s\n end",
"def xml\n @_node.asXml\n end",
"def contact_info(xml)\n super # placeholder so that I can add some doc\n end",
"def child_node; end",
"def persist_in_xml\n\nend",
"def xmldecl(version, encoding, standalone); end",
"def xmldecl(version, encoding, standalone); end",
"def xmldecl(version, encoding, standalone); end",
"def xmldecl(version, encoding, standalone); end",
"def to_xml(*)\n self\n end",
"def xml_callbacks\n @xmlcbs\n end",
"def xmldecl(version, encoding, standalone) # :nodoc:\n end",
"def element_state; end",
"def parse(xml)\n raise NotImplementedError, \"inheritor should define #{__method__}\"\n end",
"def xml_document\n @root_node.to_s\n end",
"def xml_document\n @root_node.to_s\n end",
"def xmldecl version, encoding, standalone\n end",
"def dom_class; end",
"def dom_class; end",
"def dom_class; end",
"def dom_class; end",
"def initialize(*args)\n super\n decorators(Nokogiri::XML::Node) << Nokogiri::Decorators::XBEL\n decorate!\n\n# self.root = '<xbel version=\"1.0\"></xbel>'\n end",
"def xml_document\n xml = XML::Document.new\n xml.root = self.to_xml\n xml\n end",
"def element_name; end",
"def to_xml\n render_xml\n end",
"def test_get_xml_for\n order_1 = orders(:santa_next_christmas_order)\n\n # Order with a blank shipping type, just to cover a comparison in the method.\n order_2 = orders(:an_order_ordered_paid_shipped)\n order_2.order_shipping_type = nil\n \n # Test the XML.\n require 'rexml/document'\n \n xml = REXML::Document.new(Order.get_xml_for([order_1, order_2]))\n assert xml.root.name, \"orders\"\n\n # TODO: For some elements the name don't correspond with the content.\n # This can be tested a little more.\n end",
"def to_xml\n @xml ||= get_xml\n end",
"def resource_base_name\n 'XML'\n end",
"def element; end",
"def element; end",
"def element; end",
"def element; end",
"def InitializeXMLdb\n end",
"def test_xml_declaration\r\n xdoc = XmlDocument.new()\r\n node = xdoc.create_xml_declaration('1.0', 'UTF-8')\r\n assert_equal node.attributes.count, 2\r\n xdoc.append_child(node)\r\n assert_equal xdoc.child_nodes.count, 1\r\n assert_equal xdoc.attributes.count, 0\r\n end",
"def public_xml\n resource.public_xml\n end",
"def doc\n @doc ||= xml_doc @xml\n end",
"def to_xml(xml)\n xml.Override(self.instance_values)\n end",
"def to_xml\n self.to_s\n end",
"def to_xml\n self.to_s\n end",
"def xml_to_instance\r\n ATTRIBUTES_MAP.each do |name, hash| \r\n elem = @xml.root.elements[hash[\"element\"]]\r\n unless elem.nil?\r\n val = (hash.has_key?(\"attribute\") ? elem.attributes[hash[\"attribute\"]] : elem.text)\r\n val = self.send(hash[\"from_xml\"], val) if hash.has_key?(\"from_xml\")\r\n self.send(name+\"=\", val)\r\n end\r\n end\r\n self.status = :old\r\n\r\n @xml.root.elements.each(\"link\") do |link|\r\n @feed = link.attributes[\"href\"] if link.attributes[\"rel\"] == \"edit\"\r\n end\r\n end",
"def inner_html\n self.inner_xml\n end",
"def result\n render_xml\n end",
"def to_xml\n return self.to_s\n end",
"def xmldecl ver, enc, stand\n # ignore xml declaration\n end",
"def to_xml(xml)\n xml.member(:type => type, :ref => ref, :role => role)\n end",
"def xml(*args, &blk)\n XML.new(*args, &blk)\nend",
"def xml_serialize(writer)\n end",
"def to_xml\n @xml.to_xml\n end",
"def write_xml\n true\n end",
"def method_missing(meth, *args, &blk) \n if meth.to_s =~ /^(.*)!$/\n self << XML.new($1.to_sym, *args, &blk)\n else\n real_method_missing(meth, *args, &blk)\n end\n end",
"def to_xml()\n XmlSimple.xml_out( { :address => self.to_hash() }, { :KeepRoot=>true, :NoAttr=>true } )\n end",
"def to_xml_element(one_session)\n raise NotImplementedException\n end",
"def xml_http_request?; end",
"def root_node; end",
"def to_xml\n self.xml ||= fetch({\"service\"=>self.service_type,\"metric\"=>self.metric,\"start\"=>self.sdate.to_s,\"end\"=>self.edate.to_s,\"artistID\"=>self.artist_id,\"apiKey\"=>$nbs_api_key,\"format\"=>\"xml\"})\n end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end"
] |
[
"0.7317029",
"0.7317029",
"0.71309465",
"0.6866044",
"0.66011095",
"0.6576617",
"0.65291077",
"0.6490636",
"0.64841795",
"0.6471499",
"0.64376557",
"0.6363155",
"0.6363155",
"0.6310148",
"0.6310148",
"0.62645566",
"0.6193281",
"0.61876607",
"0.61783147",
"0.61626214",
"0.6120959",
"0.6107034",
"0.60833657",
"0.6068797",
"0.6058827",
"0.6052234",
"0.6052234",
"0.6052234",
"0.6052234",
"0.6052234",
"0.6052234",
"0.6045317",
"0.60239667",
"0.5972172",
"0.59619486",
"0.5932589",
"0.5928319",
"0.592761",
"0.59095377",
"0.59095377",
"0.59095377",
"0.59095377",
"0.58955896",
"0.58719236",
"0.58713067",
"0.5852073",
"0.5803965",
"0.5798204",
"0.5798204",
"0.5793078",
"0.5792694",
"0.5792694",
"0.5792694",
"0.5792694",
"0.5787008",
"0.57696927",
"0.5764623",
"0.57622606",
"0.575183",
"0.5736756",
"0.57192236",
"0.57054555",
"0.57054555",
"0.57054555",
"0.57054555",
"0.57017165",
"0.56939894",
"0.5688672",
"0.5685912",
"0.56828517",
"0.56825036",
"0.56825036",
"0.567899",
"0.5677748",
"0.5662754",
"0.56510085",
"0.5639636",
"0.5633971",
"0.56290656",
"0.56253463",
"0.5620428",
"0.56186897",
"0.55993205",
"0.5593806",
"0.5593579",
"0.5592399",
"0.5561309",
"0.55509394",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022",
"0.5548022"
] |
0.0
|
-1
|
See for API info
|
def valid_address?( delta = 1.0 )
@required = [:ups_account, :ups_user, :ups_password]
state = STATES.has_value?(@state.downcase) ? STATES.index(@state.downcase) : @state
@data = String.new
b = Builder::XmlMarkup.new :target => @data
b.instruct!
b.AccessRequest {|b|
b.AccessLicenseNumber @ups_account
b.UserId @ups_user
b.Password @ups_password
}
b.instruct!
b.AddressValidationRequest {|b|
b.Request {|b|
b.RequestAction "AV"
b.TransactionReference {|b|
b.CustomerContext "#{@city}, #{state} #{@zip}"
b.XpciVersion API_VERSION
}
}
b.Address {|b|
b.City @city
b.StateProvinceCode state
b.PostalCode @zip
}
}
get_response "https://wwwcie.ups.com/ups.app/xml/AV"
if REXML::XPath.first(@response, "//AddressValidationResponse/Response/ResponseStatusCode").text == "1" && REXML::XPath.first(@response, "//AddressValidationResponse/AddressValidationResult/Quality").text.to_f >= delta
return true
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def apis; end",
"def api; end",
"def api; end",
"def info\n get(\"/api-info\")\n end",
"def api_mode; end",
"def inspect\n return 'Ballchasing API'\n end",
"def api\n @api\n end",
"def api_only; end",
"def api_only; end",
"def api_only; end",
"def getinfo\n @api.request 'getinfo'\n end",
"def hidden_apis; end",
"def api\n self.well_info.api\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def api_error; end",
"def info; end",
"def info; end",
"def url_api\n Guidebox\n end",
"def get_info\n end",
"def get_info\n end",
"def get_info\n end",
"def info()\n #This is a stub, used for indexing\n end",
"def api\n return @api\n end",
"def getinfo\n request :getinfo\n end",
"def inspect\n \"API key hidden for protection. Using the target URL #{@base_url}\"\n end",
"def from_api?; false end",
"def parent_api; end",
"def parent_api; end",
"def show\n render_result('Current API has no definition for just calling /docs. Call /docs/changes or /docs/deletes')\n end",
"def docs api\n\t\tget_html \"#{@options[:docs]}/#{@apis[api][:url]}.htm\"\n\tend",
"def url\n api_url\n end",
"def api_method\n ''\n end",
"def coreApiEP\n\t\tCORE_API_URL_83\n\tend",
"def http; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def info\n standardize\n # Alphebatize the API hash\n @api_sort = @api_hash.sort\n # Convert to array because SQLite\n @api_arr = @api_sort.flat_map do |_, v|\n v.is_a?(Hash) ? v.map { |_, w| escape(w) } : escape(v)\n end\n end",
"def info() \n \treturn self.response.info()\n\tend",
"def get; end",
"def info\n raise \"Not yet implemented\"\n end",
"def api_keys; rest_query(:api_key); end",
"def api_keys; rest_query(:api_key); end",
"def info\n CouchRest.get \"#{@uri}/\"\n end",
"def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error when we request the URL again\n end",
"def api_object\n unless $api\n $api = FyberAPI.new(\n 'b07a12df7d52e6c118e5d47d3f9e60135b109a1f',\n {\n appid: 157,\n format: 'json',\n device_id: '2b6f0cc904d137be2e1730235f5664094b83',\n locale: 'de',\n ip: '109.235.143.113'\n }\n )\n end\n $api\n end",
"def details; end",
"def info\n get '/'\n end",
"def info\n\tend",
"def api_key; end",
"def api_key; end",
"def info( opts = {} )\n http_action :get, nil, opts\n end",
"def info\n IbmCloudRest.get \"#{@uri}/\"\n end",
"def api_location\n nil\n end",
"def api\n @config = ZipMoney::Configuration\n configure_api if @_api.nil?\n \t @_api\n end",
"def api\n TaskMapper::Provider::Fogbugz.api\n end",
"def api\n TaskMapper::Provider::Fogbugz.api\n end",
"def info\n request('getinfo')\n end",
"def api_only=(_); end",
"def rest_endpoint; end",
"def overview\n\n end",
"def api\n methods - Object.public_methods\n end",
"def endpoints; end",
"def fetch_api_codewars_kata_info\n private_fetch_kata\n end",
"def api_methods\n self.class.instance_methods(false)\n end",
"def api_methods\n self.class.instance_methods(false)\n end",
"def api\n {\n 'host' => self['apiHost'],\n 'password' => self['apiPassword'],\n 'path' => self['apiPath'],\n 'port' => self['apiPort'],\n 'protocol' => self['apiProtocol'],\n 'username' => self['apiUsername']\n }\n end",
"def api\n TaskMapper::Provider::Fogbugz.api\n end",
"def api_url\n @@API_URL\n end",
"def initialize(api)\n @api = api\n end",
"def parse_api\n\t\t@api_data_on_electeds[\"results\"].map do |info|\n\t\t\tfirst_name = info[\"first_name\"]\n\t\t\tlast_name = info[\"last_name\"]\n\t\t\temail = info[\"oc_email\"]\n\t\t\tphone = info[\"phone\"]\n\t\t\ttwitter = info[\"twitter_id\"]\n\t\tputs \"Your elected official is #{first_name} #{last_name}. Their email is #{email} and you can call them at #{phone}. Also send them a tweet at @#{twitter}!\"\n\tend\nend",
"def info(url)\n rest = RestClient::Request.execute(\n method: :get,\n url: url,\n user: ENV['USER'],\n password: ENV['KEY'],\n headers: {\"Content-Type\" => \"application/json\"}\n )\n JSON.parse(rest, :symbolize_names => true)\n rescue RestClient::Exception\n \"Sorry something went wrong with the API\"\n end",
"def docs; end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def is_api?\n false\n end",
"def api\n @api ||= Battlenet.new(:eu)\n end",
"def hidden_apis=(_arg0); end",
"def get()\n \n end",
"def GET; end",
"def preflight; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def api_only=(_arg0); end",
"def can_use_api?\n api_enabled\n end",
"def api_keys\n rest_query(:api_key)\n end",
"def api_endpoint\n 'index'\n end",
"def api_url\n raise NotImplementedError, \"#{self.class} must implement #api_url!\"\n end",
"def api_info(req)\n client.request(req) do |response|\n json_response = ::RHC::Json.decode(response.content)\n [ json_response['supported_api_versions'], json_response['api_version'] || json_response['version'].to_f, json_response['data'] ]\n end\n end",
"def info\n super(MARKETPLACEAPP_METHODS[:info], 'MARKETPLACEAPP')\n end",
"def api_version; config[:api_version]; end"
] |
[
"0.7917624",
"0.7724827",
"0.7724827",
"0.74854916",
"0.74843943",
"0.7421503",
"0.73053926",
"0.7287437",
"0.7287437",
"0.7287437",
"0.7141845",
"0.70885766",
"0.70866466",
"0.70270675",
"0.70270675",
"0.6946844",
"0.69116867",
"0.69116867",
"0.68987346",
"0.6865924",
"0.6865924",
"0.6865924",
"0.68419033",
"0.6732809",
"0.6671526",
"0.6654624",
"0.66290456",
"0.66135126",
"0.66135126",
"0.6608462",
"0.6571086",
"0.65546024",
"0.6495967",
"0.64891344",
"0.64541197",
"0.64536875",
"0.64536875",
"0.64536875",
"0.64536875",
"0.64297706",
"0.6405526",
"0.63926786",
"0.6390532",
"0.63898623",
"0.63898623",
"0.6388517",
"0.63861406",
"0.63664246",
"0.6361155",
"0.635579",
"0.63511",
"0.63237894",
"0.63237894",
"0.6320465",
"0.6310753",
"0.6303976",
"0.6296786",
"0.6287124",
"0.6287124",
"0.6281063",
"0.62661874",
"0.6251847",
"0.6245656",
"0.62415326",
"0.62108386",
"0.61915535",
"0.617538",
"0.617538",
"0.61643624",
"0.61527914",
"0.61459744",
"0.6141825",
"0.6129432",
"0.61112946",
"0.61071163",
"0.6098104",
"0.6092557",
"0.6073914",
"0.6071078",
"0.6056979",
"0.6056643",
"0.6054247",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6049138",
"0.6027156",
"0.60224813",
"0.6022171",
"0.6021972",
"0.6021161",
"0.60192823",
"0.6011238",
"0.6010573"
] |
0.0
|
-1
|
block caller until lock is aquired, then yield
|
def with_lock
lock!(true)
yield
ensure
unlock!
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def with_lock\n lock\n begin\n yield if block_given?\n ensure\n unlock\n end\n end",
"def synchronize\n lock\n yield\n ensure\n unlock\n end",
"def synchronize # :yields:\n lock\n yield\n ensure\n unlock\n end",
"def synchronize\n lock\n begin\n yield\n ensure\n unlock\n end\n end",
"def lock\n if block_given?\n raise 'Race condition' if locking?\n\n @locking = true\n yield\n return @locking = false\n end\n @locking = true\n end",
"def synchronize\n lock(&block)\n end",
"def synchronize\n mutex.synchronize do\n yield\n end\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def lock\n # Flush everything to start with a clean state\n # and to protect the @locked variable\n flush\n\n with_flock(File::LOCK_EX) do\n replay\n result = yield\n flush\n result\n end\n end",
"def sync( &block )\n LOCK.synchronize &block\n rescue ThreadError\n yield\n end",
"def lock!; end",
"def try_lock\n end",
"def synchronize\n @mutex.synchronize do\n yield\n end\n end",
"def synchronize\n\t\t\tlock\n\t\t\tbegin\n\t\t\t\tyield\n\t\t\tensure\n\t\t\t\tunlock\n\t\t\tend\n \t\tend",
"def lock; end",
"def lock; end",
"def lock; end",
"def with_lock\n @zk_lock ||= @zk.locker(current_lock_path)\n\n begin\n @zk_lock.lock!(true)\n rescue Exception\n # handle shutdown case\n running? ? raise : return\n end\n\n if running?\n @zk_lock.assert!\n yield\n end\n ensure\n if @zk_lock\n begin\n @zk_lock.unlock!\n rescue => ex\n logger.warn(\"Failed to release lock: #{ex.inspect}\")\n end\n end\n end",
"def synchronize_block(&block)\n @lock.synchronize(&block)\n end",
"def lock\n end",
"def synchronize_read\n lock_read\n begin\n yield\n ensure\n unlock_read\n end\n end",
"def lock_for_update(name=nil)\n if locked_for_update?(name)\n logger.debug { \"we are locked for update, yield to the block\" }\n yield\n else\n zk_with_lock(:mode => :exclusive, :name => name) { yield }\n end\n end",
"def busy\n @busy = true\n yield\n ensure\n @busy = false\n end",
"def with_lock(&block)\n @lock.synchronize { yield @delegate }\n end",
"def lock_changes\n begin\n @lock_count += 1\n yield\n ensure\n @lock_count -= 1\n end\n end",
"def lock(&block)\n # TODO: only use replace strategy when server is executing the lock\n return call_strategy unless (locked_token = locksmith.lock(&block))\n\n locked_token\n end",
"def lock\n @mutex.lock\n end",
"def run_atomically(lock_key, tries=ConcurrentRestriction.lock_tries)\n acquired_lock = false\n exp_backoff = 1\n\n tries.times do\n lock_expiration = Time.now.to_i + ConcurrentRestriction.lock_timeout\n if acquire_lock(lock_key, lock_expiration)\n acquired_lock = true\n begin\n yield\n ensure\n release_lock(lock_key, lock_expiration)\n end\n break\n else\n sleep(rand(100) * 0.001 * exp_backoff)\n exp_backoff *= 2\n end\n end\n \n return acquired_lock\n end",
"def wait_until\n until yield\n wait\n end\n end",
"def wait_until\n until yield\n\twait\n end\n end",
"def without_locking\n old_value = Parts::WithLocking.locking?\n begin\n Parts::WithLocking.locking = false\n ret_value = yield\n ensure\n Parts::WithLocking.locking = old_value\n end\n ret_value\nend",
"def synchronized(o)\no.mutex.synchronize { yield }\nend",
"def with_serial_lock\n CLIENT_MUTEX.synchronize { yield }\nend",
"def use(&block)\n @mutex.synchronize { yield @obj, @mutex }\n end",
"def synchronize(&block)\n @pool.hold(&block)\n end",
"def synchronize(&block)\n @pool.hold(&block)\n end",
"def block_until_read_lock!\n begin\n path = [root_lock_path, next_lowest_write_lock_name].join('/')\n logger.debug { \"SharedLocker#block_until_read_lock! path=#{path.inspect}\" }\n @zk.block_until_node_deleted(path)\n rescue NoWriteLockFoundException\n # next_lowest_write_lock_name may raise NoWriteLockFoundException,\n # which means we should not block as we have the lock (there is nothing to wait for)\n end\n\n @locked = true\n end",
"def lock(name, mode)\n yield\n end",
"def lock!\n freeze!\n @locked = true\n self\n end",
"def hold()\n fiber = Fiber.current\n conn = acquire(fiber)\n yield conn\n end",
"def lock_working_and_store(wait=true)\n lock_store(wait) do\n lock_working(wait) do\n yield\n end\n end\n end",
"def synchronize(&block)\n @mutex.synchronize(&block)\n end",
"def locked; end",
"def _synchronize\n Test.io_lock.synchronize { yield }\n end",
"def synchronize(&block)\n @mutex.synchronize(&block)\n end",
"def non_blocking_lock!( *args, &block )\n unless non_blocking_lock( *args, &block )\n raise ::LockFailed.new( \"Failed to obtain a lock.\" )\n end\n end",
"def with_lock\n self.lock = 1\n yield\n self.lock = 0\n queue_available_jobs\n end",
"def use\n raise \"No block was given.\" if !block_given?\n \n obj = self.get_and_lock\n \n begin\n yield(obj)\n ensure\n self.free(obj)\n end\n end",
"def try_await_lock(table, i); end",
"def wait_until_available\n return unless @locked\n\n @mutex.lock\n @mutex.unlock\n end",
"def lock(key)\n returned_from_block = nil\n client.lock(key, @ttl) do |locked|\n raise UnableToAcquireLockError unless locked\n returned_from_block = yield\n end\n returned_from_block\n end",
"def yield\n wait\n callback\n end",
"def mon_synchronize\n mon_enter\n begin\n yield\n ensure\n mon_exit\n end\n end",
"def mon_synchronize\n mon_enter\n begin\n yield\n ensure\n mon_exit\n end\n end",
"def wait_until\n until yield\n wait\n end\n end",
"def mon_synchronize\n mon_enter\n begin\n yield\n ensure\n mon_exit\n end\n end",
"def call(*, &block)\n lock_instance.execute(&block)\n end",
"def wait\n done = @ractor.take\n yield(self) if block_given?\n done\n end",
"def with_lock(&blk)\n create_lock_file!\n queue = Queue.new\n\n first_lock_blk = lambda do\n if have_first_lock?(true)\n queue << :locked\n end\n end\n\n @zk.watcher.register(root_lock_path, &first_lock_blk)\n first_lock_blk.call\n\n if queue.pop\n begin\n @locked = true\n return blk.call\n ensure\n unlock!\n end\n end\n\n end",
"def locked\n end",
"def lock!\n @locked = true\n end",
"def sync(&block)\r\n thread_lock.synchronize &block\r\n end",
"def wait_while\n while yield\n wait\n end\n end",
"def work\n stat :attempting_lock_on, item_id: object_id\n if @mutex.try_lock\n stat :has_lock_on, item_id: object_id\n chore\n stat :releasing_lock_on, item_id: object_id\n @mutex.unlock\n else\n stat :bailed_on, item_id: object_id\n end\n end",
"def tsync\n @tmutex.synchronize do\n yield\n end\n end",
"def synchronize_access\n self.stream_lock.lock_read unless self.stream_lock.nil?\n begin\n yield\n ensure\n self.stream_lock.unlock_read unless self.stream_lock.nil?\n end\n end",
"def synchronize(&block)\n @semaphore.synchronize(&block)\n end",
"def start\n\t\treturn self.unlock()\n\tend",
"def wait_until_available\n return unless locked?\n\n @mutex.synchronize {}\n end",
"def waitUntil\n until yield\n sleep 0.5\n end\nend",
"def synchronize\n unless lock\n current_lock = read\n\n err = \"Resource #{current_lock['id']} locked by #{current_lock['client_name']}\"\n err << \" since #{current_lock['time']} (PID #{current_lock['process_id']})\"\n\n raise ResourceLocked.new(err)\n end\n\n yield\n\n unlock\n rescue => ex\n ex = ex.respond_to?(:cause) ? ex.cause : ex\n\n unless ex.is_a?(ResourceLocked)\n unlock if unlock_on_failure\n end\n\n abort(ex)\n end",
"def lock\n post :lock\n end",
"def synchronize(key = nil)\n mutex[key].synchronize do\n yield\n end\n end",
"def lock\n if lockfile.lock\n begin\n yield\n ensure\n lockfile.unlock\n end\n return true\n else\n return false\n end\n end",
"def wait_while\n while yield\n\twait\n end\n end",
"def lock\n shaz_nolock_lock if !@nolock\n end",
"def with_lock(&block)\n if __locked?\n block.call\n else\n __with_thread_local_lock { attr_memoized_mutex.synchronize(&block) }\n end\n end",
"def synchronize\n @rwlock.with_write_lock { yield }\n end",
"def with_serial_lock\n timeout_cap(15) do\n CLIENT_MUTEX.synchronize { yield }\n end\nend",
"def lock!\n @locked = true\n end",
"def lock!(wait = 0.1)\n until redis.call(\"SETNX\", key[:_lock], lock_timeout) == 1\n next unless lock = redis.call(\"GET\", key[:_lock])\n sleep(wait) and next unless lock_expired?(lock)\n\n break unless lock = redis.call(\"GETSET\", key[:_lock], lock_timeout)\n break if lock_expired?(lock)\n end\n end",
"def mutex; end",
"def mutex; end",
"def mutex; end",
"def mutex; end",
"def wait_while\n while yield\n wait\n end\n end",
"def lock\n\t\t\tif @locked == Thread.current\n\t\t\t\t@nested_locks += 1\n\t\t\telse\n\t\t\t\twhile (Thread.critical = true; @locked)\n\t\t\t\t\t@waiting.unshift Thread.current\n\t\t\t\t\tThread.stop\n\t\t\t\tend\n\t\t\t\t@locked = Thread.current\n\t\t\t\tThread.critical = false\n\t\t\tend\n\t\t\tself\n\t\tend",
"def yield\n\t\t\tFiber.scheduler.yield\n\t\tend",
"def try_lock\n if locked_out?\n false\n else\n lock\n true\n end\n end",
"def mutex(id, &block)\n is_expired = lambda do |locked_at|\n locked_at.to_f < Time.now.to_f\n end\n bid = batch(id)\n _key_ = \"#{bid}:lock\"\n\n until redis.setnx(_key_, Time.now.to_f + 0.5)\n next unless timestamp = redis.get(_key_)\n\n unless is_expired.call(timestamp)\n sleep(0.1)\n next\n end\n\n break unless timestamp = redis.getset(_key_, Time.now.to_f + 0.5)\n break if is_expired.call(timestamp)\n end\n yield(bid)\n ensure\n redis.del(_key_)\n end",
"def with_lock(cache_key, max_wait: nil)\n return nil unless cache_key\n\n # Set max wait\n max_wait = (max_wait || LOCK_DURATION).to_i\n\n # Wait to acquire lock\n lock_key = [LOCK_KEY_PREFIX, cache_key].join('/')\n client.with do |conn|\n sleep(LOCK_WAIT_DURATION) until conn.set(lock_key, true, nx: true, ex: max_wait)\n end\n\n # yield content\n yield\n ensure\n del(lock_key)\n end",
"def with_lock(key)\n with_multilock(Array.wrap(key)) do |lock_objects|\n yield lock_objects[key]\n end\n end",
"def lock\n self.is_locked = true\n self\n end",
"def synchronize\n self.P\n begin\n ret = yield\n ensure\n self.V\n end\n ret\n end",
"def atomic(&block)\r\n @queue.synchronized do\r\n yield self\r\n end\r\n end",
"def yield\n wait\n case result\n when Exception\n raise result\n else\n result\n end\n end",
"def within_preserved_state\n lock.synchronize do\n begin\n interactor.stop if interactor\n @result = yield\n rescue Interrupt\n # Bring back Pry when the block is halted with Ctrl-C\n end\n\n interactor.start if interactor && running\n end\n\n @result\n end"
] |
[
"0.8058668",
"0.76484823",
"0.7619658",
"0.7459504",
"0.74217576",
"0.7381096",
"0.7303057",
"0.72804105",
"0.72804105",
"0.72804105",
"0.72804105",
"0.72190434",
"0.71801776",
"0.71436113",
"0.71273816",
"0.71096826",
"0.7001381",
"0.6898819",
"0.6898819",
"0.6898819",
"0.6844573",
"0.6822353",
"0.67964596",
"0.6784797",
"0.67732",
"0.67074716",
"0.6642589",
"0.6635822",
"0.6622982",
"0.6615844",
"0.6615061",
"0.66057056",
"0.65959686",
"0.6593498",
"0.6591179",
"0.65877104",
"0.65603137",
"0.655915",
"0.655915",
"0.6548874",
"0.6545879",
"0.6542088",
"0.65388995",
"0.65249455",
"0.65216",
"0.6514406",
"0.6513705",
"0.6512385",
"0.6494865",
"0.6494054",
"0.6477039",
"0.6474982",
"0.64633656",
"0.6463115",
"0.64550173",
"0.6448392",
"0.6443161",
"0.6438824",
"0.6433008",
"0.64235693",
"0.64233327",
"0.6418173",
"0.6416131",
"0.6414682",
"0.6411333",
"0.64064443",
"0.64061034",
"0.639536",
"0.63699555",
"0.63690335",
"0.63602513",
"0.63561016",
"0.63552505",
"0.6349139",
"0.63433874",
"0.6340491",
"0.63397485",
"0.6326162",
"0.6323767",
"0.6321521",
"0.6319526",
"0.63072777",
"0.630062",
"0.6278559",
"0.62778807",
"0.62778807",
"0.62778807",
"0.62778807",
"0.6258577",
"0.6234195",
"0.62327564",
"0.6229944",
"0.6221726",
"0.6216637",
"0.62097484",
"0.61970115",
"0.6196931",
"0.61944205",
"0.6188233",
"0.61778015"
] |
0.811213
|
0
|
the basename of our lock path for the lock_path '/_zklocking/foobar/__blah/lock000000007' lock_basename is 'lock000000007' returns nil if lock_path is not set
|
def lock_basename
lock_path and File.basename(lock_path)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def lockfile_basename\n \"sync-#{syncer_name}.lock\"\n end",
"def lock_path\n File.join(lock_dir,\"Kellerkind.lock\")\n end",
"def lock_path; end",
"def lockfile_path\n return unless gemfile_path\n @lockfile_path ||= gemfile_path.dirname.join(\"#{gemfile_path.basename}.lock\")\n end",
"def lock_file_name\n @path + '/index.lock'\n end",
"def lock_file_path\n File.join(self.class.locks_dir, \"#{@name}.lock\")\n end",
"def lock_path\n @lock_path || tmp_path.join(\"vagrant.lock\")\n end",
"def basename\n @basename ||= File.basename(path)\n end",
"def lock_file ; \"#{path}.lock\" ; end",
"def basename\n s = name\n (i = s.rindex('::')) and (s = s.right(-i-2)) unless s.blank?\n s\n end",
"def lock_file_path\n @lock_file_path ||= \"#{Rails.root.to_s}/log/#{@process_name}.lock\"\n end",
"def next_lowest_write_lock_name\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename) # our idx would be 2\n\n ary[0..my_idx].reverse.find { |n| n.start_with?(EXCLUSIVE_LOCK_PREFIX) }.tap do |rv|\n raise NoWriteLockFoundException if rv.nil?\n end\n end",
"def basename(delimiter = '/', start = nil)\n return nil if is_placeholder_directory? \n \n prefix = self.key\n unless start.nil?\n prefix = prefix.gsub(start,'')\n end\n \n arr = prefix.split(delimiter)\n if arr.length == 1\n arr[0]\n else\n nil\n end\n end",
"def temp_filename(basename, tmpdir='/tmp')\r\n n = 0\r\n begin\r\n tmpname = File.join(tmpdir, sprintf('%s%d.%d', basename, $$, n))\r\n lock = tmpname + '.lock'\r\n n += 1\r\n end while File.exist?(tmpname)\r\n tmpname\r\n end",
"def lockfile_path\n config.pwd.join(LOCKFILE)\n end",
"def lock_key(tracking_key)\n parts = tracking_key.split(\".\")\n \"concurrent.lock.#{parts[2..-1].join('.')}\"\n end",
"def next_lowest_write_lock_name #:nodoc:\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename) # our idx would be 2\n\n not_found = lambda { raise NoWriteLockFoundException }\n\n ary[0..my_idx].reverse.find(not_found) { |n| n =~ /^#{EXCLUSIVE_LOCK_PREFIX}/ }\n end",
"def create_lock_path!(prefix='lock')\n @lock_path = @zk.create(\"#{root_lock_path}/#{prefix}\", \"\", :mode => :ephemeral_sequential)\n logger.debug { \"got lock path #{@lock_path}\" }\n @lock_path\n rescue Exceptions::NoNode\n create_root_path!\n retry\n end",
"def basename\n File.basename(path)\n end",
"def versionlock_file\n @versionlock_file ||= File.join(staging_dir, \"version-lock\")\n end",
"def final_path_component(path)\n path.split(PATH_SEPARATOR)[-1].split[0]\n end",
"def mutex_path(mutex)\n if mutex.start_with? 'tmp'\n mutex\n else\n 'tmp/' << mutex\n end\n end",
"def basename\n File.basename(@path, '.*')\n end",
"def got_lock?(lock_attempt, zk, config)\n children = zk.get_children(:path => config[:root])[:children].sort\n puts \"children found are #{children}\" if config[:verbose]\n mylocks = children.select {|child| child.start_with?(config[:lockname] + \".\") }\n puts \"Testing my lock (#{lock_attempt[:path]} against the first child (#{config[:root]}/#{mylocks.first})\" if config[:verbose]\n return lock_attempt[:path] == \"#{config[:root]}/#{mylocks.first}\"\nend",
"def version_from_gem_lock_file\n shell_return = run_shell(\"grep -A 1 RUBY Gemfile.lock\")\n shell_return.nil? ? nil : shell_return.stdout.split(\"\\n\")[1].strip.split(\" \")[1]\n end",
"def basename(path)\n path.chomp(\"/\")\nend",
"def basename\n @basename ||= ''\n end",
"def path_section\n $1 if @basename.to_s =~ /\\.(\\d\\w*)\\./\n end",
"def printable_part(pathname)\r\n if (!@rl_filename_completion_desired) # don't need to do anything\r\n return (pathname)\r\n end\r\n\r\n temp = pathname.rindex('/')\r\n return pathname if temp.nil?\r\n File.basename(pathname)\r\n end",
"def chop_basename(path)\n base = File.basename(path)\n if /\\A#{SEPARATOR_PAT}?\\z/o =~ base\n return nil\n else\n return path[0, path.rindex(base)], base\n end\n end",
"def locks_dir\n @locks_dir || _default_locks_dir\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 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 chop_basename(path)\n base = File.basename(path)\n if /\\A#{SEPARATOR_PAT}?\\z/o =~ base\n return nil\n else\n return path[0, path.rindex(base)], base\n end\n end",
"def filename\n path && File.basename(path)\n end",
"def chop_basename(path)\n base = File.basename(path)\n if /\\A#{SEPARATOR_PATTERN}?\\z/ =~ base\n return nil\n else\n return path[0, path.rindex(base)], base\n end\n end",
"def basename=(_arg0); end",
"def lockbox_name\n if mounted_as\n mounted_as.to_s\n else\n uploader = self\n while uploader.parent_version\n uploader = uploader.parent_version\n end\n uploader.class.name.sub(/Uploader\\z/, \"\").underscore\n end\n end",
"def lock_file\n File.join(tmpdir, \"#{ruby_version}.ledger\")\n end",
"def name\n @name ||= path.split('/').last\n end",
"def get_name(path)\n return path[/^.*\\/(.+?)\\/?$/, 1]\n end",
"def lock_id\n Integer('0x' + Digest::MD5.hexdigest(name)) % (1 << 63)\n end",
"def basename(path)\n File.basename(path)\n end",
"def get_branch_from_relpath(patch_path_rel)\n str = patch_path_rel.match(/\\.\\/([^\\/]+)\\/([^0-9]+)(.*)/)\n p \"get_branch_from_relpath str:\"\n p str\n return str[1], str[2].chop!, str[3]\n end",
"def tempfile_basename\n basename = ::File.basename(@new_resource.path, tempfile_extension)\n # the leading \"[.]chef-\" here should be considered a public API and should not be changed\n basename.insert 0, \"chef-\"\n basename.insert 0, \".\" unless ChefUtils.windows? # dotfile if we're not on windows\n basename.scrub\n end",
"def find_available_name(path)\n return path unless bucket.objects[path].exists?\n ext = File.extname(path)\n base = path[0..-ext.size-1] + \"-1\"\n loop do\n path = base + ext\n return path unless bucket.objects[path].exists?\n base = base.next\n end\n end",
"def chop_basename(path)\n base = File.basename(path)\n if base.empty? or base == '/'\n return nil\n else\n return path[0, path.rindex(base)], base\n end\n end",
"def file_name_from_path(path)\n path.split(\"/\")[-1]\n end",
"def job_key\n Digest::MD5.hexdigest(path)\n end",
"def basename(name)\n if name =~ /.*\\/(.*)/\n name = $1\n end\n name\n end",
"def basename( path )\r\n File.basename( path )\r\n end",
"def basename(suffix = T.unsafe(nil)); end",
"def basename(file_path)\n filename = File.basename(file_path)\n return filename.split('.')[0].to_sym if file_path\n end",
"def file_name\n File.basename @path\n end",
"def default_name\n path.dirname.basename.to_s\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 find_partial_name(file_path)\n return name = file_path.split('/').last.to_sym;\n end",
"def name\n @name ||= File.basename(path)\n end",
"def name\n @name ||= File.basename(path)\n end",
"def basename\n File.basename( fullpath, ext )\n end",
"def basename\n suffixed? ? name.sub(/\\.#{Regexp.escape(template.name)}$/, '') : name\n end",
"def generate_basename(chunk)\n salt = nil\n while true\n filename = Digest::MD5.hexdigest(\"#{chunk.range_start}#{salt}\") + CHUNK_EXT\n return filename unless chunks_by_basename[filename]\n salt = (salt||0) + 1\n end\n end",
"def filename\n File.basename(path)\n end",
"def name\n File.basename(path)\n end",
"def next_lowest_node\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename)\n\n raise WeAreTheLowestLockNumberException if my_idx == 0\n\n ary[(my_idx - 1)] \n end",
"def get_version(gem)\n lockfile_specs.find { |s| s.name == gem }&.version\n end",
"def name\n ::File.basename(path)\n end",
"def lockfile; end",
"def extract_name(file_path)\n if file_path[-1, 1] == \"/\"\n return nil\n end\n\n # File.basename is too eager to please and will return the last\n # component of the path even if it ends with a directory separator.\n ::File.basename(file_path)\n end",
"def version_pathname(splunk_home)\n Pathname.new(splunk_home).join('etc/splunk.version')\n end",
"def get_lock_id\n @lock_id\n end",
"def fname(path)\n path.split(\"/\").last\n end",
"def basename\n return self.name.downcase.gsub(/^.*::/, '')\n end",
"def get_basename(file_path)\n File.basename file_path\n end",
"def basename; end",
"def basename; end",
"def basename; end",
"def basename; end",
"def basename\n File.basename(self.upload.url).split(/\\?/)[0]\n end",
"def name\n $0.split(\"/\").last\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 gemfile_lock_present\n tree = repository.repo.lookup(revision).tree\n locks = tree.select{|item| item[:name] == 'Gemfile.lock' }\n binary_integer locks\n end",
"def ruby_version\n lockfile_next_version = Bundler::LockfileParser.new(lockfile_path.read).ruby_version\n\n if lockfile_next_version\n lockfile_next_version.chomp.sub(\"(\", \"\").sub(\")\", \"\").sub(/(p-?\\d+)/, ' \\1').split.join(\"-\")\n else\n super\n end\n end",
"def gem_deps_file # :nodoc:\n File.basename @path\n end",
"def get_pid\n File.open(@lock_file, 'r').read.to_i\n end",
"def del_lock(zk, config, mylock)\n puts \"deleting self #{mylock[:path]}\" if config[:verbose]\n zk.delete(:path => \"#{mylock[:path]}\")\nend",
"def handle\n @handle ||= begin\n p = read_attribute(:path)\n h = p[/^([^:])+:/]\n h.blank? ? read_attribute(:path).split('/').first : h.gsub(':','')\n end\n end",
"def inspect\n File.basename @__path\n end",
"def base_name\n File.basename @absolute_name\n end",
"def template_name\n self.path.scan(/[^\\/]+$/).first\n end",
"def get_path(gemname, version_req)\n return gemname if gemname =~ /\\.gem$/i\n specs = SourceIndex.from_installed_gems.search(gemname, version_req)\n selected = specs.sort_by { |s| s.version }.last\n return nil if selected.nil?\n # We expect to find (basename).gem in the 'cache' directory.\n # Furthermore, the name match must be exact (ignoring case).\n if gemname =~ /^#{selected.name}$/i\n filename = selected.full_name + '.gem'\n return File.join(Gem.dir, 'cache', filename)\n else\n return nil\n end\n end",
"def [](key)\n if path_portion = fragment.split(\"/\").find {|i| i.include?(key.to_s)}\n return path_portion.sub(\"#{key}=\", \"\")\n end\n \n nil\n end",
"def task_name_from_path(path)\n path = File.absolute_path(path)\n parts = path.split(File::Separator)\n if parts.length < 3 || parts[-2] != 'tasks'\n raise ArgumentError, \"Task path was not inside a module.\"\n end\n mod = parts[-3]\n name = File.basename(path).split('.')[0]\n if name == 'init'\n mod\n else\n \"#{mod}::#{name}\"\n end\n end",
"def name\n @name ||= File.basename(path)\n end",
"def part\n \"#{path.chomp('.part')}.part\"\n end",
"def blocking_path(path)\n current_path = self.path\n relative_path = '.'\n File.dirname(path).split(File::SEPARATOR).each do |segment|\n relative_path = File.join(relative_path, segment)\n current_path = File.join(current_path, segment)\n return relative_path if File.file?(current_path)\n end\n nil\n end",
"def get_code_name\n code_name = $0\n code_name = Pathname.new(code_name)\n code_name = code_name.basename.to_s\n return code_name\nend",
"def basename\n without_extension.delete_suffix(WIP_IDENTIFIER)\n .delete_suffix(DEV_IDENTIFIER)\n end"
] |
[
"0.6698864",
"0.6475923",
"0.64210224",
"0.64033467",
"0.621156",
"0.6184906",
"0.600972",
"0.5983802",
"0.59661984",
"0.59616673",
"0.5881011",
"0.58205074",
"0.5798359",
"0.578139",
"0.5766341",
"0.56991315",
"0.5672897",
"0.5625355",
"0.56149566",
"0.55898243",
"0.5580524",
"0.5565563",
"0.552134",
"0.5508385",
"0.55025744",
"0.5415981",
"0.53880095",
"0.53485113",
"0.5331311",
"0.5322412",
"0.53069115",
"0.5297962",
"0.5277844",
"0.5251445",
"0.5239559",
"0.5224208",
"0.5223767",
"0.522105",
"0.5204546",
"0.51997596",
"0.5190372",
"0.51708573",
"0.51571214",
"0.51374733",
"0.5135874",
"0.51331353",
"0.5118588",
"0.51068693",
"0.5102546",
"0.5101893",
"0.5101431",
"0.5080087",
"0.50754464",
"0.50720894",
"0.5065716",
"0.5052397",
"0.5050482",
"0.504674",
"0.504674",
"0.5040864",
"0.5034134",
"0.50261235",
"0.50244075",
"0.502427",
"0.50211185",
"0.5020914",
"0.50074786",
"0.499508",
"0.49931282",
"0.49923444",
"0.49796963",
"0.49757767",
"0.49721876",
"0.49613178",
"0.49488252",
"0.49488252",
"0.49488252",
"0.49488252",
"0.49481922",
"0.49468818",
"0.49389368",
"0.49389368",
"0.49389368",
"0.49386364",
"0.49335724",
"0.49239326",
"0.49228948",
"0.49167395",
"0.49128568",
"0.49072248",
"0.49049926",
"0.4904607",
"0.49033988",
"0.48994038",
"0.48963287",
"0.4895864",
"0.48744097",
"0.48733902",
"0.4857073",
"0.48470223"
] |
0.81779593
|
0
|
returns true if this locker is waiting to acquire lock
|
def waiting? #:nodoc:
false|@waiting
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_locked?\n return true if have_lock?\n begin\n return true unless acquire_lock\n ensure\n release_lock\n end\n false\n end",
"def waiting?\n @lock.synchronize { !defined?(@start_time) }\n end",
"def update_startlock?\r\n # When waiting for event execution or locked\r\n return (@starting or lock?)\r\n end",
"def lock_status?\n return @unlocked == true\n end",
"def has_lock?\n @has_lock || false\n end",
"def wait_until_available\n return unless locked?\n\n @mutex.synchronize {}\n end",
"def locked?\n @mutex.locked?\n end",
"def wait_until_available\n return unless @locked\n\n @mutex.lock\n @mutex.unlock\n end",
"def queueing_locked?\n should_lock_on_queueing? && lock_present?\n end",
"def waiting?\n @waiting.set?\n end",
"def try_lock\n if locked_out?\n false\n else\n lock\n true\n end\n end",
"def lock?\n return true if @_lock_type\n false\n end",
"def locked?\n self.released?\n end",
"def locked?\n\t\t\t!lockoutTime.nil? && lockoutTime.to_i != 0\n\t\tend",
"def waiting?\n @waiting\n end",
"def any_waiting?\n synchronize do\n @num_waiting > 0\n end\n end",
"def any_waiting?\n synchronize do\n @num_waiting > 0\n end\n end",
"def is_locked?\n locked\n end",
"def any_waiting?\n synchronize do\n @num_waiting > 0\n end\n end",
"def have_lock?\n !!@handle\n end",
"def is_locked\n return @is_locked\n end",
"def locked?\n finished? && Time.now.utc > finished_at + 30.minutes\n end",
"def locked?\n !!locked_by && !!locked_at && (locked_at + Delayed::Worker.max_run_time) >= Delayed::Job.db_time_now\n end",
"def available?\n return true unless coliding_locks.any?\n end",
"def access_locked?\n !!locked_at && !lock_expired?\n end",
"def locked?\n self.is_locked\n end",
"def waiting?\n @waiting\n end",
"def locked?\n return @locked\n end",
"def locked?\n\t\t\t@locked\n\t\tend",
"def locking?\n @locking\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n not @lock_name.nil?\n end",
"def locked?\n fetch_lock_info\n\n obj_exists_and_is_not_type? obj: @lock_info, type: []\n end",
"def lockable?\n @lockable\n end",
"def locked?\n locksmith.locked?\n end",
"def locked?\n !locked_at.nil?\n end",
"def locked?\n @locked\n end",
"def locked?\n end",
"def locked?\n @locked\n end",
"def waiting?\n @status[:description] == :wait\n end",
"def update_wait?\r\n # If waiting\r\n if @wait_count > 0\r\n # Reduce wait count\r\n @wait_count -= 1\r\n return true\r\n end\r\n return false\r\n end",
"def update_wait?\r\n # If waiting\r\n if @wait_count > 0\r\n # Decrease wait count\r\n @wait_count -= 1\r\n return true\r\n end\r\n return false\r\n end",
"def locked?\n (status & (1 << 0)).zero?\n end",
"def try_lock\n\t\t\t@nested_locks += 1 and return true if @locked == Thread.current\n\t\t\tresult = false\n\t\t\tThread.critical = true\n\t\t\tunless @locked\n\t\t\t\t@locked = Thread.current\n\t\t\t\tresult = true\n\t\t\tend\n\t\t\tThread.critical = false\n\t\t\tresult\n\t\tend",
"def acquire\n lock = lockSession\n if lock\n return resource[:acquire]\n else\n return false\n end\n end",
"def acquire_lock(lock_name)\n begin\n acquired = false\n sql = lock_query(lock_name)\n connection.query(sql) do |result|\n acquired = result.fetch_row.first == \"1\"\n end\n acquired\n rescue ::Exception\n false\n end\n end",
"def unlocked?\n not locked?\n end",
"def aquired?\n acquired?\n end",
"def locked?\n !!read\n end",
"def held?\n status.queued_held?\n end",
"def wait(timeout = nil)\n return true if set?\n\n @mutex.synchronize { @waiters << Thread.current }\n return true if set? # if event was set while waiting for mutex\n\n if timeout.nil?\n slept = sleep\n else\n slept = sleep(timeout)\n end\n rescue\n # let it fail\n ensure\n @mutex.synchronize { @waiters.delete(Thread.current) }\n return set?\n end",
"def running?\n # Avoid N+1 Query: `.includes_advisory_locks`\n if has_attribute?(:locktype)\n self['locktype'].present?\n else\n advisory_locked?\n end\n end",
"def unlocked?\n unlocked, _, @active_worker_timestamp = Sidekiq.redis do |redis| \n redis.multi do\n redis.setnx(@locking_key, @current_worker_timestamp)\n redis.expire(@locking_key, 600)\n redis.get(@locking_key)\n end\n end\n unlocked\n end",
"def unlocked?\n !locked?\n end",
"def wait(timeout = nil)\n begin\n Timeout::timeout timeout do\n @mutex.synchronize do\n @conditional.wait @mutex if @count > 0\n end\n end\n true\n rescue Timeout::Error\n false\n end\n end",
"def lock_expired?\n if unlock_strategy_enabled?(:time)\n locked_at && locked_at < self.class.unlock_in.ago\n else\n false\n end\n end",
"def unlocked?\n @unlocked\n end",
"def busy?()\n @mutex.synchronize() do\n return @busy\n end\n end",
"def locked?\n !status_flag?(:kSecUnlockStateStatus)\n end",
"def waiting?\n !checked_in?\n end",
"def already_locked?\n lock_stack.last == lock_stack_item\n end",
"def our_lock?(current_lock)\n return nil unless current_lock\n return false unless current_lock[\"client_name\"] == client_name\n return false unless current_lock[\"process_id\"] == Process.pid\n true\n end",
"def locked?\n locked_by.present? && locked_at.present? && locked_at > 10.minutes.ago\n end",
"def locked?\n if defined?(@locked)\n @locked\n else\n false\n end\n end",
"def before_enqueue_lock(*args)\n key = lock(*args)\n now = Time.now.to_i\n timeout = now + lock_timeout + 1\n\n # return true if we successfully acquired the lock\n return true if Resque.redis.setnx(key, timeout)\n\n # see if the existing timeout is still valid and return false if it is\n # (we cannot acquire the lock during the timeout period)\n return false if now <= Resque.redis.get(key).to_i\n\n # otherwise set the timeout and ensure that no other worker has\n # acquired the lock\n now > Resque.redis.getset(key, timeout).to_i\n end",
"def locked_out?\n # don't need a mutex because we know #owned? can't change during the call \n locked? && !owned?\n end",
"def finished?\n lock.value != 1 && queued_jobs.size.zero? && indegree.size.zero?\n end",
"def is_new_and_others_wait? waiter\n waiter.nil? && !@awaiting.empty?\n end",
"def unlocked?\n ! File.exist?(lock_file)\n end",
"def locked_open?\n lock == :open\n end",
"def supports_locking?\n false #true\n end",
"def lockout?\n @lockout\n end",
"def locked?\n @bridge.device_locked?\n end",
"def has_waiters?\n waiting_writer?(@counter.value)\n end",
"def inspect_lock(lock_key_method, *args)\n lock_until = lock_redis.get(self.send(lock_key_method, *args))\n return (lock_until.to_i > Time.now.to_i) if lock_timeout > 0\n !lock_until.nil?\n end",
"def locked_closed?\n lock == :closed\n end",
"def any_waiting_threads?\n waiting_threads_count >= 1\n end",
"def locked?\n\t\t#puts \"Came to check locked.\"\n\t\tif $redis.get(get_race_condition_key_name).blank?\n\t\t\t#puts \"the key is blank\"\n\t\t\tfalse\n\t\telse\n\t\t #puts \"key is not blank\"\n\t\t #puts \"key is: #{$redis.get(get_race_condition_key_name)}\"\n\t\t $redis.get(get_race_condition_key_name) == LOCKED\n\t\tend\n\tend",
"def locked?\n File.exist?(lock_file)\n end",
"def supports_advisory_locks?\n false\n end",
"def supports_advisory_locks?\n false\n end",
"def lock?\n record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)\n end",
"def wait_to_acquire(key, session, value = nil, check_interval = 10, options = nil)\n acquired = false\n until acquired\n acquired = acquire(key, session, value, options)\n sleep(check_interval) unless acquired\n return true if acquired\n end\n end",
"def locked?\n\t\t\t\t\treturn payment_in_progress? || paid?\n\t\t\t\tend",
"def busy?\n busy = false\n @mutex.synchronize { busy = !!@busy }\n busy\n end",
"def locked?\n File.exist?(lock_file)\n end",
"def waiting?\n entered_at.nil?\n end",
"def acquire_lock(lock_key, lock_expiration)\n # acquire the lock to work on the restriction queue\n expiration_time = lock_expiration + 1\n acquired_lock = Resque.redis.setnx(lock_key, expiration_time)\n\n # If we didn't acquire the lock, check the expiration as described\n # at http://redis.io/commands/setnx\n if ! acquired_lock\n # If expiration time is in the future, then someone else beat us to getting the lock\n old_expiration_time = Resque.redis.get(lock_key)\n return false if old_expiration_time.to_i > Time.now.to_i\n\n # if expiration time was in the future when we set it, then someone beat us to it\n old_expiration_time = Resque.redis.getset(lock_key, expiration_time)\n return false if old_expiration_time.to_i > Time.now.to_i\n end\n\n # expire the lock eventually so we clean up keys - not needed to timeout\n # lock, just to keep redis clean for locks that aren't being used'\n Resque.redis.expireat(lock_key, expiration_time + 300)\n\n return true\n end",
"def busy?\n !(@status == :wait || @status == :disabled || @status == :error)\n end",
"def acquire_lock\n\t\t@@logger.info { \"Acquiring a lock in the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => false).update(:locked => true) != 0\n\tend",
"def locked?\n raise NotImplementedError\n end",
"def lock_on_sleep?\n get_settings[:lock_on_sleep] != 0\n end",
"def busy?\n\n @queue.size > 0\n end",
"def wait(timeout = nil)\n @monitor.__send__(:mon_check_owner)\n count = @monitor.__send__(:mon_exit_for_cond)\n begin\n @cond.wait(@monitor.instance_variable_get(:@mon_data).mutex_for_cond, timeout)\n return true\n ensure\n @monitor.__send__(:mon_enter_for_cond, count)\n end\n end",
"def any_waiting_threads?\n @condition_variable.any_waiting_threads?\n end",
"def busy?()\n !@current_req.nil? || !@queue.empty? || @actor.busy?\n end",
"def busy?(purpose)\n (@exclusive_thread && @exclusive_thread != Thread.current) ||\n @waiting.any? { |k, v| k != Thread.current && !v.include?(purpose) } ||\n @sharing.size > (@sharing[Thread.current] > 0 ? 1 : 0)\n end"
] |
[
"0.7796324",
"0.7723958",
"0.76213855",
"0.7547219",
"0.75395447",
"0.7463722",
"0.743583",
"0.74192744",
"0.74141484",
"0.7384949",
"0.7359922",
"0.73179096",
"0.7313366",
"0.73017013",
"0.72940284",
"0.7290264",
"0.7290264",
"0.7225394",
"0.7203514",
"0.7185347",
"0.7130378",
"0.7102898",
"0.7101847",
"0.71006954",
"0.7096795",
"0.7056011",
"0.7045298",
"0.70112735",
"0.7005677",
"0.7004488",
"0.69755584",
"0.69755584",
"0.69755584",
"0.69755584",
"0.6975184",
"0.69714653",
"0.69676244",
"0.6965814",
"0.69534904",
"0.6950938",
"0.6941726",
"0.6928862",
"0.692351",
"0.6786014",
"0.6784168",
"0.6777669",
"0.67738175",
"0.67480123",
"0.673531",
"0.6718245",
"0.6690555",
"0.6685865",
"0.66628593",
"0.6655565",
"0.66508543",
"0.6618561",
"0.6599829",
"0.6592343",
"0.65806127",
"0.6570655",
"0.656253",
"0.65623015",
"0.656144",
"0.6555243",
"0.6555082",
"0.6548565",
"0.653933",
"0.6529538",
"0.6514811",
"0.6510661",
"0.64909947",
"0.64860827",
"0.6480847",
"0.6480286",
"0.6462142",
"0.6440255",
"0.64391404",
"0.64212185",
"0.63858587",
"0.6372402",
"0.6371157",
"0.63605964",
"0.6353783",
"0.6353783",
"0.6353537",
"0.63526785",
"0.63491446",
"0.63416654",
"0.63262",
"0.6320795",
"0.6319289",
"0.63185555",
"0.63136625",
"0.63133574",
"0.6309352",
"0.63020396",
"0.62956154",
"0.6294792",
"0.6278854",
"0.6268003"
] |
0.7277358
|
17
|
prefix is the string that will appear in front of the sequence num, defaults to 'lock'
|
def create_lock_path!(prefix='lock')
@lock_path = @zk.create("#{root_lock_path}/#{prefix}", "", :mode => :ephemeral_sequential)
logger.debug { "got lock path #{@lock_path}" }
@lock_path
rescue Exceptions::NoNode
create_root_path!
retry
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prefix(num)\n namespace + '_prefix_' + num.to_s\n end",
"def key_prefix\n \"number\"\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 jobid_prefix\n @jobid_prefix\n end",
"def reference_number_prefix\n nil\n end",
"def prefix=(prefix) @prefix = prefix end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix=(_arg0); end",
"def wrap_prefix(prefix)\n prefix\n end",
"def prefix\n number[3..5]\n end",
"def generate_lock\n lock = 'EXTENDEDPROTOCOL'\n [lock + ('ABC' * 6), 'ABCD' * 4]\n end",
"def loop_sequence_urn_id\n Instance.first.prefix + Instance.sep + selp_prefix + Instance.sep + id.to_s.rjust(Instance.just, '0')\n end",
"def prefix=(value)\n @prefix = value\n end",
"def prefix\n ''\n end",
"def proper_start str\n return \"_#{str}\" if str.match(/^[0-9]/) \n return str\n end",
"def prefix\n (\"aa\"..\"zz\").to_a.sample(2).to_s\n end",
"def update_prefix_arg(widget)\n numbers = []\n\n major_mode.event_history.reverse_each do |event|\n break unless event[:sequence] =~ /^(\\d+)$/\n numbers << $1\n end\n\n if numbers.any? && numbers != ['0']\n self.prefix_arg = numbers.reverse.join.to_i\n else\n self.prefix_arg = nil\n end\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 set_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def prefix=(_); end",
"def prefix\n regexify(bothify(fetch('aircraft.prefix')))\n end",
"def then_sequence_urn_id\n Instance.first.prefix + Instance.sep + seth_prefix + Instance.sep + id.to_s.rjust(Instance.just, '0')\n end",
"def redis_lock_key(*args)\n ['lock', self.class.name, identifier(*args)].compact.join(':')\n end",
"def prefix(new_prefix = nil)\n return @prefix if new_prefix.nil?\n @prefix = new_prefix\n end",
"def sequence_number; end",
"def prefix\n nil\n end",
"def prefix\n raise NotImplementedError\n end",
"def name_prefix=(_arg0); end",
"def prefix(value)\n merge(leprefix: value.to_s)\n end",
"def str_prefix\n\t\t\t\t\"\"\n\t\t\tend",
"def prefix\n @data['prefix']\n end",
"def build_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def lock_id\n Integer('0x' + Digest::MD5.hexdigest(name)) % (1 << 63)\n end",
"def pcb_a_part_number(number,\n revision, \n numeric_revision)\n\n self.loaded_prefix + '-' + number + '-00'\n \n end",
"def startsortkeyprefix(value)\n merge(cmstartsortkeyprefix: value.to_s)\n end",
"def set_prefix_to(a)\n Kamelopard.id_prefix = a\n end",
"def load_prefix(sections)\n return if sections.empty? || sections.first.length < 3\n\n raise \"invalid prefix\" unless sections.second.to_s&.length >= 4\n\n sections.shift\n end",
"def prefix\n match(/Prefix\\s+:\\s+([^\\s])/)\n end",
"def prefix\n @obj['prefix']\n end",
"def use_prefix\n prefix, @prefix = @prefix, nil\n @res << prefix if prefix\n\n prefix\n end",
"def redis_prefix\n @redis_prefix ||= name.underscore\n end",
"def prefix(prefix = nil, &block)\n raise ArgumentError if prefix.nil? && block.nil?\n @__cinch_prefix = prefix || block\n end",
"def startsortkeyprefix(value)\n merge(gcmstartsortkeyprefix: value.to_s)\n end",
"def prefix pref_name\n @context['prefix'] = pref_name\n end",
"def name_prefix\n 'num'\n end",
"def prefix=(value)\n value += '/' if value != '' and value[-1] != '/'\n @prefix = value\n end",
"def prefix\n \"#{name}::\"\n end",
"def kmer_prefix(kmer)\n prefix = kmer.slice(0, kmer.length-1)\n return prefix\n end",
"def pcb_unique_number\n self.pcb_prefix + '-' + self.pcb_number\n end",
"def prefix(value)\n merge(gadrprefix: value.to_s)\n end",
"def _prefix_arg0(args, prefix)\n if args.size > 0 && !args[0].nil? && !args[0].include?(prefix)\n args[0] = prefix + args[0]\n end\n args\nend",
"def issue_identifier(node)\n @issued[node] ||= begin\n res, @counter = @prefix + @counter.to_s, @counter + 1\n res\n end\n end",
"def prefix\n \"#{definition_set.global_events_prefix}#{number}_\"\n end",
"def refseq_sequence\n \"NC_0000\" + chrom.sub(/X/, \"23\").sub(/Y/, \"24\")\n end",
"def increment_sequence_number\n @sequence_number += 1\n @sequence_number = 0 if @sequence_number > 0xFFFFFFFF\n end",
"def prefix\n \" => \"\n end",
"def get_next_guids(prefix, last_guid)\n length = last_guid.length - prefix.length\n last_guid = last_guid[prefix.length..-1].to_i\n\n res1 = (last_guid + 1).to_s.rjust(length, '0').prepend(prefix);\n res2 = (last_guid + 2).to_s.rjust(length, '0').prepend(prefix);\n\n return res1, res2\nend",
"def pcba_unique_number\n self.pcba_prefix + '-' + self.pcba_number\n end",
"def route_name_prefix prefix\n @route_name_prefix = prefix\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 prefix\n self.class.prefix\n end",
"def cli_prefix=(_arg0); end",
"def prefix\n 'oai_dc' \n end",
"def exec_prefix() return @prefix end",
"def prefix(value)\n merge(aguprefix: value.to_s)\n end",
"def prefix(path)\n path ? \"#{path.underscore}__\" : ''\n end",
"def name_prefix; end",
"def start_of_line\n @prefixes = '^'\n end",
"def next_lowest_write_lock_num\n digit_from(next_lowest_write_lock_name)\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 prefix_count\n count = prefix_arg || 1\n update_prefix_arg(self)\n count\n end",
"def start_of_string\n @prefixes = '\\A' + @prefixes\n end",
"def lock_key(tracking_key)\n parts = tracking_key.split(\".\")\n \"concurrent.lock.#{parts[2..-1].join('.')}\"\n end",
"def set_serial_number number\n appname = @appname\n pattern = Regexp.new \"^#{appname}:.*$\"\n filename = @app_serial_path || \"serial_numbers\"\n # during testing redo this file does not exist, so i get errors\n if !File.exists? filename\n get_serial_number\n end\n backup filename\n # from Sed\n change_row filename, pattern, \"#{appname}:#{number}\"\n end",
"def prefix_tag(tag)\n tag = Origen::VersionString.new(tag)\n if tag.semantic?\n tag.prefixed\n else\n tag\n end\n end",
"def rid(prefix = '')\n page_hash = Digest::MD5.hexdigest(request.path)\n @rid_seq ||= 0\n @rid_seq += 1\n \"rid#{page_hash}#{@rid_seq}\"\n end",
"def starts_with?(prefix)\n prefix = prefix.to_s\n self[0, prefix.length] == prefix\n end",
"def default_sequence_name(table_name, pri_key = nil)\n serial_sequence(table_name, pri_key || 'id').split('.').last\n rescue ActiveRecord::StatementInvalid\n \"#{table_name}_#{pri_key || 'id'}_seq\"\n end",
"def _set_serial_number number\n appname = @appname\n pattern = Regexp.new \"^#{appname}:.*$\"\n filename = @app_serial_path || \"serial_numbers\"\n # during testing redo this file does not exist, so i get errors\n if !File.exists? filename\n _get_serial_number\n end\n _backup filename\n change_row filename, pattern, \"#{appname}:#{number}\"\n end",
"def prefix(path=nil)\n return ''\n end",
"def next_sequence_number!\n sequence_number && @sequence_number += 1\n end",
"def starts_with(prefix)\n search_arr(prefix.chars)\n end",
"def default_sequence_name(table, _column)\n \"#{table}_seq\"\n end",
"def seq_new_num(filelist)\n\tinitial_num = 0\n\tfor i in 0 .. filelist.size-1\n\t\tif i == 0\n\t\t\tinitial_num = get_last_seq_num(filelist[i]) \n\t\t\ti += 1\n\t\telse\t\n\t\t\tFile.open(filelist[i]) do |f|\n\t\t\t\tout = \"\"\n\t\t\t\tlast_sequence_name = \"\"\n\t\t\t\tinitial_num += 1\n\t\t\t\tf.each do |line|\n\t\t\t\t\tline.chomp!\n\t\t\t\t\tif line.chars.first == \"@\"\n\t\t\t\t\telse\n\t\t\t\t\t\tnum = line.split(\"seq.\")[1].to_i \n\t\t\t\t\t\tlast_sequence_name = num if last_sequence_name == \"\"\n\t\t\t\t\t\tif last_sequence_name != num\n\t\t\t\t\t\t\tinitial_num += 1\n\t\t\t\t\t\t\tlast_sequence_name = num\n\t\t\t\t\t\tend\n\t\t\t\t\t\tsam_fields = line.split(\"\\t\")\n\t\t\t\t\t\tsam_fields[0] = sam_fields[0].gsub(num.to_s, initial_num.to_s)\n\t\t\t\t\t\tputs sam_fields.join(\"\\t\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\ti += 1\t\t\t\n\tend\nend",
"def prefixes; end",
"def prefixes; end",
"def records_list_prefix\n 'l' + [records_count].pack('N').bytes.pack('c*')\n end",
"def validate_order_prefix(prefix)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n wait_for_landing_page_load\n retry_until_found(lambda{chkout_order_confirmation_label.exists != false}, 10)\n chkout_order_confirmation_label.should_exist\n order_num = chkout_order_confirmation_number_label.inner_text\n order_num.should match(prefix + ENDING_DIGITS_PATTERN)\n end",
"def make_next_seq_no\n if EdiHelper.current_out_is_cumulative || @return_a_string\n @out_seq = 1\n else\n @out_seq = MesControlFile.next_seq_edi(MesControlFile.const_get(\"EDI_#{@flow_type.upcase}\"))\n @seq_increased = true\n end\n @formatted_seq = sprintf('%03d', @out_seq)\n end",
"def inc_seq_no!()\n @seq_no += 1\n return(nil)\n end",
"def sequence_name(repository, property)\n \"#{property.model.storage_name(repository.name)}_#{property.field(repository.name)}_seq\"\n end",
"def serial_generator\n \"OD#{id.to_s.rjust(10, \"0\")}\"\n end"
] |
[
"0.68285567",
"0.65408534",
"0.6394521",
"0.63607705",
"0.6357636",
"0.63000584",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.62710446",
"0.6212062",
"0.618934",
"0.6136409",
"0.6078622",
"0.6072195",
"0.6067498",
"0.6048797",
"0.6018985",
"0.5998566",
"0.5991804",
"0.59775054",
"0.59687704",
"0.59544003",
"0.5948947",
"0.5942824",
"0.59285134",
"0.591776",
"0.58661276",
"0.58586615",
"0.58457816",
"0.58288044",
"0.58192205",
"0.5817915",
"0.58021504",
"0.5772695",
"0.5772599",
"0.57706374",
"0.5757394",
"0.5742435",
"0.5734886",
"0.5708217",
"0.570557",
"0.5676838",
"0.5672703",
"0.56659126",
"0.5650534",
"0.5609201",
"0.5606794",
"0.56010777",
"0.5598973",
"0.5597198",
"0.55898637",
"0.55813795",
"0.5573521",
"0.5572106",
"0.5566148",
"0.5540941",
"0.55349857",
"0.5518105",
"0.55083245",
"0.54868364",
"0.54828465",
"0.54710186",
"0.5455019",
"0.5435666",
"0.54355377",
"0.5431559",
"0.54181355",
"0.5417556",
"0.53939986",
"0.5386071",
"0.53813034",
"0.537712",
"0.53634566",
"0.5359479",
"0.53521144",
"0.5344465",
"0.53415775",
"0.53283787",
"0.5315011",
"0.5309663",
"0.5292974",
"0.52909184",
"0.528562",
"0.5282823",
"0.5282388",
"0.52804655",
"0.52790433",
"0.52790433",
"0.5278248",
"0.5273748",
"0.52599126",
"0.52537954",
"0.5253198",
"0.5251138"
] |
0.0
|
-1
|
returns the sequence number of the next lowest write lock node raises NoWriteLockFoundException when there are no write nodes with a sequence less than ours
|
def next_lowest_write_lock_num #:nodoc:
digit_from(next_lowest_write_lock_name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_lowest_write_lock_num\n digit_from(next_lowest_write_lock_name)\n end",
"def next_lowest_write_lock_name\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename) # our idx would be 2\n\n ary[0..my_idx].reverse.find { |n| n.start_with?(EXCLUSIVE_LOCK_PREFIX) }.tap do |rv|\n raise NoWriteLockFoundException if rv.nil?\n end\n end",
"def next_lowest_write_lock_name #:nodoc:\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename) # our idx would be 2\n\n not_found = lambda { raise NoWriteLockFoundException }\n\n ary[0..my_idx].reverse.find(not_found) { |n| n =~ /^#{EXCLUSIVE_LOCK_PREFIX}/ }\n end",
"def next_lowest_node\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename)\n\n raise WeAreTheLowestLockNumberException if my_idx == 0\n\n ary[(my_idx - 1)] \n end",
"def next_sequence_number\n last_sequence_number ? last_sequence_number.next : 0\n end",
"def next_open_index(index)\n (index...(index + @size)).each do |i|\n if i >= @size\n i = i % @size\n end\n\n if @nodes[i] == nil\n return i\n end\n end\n\n return -1\n end",
"def next_serial\n serial = nil\n\n # This is slightly odd. If the file doesn't exist, our readwritelock creates\n # it, but with a mode we can't actually read in some cases. So, use\n # a default before the lock.\n unless FileTest.exist?(Puppet[:serial])\n serial = 0x1\n end\n\n Puppet.settings.readwritelock(:serial) { |f|\n if FileTest.exist?(Puppet[:serial])\n serial ||= File.read(Puppet.settings[:serial]).chomp.hex\n end\n\n # We store the next valid serial, not the one we just used.\n f << \"%04X\" % (serial + 1)\n }\n\n return serial\n end",
"def set_next_seqno\n a = self.pcp_subject.pcp_items\n m = a.maximum( :seqno ) || 0\n n = a.count\n self.seqno = ( n > m ? n : m ) + 1\n end",
"def next_order_number\n return 0 unless highest_order_number\n highest_order_number + 1\n end",
"def base_sequence\n self.mutex.synchronize do\n return 0 if not self.queue[self.beg]\n return self.queue[self.beg][0]\n end\n end",
"def get_oldest_sequence_no(sys_id,cg_name)\n cg_id = get_consistency_group_id(sys_id,cg_name)\n cg_snapshots = get_consistency_group_snapshots(sys_id,cg_id)\n oldest_seq_no = 0\n\t cg_snapshots.each do |data|\n\t\t if ((oldest_seq_no > (data['pitSequenceNumber']).to_i) || oldest_seq_no == 0 )\n \toldest_seq_no = (data['pitSequenceNumber']).to_i\n \tend\n\t end\n oldest_seq_no\n end",
"def find_max_index\n return @node_names.length unless @node_names.empty?\n\n max_index = -1\n unless @nodes.empty?\n @nodes.each do |node|\n max_index = node.value if node.value > max_index\n end\n end\n max_index >= 0 ? (return max_index + 1) : (return -1)\n end",
"def next_sequence_id\n last_sequence_id + 1\n end",
"def find_min\r\n return nil if !@head\r\n cursor = @head\r\n min = cursor.data\r\n while cursor\r\n if cursor.data < min\r\n min = cursor.data\r\n end\r\n cursor = cursor.next\r\n end\r\n return min\r\n end",
"def next_journal_id\r\n id = journal_ids.max { |p,q| p <=> q }\r\n id.nil? ? 1 : id + 1\r\n end",
"def next_seq\n @seq = (@seq + 1) & 0xffffffff\n end",
"def next_sequence_number!\n sequence_number && @sequence_number += 1\n end",
"def get_next_available_counter\n if @last_filename_counter\n @last_filename_counter + 1\n else\n last_used_counter + 1\n end\n end",
"def inc_seq_no!()\n @seq_no += 1\n return(nil)\n end",
"def next_id\n @imutex.synchronize do\n @mid += 1\n end\n end",
"def next_available_index\n for index in 0..32 do\n break index unless self[index].exists?\n end\n end",
"def next_number\n Sequence.next_val\n end",
"def next_serial_number\n size + 1\n end",
"def get_next\n r = nil\n iterator_lock do\n if @iterator <= @last_id\n r = get(@iterator)\n @iterator += 1\n @iterator_file.write(\"#{@iterator.to_s(36)}\\n\")\n r\n else\n nil\n end\n end\n end",
"def increment_sequence_number\n @sequence_number += 1\n @sequence_number = 0 if @sequence_number > 0xFFFFFFFF\n end",
"def get_next_ordinal\n # largest_ordinal = 0\n # self.lesson_modules.each do | lesson_module | \n # largest_ordinal = lesson_module.lesson_ordinal if lesson_module.lesson_ordinal > largest_ordinal\n # end\n # return largest_ordinal + 1\n\n # Alternative\n return self.lesson_modules.max_by(&:lesson_ordinal).lesson_ordinal + 1\n end",
"def sequence_number\n @sequence_number ||= rand(0xFFFFFFFF)\n end",
"def next_chunk_number\n\t\t\treturn -1\n\t\tend",
"def child_index_right index\n [@d*index+@d, @heap.length-1].min\n end",
"def child_index_left index\n [@d * index + 1, @heap.length-1].min\n end",
"def last_sequence_number\n if @events.empty?\n return @last_committed_sequence_number\n end\n\n unless @last_sequence_number\n @last_sequence_number = @events.last.sequence_number\n end\n\n @last_sequence_number\n end",
"def next_sequence_value(sequence_name)\n @connection.query(\"SELECT NEXT VALUE FOR #{sequence_name} FROM RDB$DATABASE\")[0][0]\n end",
"def min_key\n @root.nil? ? nil : min_recursive(@root)\n end",
"def find_min\r\n return nil if !@head\r\n\r\n min = @head.data\r\n curr = @head \r\n \r\n while curr \r\n min = curr.data if curr.data < min \r\n curr = curr.next\r\n end\r\n\r\n return min\r\n end",
"def min\n return nil if @root.nil?\n\n min_node(@root).key\n end",
"def angry_spinlock(filename)\n\n step = File.open(File.join('data', filename)).map(&:strip).select{|line| !line.empty?}\n .first.to_i\n\n pos = 0\n size = 1\n last_at_1 = 0\n\n (1..50000000).each{|x|\n\n pos = ((pos + step) % size) + 1\n size += 1\n\n # Was this number (x) the latest to want to be written at position 1?\n if (pos == 1) then last_at_1 = x end\n\n }\n\n return last_at_1\nend",
"def getNextSequence(table,db)\n\t\tif db[table].count == 0\n\t\t\treturn 1\n\t\telse\n\t\t\tdb[table].find().sort(_id: -1).limit(1).each do |document|\n\t\t\t\treturn document[:_id]+1\n\t\t\tend\n\t\tend\n\tend",
"def next_request_id\n @next_request_mutex.synchronize do\n request_id = @next_request_id\n @next_request_id += 1\n return request_id\n end\n end",
"def peek_min\n if next_head = self.head.sibling\n current_head = self.head\n while next_head \n next_head < current_head ? @min = next_head : @min = current_head\n current_head = next_head\n next_head = next_head.sibling \n end\n else\n @min = self.head\n end\n @min\n end",
"def find_min\n if @head == nil # empty list case\n # puts \"Error: The linked list is empty. Cannot compute min.\"\n return nil\n end\n\n current = @head\n min = current.data\n current = current.next\n while current != nil\n if current.data < min\n min = current.data\n end\n current = current.next\n end\n return min\n end",
"def next_serial_number\n serial = permute(permute(@offset % BOUNDARY))\n @offset += STEP\n serial\n end",
"def next\n last? ? nil : locate + 1\n end",
"def nextSeqNum()\n $sequence_num = ($sequence_num + 1) % 256\n return $sequence_num\nend",
"def next_number\n self.to_a.size + 1\n end",
"def mint\n Mutex.new.synchronize do\n loop do\n pid = next_id\n return pid unless identifier_in_use?(pid)\n end\n end\n end",
"def next_id\n id = nil\n MinterState.transaction do\n state = read\n minter = ::Noid::Minter.new(state)\n id = minter.mint\n write!(minter)\n end # transaction\n id\n end",
"def next\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) < master_files_sorted.length\n return master_files_sorted[master_files_sorted.find_index(self)+1]\n else\n return nil\n end\n end",
"def oldest relative_index = 0\n raise ArgumentError, \"buffer is empty\" if empty?\n raise ArgumentError, \"relative_index is greater or equal to @fill_count\" if relative_index >= @fill_count\n \n absIdx = @oldest + relative_index;\n if(absIdx >= @buffer.count)\n absIdx -= @buffer.count;\n end\n \n return @buffer[absIdx];\n end",
"def get_next_childid\n\t\tStudySubject.maximum(:childid).to_i + 1\n\tend",
"def find_min\r\n \r\n if @head.nil?\r\n return nil \r\n end\r\n \r\n # current = @head\r\n min = @head.data\r\n current = @head\r\n \r\n # was failing tests until I realized stop condition for min/max traverse needs to be AFTER the end of list (current.nil?) not last node in list (current.next.nil?)\r\n until current.nil?\r\n if current.data < min \r\n min = current.data\r\n end\r\n current = current.next\r\n end\r\n \r\n return min\r\n end",
"def next_id\n (all.map(&:id).max || 0) + 1\n end",
"def next_key\n @next && @next.key\n end",
"def read_sequence(arr, curr_pos)\n n = arr.length\n idx = curr_pos + 1\n (n - curr_pos - 1).times do \n if arr[idx] < arr[idx - 1]\n return idx\n end\n idx += 1\n end\n \n n\nend",
"def next\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) < master_files_sorted.length\n return master_files_sorted[master_files_sorted.find_index(self)+1]\n else\n return nil\n end\n end",
"def first_free_port\n disks.empty? ? 0 : disks.keys.min.first + 1\n end",
"def next_pid(tid)\n if(tid == THREAD_CNT)\n return 1\n else\n return tid+1\n end\nend",
"def get_start_node\n return @nodes.reduce{|sum, pair| pair[0] < sum[0] ? pair : sum}[1] \n end",
"def min_order root_node=@root\n current = root_node\n\n until current.left.nil?\n current = current.left\n end\n\n return current\n end",
"def gid_next\n gid_last = execute(\"dscl . -list /Groups PrimaryGroupID | sort -k 2 -g | tail -1 | awk '{print $2}'\")\n gid_last.to_i + 1\n end",
"def next_sort_index\n (todo.items.map(&:sort_index).max rescue 0).to_f + 1\n end",
"def write_locked?\n @counter.value >= RUNNING_WRITER\n end",
"def next_sequence_value _sequence_name\n SecureRandom.uuid.gsub(\"-\", \"\").hex & 0x7FFFFFFFFFFFFFFF\n end",
"def sequence_number; end",
"def next_rank()\n return NEXT_RANK[self]\n end",
"def get_node_index(node)\n if ((@p).equal?(-1))\n fill_buffer\n end\n i = 0\n while i < @nodes.size\n t = @nodes.get(i)\n if ((t).equal?(node))\n return i\n end\n i += 1\n end\n return -1\n end",
"def next\n next? ? @current + 1 : nil\n end",
"def get_node_pos(string_key)\n return nil if @ring.empty?\n\n key = self.gen_key(string_key)\n nodes = @_sorted_keys\n pos = bisect(nodes, key)\n\n if pos == nodes.length\n return 0\n else\n return pos\n end\n end",
"def min_node(node)\n current = node\n\n if current.nil?\n return current\n end\n\n until current.left_node.nil?\n current = current.left_node\n end\n\n return current\n end",
"def min_node(node)\n current = node\n return current if current.left.nil?\n\n current = current.left until current.left.nil?\n current\n end",
"def min\n @keys[0]\n end",
"def lock_next(worker)\n updates = worker_set\n unless updates.empty?\n #concept copied form delayed_job. If there are a number of \n #different processes working on the queue, the niave approch\n #would result in every instance trying to lock the same record.\n #by shuffleing our results we greatly reduce the chances that\n #multilpe workers try to lock the same process\n updates = updates.to_a.sort_by{rand()}\n updates.each do |u|\n return u if u.lock(worker)\n end\n return nil\n end\n rescue DataObjects::ConnectionError\n sleep 0.1\n retry\n end",
"def assign_tx_seq_num\n self.update(tx_seq_num: Order.max_tx_seq_num + 1) \n end",
"def get_next_membership_number\n self.class.connection.execute(\"SELECT nextval('membership_number_seq')\").getvalue(0, 0).to_s\n end",
"def next_edge_index\n # starting at zero\n @next_edge_index ||= 0\n\n @next_edge_index += 1\n\n (@next_edge_index - 1)\n end",
"def get_index_last_smaller_snp(pos)\n @included_snps.each_with_index do|snp_indx, index|\n if pos < @snps[snp_indx].location.to_f\n return index-1\n end\n end\n end",
"def leader_position\n\t\t@leader_pool.synchronize(:SH) do\n\t\t\t@leader_pool.size - 1\n\t\tend\n\tend",
"def next_version\n (new_record? ? 0 : versions.calculate(:maximum, version_column).to_i) + 1\n end",
"def ensure_order_and_write\n fill_queues\n unless @heap.empty?\n #extract the minimum element from the heap \n extracted_el = @heap.extract\n write_to_disk(extracted_el)\n #add the next element from the same thread to the heap\n from_queue = extracted_el[:thread]\n fill_queues\n next_el = @thread_queues[from_queue].shift\n if next_el\n @heap.push(next_el) \n end\n end\n end",
"def next_sequence_value(sequence_name)\n select_one(\"select #{sequence_name}.nextval id from dual\")['id']\n end",
"def find_minimum\n current = @root\n\n while current.left && !current.nil?\n current = current.left\n return current.value if current.left.nil?\n end\n end",
"def gid_next\n gid_last = execute(\"dscl . -list /Users PrimaryGroupID | sort -k 2 -g | tail -1 | awk '{print $2}'\")\n gid_last.to_i + 1\n end",
"def max_index\n blocks.max(:index) || 0\n end",
"def min_child(index)\n left_child_index = left_child(index)\n right_child_index = right_child(index)\n min_child_index = left_child_index\n if right_child_index != INVALID_INDEX && @tree[right_child_index] < @tree[left_child_index]\n min_child_index = right_child_index\n end\n return min_child_index\n end",
"def next_available_id\n last_id = all_ids.map do |key|\n key.sub(\"#{self.name}_\", \"\").to_i\n end.max.to_i\n\n last_id + 1\n end",
"def next_idx(list)\n return 0 if list.empty?\n list.map { |item| item[:idx] }.max + 1\n end",
"def get_next_patid\n\t\tStudySubject.maximum(:patid).to_i + 1\n#\n#\tWhat happens if/when this goes over 4 digits? \n#\tThe database field is only 4 chars.\n#\n\tend",
"def dose_sequence_number\n return nil unless patient_id\n\n dose&.sequence_number || follow_up_for_dose&.next_sequence_number || 1\n end",
"def next_index(idx)\n idx = idx + 1\n idx = 0 if idx >= @connections.length\n idx\n end",
"def seek_contiguous_min(needle, step_lines = 10)\n\n file = @file\n min = nil\n\n # move to head of line\n seek_line_head\n\n loop do\n\n lines = backward_lines(step_lines)\n lines_pos = str_byte_index(lines, needle)\n file_pos = file.pos\n\n # for debug\n # p [\n # lines: lines,\n # lines_pos: lines_pos,\n # file_pos: file_pos\n # ].to_s\n # sleep 0.05\n\n if lines_pos.nil?\n break\n else\n\n min = file_pos + lines_pos\n\n # if not first line, add 1 to result\n min += 1 if file_pos > 0\n\n break if lines_pos > 0 || file_pos < 1\n end\n end\n\n file.seek(min) unless min.nil?\n min\n end",
"def last_sequence_id\n #if the last page exists, return its sequence_id otherwise return 0\n last_page ? last_page.sequence_id : 0\n end",
"def first\n @head.lru_next\n end",
"def min_child(index)\n ch_e = (index + 1) * 2\n ch_o = (index * 2) + 1\n\n if @nodes[ch_e] && @nodes[ch_o]\n @compare_fn[@nodes[ch_e][:value], @nodes[ch_o][:value]] ? ch_e : ch_o\n elsif @nodes[ch_e]\n ch_e\n elsif @nodes[ch_o]\n ch_o\n else\n nil\n end\n end",
"def next_free_id\n # Index 0 is not valid, so start at 1.\n found = (1...@items.length).find do |i|\n @items[i].nil?\n end\n if found\n # There's an empty slot.\n found\n else\n # No empty slots, next ID is at the end.\n @items.length\n end\n end",
"def get_next_serial_number(dt_wo)\n dt_wo.total_serial_nums += 1\n raise \"invalid serial number\" if dt_wo.total_serial_nums > 65525\n end_num = dt_wo.total_serial_nums.to_s\n serial_number = dt_wo.starting_serial_num\n serial_number = serial_number.ljust(10, \"0\")\n serial_number[serial_number.size - end_num.size, serial_number.size]= end_num\n dt_wo.current_serial_num = serial_number\n dt_wo.save!\n return serial_number\n end",
"def next_messages_id\n messages.max{|a,b| a[:id] <=> b[:id]}[:id] + 1\nend",
"def min\n @nodes.first\n end",
"def find_next_length_index(data)\n last_is_zero = false\n data.each_with_index do |num, i|\n if num.zero?\n if last_is_zero\n return i + 1\n else\n last_is_zero = true\n end\n else\n last_is_zero = false\n end\n end\n end",
"def next_message_id\n if max_message_id = redis.get('max_message_id')\n next_id = max_message_id.to_i + 1\n else\n next_id = 1\n end\n\n redis.set('max_message_id', next_id)\n next_id\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 read_next_id\n id = nil\n list = current_list\n\n if @co_index <= list.size\n id = list[@co_index - 1][:id]\n end\n\n @co_index += 1\n\n id\n end"
] |
[
"0.796564",
"0.7624367",
"0.7462293",
"0.7143519",
"0.6344001",
"0.60185",
"0.6001479",
"0.5832082",
"0.5823021",
"0.5794594",
"0.57213014",
"0.5692753",
"0.5692438",
"0.5651834",
"0.5635214",
"0.5607697",
"0.55554646",
"0.5539939",
"0.55361444",
"0.54989177",
"0.54843944",
"0.5455406",
"0.54340637",
"0.54280293",
"0.54179114",
"0.53573227",
"0.53505284",
"0.5309178",
"0.529242",
"0.5288486",
"0.52829266",
"0.5276902",
"0.5273875",
"0.52633345",
"0.52600974",
"0.52572125",
"0.52539253",
"0.5247657",
"0.5245975",
"0.52440846",
"0.523008",
"0.5228579",
"0.5197071",
"0.51852745",
"0.5175234",
"0.5161822",
"0.5149791",
"0.51468205",
"0.5139752",
"0.51270354",
"0.51267505",
"0.51127094",
"0.5104725",
"0.5099541",
"0.5098275",
"0.5081117",
"0.5077904",
"0.5060637",
"0.5059395",
"0.50519955",
"0.5046648",
"0.5037555",
"0.50351936",
"0.50320286",
"0.50249046",
"0.50240386",
"0.50166434",
"0.50153774",
"0.50090814",
"0.49781433",
"0.49672806",
"0.49671885",
"0.49496973",
"0.49493432",
"0.49461305",
"0.4941357",
"0.49196586",
"0.4904308",
"0.48988542",
"0.48980907",
"0.48949528",
"0.4893845",
"0.48909038",
"0.4883977",
"0.48769683",
"0.4868338",
"0.48659727",
"0.48612973",
"0.48533642",
"0.4850413",
"0.48489133",
"0.48383427",
"0.483413",
"0.48338783",
"0.4832741",
"0.48270658",
"0.48236164",
"0.48212248",
"0.48211196",
"0.48184282"
] |
0.79211247
|
1
|
the next lowest write lock number to ours so if we're "read010" and the children of the lock node are: %w[write008 write009 read010 read011] then this method will return write009 raises NoWriteLockFoundException if there were no write nodes with an index lower than ours
|
def next_lowest_write_lock_name #:nodoc:
ary = ordered_lock_children()
my_idx = ary.index(lock_basename) # our idx would be 2
not_found = lambda { raise NoWriteLockFoundException }
ary[0..my_idx].reverse.find(not_found) { |n| n =~ /^#{EXCLUSIVE_LOCK_PREFIX}/ }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def next_lowest_write_lock_name\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename) # our idx would be 2\n\n ary[0..my_idx].reverse.find { |n| n.start_with?(EXCLUSIVE_LOCK_PREFIX) }.tap do |rv|\n raise NoWriteLockFoundException if rv.nil?\n end\n end",
"def next_lowest_write_lock_num #:nodoc:\n digit_from(next_lowest_write_lock_name)\n end",
"def next_lowest_write_lock_num\n digit_from(next_lowest_write_lock_name)\n end",
"def next_lowest_node\n ary = ordered_lock_children()\n my_idx = ary.index(lock_basename)\n\n raise WeAreTheLowestLockNumberException if my_idx == 0\n\n ary[(my_idx - 1)] \n end",
"def next_open_index(index)\n (index...(index + @size)).each do |i|\n if i >= @size\n i = i % @size\n end\n\n if @nodes[i] == nil\n return i\n end\n end\n\n return -1\n end",
"def next_serial\n serial = nil\n\n # This is slightly odd. If the file doesn't exist, our readwritelock creates\n # it, but with a mode we can't actually read in some cases. So, use\n # a default before the lock.\n unless FileTest.exist?(Puppet[:serial])\n serial = 0x1\n end\n\n Puppet.settings.readwritelock(:serial) { |f|\n if FileTest.exist?(Puppet[:serial])\n serial ||= File.read(Puppet.settings[:serial]).chomp.hex\n end\n\n # We store the next valid serial, not the one we just used.\n f << \"%04X\" % (serial + 1)\n }\n\n return serial\n end",
"def write_locked?\n @counter.value >= RUNNING_WRITER\n end",
"def child_index_right index\n [@d*index+@d, @heap.length-1].min\n end",
"def next_available_index\n for index in 0..32 do\n break index unless self[index].exists?\n end\n end",
"def block_until_read_lock!\n begin\n path = [root_lock_path, next_lowest_write_lock_name].join('/')\n logger.debug { \"SharedLocker#block_until_read_lock! path=#{path.inspect}\" }\n @zk.block_until_node_deleted(path)\n rescue NoWriteLockFoundException\n # next_lowest_write_lock_name may raise NoWriteLockFoundException,\n # which means we should not block as we have the lock (there is nothing to wait for)\n end\n\n @locked = true\n end",
"def min_child(index)\n left_child_index = left_child(index)\n right_child_index = right_child(index)\n min_child_index = left_child_index\n if right_child_index != INVALID_INDEX && @tree[right_child_index] < @tree[left_child_index]\n min_child_index = right_child_index\n end\n return min_child_index\n end",
"def find_max_index\n return @node_names.length unless @node_names.empty?\n\n max_index = -1\n unless @nodes.empty?\n @nodes.each do |node|\n max_index = node.value if node.value > max_index\n end\n end\n max_index >= 0 ? (return max_index + 1) : (return -1)\n end",
"def child_index_left index\n [@d * index + 1, @heap.length-1].min\n end",
"def angry_spinlock(filename)\n\n step = File.open(File.join('data', filename)).map(&:strip).select{|line| !line.empty?}\n .first.to_i\n\n pos = 0\n size = 1\n last_at_1 = 0\n\n (1..50000000).each{|x|\n\n pos = ((pos + step) % size) + 1\n size += 1\n\n # Was this number (x) the latest to want to be written at position 1?\n if (pos == 1) then last_at_1 = x end\n\n }\n\n return last_at_1\nend",
"def min_child(index)\n ch_e = (index + 1) * 2\n ch_o = (index * 2) + 1\n\n if @nodes[ch_e] && @nodes[ch_o]\n @compare_fn[@nodes[ch_e][:value], @nodes[ch_o][:value]] ? ch_e : ch_o\n elsif @nodes[ch_e]\n ch_e\n elsif @nodes[ch_o]\n ch_o\n else\n nil\n end\n end",
"def find_right_entry\n maze[maze.length - 1].each_with_index do |value, index|\n return index if value == open_value\n end\n end",
"def min_key\n @root.nil? ? nil : min_recursive(@root)\n end",
"def lock_next(worker)\n updates = worker_set\n unless updates.empty?\n #concept copied form delayed_job. If there are a number of \n #different processes working on the queue, the niave approch\n #would result in every instance trying to lock the same record.\n #by shuffleing our results we greatly reduce the chances that\n #multilpe workers try to lock the same process\n updates = updates.to_a.sort_by{rand()}\n updates.each do |u|\n return u if u.lock(worker)\n end\n return nil\n end\n rescue DataObjects::ConnectionError\n sleep 0.1\n retry\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_min\r\n return nil if !@head\r\n cursor = @head\r\n min = cursor.data\r\n while cursor\r\n if cursor.data < min\r\n min = cursor.data\r\n end\r\n cursor = cursor.next\r\n end\r\n return min\r\n end",
"def fixBTree( node, index)\n # If the left sibling has more than min keys.\n if (index != 0 && node.arr[index - 1].n > self.min)\n self.borrowFromLeft(node, index)\n elsif (index != node.n && node.arr[index + 1].n > self.min)\n self.borrowFromRight(node, index)\n else\n if (index != node.n)\n self.merge(node, index)\n else\n self.merge(node, index - 1)\n end\n end\n end",
"def get_node_pos(string_key)\n return nil if @ring.empty?\n\n key = self.gen_key(string_key)\n nodes = @_sorted_keys\n pos = bisect(nodes, key)\n\n if pos == nodes.length\n return 0\n else\n return pos\n end\n end",
"def bottom_most_free_row_index(column_index)\n found_row_index = @slot_rows.size - 1\n found_row_index -= 1 until found_row_index == -1 || @slot_rows[found_row_index][column_index].value == 0\n found_row_index\n end",
"def get_node_index(node)\n if ((@p).equal?(-1))\n fill_buffer\n end\n i = 0\n while i < @nodes.size\n t = @nodes.get(i)\n if ((t).equal?(node))\n return i\n end\n i += 1\n end\n return -1\n end",
"def find_left_entry\n maze[0].each_with_index do |value, index|\n return index if value == open_value\n end\n end",
"def get_next_available_counter\n if @last_filename_counter\n @last_filename_counter + 1\n else\n last_used_counter + 1\n end\n end",
"def min\n return nil if @root.nil?\n\n min_node(@root).key\n end",
"def to_s\n c = @counter.value\n s = if running_writer?(c)\n \"1 writer running, \"\n elsif running_readers(c) > 0\n \"#{running_readers(c)} readers running, \"\n else\n \"\"\n end\n\n \"#<ReadWriteLock:#{object_id.to_s(16)} #{s}#{waiting_writers(c)} writers waiting>\"\n end",
"def mon_index(id)\n if id == last_tree_id\n return last_mon_index if rand(100) < LAST_MON_INDEX_CHANCES\n end\n rng_val = rand(100)\n return MON_INDEXES.index { |cell| cell.include?(rng_val) } || 0\n end",
"def first_free_port\n disks.empty? ? 0 : disks.keys.min.first + 1\n end",
"def find_minimum\n current = @root\n\n while current.left && !current.nil?\n current = current.left\n return current.value if current.left.nil?\n end\n end",
"def floor(key)\n position = search(key)\n return key if key == @keys[position]\n return nil if position == 0\n return @keys[position-1]\n end",
"def next_journal_id\r\n id = journal_ids.max { |p,q| p <=> q }\r\n id.nil? ? 1 : id + 1\r\n end",
"def lock_read\n read_sync_mutex.lock\n\n begin\n # If there are a non-zero number of readers and a\n # writer is waiting to acquire the exclusive lock,\n # free up the sync mutex temporarily and lock/unlock\n # the exclusive lock. This is to give the writer\n # thread a chance to acquire the lock and prevents\n # it from being constantly starved.\n if ((@readers > 0) and\n (@writer))\n read_sync_mutex.unlock\n exclusive_mutex.lock\n exclusive_mutex.unlock\n read_sync_mutex.lock\n end\n\n # Increment the active reader count\n @readers += 1\n\n # If we now have just one reader, acquire the exclusive\n # lock. Track the thread owner so that we release the\n # lock from within the same thread context later on.\n if (@readers == 1)\n exclusive_mutex.lock\n\n @owner = Thread.current\n end\n ensure\n read_sync_mutex.unlock\n end\n end",
"def next_order_number\n return 0 unless highest_order_number\n highest_order_number + 1\n end",
"def oldest relative_index = 0\n raise ArgumentError, \"buffer is empty\" if empty?\n raise ArgumentError, \"relative_index is greater or equal to @fill_count\" if relative_index >= @fill_count\n \n absIdx = @oldest + relative_index;\n if(absIdx >= @buffer.count)\n absIdx -= @buffer.count;\n end\n \n return @buffer[absIdx];\n end",
"def logical_idx_to_physical_idx(logical_idx)\n (start_idx + logical_idx) % capacity\n end",
"def min_node(node)\n current = node\n\n if current.nil?\n return current\n end\n\n until current.left_node.nil?\n current = current.left_node\n end\n\n return current\n end",
"def shard_index(n)\n orig_n = n\n n = n.to_i if n.is_a?(GenericNumeric)\n if n.is_a?(Numeric) || n.to_s =~ /^[+-]\\d+$/\n n = n.to_i if n.is_a?(String)\n n += shard_count if n<0\n stop \"Frozen file does not contain shard number #{orig_n}\" if n<0 || n>shard_count\n else\n name = n.to_s.sub(/^\\\\/,'') # Remove leading '\\\\', if any\n raise \"!Missing shard index or name\" if n.to_s == ''\n n = _shard_index(name)\n stop \"!Frozen file does not contain a shard named #{name.inspect}\" unless n\n end\n n\n end",
"def min_node(node)\n current = node\n return current if current.left.nil?\n\n current = current.left until current.left.nil?\n current\n end",
"def get_next\n r = nil\n iterator_lock do\n if @iterator <= @last_id\n r = get(@iterator)\n @iterator += 1\n @iterator_file.write(\"#{@iterator.to_s(36)}\\n\")\n r\n else\n nil\n end\n end\n end",
"def ensure_order_and_write\n fill_queues\n unless @heap.empty?\n #extract the minimum element from the heap \n extracted_el = @heap.extract\n write_to_disk(extracted_el)\n #add the next element from the same thread to the heap\n from_queue = extracted_el[:thread]\n fill_queues\n next_el = @thread_queues[from_queue].shift\n if next_el\n @heap.push(next_el) \n end\n end\n end",
"def next_id\n @imutex.synchronize do\n @mid += 1\n end\n end",
"def latest_file_index\n latest_index = 0\n latest_time = Time.at(0)\n (0..MAX_SAVE_SLOT-1).each do |i|\n filename = make_filename(i)\n next if !FileTest.exist?(filename)\n file_time = File.mtime(filename)\n if file_time > latest_time\n latest_time = file_time\n latest_index = i\n end\n end\n return latest_index\n end",
"def lock_write\n write_sync_mutex.lock\n\n begin\n @writer = true\n\n exclusive_mutex.lock\n\n @owner = Thread.current\n ensure\n write_sync_mutex.unlock\n end\n end",
"def get_next_ordinal\n # largest_ordinal = 0\n # self.lesson_modules.each do | lesson_module | \n # largest_ordinal = lesson_module.lesson_ordinal if lesson_module.lesson_ordinal > largest_ordinal\n # end\n # return largest_ordinal + 1\n\n # Alternative\n return self.lesson_modules.max_by(&:lesson_ordinal).lesson_ordinal + 1\n end",
"def min_order root_node=@root\n current = root_node\n\n until current.left.nil?\n current = current.left\n end\n\n return current\n end",
"def min_search(node)\n if node.left\n min_search(node.left)\n else\n return node\n end\n end",
"def newest relative_index = 0\n raise ArgumentError, \"buffer is empty\" if empty?\n raise ArgumentError, \"relative_index is greater or equal to @fill_count\" if relative_index >= @fill_count\n\n # newestIdx is actually @newest - 1\n newestIdx = @newest - 1;\n if(newestIdx < 0)\n newestIdx += @buffer.count;\n end\n\n absIdx = newestIdx - relative_index;\n if(absIdx < 0)\n absIdx += @buffer.count;\n end\n\n return @buffer[absIdx];\n end",
"def lowest(levels)\n levels_sym = Access::Validate.levels(levels)\n\n return nil if Access::Core.is_no_level?(levels)\n return :reader if levels_sym.include?(:reader)\n return :writer if levels_sym.include?(:writer)\n\n :owner if levels_sym.include?(:owner)\n end",
"def next_check_number\n\t\tmaximum = cash_bank_check_offereds.maximum(\"number\")\n\t\t(maximum ? maximum+1 : initial_check_number).to_s\n\tend",
"def release_write_lock\n while(true)\n c = @counter.value\n if @counter.compare_and_swap(c,c-RUNNING_WRITER)\n @reader_mutex.synchronize { @reader_q.broadcast }\n if waiting_writers(c) > 0\n @writer_mutex.synchronize { @writer_q.signal }\n end\n break\n end\n end\n true\n end",
"def find_node( index )\n\n\n\t\tcount = 0\n\t\tcurrent_node = @head\n\t\tlast_node = nil\n\n\t\twhile count < index\n\n\n\t\traise \"No node at index\" if current_node.next.nil?\n\n\t\t\tprint_node( current_node, count )\n\n\t\t\tlast_node = current_node\n\t\t\tcurrent_node = current_node.next\n\t\t\tcount += 1\n\n\t\tend\n\n\t\tputs \"Weight: #{current_node.data[ 1 ]}\"\n\n\t\treturn last_node, count\n\n\tend",
"def next\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) < master_files_sorted.length\n return master_files_sorted[master_files_sorted.find_index(self)+1]\n else\n return nil\n end\n end",
"def max_key\n @root.nil? ? nil : max_recursive(@root)\n end",
"def lazy_index(index)\n index -= @map.keys.select{|e| e < index}.size\n result = 0\n @deleted.each do |deleted_index|\n if deleted_index - result > index\n return result + index\n else\n index -= deleted_index - result\n result = deleted_index + 1\n end\n end\n result + index\n end",
"def min_number_of_a_level(level)\n max_number_of_a_level(level - 1) + 1\n end",
"def find_and_lock_job(node)\r\n\t\t\tArmory::Job.find_job(node).each do |job|\r\n\t\t\t\treturn job if job.aquire_lock?(self.name)\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\treturn nil\r\n\t\tend",
"def next_reader!\n return if @stack.first == @master\n @stack[0] = @scheduler.next\n rescue Scheduler::NoMoreItems\n logger.warn \"[MULTIDB] All slaves are blacklisted. Reading from master\"\n @stack[0] = @master\n end",
"def min_under_node node\n current = node.right\n while current.left\n current = current.left\n end\n current\n end",
"def value_given_node_no_support(node_num)\n met_resp = analyze_head_support\n return nil if met_resp[:node].nil?\n\n node, counter = self.head.next_node, 1\n until node.nil? || counter == node_num\n counter += 1\n node = node.next_node\n end\n\n node\n end",
"def get_child_index\n return 0\n end",
"def lock_id\n Integer('0x' + Digest::MD5.hexdigest(name)) % (1 << 63)\n end",
"def get_node(i=0)\n nodes.select {|a| a.number == i.to_i}.first\n end",
"def key_for_min_value(name_hash)\n lowestnum = 1000\n name_hash.each_value do |hashvalue|\n if hashvalue < lowestnum\n lowestnum = hashvalue\n end\n end\n name_hash.index(lowestnum)\nend",
"def bfs_11(node, find_this_value)\n\t\t# establish an empty array for queue\n\t\tqueue = []\n\t\t# then push node value into queue\n\t\tqueue.push(node)\n\t\t# while queue is not empty, \n\t\twhile queue.length != 0\n\t\t\t# set a variable to shift out FIFO value, which is the first element in variable\n\t\t\tvalue = queue.shift\n\t\t\t# return the variable with the shifted FIFO value if it equals 11\n\t\t\treturn value.payload if value.payload == find_this_value\n\t\t\t# if not, then loop thru children of variable and push each |child| back to the queue\n\t\t\tvalue.children.each do |child|\n\t\t\t\tqueue.push(child)\n\t\t\tend\n\t\tend\n\tend",
"def find_min\r\n return nil if !@head\r\n\r\n min = @head.data\r\n curr = @head \r\n \r\n while curr \r\n min = curr.data if curr.data < min \r\n curr = curr.next\r\n end\r\n\r\n return min\r\n end",
"def next\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) < master_files_sorted.length\n return master_files_sorted[master_files_sorted.find_index(self)+1]\n else\n return nil\n end\n end",
"def find_value(register)\n for r in @reg_writes\n if register == r.register\n return r.value\n end\n end\n\n nil\n end",
"def min(key)\n key = find(key) if !key.is_a? Node\n return key if key.left.nil? && key.right.nil?\n min(key.left)\n end",
"def left_child(index)\n left = index * 2 + 1\n if left >= @tree.length\n return INVALID_INDEX\n else\n return left\n end\n end",
"def max_index\n blocks.max(:index) || 0\n end",
"def find_bit(data, idx_bit_begin_search)\n data_32bits = data.unpack('N*')\n # Mask the ignored bits with 0\n data_32bits[0] = data_32bits[0] & ((1 << (32-idx_bit_begin_search))-1) if (idx_bit_begin_search > 0)\n idx_not_null = data_32bits.find_index { |v| v != 0 }\n return nil if (idx_not_null == nil)\n not_null = data_32bits[idx_not_null]\n position_in_32bits = 0\n mask = (1 << 31)\n while ((not_null & mask) == 0)\n position_in_32bits += 1\n mask = mask >> 1\n end\n return idx_not_null*32 + position_in_32bits\n end",
"def get_next_childid\n\t\tStudySubject.maximum(:childid).to_i + 1\n\tend",
"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_min\n if @head == nil # empty list case\n # puts \"Error: The linked list is empty. Cannot compute min.\"\n return nil\n end\n\n current = @head\n min = current.data\n current = current.next\n while current != nil\n if current.data < min\n min = current.data\n end\n current = current.next\n end\n return min\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 next_chunk_number\n\t\t\treturn -1\n\t\tend",
"def key_for_min_value(name_hash)\n low_val = (2**(0.size * 8 - 2) - 1) # largest posible fixnum\n low_key = nil\n\n name_hash.each do |key, value|\n value.nil? ? nil : (low_val > value ? (low_val = value; low_key = key) : nil)\n end\n low_key\nend",
"def min\n return nil if empty?\n\n root = @root\n while root\n return root unless root.left\n root = root.left\n end\n\n root\n end",
"def base_sequence\n self.mutex.synchronize do\n return 0 if not self.queue[self.beg]\n return self.queue[self.beg][0]\n end\n end",
"def next_sequence_number\n last_sequence_number ? last_sequence_number.next : 0\n end",
"def next_rank()\n return NEXT_RANK[self]\n end",
"def got_lock?(lock_attempt, zk, config)\n children = zk.get_children(:path => config[:root])[:children].sort\n puts \"children found are #{children}\" if config[:verbose]\n mylocks = children.select {|child| child.start_with?(config[:lockname] + \".\") }\n puts \"Testing my lock (#{lock_attempt[:path]} against the first child (#{config[:root]}/#{mylocks.first})\" if config[:verbose]\n return lock_attempt[:path] == \"#{config[:root]}/#{mylocks.first}\"\nend",
"def successor(node)\n min_parent = min_value_root(node.parent, node.value)\n left_most = left_most(node.more)\n if min_parent\n min_parent.value < left_most.parent ? min_parent : left_most\n else\n left_most\n end\nend",
"def max_write_retries\n options[:max_write_retries] || Cluster::MAX_WRITE_RETRIES\n end",
"def min_reg_address\n @min_reg_address || 0\n end",
"def set_lock\n klass = self.class\n lock_column_name = klass.locking_column\n\n if has_attribute?(lock_column_name) && klass.parent_relation_keys.count > 0\n criteria = klass.parent_relation_keys.inject({}) do |result, parent_key|\n result[parent_key] = read_attribute(parent_key)\n result\n end\n relation = klass.unscoped.where(criteria)\n\n sql = <<-SQL\n #{relation.select(\"COUNT(#{lock_column_name}) AS value, 0 sort_order\").to_sql}\n UNION\n #{relation.select(\"MAX(#{lock_column_name}) AS value, 1 sort_order\").to_sql}\n ORDER BY sort_order\n SQL\n\n result = klass.connection.execute(sql)\n current_count = result[0][\"value\"]\n current_max = result[1][\"value\"]\n\n lock_value = (current_count.to_s == \"0\" ? 0 : current_max.to_i + 1)\n\n write_attribute(lock_column_name, lock_value)\n end\n end",
"def lowest_available_row_in_column(col_number)\n spot = nil\n\n index = col_number\n\n while spot.nil? do\n if open_space?(index)\n spot = index\n else\n index += @columns_size\n end\n end\n\n spot\n end",
"def pick_best_node_for_read_id(sequence_id, nodes)\n best_node = nodes.min do |n1, n2|\n r1 = n1.short_reads.find{|r| r.read_id == sequence_id}\n r2 = n2.short_reads.find{|r| r.read_id == sequence_id}\n r1.start_coord <=> r2.start_coord\n end\n if best_node\n best_noded_read = best_node.short_reads.find{|r| r.read_id == sequence_id}\n [best_node, best_noded_read.direction, best_noded_read]\n else\n []\n end\n end",
"def last_sibling_index(parent)\n return -1 if groups.empty?\n\n if parent.nil?\n parent_index = 0\n sibling_level = 1\n else\n parent_index = groups.find_index(parent)\n sibling_level = parent.level + 1\n end\n\n raise \"Could not find group #{parent.name}\" if parent_index.nil?\n\n (parent_index..(header.groups_count - 1)).each do |i|\n break i unless groups[i].level == sibling_level\n end\n end",
"def find_min\r\n \r\n if @head.nil?\r\n return nil \r\n end\r\n \r\n # current = @head\r\n min = @head.data\r\n current = @head\r\n \r\n # was failing tests until I realized stop condition for min/max traverse needs to be AFTER the end of list (current.nil?) not last node in list (current.next.nil?)\r\n until current.nil?\r\n if current.data < min \r\n min = current.data\r\n end\r\n current = current.next\r\n end\r\n \r\n return min\r\n end",
"def min_value\n if @head.nil?\n return nil\n else\n if head.left\n min_value = min_search(head.left).data\n else\n min_value = head.data\n end\n end\n return min_value\n end",
"def next_bracket_num(pool_users, min_num = 1)\n next_bracket_num = min_num\n existing = pool_users.detect{|pool_user| next_bracket_num == pool_user.bracket_num}\n if existing\n next_bracket_num(pool_users, next_bracket_num + 1)\n else\n next_bracket_num\n end\n end",
"def next_key\n @next && @next.key\n end",
"def right_child_index(i)\n (i * 2) + 1\n end",
"def binary(lo, hi, key)\n return lo if lo > hi\n mid = lo + (hi - lo)/2\n cmp = key <=> @keys[mid]\n return binary(lo, mid-1, key) if cmp < 0\n return binary(mid+1, hi, key) if cmp > 0\n return mid\n end",
"def key_for_min_value(name_hash)\n lowest_num = 1000000000\n lowest_num_key = \" \"\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, num|\n if num < lowest_num\n lowest_num = num\n lowest_num_key = name\n end\n end\n return lowest_num_key\n end\nend",
"def sink index\n loop do\n # define all other relevant index values\n last_item_index = size - 1\n l_child = 2 * index + 1\n r_child = 2 * index + 2\n # default to L in case of tie\n smaller_child = l_child\n # set smaller_child to right_child if that is a valid index and it is less than the left\n smaller_child = r_child if (r_child < last_item_index && less_than?(r_child, l_child))\n # if we are outside the bounds of our tree\n # or if we cannot sink item at `index` anymore\n break if (l_child >= last_item_index || less_than?(index, smaller_child))\n # otherwise, swap the values, \"bubbling\" the item down\n swap_values_at(smaller_child, index)\n # set the new index to the positions we've just moved to\n index = smaller_child\n end\n end",
"def right_child(index)\n right = index * 2 + 2\n if right >= @tree.length\n return INVALID_INDEX\n else\n return right\n end\n end"
] |
[
"0.79830515",
"0.788099",
"0.78305125",
"0.6740962",
"0.5577099",
"0.54548454",
"0.5447671",
"0.5374773",
"0.5318778",
"0.5118336",
"0.50976884",
"0.5096156",
"0.49826834",
"0.49427113",
"0.4917019",
"0.48869357",
"0.48385802",
"0.48154387",
"0.4769437",
"0.4744325",
"0.47083566",
"0.47029534",
"0.46966434",
"0.46935222",
"0.46815106",
"0.46802047",
"0.46756676",
"0.46683267",
"0.46468395",
"0.46261096",
"0.46245176",
"0.4602411",
"0.45904714",
"0.45873642",
"0.4586937",
"0.45658576",
"0.4559077",
"0.45547697",
"0.4549973",
"0.4540988",
"0.45364276",
"0.45098996",
"0.44901568",
"0.44883558",
"0.44832614",
"0.44828227",
"0.44761592",
"0.44733477",
"0.44534436",
"0.44438285",
"0.44178835",
"0.44048244",
"0.4398578",
"0.43972424",
"0.43922907",
"0.43789905",
"0.4376851",
"0.4372042",
"0.43702796",
"0.4363311",
"0.43604606",
"0.43538",
"0.43532664",
"0.43341884",
"0.43303597",
"0.43261167",
"0.4325171",
"0.43244642",
"0.43213627",
"0.43156725",
"0.43113488",
"0.43105203",
"0.43068916",
"0.43018967",
"0.42971897",
"0.42912242",
"0.4291045",
"0.42894274",
"0.42852512",
"0.4284477",
"0.42776206",
"0.42746243",
"0.42679846",
"0.42669722",
"0.4263779",
"0.4258738",
"0.42556804",
"0.42545",
"0.425251",
"0.4252456",
"0.4244176",
"0.4240395",
"0.42398244",
"0.42394376",
"0.42365435",
"0.4229748",
"0.4229548",
"0.422042",
"0.42189226",
"0.42172164"
] |
0.7865699
|
2
|
TODO: make this generic, can either block or nonblock
|
def block_until_read_lock!
begin
path = [root_lock_path, next_lowest_write_lock_name].join('/')
logger.debug { "SharedLocker#block_until_read_lock! path=#{path.inspect}" }
@zk.block_until_node_deleted(path)
rescue NoWriteLockFoundException
# next_lowest_write_lock_name may raise NoWriteLockFoundException,
# which means we should not block as we have the lock (there is nothing to wait for)
end
@locked = true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def blocks() end",
"def block?; end",
"def blocks; end",
"def blocks; end",
"def blocks; end",
"def accept_nonblock(*) end",
"def accept_nonblock(*) end",
"def accept_nonblock(*) end",
"def block_node; end",
"def block_node; end",
"def accept_nonblock\r\n end",
"def block\n true\n end",
"def run(&block); end",
"def captured_by_block?; end",
"def process(&block); end",
"def callBlock\n yield\n yield\nend",
"def perform(&block); end",
"def return(&block); end",
"def multi(&block); end",
"def run(&block)\n end",
"def block_given?() end",
"def captured_by_block; end",
"def block_node=(_); end",
"def write_nonblock\n end",
"def require_block; end",
"def run_nonblock(&block)\n @timeout = 0\n run &block\n end",
"def execute(&block)\n\tblock\nend",
"def execute(&block)\n\tblock\nend",
"def with_block(&block)\n end",
"def block_class() Block; end",
"def block_checker\n block_given?\nend",
"def after_block_boundary?; end",
"def block=(_arg0); end",
"def block=(_arg0); end",
"def process_blocks(blocks); end",
"def callBlock\n yield # Invokes block\n yield # Invokes block again\nend",
"def run_block\n yield\nend",
"def block?\n !!block\n end",
"def skip_or_pending_inside_block?(param0 = T.unsafe(nil)); end",
"def block(_hash)\n raise Sibit::NotSupportedError, 'block() doesn\\'t work here'\n end",
"def run_block_proc\n yield\nend",
"def runblock\r\n\t\t\t@b.call\r\n\t\tend",
"def runblock\r\n\t\t\t@b.call\r\n\t\tend",
"def use_blocker\n blocker do\n # next\n # break\n # return\n \"HA!\"\n # next\n # break\n # return\n end\n puts \"DONE!\"\nend",
"def non_blocking?()\n #This is a stub, used for indexing\n end",
"def record_block\n @block = true\n end",
"def block_valid?(block)\n # ...\n end",
"def select(&block); end",
"def execute(&block)\r\n block\r\nend",
"def call_block\n @_block.call(self) if @_block\n end",
"def before_block_boundary?; end",
"def call_block \n yield('hello', 99) \nend",
"def call_block \n yield('hello', 99) \nend",
"def block_checker(param) \n [ param , block_given? ]\nend",
"def yield; end",
"def try\n if block_given?\n yield\n else\n puts \"no block\"\n end\nend",
"def i_take_a_block\n yield\nend",
"def call_block\r\n puts \"Start of method\"\r\n yield\r\n yield\r\n puts \"End of method\"\r\nend",
"def execute(&block)\n\tblock.call\nend",
"def execute(&block)\n\tblock.call\nend",
"def execute(&block)\n\tblock.call\nend",
"def execute(&block)\n\tblock.call\nend",
"def try\n if block_given?\n yield\n else\n puts 'no block'\n end\nend",
"def call_block\n puts \"start\"\n yield \"foobar\" if block_given?\n puts \"end\"\nend",
"def get_block(*params); raise('Stub or mock required.') end",
"def return!(&block); end",
"def call_block(&block)\n block.call\nend",
"def block_eg1(cutblock)\n puts \"this is the first message from 1 \"\n cutblock.call\n puts \"this is the middle message\"\n cutblock.call\n puts \"this is the last\\n\\n\"\nend",
"def execute(block)\n block.call\nend",
"def execute(block)\n block.call\nend",
"def execute(block)\n block.call\nend",
"def execute(block)\n block.call\nend",
"def execute(block)\n block.call\nend",
"def execute(block)\n block.call\nend",
"def execute(block)\n block.call\nend",
"def recv_nonblock(*rest) end",
"def begin; end",
"def execute(&block)\n block\nend",
"def execute(&block)\n block\nend",
"def block_method\nputs \"called outside block in block_method\"\n#add method, to check if there is a block on this method\nyield if block_given? #predicate method, it have question mark on end\nputs \"now we are returning again to block\"\nend",
"def process(wait = T.unsafe(nil), &block); end"
] |
[
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.78133965",
"0.7699215",
"0.7694581",
"0.73930335",
"0.73930335",
"0.73930335",
"0.7276621",
"0.7276621",
"0.7276621",
"0.7263457",
"0.7263457",
"0.7263333",
"0.7010474",
"0.69086325",
"0.6905294",
"0.6861207",
"0.67585725",
"0.6720104",
"0.669905",
"0.66816384",
"0.66717196",
"0.6643376",
"0.6557262",
"0.6540675",
"0.6522777",
"0.65187836",
"0.64839596",
"0.6479809",
"0.6479809",
"0.64780015",
"0.6477733",
"0.6469503",
"0.6447242",
"0.6445851",
"0.6445851",
"0.6442374",
"0.64239323",
"0.63904893",
"0.63677675",
"0.6360876",
"0.63401955",
"0.63390446",
"0.6333093",
"0.6333093",
"0.6314067",
"0.6313006",
"0.6305765",
"0.63009155",
"0.6286968",
"0.62704664",
"0.62566644",
"0.62543297",
"0.6215266",
"0.6215266",
"0.6209126",
"0.62086046",
"0.6188388",
"0.6184324",
"0.61841106",
"0.61807257",
"0.61807257",
"0.61807257",
"0.6179671",
"0.6174199",
"0.61735195",
"0.61715573",
"0.6167267",
"0.6161176",
"0.61608213",
"0.61564636",
"0.61564636",
"0.61564636",
"0.61564636",
"0.61564636",
"0.61564636",
"0.61564636",
"0.6151634",
"0.6146726",
"0.6137187",
"0.6137187",
"0.61355317",
"0.6131738"
] |
0.0
|
-1
|
the node that is nextlowest in sequence number to ours, the one we watch for updates to
|
def next_lowest_node
ary = ordered_lock_children()
my_idx = ary.index(lock_basename)
raise WeAreTheLowestLockNumberException if my_idx == 0
ary[(my_idx - 1)]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_start_node\n return @nodes.reduce{|sum, pair| pair[0] < sum[0] ? pair : sum}[1] \n end",
"def first\n @head.lru_next\n end",
"def next_node\n @SuccessorReference.value\n end",
"def node_first\n @head\n end",
"def min\n @nodes.first\n end",
"def next(num)\n @node = num\n @hour.number +=1\n end",
"def peek_min\n if next_head = self.head.sibling\n current_head = self.head\n while next_head \n next_head < current_head ? @min = next_head : @min = current_head\n current_head = next_head\n next_head = next_head.sibling \n end\n else\n @min = self.head\n end\n @min\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 get_next_node(node)\n i = node.number + 1\n i = 0 if i >= nodes.size\n get_node(i)\n end",
"def increment(node)\n change_by node, 1\n end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def next_node\n peer = nil\n if !parent.nil? and parent.respond_to?(:children)\n index = parent.children.index(self)\n peer = parent.children[index + 1]\n end\n peer\n end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def succ\n @nxt || self\n end",
"def get_node(i=0)\n nodes.select {|a| a.number == i.to_i}.first\n end",
"def next_open_index(index)\n (index...(index + @size)).each do |i|\n if i >= @size\n i = i % @size\n end\n\n if @nodes[i] == nil\n return i\n end\n end\n\n return -1\n end",
"def find_start(id, from)\n from= to_epoch(from)\n node = $devices[id].head\n while node.next do\n return node if node.value >= from\n node = node.next\n end\n return nil #from time not in list\nend",
"def next_event\n return current_event unless next_event?\n\n current_event.update!(visited: true)\n update!(current_event: current_event.next_event)\n current_event\n end",
"def get_next()\n return @next_node\n end",
"def item_at_head\n\t\t\t@head.next\n\t\tend",
"def get_prev()\n return @prev_node\n end",
"def find_min\r\n return nil if !@head\r\n\r\n min = @head.data\r\n curr = @head \r\n \r\n while curr \r\n min = curr.data if curr.data < min \r\n curr = curr.next\r\n end\r\n\r\n return min\r\n end",
"def next\n last? ? nil : locate + 1\n end",
"def find_node(index)\n counter = 0\n current_node = @first\n while counter < index \n current_node = current_node.next_node\n counter += 1\n end\n current_node\n\n end",
"def find_node_at(index)\n current_index = 0\n node = @head\n until current_index == index\n puts current_index\n node = node.next\n current_index += 1\n end\n puts \"returning node at #{current_index}\"\n node\n end",
"def next\n @next ||= Changeset.where([\"id > ? AND repository_id = ?\", id, repository_id]).order('id ASC').first\n end",
"def next\n next? ? @current + 1 : nil\n end",
"def predecessor\n Algorithm.where(next: self).first\n end",
"def next_edge_index\n # starting at zero\n @next_edge_index ||= 0\n\n @next_edge_index += 1\n\n (@next_edge_index - 1)\n end",
"def first\n @head.val\n end",
"def next\n\t\tself + 1\n\tend",
"def next\n versionable.versions.next_version( self.number )\n end",
"def at(index)\n\t\t@current_node = @head\n\n\t\tindex.times do \n\t\t\t@current_node = @current_node.next_node\n\t\tend\n\n\t\treturn @current_node\n\tend",
"def next\n @pointer += 1\n end",
"def head\n @current_node = @head\n end",
"def next\n parent[parent.place(self) + 1]\n end",
"def next_key\n @next && @next.key\n end",
"def next\n\t\tTask.order(:position).where(\"position > ?\", position).first\n\tend",
"def next_number\n Sequence.next_val\n end",
"def min_node(node)\n current = node\n return current if current.left.nil?\n\n current = current.left until current.left.nil?\n current\n end",
"def find_node( index )\n\n\n\t\tcount = 0\n\t\tcurrent_node = @head\n\t\tlast_node = nil\n\n\t\twhile count < index\n\n\n\t\traise \"No node at index\" if current_node.next.nil?\n\n\t\t\tprint_node( current_node, count )\n\n\t\t\tlast_node = current_node\n\t\t\tcurrent_node = current_node.next\n\t\t\tcount += 1\n\n\t\tend\n\n\t\tputs \"Weight: #{current_node.data[ 1 ]}\"\n\n\t\treturn last_node, count\n\n\tend",
"def next_gen\n @grid.calc_new_generation\n @generation += 1\n @current_gen_same_as_prev = @grid.current_gen_same_as_prev\n end",
"def peek\n @nodeset[1]\n end",
"def next(node)\n @path[@path.index(node) + 1]\n end",
"def peek\n @nodes[0]\n end",
"def next_starting_position\n\t\tpos = @starting_positions[@pos_idx]\n\t\t@pos_idx = (@pos_idx + 1) % @starting_positions.length\n\t\tpos\n\tend",
"def find_min\r\n return nil if !@head\r\n cursor = @head\r\n min = cursor.data\r\n while cursor\r\n if cursor.data < min\r\n min = cursor.data\r\n end\r\n cursor = cursor.next\r\n end\r\n return min\r\n end",
"def get_node_index(node)\n if ((@p).equal?(-1))\n fill_buffer\n end\n i = 0\n while i < @nodes.size\n t = @nodes.get(i)\n if ((t).equal?(node))\n return i\n end\n i += 1\n end\n return -1\n end",
"def next\n update_current(list_index_of(@current))\n end",
"def min_record\n min = record(infimum.next)\n min if min != supremum\n end",
"def find_node(index)\n\n\t\t#start at the head\n\t\tcounter = 0\n\t\tcurrent_node = @head\n\n\t\t# crawl to index position\n\t\t# outputs each node value for visibility\n\t\twhile counter < index\n\t\t\tcurrent_node = current_node.next\n\t\t\tcounter += 1\n\t\tend\n\n\t\tputs \"Found node at index #{index} with value: #{current_node.data}\"\n\t\tcurrent_node\n\tend",
"def find_min\n if @head == nil # empty list case\n # puts \"Error: The linked list is empty. Cannot compute min.\"\n return nil\n end\n\n current = @head\n min = current.data\n current = current.next\n while current != nil\n if current.data < min\n min = current.data\n end\n current = current.next\n end\n return min\n end",
"def next\r\n next_values[0]\r\n end",
"def first\n @current = self.head if self.head\n @current.value rescue nil\n end",
"def get_head\n nekst = @next_object\n @next_object = get_next_for(nekst)\n return nekst\n end",
"def seed_first_node\n return if pending.empty?\n\n # Find the earliest one from top candidates (with top 20% highest coeff values)\n candidates = Array.new\n max_coeff = 0.0\n graph.each_pair {|node, relations|\n node_coeff = 1.0 # count itself\n relations.each {|relation|\n relation_node, relation_coeff = *relation\n node_coeff += relation_coeff if relation_coeff >= 0.0 # ignore exclusive nodes\n }\n max_coeff = node_coeff if (max_coeff < node_coeff)\n candidates << [node, node_coeff]\n }\n candidates = candidates.select {|candidate| candidate[1] >= max_coeff * 0.8}\n candidate = (candidates.max_by{|h| h[0].trigger_time})[0] # use the earliest node\n\n # Seed this candidate as the fist node\n coeff = 1.0 # count it self as coeff = 1.0\n pending.delete(candidate)\n seeded[candidate] = coeff\n update_pending_coeff(candidate, false)\n self.coeff_stats = seeded.values.mean_sigma\n end",
"def current\n return nil unless @node\n @node.item\n end",
"def next_id\n self[:next_id]\n end",
"def next\n @next ||=\n if next_uri\n node_cache.fetch(next_uri) do\n node = self.class.new(node_cache, next_uri, adapter, graph)\n node.prev = self\n node\n end\n end\n end",
"def getnext(oid)\n roid=[]\n roid=self.oid2roid(oid) if (oid<=>self.oid) >= 0\n roid_first = roid.first\n return nil if roid_first and roid_first > @nodes.size-1\n @nodes.each_index do\n |index|\n next if roid_first and roid_first > index\n node = @nodes[index]\n node = node.getnext(oid) if node\n # I have some nil elements, but not the last\n next if not node\n return node\n end\n # It is not expected to get here\n return nil\n end",
"def next_id\n @imutex.synchronize do\n @mid += 1\n end\n end",
"def node; changeset.node; end",
"def node\n return @node\n end",
"def next_node(board)\n #find node with least possible values available\n #but not one we've looked at recently.. hm\n #also do not choose a complete node\n\n #method to return next node reading puzzle like a book\n candidate = board[@cur/10][@cur%10]\n @cur += 1\n @cur = 0 if @cur >= 89\n @cur += 1 if @cur%10 == 9\n if !candidate.value.nil?\n #we don't want to return a node that we've assigned, \n #so if this is the case let's find another option\n return next_node(board)\n else\n #the value of this node is nil, so we can try to assign it\n return candidate\n end\nend",
"def node_search\n while (current_node = queue.shift).present? && final.nil?\n @processed += 1\n yield(current_node)\n log \"\\rProcessing #{start.name}.... %d / %d / %d / %d @ %ds - depth: %d\", @unmarked, @requeued, @processed, @steps, (Time.now - @started), current_node.depth\n end\n\n format_results\n save_results if final.present?\n self.final_path\n end",
"def see_next\n if @index >= @normalized_numbers.length\n return -1\n else\n return @normalized_numbers[@index]\n end\n end",
"def next_sibling\n # Raise error in case we are root\n raise RationalNumberIsRootNoSiblingsError if root?\n\n _parent = self.parent # Get parent already to avoid duplicate calculations\n _position = ((@nv - _parent.nv) / _parent.snv) + 1\n value_from_parent_and_position(_parent, _position)\n end",
"def next_match_number\n # This returns a PGresult object\n # [http://rubydoc.info/github/ged/ruby-pg/master/PGresult]\n result = Match.connection.execute(\"SELECT nextval('match_number_seq')\")\n result[0]['nextval']\n end",
"def get_next_entry; end",
"def next_id\n self.latest_id += 1\n end",
"def next_replica\n return @master.data_nodes[@master.data_nodes.keys[(rand * @master.data_nodes.size).floor]]\n end",
"def next_player\n if @switch.next != nil\n @current_player = @switch.next\n else\n @current_player = @switch.first\n end\n # @current_player = @lives.each.next\n # @current_player = @lives.map.with_index {|(name,lives),index| index += 1 } #should be equal to the next key value pair in the hash\nend",
"def next_version\n work.next_version\n end",
"def next_version \n # NOTE: if self (the item) was not reified from a version, i.e. it is the\n # \"live\" item, we return nil. Perhaps we should return self instead?\n subsequent_version = trail_version ? next_trail_version : nil\n subsequent_version.reify if subsequent_version\n end",
"def node_at(index)\n node = head\n index.times { node = node.next_node }\n node\n end",
"def first\n @head\n end",
"def find_min\r\n \r\n if @head.nil?\r\n return nil \r\n end\r\n \r\n # current = @head\r\n min = @head.data\r\n current = @head\r\n \r\n # was failing tests until I realized stop condition for min/max traverse needs to be AFTER the end of list (current.nil?) not last node in list (current.next.nil?)\r\n until current.nil?\r\n if current.data < min \r\n min = current.data\r\n end\r\n current = current.next\r\n end\r\n \r\n return min\r\n end",
"def next_revision\n self.class.find(:first, :conditions => {:revisable_original_id => revisable_original_id, :revisable_number => revisable_number + 1})\n end",
"def head\n @head ||= node.attr(:head).to_i\n end",
"def next\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) < master_files_sorted.length\n return master_files_sorted[master_files_sorted.find_index(self)+1]\n else\n return nil\n end\n end",
"def next_nodes\n transitions.map(&:target)\n end",
"def min_node(node)\n current = node\n\n if current.nil?\n return current\n end\n\n until current.left_node.nil?\n current = current.left_node\n end\n\n return current\n end",
"def find_node(calling_node, key)\n @router.touch(calling_node)\n return @router.get_closest_nodes(key)\n end",
"def node\n @node\n end",
"def node\n @node\n end",
"def prev\n @prev ||= node_cache.fetch(prev_uri) if prev_uri\n end",
"def get_next()\n\t\t\treturn @next\n\t\tend",
"def next\n master_files_sorted = self.sorted_set\n if master_files_sorted.find_index(self) < master_files_sorted.length\n return master_files_sorted[master_files_sorted.find_index(self)+1]\n else\n return nil\n end\n end",
"def head\n return @head.value\n end",
"def local_node\n @local_node ||= DPN::Workers.nodes.node(to_node)\n end",
"def value_given_node_no_support(node_num)\n met_resp = analyze_head_support\n return nil if met_resp[:node].nil?\n\n node, counter = self.head.next_node, 1\n until node.nil? || counter == node_num\n counter += 1\n node = node.next_node\n end\n\n node\n end",
"def next\n @next && @next.value\n end",
"def next_revision_number\n # Need to retrieve existing revision numbers to sort them as integers\n sql = \"SELECT revision FROM #{Changeset.table_name} \" \\\n \"WHERE repository_id = #{id} AND revision NOT LIKE 'tmp%'\"\n @current_revision_number ||= (self.class.connection.select_values(sql).collect(&:to_i).max || 0)\n @current_revision_number += 1\n end",
"def next_rank()\n return NEXT_RANK[self]\n end",
"def view_next_order\n @queue.peek\n end",
"def next_node(n)\n w = @weights[n]\n index = 0\n wmax = w[-1][1]\n beta = @random.rand(2*wmax)\n while w[index][1] < beta do\n beta -= w[index][1]\n index = (index + 1) % w.length\n end\n return w[index][0]\n end",
"def next_sequence_number\n last_sequence_number ? last_sequence_number.next : 0\n end",
"def next\n @next||=after.first\n end",
"def get_next_state(matrix,x2,y2)\r\n if 1==matrix[[@x+x2,@y+y2]].state\r\n @live_neighbor=@live_neighbor.to_i+1\r\n end\r\n end",
"def next_node\n children.first || successor\n end"
] |
[
"0.63810354",
"0.62072104",
"0.61714005",
"0.6124966",
"0.6106693",
"0.6052942",
"0.602598",
"0.6001068",
"0.59761685",
"0.59524286",
"0.5914708",
"0.590137",
"0.58750546",
"0.5847874",
"0.5839853",
"0.5834481",
"0.58116263",
"0.57894397",
"0.5781323",
"0.5772019",
"0.57633394",
"0.57499313",
"0.574953",
"0.5728388",
"0.5725315",
"0.572357",
"0.5719742",
"0.5706362",
"0.57050407",
"0.56900203",
"0.5681565",
"0.566136",
"0.56600136",
"0.56521654",
"0.56348693",
"0.563359",
"0.5632981",
"0.561669",
"0.5616614",
"0.5612764",
"0.5595571",
"0.5593734",
"0.55915",
"0.5590903",
"0.557191",
"0.5566777",
"0.55648994",
"0.55538124",
"0.55510753",
"0.55477875",
"0.55328876",
"0.5528007",
"0.5516788",
"0.5516665",
"0.550334",
"0.54970956",
"0.54944456",
"0.54861975",
"0.54752624",
"0.54751766",
"0.54749405",
"0.5471946",
"0.54613036",
"0.5460403",
"0.54578173",
"0.54546857",
"0.5453349",
"0.5452996",
"0.54517823",
"0.54516023",
"0.5451429",
"0.5439563",
"0.5435928",
"0.54323477",
"0.5426898",
"0.5425112",
"0.54183793",
"0.5417718",
"0.54164416",
"0.5414996",
"0.54149556",
"0.54128253",
"0.5412599",
"0.54114836",
"0.54114836",
"0.54109454",
"0.54098386",
"0.54091805",
"0.5407764",
"0.54003537",
"0.53943276",
"0.53923464",
"0.53842956",
"0.5384232",
"0.5384196",
"0.5381655",
"0.5381053",
"0.5381036",
"0.5378101",
"0.5378079"
] |
0.6022885
|
7
|
Testing password complexity for dat securitayyy
|
def password_complexity
return if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,20}$/
errors.add :password, 'Password complexity requirement not met.'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def password_complexity\n if password.present? and not password.match(/\\A(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).*/)\n errors.add :password, I18n.t('weak_password')\n end\n end",
"def password_complexity\n if password.present? and not password.match('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&#]).{8,}')\n errors.add :password, \"must include at least one lowercase letter, one uppercase letter,one Special Character and one digit\"\n end\n end",
"def password_complexity\n if password.present? and not password.match(/(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])/)\n errors.add :password, \"must include at least one lowercase letter, one uppercase letter, and one digit\"\n end\n end",
"def password_complexity\n # Regexp extracted from https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a\n return if password.blank? || password =~ /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/\n errors.add :password, ' must have the following requirements: password must be at least 8 character, with a capital letter, a number, and a special character'\n end",
"def password_complexity\n\t\tif password.present? and not password.match(/(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+/)\n\t\t\terrors.add(:password, \"must include at least one lowercase letter, one\" +\n\t\t\t\t\" uppercase letter, and one digit\")\n\t\tend\n\tend",
"def password_complexity\n minimum_haystack = (10**14) # Withstand for 1 second of a massive cracking array\n pass = send(sorcery_config.password_attribute_name)\n\n alphabet_size = 0\n alphabet_size += 26 if pass.gsub(/[^a-z]/, '').length > 0\n alphabet_size += 26 if pass.gsub(/[^A-Z]/, '').length > 0\n alphabet_size += 10 if pass.gsub(/[^0-9]/, '').length > 0\n alphabet_size += 33 if pass.gsub(/[a-zA-Z0-9]/, '').length > 0\n\n haystack_size = alphabet_size**pass.length\n\n if haystack_size < minimum_haystack\n if alphabet_size < 40\n errors.add(:password, \"isn't complex enough, try adding more types of character (upper case, lower case, numeric and symbol)\")\n end\n if pass.length < 10\n errors.add(:password, \"isn't complex enough, try increasing its length\")\n end\n end\n\n return haystack_size\n end",
"def check_password_contents\n if /[a-zA-Z]+/.match(@password) && /\\d+/.match(@password) && /[[:punct:]]/.match(@password)\n else\n generate\n end\n end",
"def valid_password?(password); end",
"def test_password\n p1 = \"mypassword123\"\n p2 = \"mypassword1234\"\n s1 = Password.update(p1)\n assert_equal(true, Password.check(p1,s1), \"Password was not stored correctly\")\n assert_equal(false, Password.check(p2,s1), \"Password check is broken\")\n\tend",
"def password_strength\n minimum_length = 8\n # Regex matches at least one lower case letter, one uppercase and one digit\n complexity_regex = /\\A(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/\n # When a user is updated but not its password, the password param is nil\n if password.present? &&\n (password.length < minimum_length || !password.match(complexity_regex))\n errors.add :password, :weak_password\n end\n end",
"def test_length\n pw1 = \"Test1\"\n pw2 = \"Test2test\"\n\n assert_equal(false, StringChecker.is_safe_pw?(pw1)) # to short, min 8 character inputs\n assert_equal(true, StringChecker.is_safe_pw?(pw2))\n end",
"def validate_password\n score = []\n score << repetitive_substring(@row[\"password\"])\n score << string_length(@row[\"password\"])\n score << upper_lower_case(@row[\"password\"])\n score << digit(@row[\"password\"])\n character_change = score.sum\n @row[\"status\"] = (character_change.zero? ? \"Strong\" : character_change)\n return @row\n end",
"def test_14_meets_all_requirements?\n result = valid_password?(\"123EyesOn@ME\", \"gdavida\")\n assert(result, \"123EyesOn@ME meets all password requirements and should be valid\")\n end",
"def validate_password(input_string)\n password, rule = parse_input(input_string)\n\n # vjkjjcjjrjjmtnbjjjnj\n password_size =\n password.chars.filter { |char| char == rule.letter }.size\n\n rule.min <= password_size && password_size <= rule.max\nend",
"def test_contain_password12\n result = contains_password?(\"password1\")\n refute(result, \"'password1' should not be valid because it contains 'password'\")\n end",
"def valid_password?; end",
"def test_contain_password11\n result = contains_password?(\"passwrd1*\")\n assert(result, \"'passwrd1*' should be valid because it doesn't contain 'password'\")\n end",
"def test_assert_that_password_with_5_chars_is_invalid\n\t\tpassword = \"hTi\"\n\t\tassert_equal(\"invalid\", set_up_password(password))\n\tend",
"def password=(should); end",
"def test_rejects_password_of_7_characters\n result = valid_password?(\"1Abils&\")\n refute(result, \"'1ABils&' should be invalid because it only has 7 characters\")\n end",
"def test_seqence_valid14\n result = contains_password?(\"password1\")\n refute(result, \"'passwrd123*' should not be valid because it contains a sequence\")\n end",
"def test_sequence_valid13\n result = contains_password?(\"passwrd12*\")\n assert(result, \"'passwrd12*' should be valid because it doesn't contain a sequence\")\n end",
"def test_4_accepts_password_of_8_characters\n result = at_least_eight_characters?(\"1Abjils&\")\n assert(result, \"'1ABjils&' has 8 characters, should be valid\")\n end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def test_characters_added_to_valid_password\nresult = add_characters_if_valid(\"shawn\")\nassert_equal(\"xX_shawn_Xx\", result)\nend",
"def test_password_matches_custom_password\n user = User.named(\"user\", :password => \"verysecret\")\n assert(!user.password_matches?(\"user\"))\n assert(user.password_matches?(\"verysecret\"))\n end",
"def test_number\n\n pw1 = \"Testtest\"\n pw2 = \"Test2test\"\n\n assert_equal(false, StringChecker.is_safe_pw?(pw1))\n assert_equal(true, StringChecker.is_safe_pw?(pw2))\n end",
"def validate_password\n puts \"Enter your User ID and Password here.\"\n user_id = gets.chomp\n password = gets.chomp\n\n same(user_id, password)\n long_enough(user_id)\n long_enough(password)\n does_not_contain_special(user_id)\n contains_special(password)\n is_password(password)\nend",
"def pass_strength_simple(password)\n\t\tup= password.count(\"A-Z\") #possible values for uppercase letters\n\t\tlo= password.count(\"a-z\") #possible values for lowercase letters\n\t\tnu= password.count(\"0-9\") #possible values for number\n\t\tsy= password.length - up - lo - nu\n\t\tsum = 0\n\t\tif 0 < up\n\t\t\tsum += 26\n\t\tend\n\t\tif 0 < lo\n\t\t\tsum += 26\n\t\tend\n\t\tif 0 < nu\n\t\t\tsum += 10\n\t\tend \n\t\tif 0 < sy\n\t\t\tsum += 32\n\t\tend\n\t\treturn sum ** password.length\n\tend",
"def valid_pass?(test_pass)\n Encrypt::Password.validatePassword test_pass, password\n end",
"def test_seqence_valid19\n result = engine(\"TrumppasswORd12%\")\n refute(result, \"'Trump1%' should not be valid because it contains password.\")\n end",
"def test_valid_length_password \n user = User.new(:login => \"abder\", :email => \"abder.rahman.ali@gmail.com\", :password_confirmation => \"aa\")\n \n\t user.password = \"aaaaa\"\n\t assert user.valid?\n end",
"def check_pw pw\n (encrypt pw) == (self[:password])\n end",
"def standard_password\n \"!@Cd5678\"\n end",
"def password_required?; end",
"def valid_password?(password)\n (password != password.downcase) &&\n (password != password.upcase) &&\n (password.length >= 8) &&\n (/[0-9]/.match(password) != nil) &&\n (/[^0-9A-Z]/.match(password.upcase) != nil) &&\n not_forbidden?(password)\nend",
"def test_10_accepts_doesnt_include_password\n result = doesnt_include_password?(\"Hat123!!\")\n assert(result, \"Hat123!! has non alphanumeric, should be valid\")\n end",
"def match_password_basic(p)\n puts \"p: #{p}\"\n puts \"password: #{password}\"\n p == password\n end",
"def valid?(password)\n # Does not contain i o l\n return false if password =~ /i|o|l/\n\n # Finds a straight\n return false unless password\n .split('')\n .each_cons(3)\n .find {|a| a[1] == a[0].next && a[2] == a[1].next }\n\n # Contains two different overlapping pairs\n return false unless password\n .split('')\n .slice_when{|i,j| i!=j}\n .select{|a| a.size == 2}\n .uniq\n .count >= 2\n return true\nend",
"def test_set_hashpass\n\t\tres = DB.exec(\"SELECT hashpass FROM people WHERE id=1\")\n\t\told_hashpass = res[0]['hashpass']\n\t\tassert old_hashpass.size > 20\n\t\tDB.exec_params(\"SELECT set_hashpass($1, $2)\", [1, 'bl00p€r'])\n\t\tres = DB.exec(\"SELECT hashpass FROM people WHERE id=1\")\n\t\trefute_equal old_hashpass, res[0]['hashpass']\n\t\tassert res[0]['hashpass'].size > 20\n\t\t# password must be > 3 characters\n\t\terr = assert_raises PG::RaiseException do\n\t\t\tDB.exec_params(\"SELECT set_hashpass($1, $2)\", [1, 'x¥z'])\n\t\tend\n\t\tassert err.message.include? 'short_password'\n\tend",
"def strong_password\n /^(?=.*\\d)(?=.*[a-z])(?=.*[\\W_]).{6,}$/i\n end",
"def valid_passwords(input)\n # Filter map is fun. If the output is falsy it filters it out, otherwise it\n # keeps our shiny new transformed output. Think of it as combining `select`\n # and `map` into one function. I believe it was added in 2.7\n input.filter_map do\n # Yes yes, english operators are evil and I should quit stealing from Perl\n # early escapes. It's still useful as `next` returns `nil` if `extract_password`\n # happens to return `nil`, meaning no matches, or an invalid line of input.\n extracted_password = extract_password(_1) or next\n\n # Now this line is fun! This is why we transformed the input into symbol\n # keys. This is one-line right hand assignment, which means each of those\n # keys are now valid variables we can use in the rest of the function.\n #\n # I may well ask if MatchData can behave more like this naturally later,\n # could you imagine how useful that'd be?\n extracted_password => {\n input:, low_count:, high_count:, target_letter:, password:\n }\n\n # Now to make those counts into ints we can use.\n low_count = low_count.to_i\n high_count = high_count.to_i\n\n # Then pull out the counts of each letter in the word, and get\n # only our target letter out of it. Again, not the most efficient, but\n # not the point of this exercise. Optimizing that is left as an\n # exercise to the reader.\n target_letter_count = letter_counts(password)[target_letter]\n\n # Now then, if that target letter count is between our high and low\n # bounds we return the input, otherwise we return `nil` meaning it's\n # invalid and it gets filtered out.\n (low_count..high_count).include?(target_letter_count) ? input : nil\n end\nend",
"def test_5_rejects_password_of_7_characters\n result = at_least_eight_characters?(\"1Abils&\")\n refute(result, \"'1ABils&' has 7 characters, should be valid\")\n end",
"def test_password(index = 0)\n TEST_PASSWORDS[index]\n end",
"def test_password(index = 0)\n TEST_PASSWORDS[index]\n end",
"def get_password\n status = true\n while status == true\n @password = @@prompt.mask(\"Create a password with at least 5 character\") do |q|\n q.validate(/[a-z\\ ]{5,15}/)\n end\n @password_2 = @@prompt.mask(\"Retype your password\") do |q|\n q.validate(/[a-z\\ ]{5,15}/)\n end\n if @password == @password_2\n system(\"clear\")\n status = false \n break\n else @password != @password_2\n puts \"Wrong password, try again\".colorize(:red)\n status = true\n end\n end\n end",
"def test_invalid_length_password\n\t user = User.new(:login => \"abder\", :email => \"abder.rahman.ali@gmail.com\", :password_confirmation => \"aa\")\n\t \n\t user.password = \"aa\"\n\t assert !user.valid?\n\t assert_equal \"The password must be at least 4-characters long\", user.errors.on(:password)\n\t \n\t user.password = \"aaa\"\n\t assert !user.valid?\n\t assert_equal \"The password must be at least 4-characters long\", user.errots.on(:password)\n end",
"def generate_password\n ['test', 'guest'].sample\nend",
"def passwords_match?\n context.user.password == context.password\n end",
"def test_rejects_passwords_without_non_alphanumerics\n result = valid_password?(\"1Abjilsa\")\n refute(result, \"'1Abjils&a' should be invalid because it has no non-alphanumeric characters\")\n end",
"def valid_password?(str)\n return false unless str.size == 6\n\n last = nil\n had_pair = false\n counter = 1\n\n str.each_char do |char|\n if last == char\n # puts 'raise'\n counter += 1\n else\n # puts \"ok - #{counter}\"\n had_pair = true if counter == 2\n counter = 1\n end\n\n # invalid decrease\n if last && char.to_i < last.to_i\n return false\n end\n\n last = char\n end\n\n had_pair || counter == 2\nend",
"def generate\n @password = (1..@length).map { (33 + rand(89)).chr }.join \n check_password_contents\n @password\n end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def password\n\n end",
"def valid_password(password)\n password = password.to_s.split('').map(&:to_i)\n dubs = false\n for i in 1..5 do\n if password[i] == password[i-1] then \n dubs = true \n elsif password[i] < password[i-1] then\n return false\n end\n end\n return dubs\nend",
"def password\n end",
"def password\n end",
"def generate_password\n [*('a'..'z'), *('A'..'Z'), *('0'..'9')].sample(8).join\n end",
"def test_password_matches_default_password\n user = User.named(\"user\")\n assert(!user.password_matches?(\"blabla\"))\n assert(user.password_matches?(\"user\"))\n end",
"def valid_password_count(...) = valid_passwords(...).size",
"def password_digest(password); end",
"def is_password_password(pass)\n if pass.downcase == 'password'\n 'Sorry, password cannot be password.'\n else\n 'Yay, password is not password.'\n end\nend",
"def check_password(check_char, pos_1, pos_2, password)\n (password.chars[pos_1 -1] == check_char) ^ (password.chars[pos_2 -1] == check_char) \nend",
"def valid_password?(password)\n true\n end",
"def guess_password(attempt)\n SlowEquality.str_eql?(REAL_PASSWORD, attempt)\n end",
"def main\n range = (168630..718098).to_a\n range.map!(&:to_s)\n range.filter! { |input| is_valid_password?(input) }\n\n puts \"There are #{range.length} valid passwords\"\nend",
"def test_11_rejects_doesnt_include_password\n result = doesnt_include_password?(\"Hapasswordt@HAT!\")\n refute(result, \"Hat@HAT! has no alphanumeric, should be valid\")\n end",
"def valid_password? password\r\n self.password === Digest::MD5.hexdigest(password)[0..19]\r\n end",
"def password_match?(login_password)\n\t\tencrypted_password == encrypt(login_password)\t\n\tend",
"def random_password\r\n chars = (\"a\"..\"z\").to_a + (\"1\"..\"9\").to_a \r\n newpass = Array.new(8, '').collect{chars[rand(chars.size)]}.join\r\n end",
"def input(user_id, password)\n if user_id == password\n 'Password and username cannot be the same'\n elsif user_id.length <= 6 && password.length <= 6\n 'Password and username must be at least six characters long'\n end\nend",
"def has_password?(password_soumis)\n # Compare encrypted_password avec la version cryptée de password_soumis.\n encrypted_password == encrypt(password_soumis)\n end",
"def make_up_password\n\to = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten\n\tpass = (0...12).map { o[rand(o.length)] }.join + \"@\"\n\tputs \"Using #{pass} for password\\n\"\n\treturn pass\nend",
"def password(input)\n\t(/^(?=.*[^a-zA-Z])(?!.*([a-z])([a-z])([a-z]))(?=.*[a-z])(?=.*[A-Z])\\S{10,}$/ =~ input)? \"true\" : \"false\"\nend",
"def password_valid\n @password.length >= 7 && (@password.include?(\"!\") || @password.include?(\"$\"))\n end",
"def validate_password(password)\n return false unless password != nil\n if password.length < 4 || password.length > 19\n return false\n end\n return true\n end",
"def has_password?(password_soumis)\n\t\t# Compare encrypted_password avec la version cryptée de password_soumis.\n encrypted_password == encrypt(password_soumis)\n end",
"def passwords(data, pkt)\n\tif( (data =~ /(\\s|_)(p|P)(a|A)(s|S)(s|S)(w|W)(o|O)(r|R)(d|D)(\\s|:|=)/) != nil )\n\t\tputs $alertNum.to_s() + \". ALERT: \" + \"password leaked in the clear from \" + pkt.ip_saddr + \" (\" + pkt.proto.last + \")!\" \n\t\t$alertNum += 1\n\tend\n\nend",
"def valid_password?(plain)\n password == hash_crypt(plain.to_s) \n end",
"def generate_password\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z @ # $ & ! }\n (0...6).map{ charset.to_a[rand(charset.size)] }.join\n end",
"def password=(new_password); end",
"def random_password\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n password = ''\n #40.times { |i| password << chars[rand(chars.size-1)] }\n 15.times { |i| password << chars[rand(chars.size-1)] }\n self.password = password\n self.password_confirmation = password\n self.pwd = password\n self\n end",
"def validate_password(challenge)\n actual = BCrypt::Password.new(password_digest)\n actual == challenge\n end",
"def is_valid_passchars?(passphrase)\n words = passphrase.split(' ').map { |word| word.chars.sort.join('') }\n words.uniq.length == words.length\nend",
"def authenticate(user, password)\n salt = user.password_salt \n\n hash = PBKDF2.new do |p|\n p.password = password.unpack(\"B*\").first\n p.salt = salt\n p.iterations = 10000\n end\n\n pass_hash = hash.hex_string\n \n pass_hash == user.password_hash \n end",
"def validate_password(password)\n return false unless @digest_parts.any? # RUBY\n\n @a1 = ::Digest::MD5.hexdigest(@digest_parts['username'] + ':' + @realm + ':' + password)\n validate\n end",
"def validatePassword(password)\n if (password == nil)\n return false\n end\n \n return true # TODO This is wrong. Finish this function.\nend",
"def get_password(password)\n password\n end",
"def input_acceptable_password\n fill_in(PASSWORD_INPUT_ID, :with => 'qwerty12345')\n end",
"def password_required?; false; end",
"def test_rejects_passwords_without_numbers\n result = valid_password?(\"Abjils&a\")\n refute(result, \"'Abjils&a' should be invalid because it contains no numbers\")\n end",
"def random_password(size=10)\n random_string(size, :chars, 'ABCDEFGHJKLMNPQRSTUVWXYabcdefghkmnpqrstuvwxyz23456789#%^&$*i-_+=')\n end"
] |
[
"0.7701583",
"0.75790644",
"0.75339276",
"0.75182414",
"0.75172895",
"0.73275155",
"0.7224962",
"0.72051704",
"0.71196306",
"0.70846075",
"0.70819974",
"0.70616686",
"0.7053988",
"0.698081",
"0.69537574",
"0.693175",
"0.6907298",
"0.68338525",
"0.68187827",
"0.67965794",
"0.6790384",
"0.67849576",
"0.67845076",
"0.6781342",
"0.6781342",
"0.6781342",
"0.6781342",
"0.6781342",
"0.6781342",
"0.67680395",
"0.6762373",
"0.6756891",
"0.6750726",
"0.6749484",
"0.67480195",
"0.67437845",
"0.6717148",
"0.671227",
"0.67050225",
"0.66692233",
"0.6668633",
"0.6664105",
"0.6655244",
"0.6637677",
"0.66317254",
"0.6613134",
"0.6609929",
"0.6605911",
"0.6603203",
"0.6603203",
"0.65870106",
"0.65753037",
"0.6575252",
"0.6571596",
"0.6567782",
"0.6557632",
"0.65571123",
"0.6527452",
"0.6527452",
"0.6527452",
"0.6527452",
"0.6525399",
"0.6523853",
"0.6521214",
"0.6521214",
"0.65170825",
"0.6512236",
"0.650744",
"0.65046304",
"0.6479039",
"0.6476791",
"0.64750695",
"0.646254",
"0.6454637",
"0.6451353",
"0.6440166",
"0.64273894",
"0.6424093",
"0.6423144",
"0.64145833",
"0.6402758",
"0.63894576",
"0.63874185",
"0.6386957",
"0.63598865",
"0.635457",
"0.63539594",
"0.63489676",
"0.6345489",
"0.6337797",
"0.6331507",
"0.63152474",
"0.63132423",
"0.6313227",
"0.6305862",
"0.6292798",
"0.62917423",
"0.6285929",
"0.62842983",
"0.6282283"
] |
0.7872143
|
0
|
Escape bytea values. Uses historical format instead of hex format for maximum compatibility.
|
def escape_bytea(str)
# each_byte used instead of [] for 1.9 compatibility
str.gsub(/[\000-\037\047\134\177-\377]/n){|b| "\\#{sprintf('%o', b.each_byte{|x| break x}).rjust(3, '0')}"}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bytea(value)\n \"'\\\\x#{value.unpack1('H*')}'::bytea\"\n end",
"def quote_binary(v)\n X_AND_SINGLE_QUOTE + v.unpack(\"H*\")[0] + SINGLE_QUOTE\n end",
"def quote_binary(v)\n X_AND_SINGLE_QUOTE + v.unpack(\"H*\")[0] + SINGLE_QUOTE\n end",
"def quote_binary(v)\n X_AND_SINGLE_QUOTE + v.unpack(\"H*\")[0] + SINGLE_QUOTE\n end",
"def hex() end",
"def escape(value)\n _escape(value.to_s.to_str)\n rescue ArgumentError\n _escape(value.to_s.to_str.force_encoding(Encoding::UTF_8))\n end",
"def to_hex8\n \"##{to_basic_hex8}\"\n end",
"def escape(value)\n end",
"def gas_escape(str)\n str.gsub(/./) { |s| \"\\\\x#{s[0].ord.to_s(16)}\"}\n end",
"def create_escape_value(value)\n if value.is_a?(String) || value.is_a?(Symbol)\n \"#{sanitize_escape_sequences(value.to_s)}\"\n else\n value\n end\n end",
"def insert_bytea(column, value = :no_value)\n @columns << column\n @values << Translate.escape_bytea(value, @connection.pgconn) unless value == :no_value\n end",
"def string_to_binary(value)\n # Escape data prior to insert into a bytea column\n if value\n res = ''\n value.each_byte { |b| res << sprintf('\\\\\\\\%03o', b) }\n res\n end\n end",
"def convert_escape_characters(*args, &block)\n maatsf_convert_escape_characters(super(*args, &block))\n end",
"def escape_value(value)\n value = value.to_s.dup\n value.gsub!(%r{\\\\([0nrt])}, '\\\\\\\\\\1')\n value.gsub!(%r{\\n}, '\\n')\n value.gsub!(%r{\\r}, '\\r')\n value.gsub!(%r{\\t}, '\\t')\n value.gsub!(%r{\\0}, '\\0')\n value\n end",
"def literal_blob(v)\n blob = '0x'\n v.each_byte{|x| blob << sprintf('%02x', x)}\n blob\n end",
"def bytes_to_hex(bytes)\n bytes.map { |x| \"%02X\" % x }.join\n end",
"def encode_quoted_printable!\n self.replace(self.encode_quoted_printable)\n end",
"def to_hex(bytes)\n bytes.map { |b| format('%02x', b) }.join\n end",
"def bytes_to_hex(bytes)\n bytes.map { |i| format('%<byte>02x', byte: i) }.join\nend",
"def shell_escape\n inspect.gsub(/\\\\(\\d{3})/) { $1.to_i(8).chr }\n end",
"def escape(val)\n return val\n end",
"def escape(str)\n str.to_s.gsub(/[%\\s]/) { |m| format(\"%%%<code>02X\", code: m.ord) }\n end",
"def escape(str)\n str.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").force_encoding('US-ASCII')\n end",
"def as_hex\n raise NotImplementedError\n end",
"def hex_code(string, background = T.unsafe(nil)); end",
"def hex_code(string, background = T.unsafe(nil)); end",
"def convert_args(args)\n args.collect { |arg| arg.dup.force_encoding('ASCII-8BIT') }\n end",
"def escape(str, unsafe = @regexp[:UNSAFE])\n unless unsafe.kind_of?(Regexp)\n # perhaps unsafe is String object\n unsafe = Regexp.new(\"[#{Regexp.quote(unsafe)}]\", false)\n end\n str.gsub(unsafe) do\n us = $&\n tmp = ''\n us.each_byte do |uc|\n tmp << sprintf('%%%02X', uc)\n end\n tmp\n end.force_encoding(Encoding::US_ASCII)\n end",
"def escape(str, unsafe = @regexp[:UNSAFE])\n unless unsafe.kind_of?(Regexp)\n # perhaps unsafe is String object\n unsafe = Regexp.new(\"[#{Regexp.quote(unsafe)}]\", false)\n end\n str.gsub(unsafe) do\n us = $&\n tmp = ''\n us.each_byte do |uc|\n tmp << sprintf('%%%02X', uc)\n end\n tmp\n end.force_encoding(Encoding::US_ASCII)\n end",
"def escape_value(connection, value)\n connection.quote(value)\n end",
"def quote(value, column = nil)\n case value\n when String, ActiveSupport::Multibyte::Chars\n value_S = value.to_s\n if column && column.type == :binary && column.class.respond_to?(:string_to_binary)\n \"'#{column.class.string_to_binary(value_S)}'\"\n else\n super(value, column)\n end\n else\n super(value, column)\n end\n end",
"def to_hex(allow_3 = false)\n \"##{to_basic_hex(allow_3)}\"\n end",
"def as_hex_ewkb(allow_srid=true,allow_z=true,allow_m=true)\r\n \tas_ewkb(allow_srid, allow_z, allow_m).unpack('H*').join('').upcase\r\n end",
"def format_ebnf_char(c)\n case c.ord\n when (0x21) then (@options[:html] ? %(\"<code class=\"grammar-literal\">#{@coder.encode c}</code>\") : %{\"#{c}\"})\n when 0x22 then (@options[:html] ? %('<code class=\"grammar-literal\">"</code>') : %{'\"'})\n when (0x23..0x7e) then (@options[:html] ? %(\"<code class=\"grammar-literal\">#{@coder.encode c}</code>\") : %{\"#{c}\"})\n when (0x80..0xFFFD) then (@options[:html] ? %(\"<code class=\"grammar-literal\">#{@coder.encode c}</code>\") : %{\"#{c}\"})\n else escape_ebnf_hex(c)\n end\n end",
"def format_abnf_char(c)\n if /[\\x20-\\x21\\x23-\\x7E]/.match?(c)\n @options[:html] ? %(\"<code class=\"grammar-literal\">#{@coder.encode c}</code>\") : c.inspect\n else\n escape_abnf_hex(c)\n end\n end",
"def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end",
"def to_hex\n @value.unpack(\"H*\").join\n end",
"def to_hex(sep_bytes=false)\n hx = @bytes.unpack('H*')[0].upcase\n if sep_bytes\n sep = \"\"\n (0...hx.size).step(2) do |i|\n sep << \" \" unless i==0\n sep << hx[i,2]\n end\n hx = sep\n end\n hx\n end",
"def escape(string); end",
"def escape_value(value)\n CGI.escape(value.to_s).gsub('%20', '+')\n end",
"def hex(value)\n \"0x\" + value.to_s(16)\n end",
"def ascii_s(hex_s)\n [hex_s].pack('H*')\nend",
"def quote_and_escape(value)\n case value\n when \"NULL\"\n value\n else\n value = value.gsub(/\\\\/, ARRAY_ESCAPE)\n value.gsub!(/\"/,\"\\\\\\\"\")\n \"\\\"#{value}\\\"\"\n end\n end",
"def escaped_char(escape)\n if escape =~ /^\\\\([0-9a-fA-F]{1,6})[ \\t\\r\\n\\f]?/\n $1.to_i(16).chr(Encoding::UTF_8)\n else\n escape[1]\n end\n end",
"def escape(s)\n s.to_s.gsub(\"+\", \"%2B\")\n end",
"def hexbytes\n to_s.bytes.map { |b| sprintf(\"%02x\", b) }.join(\",\")\n end",
"def to_ascii; convert_format(UTF8, ASCII8BIT);end",
"def escape(str); end",
"def hex!\n @hex = true\n end",
"def blob(val)\n val.gsub(/[\\000-\\037\\047\\134\\177-\\377]/) do |b|\n \"\\\\#{ b[0].to_s(8).rjust(3, '0') }\"\n end\n end",
"def cvrt_a_ins(a)\n \"%016b\" % a\n end",
"def set_escaped(options={})\n self.split(//).map do |ch|\n res = ch.escaped\n res = \"\\\\x#{'%02X' % ch.ord}\" if options[:no_ctrl] && res=~/^\\\\\\w$/\n res.gsub(\"-\",'\\\\-')\n end.join\n end",
"def hex(value)\n value[1..-1].hex + 0xff000000\n end",
"def asciihex(data)\n data.chop! if data[-1,1] == \">\"\n data = data[1,data.size] if data[0,1] == \"<\"\n data.gsub!(/[^A-Fa-f0-9]/,\"\")\n data << \"0\" if data.size % 2 == 1\n data.scan(/.{2}/).map { |s| s.hex.chr }.join(\"\")\n rescue Exception => e\n # Oops, there was a problem decoding the stream\n raise MalformedPDFError, \"Error occured while decoding an ASCIIHex stream (#{e.class.to_s}: #{e.to_s})\"\n end",
"def escape(stream = '')\n return stream if absent?(stream)\n\n stream.gsub(/\\e/, '\\\\e')\n end",
"def escape_string (string)\n string.gsub(/([\\x00-\\x1f\\x21-\\x2f\\x3a-\\x40\\x5b-\\x5e\\x60\\x7b-\\x7f])/, '\\\\\\\\\\\\1')\n end",
"def to_hexstr\n Common.unpackbytes(to_s)\n end",
"def encode_bytes(*bytes)\n bytes.pack('C*')\n end",
"def hex_str\n \"##{hex_val}\"\n end",
"def _escape(text)\n ensure_mutable = text.is_a?(BuilderMutableString) ? text : BuilderMutableString.new(text)\n ensure_mutable.to_xs\n end",
"def in_hex\n Bases.val(self).in_hex\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def escape(input); input.to_s.gsub('\"', '\\\\\"'); end",
"def escape(s); s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n){'%'+$1.unpack('H2'*$1.size).join('%').upcase}.tr(' ', '+') end",
"def hyphenated_set_encoding\n \"#{self[0].set_escaped(no_ctrl: true)}-#{self[-1].set_escaped(no_ctrl: true)}\"\n end",
"def escape(string)\n encoding = string.encoding\n string.b.gsub(/([^ a-zA-Z0-9_.\\-~]+)/) do |m|\n '%' + m.unpack('H2' * m.bytesize).join('%').upcase\n end.tr(' ', '+').force_encoding(encoding)\n end",
"def to_hex_s\n TypeConversion.numeric_byte_array_to_hex_string(to_a)\n end",
"def literal_blob_append(sql, v)\n sql << \"'\" << v.gsub(/[\\000-\\037\\047\\134\\177-\\377]/n){|b| \"\\\\#{(\"%o\" % b[0..1].unpack(\"C\")[0]).rjust(3, '0')}\"} << \"'\"\n end",
"def to_hexified_s\n to_binary_s.scan(/../).join(\" \")\n end",
"def escape(s)\n s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {\n '%' + $1.unpack('H2' * bytesize($1)).join('%').upcase\n }.tr(' ', '+')\n end",
"def encode_string(value)\n [value.bytesize, value].pack(\"L>A*\")\n end",
"def as_hex_wkb\r\n as_hex_ewkb(false,false,false)\r\n end",
"def escape_ini_value(value)\n value = value.to_s.dup\n value.gsub!(%r/\\\\([0nrt])/, '\\\\\\\\\\1')\n value.gsub!(%r/\\n/, '\\n')\n value.gsub!(%r/\\r/, '\\r')\n value.gsub!(%r/\\t/, '\\t')\n value.gsub!(%r/\\0/, '\\0')\n value\n end",
"def tns_hexify\n self.each_byte.map do |byte|\n (HEXCHARS[(byte >> 4)] + HEXCHARS[(byte & 0xf )])\n end.join()\n end",
"def to_hex(alpha = false)\n return \"undefined\" if undefined?\n collection = alpha ? Channels : Channels-[:alpha]\n \"#\"+collection.map{|c| sprintf(\"%02X\",(send(c) * 255).round)}.join\n end",
"def encode_quoted_printable\n result = [self].pack(\"M*\")\n # Ruby's quoted printable encoding uses soft line breaks to buffer spaces\n # at the end of lines, rather than encoding them with =20. We fix this.\n result.gsub!(/( +)=\\n\\n/) { \"=20\" * $1.length + \"\\n\" }\n # Ruby's quoted printable encode puts a soft line break on the end of any\n # string that doesn't already end in a hard line break, so we have to\n # clean it up.\n result.gsub!(/=\\n\\Z/, '')\n result\n end",
"def to_standard_hex\n color = @value.dup\n color.insert(0, '#') unless color.start_with? '#'\n\n # Convert shorthand hex to standard hex.\n if color.size == 4\n color.slice!(1, 3).chars { |char| color << char * 2 }\n end\n color\n end",
"def protected\n write_raw \"\\x1b&\"\n yield\n write_raw \"\\x1b'\"\n end",
"def ascii_quotes\n value = self.gsub(/'/, \"'\").gsub(/\"/, \""\")\n return value\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def to_hex_s\n strings = to_bytes.map do |byte|\n string = byte.to_s(16)\n string = \"0#{string}\" if string.length == 1\n string\n end\n strings.join.upcase\n end",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def non_utf8_character\n [0x92].pack('C*')\n end",
"def quote(value, column = nil)\n if value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n \"'#{value.as_hex_ewkb}'\"\n else\n original_quote(value,column)\n end\n end",
"def quote(value, column = nil)\n if value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n \"'#{value.as_hex_ewkb}'\"\n else\n original_quote(value,column)\n end\n end",
"def hex(byte)\n byte.to_s(16).upcase\n end",
"def quote(value, column = nil)\n if value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n \"'#{value.as_hex_ewkb}'\"\n else\n original_quote(value,column)\n end\n end",
"def escape(x)\n x = x.to_s\n x.gsub! @delimiter, @edelim if @delimiter\n x.gsub! @internal_delimiter, @eidelim\n x\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def to_hex\n Dash.to_hex(self)\n end",
"def hex_encode_keywords\n if self =~ /(select)/i\n foo=$1\n newstr = self.gsub(foo, foo.gsub(/e/i, \"%#{'e'.hexme}\"))\n else\n newstr = self\n end\n if newstr =~ /(update)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/p/i, \"%#{'p'.hexme}\"))\n end\n if newstr =~ /(insert)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/s/i, \"%#{'s'.hexme}\"))\n end\n if newstr =~ /(delete)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/l/i, \"%#{'l'.hexme}\"))\n end\n if newstr =~ /(union)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.gsub(/n/i, \"%#{'n'.hexme}\"))\n end\n if newstr =~ /[, ](concat)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.gsub(/c/i, \"%#{'c'.hexme}\"))\n end\n if newstr =~ /(group_concat)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.gsub(/o/i, \"%#{'o'.hexme}\"))\n end\n if newstr =~ /(information_schema)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.gsub(/a/i, \"%#{'a'.hexme}\"))\n end\n if newstr =~ /(cast)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/t/i, \"%#{'t'.hexme}\"))\n end\n if newstr =~ /(convert)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/v/i, \"%#{'v'.hexme}\"))\n end\n if newstr =~ /(substring)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.gsub(/s/i, \"%#{'s'.hexme}\"))\n end\n if newstr =~ /(sleep)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/p/i, \"%#{'p'.hexme}\"))\n end\n if newstr =~ /(benchmark)/i\n foo=$1\n newstr = newstr.gsub!(foo, foo.sub(/b/i, \"%#{'b'.hexme}\"))\n end\n return newstr\n end",
"def escape(str)\n str.dump\n end",
"def unescape(val)\n\tval.gsub!(/(\\\\x[\\da-f]{2}|\\\\u[\\da-f]{4})/) { [$1[2..-1].hex].pack('U') }\n\tval\nend",
"def x\n\t\tt =\"\"; \n\t\tself.each_byte do |a| \n\t\t\tif a == \"\\r\"[0] then\n\t\t\t\tt << \"\\\\r\"\n\t\t\telsif a == \"\\t\"[0] then\n\t\t\t\tt << \"\\\\r\"\n\t\t\telsif a == \"\\n\"[0] then\n\t\t\t\tt << \"\\\\n\"\n\t\t\telsif a == \"\\b\"[0] then\n\t\t\t\tt << \"\\\\b\"\n\t\t\telsif a > 0 && a < 32 then\n\t\t\t\tt << (\"\\\\x%2.2d\" % a)\n\t\t\telse \n\t\t\t\tt << a.chr\n\t\t\tend\n\t\tend\n\t\tt\n\t\t#return gsub(/\\r/, \"\\\\r\").gsub(/\\n/, \"\\\\n\").gsub(/\\t/, \"\\\\t\")\n\tend",
"def escape_xml(value)\n value.to_s.gsub(/[&<>\"']/) { |s| ESCAPE_TABLE[s] } # or /[&<>\"']/\n end",
"def escape(string)\n string.gsub(/([^ a-zA-Z0-9_.-]+)/) do\n $1.nil? ? nil : ('%' + $1.unpack('H2' * $1.bytesize).\n compact.join('%').upcase)\n end.tr(' ','+')\nend",
"def escape(str)\n str.dump[1..-2]\nend",
"def to_hex(with_alpha=false)\n rgb = self.to_a\n rgb = rgb[0...3] unless with_alpha\n hex = rgb.inject(\"\"){|hex, c| hex + c.to_s(16).rjust(2,\"0\")}\n return \"#\" + hex\n end",
"def dhcp_option_value_byte(data, value)\r\n data << 0x01.chr\r\n data << value.chr\r\n end",
"def to_hexa\n [self.token].pack('H*')\n end"
] |
[
"0.6670051",
"0.6374127",
"0.6374127",
"0.6338109",
"0.6279088",
"0.6274744",
"0.61785936",
"0.6166857",
"0.61466247",
"0.6128632",
"0.60658073",
"0.6060971",
"0.59690356",
"0.589262",
"0.5851431",
"0.58511394",
"0.58188415",
"0.58101386",
"0.5790922",
"0.5764202",
"0.5746119",
"0.5719201",
"0.56964695",
"0.5688602",
"0.5681495",
"0.5681495",
"0.56280243",
"0.5614776",
"0.5614776",
"0.5589023",
"0.5569951",
"0.55648273",
"0.5559605",
"0.55581146",
"0.554413",
"0.55292034",
"0.5511464",
"0.5510064",
"0.5499869",
"0.5499656",
"0.54983455",
"0.5497886",
"0.54959714",
"0.54931045",
"0.5492793",
"0.54875726",
"0.54866207",
"0.54801536",
"0.547867",
"0.5476247",
"0.54679656",
"0.54669553",
"0.5454861",
"0.54502314",
"0.54471517",
"0.54470754",
"0.54181856",
"0.54080606",
"0.53999925",
"0.5399274",
"0.53988034",
"0.53974444",
"0.53962904",
"0.5394355",
"0.5383982",
"0.5381201",
"0.53549373",
"0.5353476",
"0.5334081",
"0.5330232",
"0.53284115",
"0.5326444",
"0.5314873",
"0.52999",
"0.5299563",
"0.52995443",
"0.5296933",
"0.5278773",
"0.52785987",
"0.52785903",
"0.5277939",
"0.52673125",
"0.5264921",
"0.52596515",
"0.52596515",
"0.5258553",
"0.5258171",
"0.52539736",
"0.52452403",
"0.5235806",
"0.5231801",
"0.52304",
"0.52222866",
"0.5221495",
"0.5206401",
"0.51809436",
"0.5178945",
"0.51719344",
"0.5153579",
"0.51405305"
] |
0.7547868
|
0
|
Escape strings by doubling apostrophes. This only works if standard conforming strings are used.
|
def escape_string(str)
str.gsub("'", "''")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def escape(input); input.to_s.gsub('\"', '\\\\\"'); end",
"def qesc(s)\n s.gsub(\"'\", \"''\")\nend",
"def shell_escape(s)\n s = s.to_s\n if s !~ /^[0-9A-Za-z+,.\\/:=@_-]+$/\n s = s.gsub(\"'\") { \"'\\\\''\" }\n s = \"'#{s}'\"\n end\n s\n end",
"def quote_str(s)\n s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")\n end",
"def escape_for_single_quotes(str)\n str.gsub \"'\", \"''\"\n end",
"def quote_string(string)\n string.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\") \n end",
"def _quoteString ( str )\n str.gsub( /\\\\/, '\\&\\&' ).gsub( /'/, \"''\" ) # ' (for ruby-mode)\n end",
"def escape_quotes(unfiltered)\n unfiltered.to_s.gsub(/'/, \"''\")\n end",
"def escape(s)\n s.to_s.gsub('\"', '"').gsub(\"'\", ''')\n end",
"def quote_string(string)\n string.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")\n end",
"def esc(inString)\n #2015-04-04 BN: gsub stumbles on apostrophes so I created a unique treatment for them\n # from http://stackoverflow.com/questions/8929218/how-to-replace-an-apostrophe-using-gsub\n inString = inString.gsub(/[']/, \"\\\\\\\\\\'\")\n\n #For each of the characters in the list of characters to be escaped\n $eChars.each do |thisChar|\n #Replace every instance of thisChar with thisChar appended to an\n #escape character. We have to escape the escape to use it\n inString = inString.gsub(thisChar, \"\\\\\"+thisChar)\n end\n return inString\nend",
"def quote_string(s)\n s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\") # ' (for ruby-mode)\n end",
"def escape_double_quotes(str_to_escape)\n # Hash containing the required conversion\n conversions = {\n %r{\"}=>'"'\n } \n escaped_str = str_to_escape\n conversions.each do |x,y|\n escaped_str = escaped_str.gsub(x,y)\n end \n return escaped_str\n end",
"def escape_quotes(text)\n text.gsub(\"'\", \"''\")\n end",
"def escape_for_double_quotes(str)\n str.gsub(/[\\\\\"`$]/) { |c| \"\\\\#{c}\" }\nend",
"def escape_double_quote (s)\n if ( /\"/ =~ s )\n return '\"' + s.gsub('\"','\"\"') + '\"'\n else\n return '\"' + s + '\"'\n end\nend",
"def escape_single_quotes(str_to_escape)\n # Hash containing the required conversion\n conversions = {\n %r{'}=>'%26apos;'\n } \n escaped_str = str_to_escape\n conversions.each do |x,y|\n escaped_str = escaped_str.gsub(x,y)\n end \n return escaped_str\n end",
"def quote_string(s)\n s.gsub('\\\\'.freeze, '\\&\\&'.freeze).gsub(\"'\".freeze, \"''\".freeze) # ' (for ruby-mode)\n end",
"def double_escape_quotes(s)\n s.gsub(/\\\"/, \"\\\"\\\"\") unless s.nil?\n end",
"def escape(string)\n return '' if string.nil?\n return string unless string.to_s =~ /[\\\\\\$`\" \\(\\)\\{\\}\\[\\]]/\n '\"' + string.to_s.gsub(/[\\\\\\$`\"]/) { |match| '\\\\' + match } + '\"'\n end",
"def escape_quotes input\n\t\tinput.gsub!(/([\\'\\\"])/,\"\\\\\\1\") #single quote\n\t\t\n\t\treturn input\n\tend",
"def escape(s)\n s.gsub('\"', '\\\"')\nend",
"def escape(str); end",
"def escape(*chars)\n gsub(/(?<!\\\\)(#{chars.join(\"|\")})/) do |char|\n \"\\\\\" + char\n end\n end",
"def character_escape(string)\n string.gsub(/^'/, '').gsub(/'$/, '').gsub(/\\\\'/, \"'\")\n end",
"def escape(string); end",
"def escape_single_quotes(str)\n str.gsub(\"'\", '\\\\\\\\\\'')\nend",
"def quote_string(s) #:nodoc:\n s.gsub(/'/, \"''\") # ' (for ruby-mode)\n end",
"def escape_string(string)\n string.to_s.gsub(/([\\\\()|\\-!@~\"&\\/\\^\\$=])/, '\\\\\\\\\\\\1')\n end",
"def escape(s)\n s.to_s.gsub(\"+\", \"%2B\")\n end",
"def add_quotes_to_string(string)\n string = \"'#{string}'\"\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def likeEscape( str )\n str.gsub( \"\\\\\", \"\\\\\\\\\" ).gsub( \"%\", \"\\%\" ).gsub( \"_\", \"\\_\" )\n end",
"def escape(str)\n str.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").force_encoding('US-ASCII')\n end",
"def quote_and_escape(text, quote = '\"')\n \"#{quote}#{text.gsub(/#{quote}/) { |m| \"#{m}\\\\#{m}#{m}\" }}#{quote}\"\n end",
"def escape(string)\n # This code is taken directly from the documentation so we dont have to rely on the SQLite3::Database class. This way it can also be used with JRuby and IronRuby...\n # http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html\n string.to_s.gsub(\"'\", \"''\")\n end",
"def escape_quotes(str)\n str.gsub(\"\\\"\", \"'\")\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape_for_cql_double_quotes(str)\n str = str.gsub('\"', \" \")\n str = str.gsub(\"'\", \"''\")\n\n return str\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] }\n end",
"def escape(text)\n text.gsub('\"', '\\\"')\nend",
"def escape(str)\n str.gsub(' ', '%20')\n end",
"def dquote( str ) #:nodoc:\n unless str =~ /^\".*?\"$/\n '\"' + str.gsub(/[\"\\\\]/n) {|s| '\\\\' + s } + '\"'\n else\n str\n end\n end",
"def quote( val )\n\t\treturn %q{\"%s\"} % [ val.to_s.gsub(/\"/, '\\\\\"') ]\n\tend",
"def sanitize_sql_like(text, escape_character = '\\\\')\n text.to_s.gsub(/(^|.)([%_])/) do |s|\n ($1 == escape_character) ? s : [$1, escape_character, $2].compact.join\n end\n end",
"def escape(s)\n s.gsub(/[&<>`]/, \"&\" => \"&\", \"<\" => \"<\", \">\" => \">\", \"`\" => \"`\")\n end",
"def to_escaped_for_sql_like\n gsub(/[\\\\%_]/) { |x| '\\\\' + x }.gsub(\"*\", \"%\")\n end",
"def escape_quotes(beg_str, end_str)\n case [beg_str[-1], end_str]\n when ['(', ')'], ['[', ']'], ['{', '}']\n [beg_str.sub(/.\\z/) { \"\\0\" }, \"\\0\"]\n else\n [beg_str, end_str]\n end\n end",
"def escape(string)\n string.gsub('\\\\', '\\\\\\\\').\n gsub(\"\\b\", '\\\\b').\n gsub(\"\\f\", '\\\\f').\n gsub(\"\\t\", '\\\\t').\n gsub(\"\\n\", '\\\\n').\n gsub(\"\\r\", '\\\\r').\n gsub('\"', '\\\\\"')\n end",
"def esc(word)\n word.gsub(\"&\", \"&\").gsub(\"<\", \"<\")\n end",
"def quote_and_escape(value)\n case value\n when \"NULL\"\n value\n else\n value = value.gsub(/\\\\/, ARRAY_ESCAPE)\n value.gsub!(/\"/,\"\\\\\\\"\")\n \"\\\"#{value}\\\"\"\n end\n end",
"def esc(str)\n str = str.to_s.gsub(\"&\", \"&\")\n str = str.gsub(\"\\\"\", \"'\")\n str = str.gsub(\"\\\"\", \""\")\n str = str.gsub(\"<\", \"<\")\n str.gsub(\">\", \">\")\nend",
"def escape(text)\n return text.gsub(/[\\`*_{}\\[\\]()#+\\-.!]/, \"\\\\\\\\\\\\0\")\n end",
"def extra_escape(string)\n string.gsub('\\\\', '\\\\\\\\\\\\').\n gsub(\"\\\\'\", '\\\\\\\\' + \"'\").\n gsub('\\\\\\\\\\\\', '\\\\\\\\\\\\')\n end",
"def replace_quote(string)\n # do not know those two are different\n # ERB::Util.html_escape string.to_s.gsub 'aaa', 'bbb'\n # ERB::Util.html_escape string.to_s\n # since it is safebuffer and html_safe, this will output with single\n # quotes for example: data-datatable-multiselect=' <select multiple='multi\n # ERB::Util.html_escape string\n # replace single quote with double quote\n string.to_s.tr \"'\", '\"'\n end",
"def sanitize_sql_like(string, escape_character = '\\\\')\n pattern = Regexp.union(escape_character, '%', '_')\n string.gsub(pattern) { |x| [escape_character, x].join }\n end",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def escape(string)\n return \"\" if string.nil?\n string = ':' + string.to_s if string.kind_of? Symbol\n string.gsub(\"\\\\\", \"\\\\\\\\\").gsub(\"&\", \"\\&\").gsub(\":\", \"\\:\").gsub(\"/\", \"\\/\")\n end",
"def latex_escape(s)\n quote_count = 0\n s.to_s.\n gsub(/([{}_$&%#])/, \"__LATEX_HELPER_TEMPORARY_BACKSLASH_PLACEHOLDER__\\\\1\").\n gsub(/\\\\/, BACKSLASH).\n gsub(/__LATEX_HELPER_TEMPORARY_BACKSLASH_PLACEHOLDER__/, BS).\n gsub(/\\^/, HAT).\n gsub(/~/, TILDE).\n gsub(/\"/) do\n quote_count += 1\n quote_count.odd? ? %{\"`} : %{\"'}\n end\n end",
"def quote_string(s) #:nodoc:\n @connection.escape(s)\n end",
"def escape_double_quotes\r\n return self.gsub('\"', '\\\"')\r\n end",
"def bad_sanitize(str)\n str.gsub(/'/,\"''\")\nend"
] |
[
"0.7722508",
"0.7642704",
"0.7585502",
"0.7551453",
"0.7524091",
"0.7514853",
"0.75065154",
"0.747003",
"0.745325",
"0.74331826",
"0.74293447",
"0.7424182",
"0.7401624",
"0.7389724",
"0.7354956",
"0.7320594",
"0.73129207",
"0.7294251",
"0.7289715",
"0.7284854",
"0.7272765",
"0.7229775",
"0.7227155",
"0.72167116",
"0.7187454",
"0.71863633",
"0.7150644",
"0.7133633",
"0.71298265",
"0.7107053",
"0.71026933",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.7100007",
"0.70987153",
"0.7087071",
"0.7083501",
"0.7077869",
"0.70687157",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.70662844",
"0.7059765",
"0.7036796",
"0.70259666",
"0.69503516",
"0.6949836",
"0.68994236",
"0.68710876",
"0.6864705",
"0.68559587",
"0.6838878",
"0.6824208",
"0.68109226",
"0.6808236",
"0.6766875",
"0.673793",
"0.67363185",
"0.6733627",
"0.6731627",
"0.6731305",
"0.67196316",
"0.67162997",
"0.671561",
"0.67135435",
"0.6711899"
] |
0.76568407
|
1
|
Execute the given SQL with this connection. If a block is given, yield the results, otherwise, return the number of changed rows.
|
def execute(sql, args=nil)
args = args.map{|v| @db.bound_variable_arg(v, self)} if args
q = check_disconnect_errors{execute_query(sql, args)}
begin
block_given? ? yield(q) : q.cmd_tuples
ensure
q.clear if q && q.respond_to?(:clear)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def execute_all( sql ) # :yields: row\n loop do\n stmt = prepare( sql )\n stmt.execute do |result|\n result.each { |row| yield row if block_given? }\n end\n sql = stmt.remainder\n if sql.length > 0\n yield nil if block_given? # notify of new query starting\n else\n break\n end\n end\n end",
"def execute( *params )\n bind( *params )\n begin\n # save the error state at the beginning of the execution. We only want to\n # reraise the error if it was raised during this execution.\n s_before = $!\n if block_given? then\n while row = next_row\n yield row\n end\n else\n all_rows\n end\n ensure\n s = $!\n begin\n reset_for_next_execute!\n rescue\n # rescuing nothing on purpose\n end\n raise s if s != s_before\n end\n end",
"def cursor_eachrow(sql, name='csr', transaction=true, buffer_size=10000)\n count = 0\n begin\n begin_db_transaction if transaction\n open_cursor(sql, name, buffer_size)\n while (row = fetch_cursor(name)) do\n count+= 1\n #puts \"EACH CSR #{row.inspect}\"\n yield row\n end\n close_cursor(name)\n ensure\n commit_db_transaction if transaction\n end\n count\n end",
"def each\n @pool.with do |conn|\n conn.send_query @sql\n conn.set_single_row_mode\n loop do\n res = conn.get_result\n break unless res\n res.check\n res.stream_each { |row| yield row }\n end\n end\n end",
"def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def execute(sql)\n begin\n db = SQLite3::Database.new(@@db_file)\n @@_set_db_handler.call(db)\n if block_given?\n db.execute(sql) do |row|\n yield row\n end\n else\n return db.execute(sql)\n end\n ensure\n db.close\n end\n end",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"def fetch_rows(sql, &block)\n execute(sql) do |r|\n r.each(:symbolize_keys => true, &block)\n end\n self\n end",
"def execute(sql, name = nil, &block)\n log(sql, name) do\n @connection.query(sql, &block)\n end\n end",
"def sql_update(sql)\n exec(sql)\n # return affected rows.\n end",
"def run_cursor_loop(connection, &block)\n Backfiller.log 'Start cursor loop'\n\n total_count = 0\n cursor = build_cursor(connection)\n\n loop do\n finished, count = cursor.transaction do\n run_fetch_loop(cursor, &block)\n end\n\n total_count += count\n\n Backfiller.log \"Total processed #{total_count}\"\n break if finished\n end\n end",
"def _execute(conn, sql, opts)\n begin\n r = log_yield(sql){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif block_given?\n yield conn\n end\n rescue ::Mysql2::Error => e\n raise_error(e, :disconnect=>MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message))\n end\n end",
"def each_row_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_row_batch(&block) if block_given?\n cursor.iterate_batched\n end",
"def execute\n # First, execute the SQL, applying the valid after_filters\n ret = apply_after_filters(execute_sql)\n\n # Set changed property to true\n changed\n\n # Notify all observers of the ids of the current result\n # set\n notify_observers(\n ret.collect{|instance| instance.send(model.primary_key)},\n self\n )\n\n # Reset the Query\n reset!\n\n # Return the results\n ret\n end",
"def execute(&block)\n TempTableContext.with_context(db) {|context| execute_in_context(context, &block)}\n end",
"def fetch_rows(sql, &block)\n raise NotImplementedError, NOTIMPL_MSG\n end",
"def fetch_rows(sql, opts=OPTS, &block)\n db.execute(sql){|result| process_result_set(result, opts, &block)}\n self\n end",
"def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end",
"def each_row(the_query, &block)\n begin\n query(the_query)\n unless @result.nil?\n @affected_rows = @result.num_rows # This is non-zero is we do a select, and get results.\n if block_given?\n @result.each(&block)\n else\n result = []\n @result.each { |row| result << row }\n return result\n end\n end\n rescue Mysql::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend",
"def execute(sql, opts=OPTS)\n _execute(sql, opts) do |conn|\n begin\n yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})\n ensure\n stmt.close if stmt\n end\n end\n end",
"def execute\n conn = connection\n Benchmark.bm { |x| x.report { yield conn } }\n conn.close\n end",
"def execute_query(sql, args)\n\t\t\t\t\t@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def open_cursor_with_sql(name, *sql_and_args, &block)\n connection.cursor_eachrow(sql_and_args, name, &block)\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)} \n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}\n end",
"def execute\n @result = session.execute(statement)\n execution_successful?\n end",
"def run(&block)\n case prepared_type\n when :select, :all\n # Most common scenario, so listed first\n all(&block)\n when :each\n each(&block)\n when :insert_select\n with_sql(prepared_sql).first\n when :first\n first\n when :insert, :update, :delete\n if opts[:returning] && supports_returning?(prepared_type)\n returning_fetch_rows(prepared_sql)\n elsif prepared_type == :delete\n delete\n else\n send(prepared_type, *prepared_modify_values)\n end\n when :insert_pk\n fetch_rows(prepared_sql){|r| return r.values.first}\n when Array\n case prepared_type[0]\n when :map, :as_hash, :to_hash, :to_hash_groups\n send(*prepared_type, &block) \n end\n else\n Sequel::Deprecation.deprecate(\"Using an unsupported prepared statement type (#{prepared_type.inspect})\", 'Switch to using :select as the prepared statement type')\n all(&block)\n end\n end",
"def roby_execute(&block)\n execution_engine.execute(&block)\n end",
"def affected_rows(*args, &blk)\n execute(false) do |conn|\n conn.send(:affected_rows, *args, &blk)\n end\n end",
"def fetch_rows(sql)\n return cursor_fetch_rows(sql){|h| yield h} if @opts[:cursor]\n execute(sql){|res| yield_hash_rows(res, fetch_rows_set_cols(res)){|h| yield h}}\n end",
"def execute( *bind_vars )\n reset! if active? || done?\n\n bind_params(*bind_vars) unless bind_vars.empty?\n @results = ResultSet.new(@connection, self)\n\n step if 0 == column_count\n\n yield @results if block_given?\n @results\n end",
"def execute(sql)\n log_info(sql)\n @pool.hold {|c| c.immediate(sql)}\n end",
"def query(the_query)\n raise Mysql::Error, 'Not Connected' if @my.nil?\n\n begin\n if @result != nil\n @result.free # Free any result we had left over from previous use.\n @result = nil\n end\n @affected_rows = 0 # incase this query crashes and burns, this will have a value.\n @result = @my.query(the_query)\n @affected_rows = @my.affected_rows # This is non-zero for insert/delete/update of rows\n if block_given?\n yield @result\n else\n return @result\n end\n rescue Mysql::Error => e\n if @result != nil\n @result.free # Free any result we had left over from previous use.\n @result = nil\n end\n raise e\n end\n end",
"def runQuery(query, &block)\n begin\n debug \"SQL Query: '#{query}'\"\n reply=@my.query(query)\n # Check if the SQL result contains anything at all...\n # If so, then call the block of commands to process it\n if (reply != nil && reply.num_rows() > 0)\n reply.each() { |result|\n debug \"SQL Reply: '#{result.to_s}'\"\n yield(result)\n }\n else\n debug \"SQL Reply is EMPTY!\"\n end\n rescue MysqlError => e\n debug \"ERROR - SQL Error: '#{e}'\"\n end\n end",
"def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end",
"def fetch_rows(sql)\n execute(sql) do |res|\n columns = set_columns(res)\n yield_hash_rows(res, columns) {|h| yield h}\n end\n end",
"def execute(sql, opts={}, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def each(&block)\n\t plan.query_each(result_set, &block)\n\t self\n\tend",
"def execute_and_free(sql, name = nil, async: false) # :nodoc:\n sql = transform_query(sql)\n check_if_write_query(sql)\n\n mark_transaction_written_if_write(sql)\n yield raw_execute(sql, name, async: async)\n end",
"def process_row(connection, row)\n Array(task.execute_sql(connection, row)).each do |sql|\n connection.execute(sql)\n end\n end",
"def affected\n IBM_DB.num_rows(@stmt)\n end",
"def runQuery(query, &block)\n raise \"Trying to run a query when not connected to inventory DB\" if not @connected\n begin\n debug \"SQL Query: '#{query}'\"\n reply=@my.query(query)\n # Check if the SQL result contains anything at all...\n # If so, then call the block of commands to process it\n if (reply.num_rows() > 0)\n reply.each() { |result|\n debug \"SQL Reply: '#{result.to_s}'\"\n yield(result)\n }\n else\n debug \"SQL Reply is EMPTY!\"\n end\n rescue MysqlError => e\n debug \"ERROR - SQL Error: '#{e}'\"\n end\n end",
"def each_row(the_query, &block)\n begin\n query(the_query, { as: :array, cache_rows: false })\n unless @result.nil?\n if block_given?\n @affected_rows = @result.count # This is non-zero is we do a select, and get results.\n @result.each(&block)\n else\n result = []\n @result.each { |row| result << row }\n return result\n end\n end\n rescue Mysql2::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end",
"def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end",
"def _execute(conn, sql, opts, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n conn.execute(sql, opts[:arguments], &block)\n end\n end",
"def execute(&block)\n block.call\n end",
"def execute(&block)\n block.call\n end",
"def cursor_fetch_rows(sql)\n server_opts = {:server=>@opts[:server] || :read_only}\n cursor = @opts[:cursor]\n hold = cursor[:hold]\n cursor_name = quote_identifier(cursor[:cursor_name] || 'sequel_cursor')\n rows_per_fetch = cursor[:rows_per_fetch].to_i\n\n db.send(*(hold ? [:synchronize, server_opts[:server]] : [:transaction, server_opts])) do \n begin\n execute_ddl(\"DECLARE #{cursor_name} NO SCROLL CURSOR WITH#{'OUT' unless hold} HOLD FOR #{sql}\", server_opts)\n rows_per_fetch = 1000 if rows_per_fetch <= 0\n fetch_sql = \"FETCH FORWARD #{rows_per_fetch} FROM #{cursor_name}\"\n cols = nil\n # Load columns only in the first fetch, so subsequent fetches are faster\n execute(fetch_sql) do |res|\n cols = fetch_rows_set_cols(res)\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n loop do\n execute(fetch_sql) do |res|\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n end\n rescue Exception => e\n raise\n ensure\n begin\n execute_ddl(\"CLOSE #{cursor_name}\", server_opts)\n rescue\n raise e if e\n raise\n end\n end\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end",
"def execute_block(statements, environment)\n previous = @environment\n begin\n @environment = environment\n\n statements.each do |statement|\n execute statement\n end\n ensure\n @environment = previous\n end\n nil\n end",
"def exec(sql, *bindvars, &block)\n ret = nil\n thread = Thread.new { ret = super }\n thread.join\n ret\n rescue Interrupt\n self.break\n raise\n end",
"def each(*args, &block)\n @stmt.each(*args, &block)\n end",
"def execute\n listen_for_changes\n @block.call\n end",
"def update_sql(sql, name = nil) #:nodoc:\r\n execute( sql, name )\r\n return @affected_rows\r\n end",
"def execute(sql, opts)\n r = synchronize(opts[:server]) do |conn|\n log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn) do\n conn.query_with_flags(sql, timezone.nil? || timezone == :local ? LOCAL_TIME_QUERY_FLAGS : QUERY_FLAGS)\n end\n end\n yield r\n rescue ::Trilogy::Error => e\n raise_error(e)\n end",
"def execute(query, *binds)\n res = nil\n\n mutex.synchronize do\n self.last_query = query\n self.last_statement = sth = new_statement(query)\n res = sth.execute(*binds)\n sth.finish\n yield res if block_given?\n end\n\n return res\n end",
"def query(sql)\n if NB.neverblocking? && NB.reactor.running?\n send_query sql\n NB.wait(:read, IO.new(socket))\n get_result\n else\n super(sql)\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute(&block)\n\tblock\nend",
"def execute(&block)\n\tblock\nend",
"def find_cursor(name, transaction, *findargs)\n count = 0\n begin\n connection.begin_db_transaction if transaction\n open_cursor(name, *findargs)\n while (row = ActiveRecord::Base.fetch_cursor(name)) do\n count+= 1\n yield row\n end\n close_cursor(name)\n ensure\n connection.commit_db_transaction if transaction\n end\n count\n end",
"def executeSQL(qStr, *params, &block)\n @statement_cache ||= {}\n #@statement_cache[qStr] ||= @db.prepare(qStr)\n @statement_cache[qStr] ||= qStr\n\n puts \"executeSQL: '#{qStr}', '#{params.join(\"', '\")}'\" if ::RdfContext::debug?\n if block_given?\n @db.execute(@statement_cache[qStr], *params) do |row|\n puts \"executeSQL res: #{row.inspect}\" if ::RdfContext::debug?\n row = row.keys.select{|k| k.is_a?(Integer)}.sort.map{|k| row[k]} if row.is_a?(Hash)\n yield(row)\n end\n else\n puts \"executeSQL no block given\" if ::RdfContext::debug?\n @db.execute(@statement_cache[qStr], *params)\n end\n rescue SQLite3::SQLException => e\n puts \"SQL Exception (ignored): #{e.message}\" if ::RdfContext::debug?\n end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def execute(sql, *args, &block)\n @db.log_yield(sql){super}\n rescue SwiftError => e\n @db.send(:raise_error, e)\n end",
"def execute_batch(sql, *args, &block)\n @db.execute_batch(rewrite_table_names(sql), *args, &block)\n end",
"def execute\n yield ResultEnumerator.new(self)\n end",
"def exec(sql)\n Logging.with_logged_query self, sql do\n raw_connection.exec sql\n end\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n self.columns = cols = stmt.result_fields.map{|c| output_identifier(c)}\n col_count = cols.size\n stmt.each do |result|\n row = {}\n col_count.times{|i| row[cols[i]] = result[i]}\n yield row\n end\n end\n end",
"def each_instance_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_instance_batch(self, &block) if block_given?\n cursor.iterate_type(self).iterate_batched\n end",
"def count_sql_queries_to_load\n result = 0\n\n ActiveSupport::Notifications.subscribe('sql.active_record') do |_name, _start, _finish, _id, payload|\n result += 1\n end\n\n yield\n\n result\n end",
"def query(sql)\n if Fiber.respond_to? :current and Fiber.current[:neverblock]\t\t \n send_query sql\n @fiber = Fiber.current\t\t \n Fiber.yield \n else\t\t \n super(sql)\n end\t\t\n end",
"def exec(query, args = [], result = 0, &block)\n connect do |c|\n t = Txn.new(c, @log)\n if block_given?\n t.exec(query, args, result, &block)\n else\n t.exec(query, args, result)\n end\n end\n end",
"def exec(&block)\n raise InvalidDbError if @stale\n\n return exec_in_staging(true, &block) if self.staging?\n\n begin\n self.staging\n exec_in_staging(false, &block)\n self.staging.write\n ensure\n self.unstage\n end\n\n end",
"def execute\n yield self if block_given?\n end",
"def execute(sql, name = 'SQL')\n log(sql, name) do\n @connection.async_exec(sql)\n end\n end",
"def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)\n sql = transform_query(sql)\n\n if preventing_writes? && write_query?(sql)\n raise ActiveRecord::ReadOnlyError, \"Write query attempted while in readonly mode: #{sql}\"\n end\n\n materialize_transactions\n mark_transaction_written_if_write(sql)\n\n binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)\n\n if without_prepared_statement?(binds)\n log(sql, name) { @connection.execute_query(sql) }\n else\n log(sql, name, binds) do\n # this is different from normal AR that always caches\n cached_statement = fetch_cached_statement(sql) if prepare && @jdbc_statement_cache_enabled\n @connection.execute_prepared_query(sql, binds, cached_statement)\n end\n end\n end",
"def execute(&block)\n\tblock.call\nend",
"def execute(&block)\n\tblock.call\nend",
"def execute(&block)\n\tblock.call\nend",
"def execute(&block)\n\tblock.call\nend",
"def query(sql, *binds)\n ds = mysql.fetch(sql, *binds)\n mysql.execute_dui(ds.update_sql) {|c| return c.last_id > 0 ? c.last_id : c.affected_rows}\n end",
"def execute_statement(sql)\n results = ActiveRecord::Base.connection.execute(sql)\n if results.present?\n return results\n else\n return nil\n end\n end",
"def execute(sql)\n @database_handle.execute(sql)\n end",
"def execute(sql)\r\n\t\t@connection.Execute(sql)\r\n\tend",
"def execute(&block)\n define_method(:execute, &block)\n end",
"def dynamodb_execute\n begin\n yield\n rescue => error\n return error\n end\n end",
"def fetch_rows(sql)\n execute(sql) do |r|\n i = -1\n cps = db.conversion_procs\n cols = r.fetch_fields.map do |f| \n # Pretend tinyint is another integer type if its length is not 1, to\n # avoid casting to boolean if convert_tinyint_to_bool is set.\n type_proc = f.type == 1 && cast_tinyint_integer?(f) ? cps[2] : cps[f.type]\n [output_identifier(f.name), type_proc, i+=1]\n end\n self.columns = cols.map(&:first)\n if opts[:split_multiple_result_sets]\n s = []\n yield_rows(r, cols){|h| s << h}\n yield s\n else\n yield_rows(r, cols){|h| yield h}\n end\n end\n self\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def batch(conn, sql, ctx: nil, limit: 1000, batch_wrapper: nil, silent: false, &block)\n ctx ||= {}\n ctx.update({:count => 0, :start_time => Time::now.to_f })\n\n # if no batch_wrapper is passed in, make a default that just\n # calls passed-in process_batch proc\n if batch_wrapper.nil?\n batch_wrapper = Proc.new do |process_batch|\n process_batch.call\n end\n end\n \n keep_going = true\n offset = 0\n while keep_going\n results = conn.query(sql + \" LIMIT #{limit} OFFSET #{offset}\")\n if results.count > 0\n\n # Proc closure over local vars\n process_batch = Proc.new do\n results.each do |row|\n begin\n block.call row, ctx\n rescue\n puts \"ERROR in #batch, processing row=#{row}\"\n raise\n end\n ctx[:count] += 1\n end\n end\n \n batch_wrapper.call(process_batch)\n \n elapsed = Time::now.to_f - ctx[:start_time]\n rate = 0\n if elapsed > 0\n rate = ctx[:count] / elapsed\n end\n puts \"Processed #{ctx[:count]} records so far in batch(): overall rate: #{rate} records/sec\" unless silent\n\n offset += limit\n else\n keep_going = false\n end\n end\n end",
"def exec_raw(sql, options = {})\n cursor = $connection.exec(sql)\n if(options[:return_hash])\n recordset, = pack_cursor(cursor, :return => \"hash\")\n return recordset\n else\n return_data = []\n while current_row = cursor.fetch()\n return_data.push(current_row)\n end\n return return_data\n end\n end",
"def query(sql, name = nil) #:nodoc:\n log(sql, name) do\n @connection.execute(sql).rows\n end\n end",
"def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end",
"def cti_execute_sql(sql)\n return execute(sql) if sql.is_a?(String)\n sql.map do |query|\n execute(query)\n end\n end"
] |
[
"0.695509",
"0.6553263",
"0.6432515",
"0.6257274",
"0.62539184",
"0.624179",
"0.6214166",
"0.614379",
"0.611238",
"0.6103601",
"0.6085855",
"0.6078134",
"0.6071048",
"0.6059197",
"0.6017211",
"0.6016044",
"0.59675395",
"0.59508336",
"0.5934793",
"0.5862775",
"0.5843922",
"0.57751876",
"0.5763958",
"0.57319164",
"0.57251185",
"0.57242984",
"0.5694337",
"0.56873935",
"0.5681154",
"0.56795055",
"0.5675687",
"0.56715465",
"0.5659881",
"0.5646304",
"0.5639266",
"0.56262875",
"0.5616267",
"0.5596054",
"0.5583138",
"0.5570324",
"0.5561974",
"0.553704",
"0.5529839",
"0.5529713",
"0.5525444",
"0.55107427",
"0.54993093",
"0.5488769",
"0.5484749",
"0.5482705",
"0.54725266",
"0.54678804",
"0.54536515",
"0.54536515",
"0.54515564",
"0.54476357",
"0.54384875",
"0.5411157",
"0.5403592",
"0.5398417",
"0.5394591",
"0.5389892",
"0.538869",
"0.53648907",
"0.5361287",
"0.5358646",
"0.5358646",
"0.534481",
"0.53386396",
"0.5328104",
"0.53091466",
"0.53050214",
"0.5291447",
"0.5289263",
"0.52874327",
"0.52864736",
"0.5271225",
"0.5267531",
"0.5266918",
"0.5259541",
"0.52593964",
"0.5240906",
"0.52404636",
"0.52382535",
"0.52382183",
"0.52382183",
"0.52382183",
"0.52378756",
"0.52325904",
"0.52230597",
"0.52044845",
"0.51920027",
"0.51895285",
"0.5188276",
"0.5177802",
"0.51774037",
"0.5171903",
"0.516307",
"0.5153866",
"0.5121691"
] |
0.60827494
|
11
|
Return the PGResult object that is returned by executing the given sql and args.
|
def execute_query(sql, args)
@db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def exec_query(sql, name = nil, binds = [])\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n result_array = result_as_array(result)\n if ArVer::GTEQ_4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end",
"def execute( sql, backwards_compat=false )\r\n result = @conn.query( sql )\r\n if backwards_compat\r\n return PGresult.new( result )\r\n else\r\n ResultSet.new result\r\n end\r\n rescue Exception => e\r\n raise DataAccessException.new( e.message, e ), $!, caller\r\n end",
"def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end",
"def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end",
"def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend",
"def run_sql(sql)\n #connect to the|db|\n conn = PG.connect(:dbname => 'rogbloll')\n\n\n #execute the db in the argument\n res = conn.exec(sql)\n\n #now close the db\n conn.close\n\n #now return the result of the query...\n res\n\n\n \n end",
"def execute(*args)\n result = raw_execute(*args)\n result.payload.key?('value') ? result['value'] : result\n end",
"def execute(*args)\n raw_execute(*args)['value']\n end",
"def call(*args)\n tuples = execute(*args)\n\n if result == :one\n tuples.first\n else\n tuples\n end\n end",
"def call(*args)\n tuples = execute(*args)\n\n if result == :one\n tuples.first\n else\n tuples\n end\n end",
"def execute_statement(sql)\n results = ActiveRecord::Base.connection.execute(sql)\n if results.present?\n return results\n else\n return nil\n end\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: 'goodfoodhunting')\n result = conn.exec(sql)\n conn.close\n return result\nend",
"def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end",
"def execute\n # build the query string\n # run the query\n # return the results\n end",
"def exec_raw(sql, options = {})\n cursor = $connection.exec(sql)\n if(options[:return_hash])\n recordset, = pack_cursor(cursor, :return => \"hash\")\n return recordset\n else\n return_data = []\n while current_row = cursor.fetch()\n return_data.push(current_row)\n end\n return return_data\n end\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: \"memetube\", host: \"localhost\")\n begin\n result = conn.exec(sql)\n ensure\n conn.close\n end\n result\nend",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def execute(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n q = check_disconnect_errors{execute_query(sql, args)}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def execute(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"execute: #{sql}\" }\n r = client.execute(sql)\n\n r.do\n r\n\n rescue => e\n handle_error(e)\n end",
"def sql_query(sql)\n db = PG.connect(:dbname => 'todo_book', :host => 'localhost')\n query_result = db.exec(sql)\n db.close\n\n return query_result\nend",
"def execute(sql, args = nil, bulk_args = nil, http_options = {})\n @logger.debug sql\n req = Net::HTTP::Post.new('/_sql', headers)\n body = { 'stmt' => sql }\n body['args'] = args if args\n body['bulk_args'] = bulk_args if bulk_args\n req.body = body.to_json\n response = request(req, http_options)\n @logger.debug response.body\n\n case response.code\n when /^2\\d{2}/\n ResultSet.new response.body\n else\n @logger.info(response.body)\n raise CrateRuby::CrateError, response.body\n end\n end",
"def execute(*args)\n @db.execute(*args)\n end",
"def execute_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return perform_select(query_string).get_rows()\n end",
"def execute sql\n db[sql]\n end",
"def postgres_query(sql=nil,doprint=false)\n ip = datastore['RHOST']\n port = datastore['RPORT']\n postgres_login unless self.postgres_conn\n unless self.postgres_conn\n return {:conn_error => true}\n end\n if self.postgres_conn\n sql ||= datastore['SQL']\n vprint_status \"#{ip}:#{port} Postgres - querying with '#{sql}'\"\n begin\n resp = self.postgres_conn.query(sql)\n rescue RuntimeError => e\n case sql_error_msg = e.to_s.split(\"\\t\")[1] # Deal with some common errors\n when \"C42601\"\n sql_error_msg += \" Invalid SQL Syntax: '#{sql}'\"\n when \"C42P01\"\n sql_error_msg += \" Table does not exist: '#{sql}'\"\n when \"C42703\"\n sql_error_msg += \" Column does not exist: '#{sql}'\"\n when \"C42883\"\n sql_error_msg += \" Function does not exist: '#{sql}'\"\n else # Let the user figure out the rest.\n if e == Timeout::Error\n sql_error_msg = 'Execution expired'\n elsif sql_error_msg.nil?\n sql_error_msg = e.inspect\n else\n sql_error_msg += \" SQL statement '#{sql}' returns #{e.inspect}\"\n end\n end\n return {:sql_error => sql_error_msg}\n end\n postgres_print_reply(resp,sql) if doprint\n return {:complete => resp}\n end\n end",
"def get_result\n\t\texecute unless @result\n\t\treturn @result\n\tend",
"def run_sql(sql)\n connection = PG.connect(dbname: \"facebook_lab\", host: \"localhost\")\n result = connection.exec(sql)\n connection.close\n result\nend",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def query_return_first(sql, *binds)\n mysql.fetch(sql, *binds).first\n end",
"def execute_query(sql, args)\n\t\t\t\t\t@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def execute(query, *binds)\n res = nil\n\n mutex.synchronize do\n self.last_query = query\n self.last_statement = sth = new_statement(query)\n res = sth.execute(*binds)\n sth.finish\n yield res if block_given?\n end\n\n return res\n end",
"def getDBValue(connection, query, id1, *id2)\r\n dbi_query = connection.prepare(query)\r\n dbi_query.execute(id1, *id2)\r\n #fetch the result\r\n return dbi_query.fetch\r\nend",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def run_sql(sql)\n db = PG.connect(dbname: 'goodfoodhunting')\n results = db.exec(sql)\n db.close\n results\nend",
"def execute_scalar( sql )\r\n resultset = execute( sql )\r\n return nil unless resultset.rowcount > 0\r\n raise InvalidOperationException.new( \"excecute_scalar can not return multiple rows\" ) if resultset.rowcount > 1\r\n return resultset.rows.first.send( resultset.columns.first.name.to_sym )\r\n end",
"def ask(sql, *args, into: nil)\n catch(:ok) do\n each(sql, *args, into: into) { |row| throw :ok, row }\n nil\n end\n end",
"def _query(q, params={})\n engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(db)\n result = engine.execute(q, Core::HashWithIndifferentAccess.new(params))\n Neo4j::Cypher::ResultWrapper.new(result)\n end",
"def call(*args)\n params = build_params args\n cstmt = @connection.prepare_call \"{call #{name}(#{Array.new(@cols.length){'?'}.join ', '})}\"\n begin\n process_result( args, cstmt.call(*params) )\n ensure\n cstmt.close\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GBDResultSet.new(resp)\n return results\n end",
"def single(sql, values = [])\n r = $db.exec_params(sql, values)\n return nil if r.ntuples == 0\n convert_to_ruby_types(r.first)\nend",
"def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GetDatabaseResultSet.new(resp)\n return results\n end",
"def execute *params\r\n sql = parse_args( *params )\r\n @driver.execute( sql )\r\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: 'movies')\n result = conn.exec(sql)\n conn.close\n result\nend",
"def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = CreateDatabaseResultSet.new(resp)\n return results\n end",
"def run_sql(sql, arr = []) # array is for security feature\n db = PG.connect(ENV['DATABASE_URL'] || {dbname: 'picgallary'})\n results = db.exec_params(sql, arr)\n db.close\n return results\n end",
"def run\n if @prepared_type == :insert\n fetch_rows(prepared_sql){|r| return r.values.first}\n else\n super\n end\n end",
"def query_return_first_value(sql, *binds)\n mysql.fetch(sql, *binds).single_value\n end",
"def execute(sql)\n stmt = IBM_DB.exec(@conn, sql)\n raise Error.new(error_msg, error_sqlstate) unless stmt\n Statement.new(stmt)\n end",
"def run\n Application.logger.info \"Executing #{self.class.to_s} (UseCase)\"\n _r = execute\n Application.logger.info \"Returned from #{self.class.to_s} => #{_r.inspect}\"\n _r\n end",
"def select(sql, name = nil, binds = [])\n ret = exec_query(sql, name, binds)\n ArVer::GTEQ_4 ? ret : ret.to_a\n end",
"def execute(sql)\n @logger.debug(\"SQL: #{sql}\") if @logger\n retrieve_connection.query(sql)\n end",
"def run_sql(sql)\n db = PG.connect(:dbname => 'movies', :host => 'localhost')\n result = db.exec(sql)\n db.close\n result\n end",
"def execute\n @result = session.execute(statement)\n execution_successful?\n end",
"def run_sql(sql, arr = [])\n db = PG.connect(ENV['DATABASE_URL'] || {dbname: 'native_plants'})\n results = db.exec_params(sql, arr)\n db.close\n return results\nend",
"def run_sql(sql)\n\tconn = PG.connect(dbname: \"video_store\", host: 'localhost')\n\tresult = conn.exec(sql)\n\tconn.close\n\tresult \nend",
"def execute(sql, name = nil)\n raise NotImplementedError, \"execute is an abstract method\"\n end",
"def run_sql(sql_query)\n\tconn = PG.connect(dbname: 'first_crud_app')\n\tresult = conn.exec(sql_query)\n\tconn.close\n\tresult\nend",
"def sql(cmd, res = [])\n @sqr = job?(cmd) ? res : job.data\n end",
"def execute(query)\n # use exec_params instead of exec for security\n #\n # Unlike PQexec, PQexecParams allows at most one SQL command in the given string.\n # (There can be semicolons in it, but not more than one nonempty command.)\n # This is a limitation of the underlying protocol, but has some usefulness\n # as an extra defense against SQL-injection attacks.\n # https://www.postgresql.org/docs/current/static/libpq-exec.html\n query = squish(query)\n log \"SQL: #{query}\" if @log_sql\n conn.exec_params(query, []).to_a\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n execute(sql, name, binds)\n end",
"def select_one(sql)\n result = execute(sql)\n result.fetch_hash\n end",
"def run\n basecmd = []\n basecmd << command(:psql)\n basecmd << \"-U\" unless @resource[:role].nil?\n basecmd << \"#{@resource[:role]}\" unless @resource[:role].nil?\n basecmd << \"-d\" unless @resource[:database].nil?\n basecmd << \"#{@resource[:database]}\" unless @resource[:database].nil?\n \n # We execute by default.\n execute = true\n unless @resource[:query].nil?\n cmd = basecmd\n cmd << '-qAtc'\n \n sqlcmd = \"#{@resource[:query]}\"\n \n cmd << sqlcmd\n \n raw, status = Puppet::Util::SUIDManager.run_and_capture(cmd, 'postgres')\n if status == 0\n execute = false # Got an ok result, so we'll evaluate.\n\n if ! @resource[:rows].nil?\n target_rows = Integer(@resource[:rows].gsub(/[^\\d]/,''))\n operand = @resource[:rows].gsub(/[\\d]/,'').chomp.downcase\n returned_rows = (raw.length <= 0 ? 0 : raw.lines.count)\n if operand.match(/lte|less than or equal|<=/)\n execute = true if returned_rows <= target_rows\n elsif operand.match(/gte|greater than or equal|>=/)\n execute = true if returned_rows >= target_rows\n elsif operand.match(/lt|less than|</)\n execute = true if returned_rows < target_rows \n elsif operand.match(/gt|greater than|>/)\n execute = true if returned_rows > target_rows\n else\n execute = true if returned_rows == target_rows\n end\n end\n else\n # We stop an execution if rows or result params are set\n # on the assumption that if you want to evaluate against criteria like those\n # you want to actually do so.\n execute = false if (! @resource[:rows].nil? or ! @resource[:result].nil?)\n end\n end\n \n unless execute == false\n cmd = basecmd\n if ! @resource[:command].nil?\n cmd << '-qAtc'\n \n sqlcmd = \"#{@resource[:command]}\"\n \n cmd << sqlcmd \n elsif ! @resource[:file].nil?\n cmd << '-qAtf'\n \n sqlcmd = \"#{@resource[:file]}\"\n \n cmd << sqlcmd\n else\n # Right now we send a warning. This should still trigger a refresh if you\n # want to use queries to conditionally do things for some insane reason.\n self.warning(\"Nothing to do.\")\n end\n \n raw, status = Puppet::Util::SUIDManager.run_and_capture(cmd, 'postgres')\n if status != 0\n self.fail(\"Error executing SQL - result #{raw}\")\n else\n @ran = true\n end\n else\n self.fail(\"Execution criteria failed. Failing to prevent dependant resources from executing.\")\n end\n end",
"def execute(sql, name = nil)\n exec_no_cache(sql, name, nil)\n end",
"def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end",
"def exec_query(sql, name = 'SQL', binds = [], prepare: false) # rubocop:disable Lint/UnusedMethodArgument\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n stmt = @connection.run(sql)\n\n columns = stmt.columns\n values = stmt.to_a\n stmt.drop\n\n values = dbms_type_cast(columns.values, values)\n column_names = columns.keys.map { |key| format_case(key) }\n ActiveRecord::Result.new(column_names, values)\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def run(query:)\n Vidalia::log(\"SQL query text: \\\"#{query}\\\"\",:style => :debug)\n open_connection\n result = launch_query_command(query: query)\n if result.size > 0\n count = 1\n result.each do |r|\n Vidalia::log(\"SQL query result (#{count}): \\\"#{r.inspect}\\\"\",:style => :debug)\n count += 1\n end\n else\n Vidalia::log(\"SQL query: NO RESULTS FOUND\",:style => :debug)\n end\n rescue Exception => e\n raise e\n else\n return result\n ensure\n close_connection\n end",
"def call(*args)\n in_context do\n self.execute(*args)\n end\n end",
"def batch_command__pg_gem call, *args\n @results ||= []\n call = array__from call\n call = call.first\n exec_method ||= \"exec\"\n command = args.join \" \"\n exec_rv, exception = begin\n e = !(call.respond_to? exec_method) && NoMethodError.new(\"undefined method `#{exec_method}' for #{call.class}\")\n (e && [nil, e] || [(call.send exec_method, command), nil])\n rescue => e2\n [nil, e2]\n end\n exec_rv_entries = exec_rv.entries rescue exec_rv\n exception_info = (exception_info_base [exception]) rescue []\n @results.push({\n :time => Time.now.inspect,\n :call => call,\n :args => args,\n :command => command,\n :success => exception_info[2].negate_me,\n :output => exec_rv_entries,\n :batch_command_method => \"batch_command__pg_gem\",\n :exception_info => exception_info,\n })\n @results\n end",
"def query_name(v_quote)\n\n begin\n\n # connect to the database\n conn = PG.connect(dbname: 'test', user: 'something', password: '4321')\n\n # prepare SQL statement\n conn.prepare('q_statement',\n \"select details.id, name, age, quote\n from details\n join quotes on details.id = quotes.details_id\n where quote = $1\")\n\n # execute prepared SQL statement\n rs = conn.exec_prepared('q_statement', [v_quote])\n\n # deallocate prepared statement variable\n conn.exec(\"deallocate q_statement\")\n\n # return array of values returned by SQL statement\n return rs.values[0]\n\n rescue PG::Error => e\n\n puts 'Exception occurred'\n puts e.message\n\n ensure\n\n conn.close if conn\n\n end\n\nend",
"def query(sql)\n database.execute2(sql)\n end",
"def Result(*args)\n Auger::Result.new(*args)\n end",
"def execute *args\n if args.first == :query\n self\n else\n opts = args.last.is_a?(Hash) ? args.last : {}\n results = []\n\n pagination = opts.delete(:paginate) || {}\n model.send(:with_scope, :find => opts) do\n @conditions.paginate(pagination) unless pagination.empty?\n results = model.find args[0], to_find_parameters\n if @conditions.paginate?\n paginate_result_set results, to_find_parameters\n end\n end\n results\n end\n end",
"def query(sql, *bind_values)\n @pool.acquire { |conn| conn.query(sql, *bind_values).first }\n end",
"def exec(sql)\n Logging.with_logged_query self, sql do\n raw_connection.exec sql\n end\n end",
"def query(sql, name, binds)\n \n rs = SA.instance.api.sqlany_execute_direct(@connection, sql)\n raise ActiveRecord::StatementInvalid.new(\"#{SA.instance.api.sqlany_error(@connection)}:#{sql}\") if rs.nil?\n \n max_cols = SA.instance.api.sqlany_num_cols(rs)\n fields = {}\n max_cols.times do |i|\n fields[i] = SA.instance.api.sqlany_get_column_info(rs, i)[2]\n end\n \n rows = []\n while SA.instance.api.sqlany_fetch_next(rs) == 1\n result = Array.new(max_cols)\n max_cols.times do |cols|\n result[cols] = SA.instance.api.sqlany_get_column(rs, cols)[1]\n end\n rows << result\n end\n @affected_rows = SA.instance.api.sqlany_affected_rows(rs)\n SA.instance.api.sqlany_free_stmt(rs)\n\n return rows, fields\n end",
"def get_entry(first_name, last_name)\n begin\n conn = open_db()\n query = \"select * from listings where fname = $1 and lname = $2\"\n conn.prepare('q_statement', query)\n user_hash = conn.exec_prepared('q_statement', [first_name, last_name])\n conn.exec(\"deallocate q_statement\")\n user_hash.to_a.size > 0 ? (return user_hash[0]) : (return {})\n rescue PG::Error => e\n puts 'Exception occurred'\n puts e.message\n ensure\n conn.close if conn\n end\nend",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def query_single(sql, *params)\n results = run(sql, *params)\n results.each(as: :array, :first => true).first\n end",
"def run_sql(sql)\n\tdb = PG.connect(dbname: 'address_book', host: 'localhost')\n\tresult = db.exec(sql)\n\tdb.close\n\tresult\nend",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def select_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return select_cached(query_string)\n end",
"def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end",
"def execute(sql)\n log_info(sql)\n @pool.hold {|c| c.immediate(sql)}\n end",
"def query(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n check_disconnect_errors{super}\n end",
"def execute\n ds = DataSource.new(@dataSource, @@obj)\n if ds.nil?\n return nil\n else\n return ds.execute(self)\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def temp_exec(*args)\n child = Reticular.new(@body + \";\", args)\n child.execute\n child.stack\n end",
"def execute\n ActiveRecord::Base.connection.execute(source)\n end",
"def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @charset.convert v}\n begin\n @sqlstate = \"00000\"\n nfields = @protocol.stmt_execute_command @statement_id, values\n if nfields\n @fields = @protocol.retr_fields nfields\n @result = StatementResult.new @fields, @protocol, @charset\n else\n @affected_rows, @insert_id, @server_status, @warning_count, @info =\n @protocol.affected_rows, @protocol.insert_id, @protocol.server_status, @protocol.warning_count, @protocol.message\n end\n return self\n rescue ServerError => e\n @last_error = e\n @sqlstate = e.sqlstate\n raise\n end\n end",
"def fetch_row(sql)\n # Run the query\n results = query(sql)\n\n # Check result counts\n if results.count == 0\n check.critical(\"Expected to receive a single row, but result set is empty\", \"SQL: #{sql}\")\n end\n if results.count > 1\n check.critical(\"Expected to receive a single row, but result has #{results.count} lines\", \"SQL: #{sql}\")\n end\n\n # Get the first and only row\n return results.first\n end",
"def execute(sql, *args, &block)\n @db.log_yield(sql){super}\n rescue SwiftError => e\n @db.send(:raise_error, e)\n end",
"def query(sql, rescue_exception = true)\n debug(sql) if $DBG\n return query_statement(sql)\n rescue Object => ex\n if rescue_exception\n handle_sql_exception(ex, sql)\n else\n raise\n end\n end",
"def execute command, *bind\n start = Time.now\n record, command = command, bind.shift if command.kind_of?(Class) && command < Record\n record ? Result.new(record, db.execute(command, *bind)) : db.execute(command, *bind)\n ensure\n log_command(start, command, bind) if @trace\n end"
] |
[
"0.7122949",
"0.69058275",
"0.6898071",
"0.6690125",
"0.65527105",
"0.6494794",
"0.64539707",
"0.6427724",
"0.6418019",
"0.62747717",
"0.62501246",
"0.62494457",
"0.62494457",
"0.6215481",
"0.6181223",
"0.61786216",
"0.6139155",
"0.61268324",
"0.61180377",
"0.61159366",
"0.6082408",
"0.60507953",
"0.60363376",
"0.59949166",
"0.59920096",
"0.5942855",
"0.59023476",
"0.5879929",
"0.58655393",
"0.5841379",
"0.58214706",
"0.581697",
"0.579198",
"0.5774914",
"0.577443",
"0.57719445",
"0.57405734",
"0.5733401",
"0.5724343",
"0.569589",
"0.5694149",
"0.56751883",
"0.5639798",
"0.56379783",
"0.5632427",
"0.56296235",
"0.56144536",
"0.56116915",
"0.56064445",
"0.56056505",
"0.5596269",
"0.5589827",
"0.5577368",
"0.5575902",
"0.5574544",
"0.5570083",
"0.5569763",
"0.5568268",
"0.5556645",
"0.55446124",
"0.554088",
"0.55315524",
"0.552124",
"0.55182457",
"0.5503275",
"0.55012697",
"0.55010223",
"0.5489736",
"0.5454243",
"0.54427207",
"0.54399437",
"0.5439534",
"0.54321545",
"0.5424105",
"0.54212946",
"0.5410815",
"0.5409992",
"0.5406221",
"0.5402488",
"0.5399944",
"0.5393754",
"0.5392534",
"0.538694",
"0.53867245",
"0.53849894",
"0.5381403",
"0.53797424",
"0.5376031",
"0.53746015",
"0.53725505",
"0.53719836",
"0.5358896",
"0.53463805",
"0.5332565",
"0.5325633",
"0.5321458",
"0.53203976",
"0.53178567",
"0.5310573",
"0.5299433"
] |
0.5912038
|
26
|
Convert given argument so that it can be used directly by pg. Currently, pg doesn't handle fractional seconds in Time/DateTime or blobs with "\0", and it won't ever handle Sequel::SQLTime values correctly. Only public for use by the adapter, shouldn't be used by external code.
|
def bound_variable_arg(arg, conn)
case arg
when Sequel::SQL::Blob
{:value=>arg, :type=>17, :format=>1}
when Sequel::SQLTime
literal(arg)
when DateTime, Time
literal(arg)
else
arg
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def convert_for_timestamp_shape(arg)\n return nil if arg.nil?\n\n time_value = case arg\n when Time\n arg\n when Date, DateTime\n arg.to_time\n when Integer, Float\n Time.at(arg)\n else\n Time.parse(arg.to_s)\n end\n time_value.utc.iso8601\n end",
"def prepared_statement_arg(v)\n case v\n when Numeric\n v.to_s\n when Date, Time\n literal(v).gsub(\"'\", '')\n else\n v\n end\n end",
"def to_postgres_string\n min_string = minutes.to_s\n sec_string = seconds.to_s\n \n min_string = \"0\" + min_string if minutes.to_s.length < 2\n sec_string = \"0\" + sec_string if seconds.to_s.length < 2\n \n return hours.to_s+\":\"+min_string+\":\"+sec_string\n end",
"def to_sequel_time\n begin\n Sequel.datetime_class.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def bound_variable_arg(arg, conn)\n case arg\n # TODO TDD it:\n when Sequel::SQL::Blob\n # the 1 means treat this as a binary blob\n {:value => arg, :format => 1}\n when Sequel::SQLTime\n # the literal methods put quotes around things, but this is a bound variable, so we can't use those\n arg.strftime(BOUND_VARIABLE_SQLTIME_FORMAT)\n when DateTime, Time\n # the literal methods put quotes around things, but this is a bound variable, so we can't use those\n from_application_timestamp(arg).strftime(BOUND_VARIABLE_TIMESTAMP_FORMAT)\n else\n arg\n end\n end",
"def coerce_timestamp(timestamp)\n # bug in JRuby prevents correcly parsing a BigDecimal fractional part, see https://github.com/elastic/logstash/issues/4565\n timestamp.is_a?(BigDecimal) ? LogStash::Timestamp.at(timestamp.to_i, timestamp.frac * 1000000) : LogStash::Timestamp.at(timestamp)\n end",
"def cast_string(arg, sql_type = nil)\n cast(arg, sql_type || String).sql_string\n end",
"def convert_timestamp(timestamp)\n timestamp = db.to_application_timestamp(timestamp) if timestamp.is_a?(String)\n timestamp\n end",
"def typecast_value(column_type, value)\n return nil if value.nil?\n case column_type\n when :integer\n Integer(value)\n when :string\n value.to_s\n when :float\n Float(value)\n when :decimal\n case value\n when BigDecimal\n value\n when String, Float\n value.to_d\n when Integer\n value.to_s.to_d\n else\n raise ArgumentError, \"invalid value for BigDecimal: #{value.inspect}\"\n end\n when :boolean\n case value\n when false, 0, \"0\", /\\Af(alse)?\\z/i\n false\n else\n value.blank? ? nil : true\n end\n when :date\n case value\n when Date\n value\n when DateTime, Time\n Date.new(value.year, value.month, value.day)\n when String\n value.to_date\n else\n raise ArgumentError, \"invalid value for Date: #{value.inspect}\"\n end\n when :time\n case value\n when Time\n value\n when String\n value.to_time\n else\n raise ArgumentError, \"invalid value for Time: #{value.inspect}\"\n end\n when :datetime\n raise(ArgumentError, \"invalid value for #{tc}: #{value.inspect}\") unless value.is_one_of?(DateTime, Date, Time, String)\n if Sequel.datetime_class === value\n # Already the correct class, no need to convert\n value\n else\n # First convert it to standard ISO 8601 time, then\n # parse that string using the time class.\n (Time === value ? value.iso8601 : value.to_s).to_sequel_time\n end\n else\n value\n end\n end",
"def to_time\n begin\n Time.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def from_database_type(obj)\n case obj\n when String, Float, Integer, NilClass, TrueClass, FalseClass\n obj\n when java.sql.Date, java.sql.Time, java.sql.Timestamp\n Time.at(obj.time/1000)\n when java.sql.Blob\n String.from_java_bytes(obj.get_bytes(1,obj.length))\n when java.sql.Clob\n obj.get_sub_string(1, obj.length)\n when java.math.BigDecimal\n BigDecimal.new(obj.to_s)\n else\n raise \"Can't find correct type to convert #{obj.inspect} into\"\n end\n end",
"def cast_numeric(arg, sql_type = nil)\n cast(arg, sql_type || Integer).sql_number\n end",
"def typecast_value_datetime(value)\n Sequel.typecast_to_application_timestamp(value)\n end",
"def cast(arg, sql_type)\n SQL::Cast.new(arg, sql_type)\n end",
"def ruby_from_volt(val, type)\n return nil if val.nil?\n\n case type\n when Types::DECIMAL then dec_from_str(val)\n when Types::TIMESTAMP then time_from_milli_epoch(val)\n else val\n end\n end",
"def format_parameter(parameter)\n parameter.instance_of?(Time) ? iso_format(parameter) : parameter.to_s\n end",
"def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n if type == :decimal\n # Force an explicit scale if none supplied to specify the fixed\n # point form of Virtuoso's DECIMAL type. If no scale is specified,\n # the Virtuoso DECIMAL type stores floating point values.\n precision ||= 32\n scale ||= 0\n end\n super(type, limit, precision, scale)\n end",
"def arg_to_native(arg)\n return nil if arg.type == 0x00\n\n # arg_type = TYPE_SHORTHANDS[arg_type] if arg_type.is_a?(Symbol)\n\n value = if pack_char = PACK_CHARS_FOR_DATA_TYPE[arg.type]\n value = arg.value.to_byte_string.unpack( PACK_CHARS_FOR_DATA_TYPE[arg.type] )[0]\n value\n else\n\n case arg.type\n when 0x09 # immediate 8-byte string\n arg.value.to_byte_string.strip_to_null\n when 0x0e # variable-length string\n arg.value.to_byte_string[1..-1]\n else\n if arg.type > DATA_TYPE_MAX # immediate type-less 8-byte string\n [arg.type,arg.value].flatten.to_byte_string.strip_to_null #FIXME: can have random crap after first null byte, cleanup\n else\n raise Gta3Vm::Vm::InvalidDataType, \"unknown data type #{arg_type} (#{hex(arg_type)})\"\n end\n end\n\n end\n\n value = value.round(FLOAT_PRECISION) if value.is_a?(Float)\n\n value\n\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def cast(param, type)\n if param.nil?\n return nil\n elsif type == Integer\n return Integer(param)\n elsif type == String\n return String(param)\n elsif type == Float\n return Float(param)\n elsif type == Date\n return Date.parse(param)\n elsif type == Time\n return Time.parse(param)\n end\n rescue ArgumentError\n errors.append(I18n.t('digget.cast', param: param, type: type))\n end",
"def must_convert?\n big_query_conversion_column.present? && unit != 'seconds'\n end",
"def to_sql\n \"timestamp '#{to_s}'\"\n end",
"def convert_time(timevalue)\n if (is_numeric?(timevalue))\n Time.at(timevalue.to_i).utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n else\n begin\n Time.parse(timevalue).utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n rescue\n raise \"Invalid time value: '#{timevalue}'. Must be a timestamp (seconds since epoch) or a valid time string (e.g. YYYY-MM-DDTHH:MM:SSZ)\"\n end\n end\n end",
"def typecast_to_primitive(value)\n \n if value.kind_of?(::DateTime)\n result = value.to_time\n else\n result = ::DateTime.parse(value.to_s).to_time \n end\n \n return result\n \n rescue ArgumentError\n value\n end",
"def must_convert?\n self.big_query_conversion_column.present? && self.unit != 'seconds'\n end",
"def castTime(hash={})\n\t\troundTime(hash)\n\tend",
"def convert_time(t)\n case t\n when nil then nil\n when Date then t.to_time.utc.iso8601(3)\n when Time then t.utc.iso8601(3)\n when String then Time.parse(t).utc.iso8601(3)\n else raise \"Invalid time format '#{t.class}'. Valid options are Time, Date, or String\"\n end\n rescue StandardError => e\n raise \"Failed to parse time value '#{t}'. #{e.message}\"\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n return value if value.utc? && Mongoid.use_utc?\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def time_conversion(minutes)\nend",
"def translate_timestamp(timestamp)\n # seconds -> milliseconds\n timestamp.to_i * 1000\n end",
"def convert_datetime_to_db_format_in_params(submitted_params, model, method_name)\n logger.debug \"==== CONVERTING DATE TIME ====\"\n show_params(submitted_params)\n date_field_name = method_name+'_date'\n time_field_name = method_name+'_time'\n\n\n timestamp_field = method_name\n\n logger.debug \"DEBUG: submitted_params[#{model}][#{date_field_name}]\"\n submitted_date_field = submitted_params[model][date_field_name]\n submitted_time_field = submitted_params[model][time_field_name]\n logger.debug \"DEBUG: Submitted date field: #{submitted_date_field}\"\n logger.debug \"DEBUG: Submitted time field: #{submitted_time_field}\"\n\n\n #Avoid nil fields and do nothing\n if !submitted_date_field.blank?# and submitted_time_field != nil\n #Try and parse the values entered\n begin\n \tsubmitted_time_field = Time.now.strftime('%H:%M') if submitted_time_field.blank?\n postgres_timestamp = date_time_to_db_format(submitted_date_field,submitted_time_field)\n logger.debug \"DEBUG: Postgres timestamp is #{postgres_timestamp}\"\n\n #And add a happy one for updating the date\n submitted_params[model][timestamp_field] = postgres_timestamp\n\n rescue\n #Throw a nice exception\n raise TimeParseException.new('The datestring \\\"'+submitted_date_field+\" \" +submitted_time_field+'\\\" was not parseable')\n end\n\n show_params(submitted_params)\n\n\n end\n\t#Remove the field names that active record wont like\n\tsubmitted_params[model].delete(date_field_name)\n\tsubmitted_params[model].delete(time_field_name)\n\n\tlogger.debug \"==== /CONVERTING DATE TIME ====\"\n\n\treturn submitted_params\n end",
"def quote(value, column = nil) #:nodoc:\n return super unless column\n\n case value\n when Float\n return super unless value.infinite? && column.type == :datetime\n \"'#{value.to_s.downcase}'\"\n when Numeric\n return super unless column.sql_type == 'money'\n # Not truly string input, so doesn't require (or allow) escape string syntax.\n \"'#{value}'\"\n when String\n case column.sql_type\n when 'bytea' then \"E'#{escape_bytea(value)}'::bytea\"\n when 'xml' then \"xml '#{quote_string(value)}'\"\n when /^bit/\n case value\n when /^[01]*$/ then \"B'#{value}'\" # Bit-string notation\n when /^[0-9A-F]*$/i then \"X'#{value}'\" # Hexadecimal notation\n end\n else\n super\n end\n else\n super\n end\n end",
"def to_class(s)\n if valid_date_time?(s)\n Time.strptime(s, '%Y-%m-%d.%H:%M:%S').to_i\n elsif valid_date?(s)\n Date.strptime(s, '%Y-%m-%d').to_i\n elsif valid_time?(s)\n Time.strptime(s, '%H:%M:%S').to_i\n elsif valid_integer?(s)\n s.to_i\n elsif valid_float?(s)\n s.to_f\n else\n s\n end\n end",
"def type_to_sql(*args); connection.type_to_sql(*args); end",
"def raw_cast(value)\n # We can strip value here but we do not want to squish it unless for number\n value = value.to_s.strip\n return nil if value.empty?\n\n case data_type\n when 'number'\n BigDecimal(remove_decimal_mark(value.squish))\n when 'date'\n # date_format likely will be '%m/%d/%Y', but if we got '19/8/2014',\n # then `strptime` will raise invalid date error\n # Sometimes we can get '27/11 /1981' also :(\n begin\n Date.strptime(value, @resultset.date_format)\n rescue StandardError\n # We could be getting back these date:\n # '17.12.95', '19/05/99', '27/11 /1981'\n # '1959-07-03' will be beyond us, so consider returning exact value\n value = value.gsub(/-|\\./, '/')\n split = value.split('/').map(&:strip)\n split[2] = \"19#{split[2]}\" if split[2].size == 2\n value = split.join('/')\n\n Date.strptime(\n Date.parse(value)\n .strftime(@resultset.date_format), @resultset.date_format\n )\n end\n when 'time'\n DateTime.strptime(\"1/1/-4712 #{value}\", @resultset.timestamp_format)\n when 'timestamp'\n DateTime.strptime(value, @resultset.timestamp_format)\n when 'container'\n # container may return value that include URI scheme already\n return URI.parse(value) if value.start_with?('http')\n URI.parse(\"#{@resultset.server.url}#{value}\")\n else\n value\n end\n rescue StandardError => e\n warn \"Could not coerce #{name}: #{value} due to #{e.message.force_encoding(\"UTF-8\")}\"\n value\n end",
"def to_datetime string_or_datetime\n if string_or_datetime.is_a?(String)\n Sequel.string_to_datetime(string_or_datetime)\n else\n string_or_datetime\n end\n end",
"def cast_value(v)\r\n return nil if v.nil?\r\n if @type == :date\r\n self.style = STYLE_DATE if self.style == 0\r\n v\r\n elsif (@type == :time && v.is_a?(Time)) || (@type == :time && v.respond_to?(:to_time))\r\n self.style = STYLE_DATE if self.style == 0\r\n # one simple little fix. I DO NOT WANT TIME IN LOCAL TIME!\r\n unless v.is_a?(Time)\r\n v = v.respond_to?(:to_time) ? v.to_time : v\r\n end\r\n v\r\n elsif @type == :float\r\n v.to_f\r\n elsif @type == :integer\r\n v.to_i\r\n elsif @type == :boolean\r\n v ? 1 : 0\r\n elsif @type == :iso_8601\r\n #consumer is responsible for ensuring the iso_8601 format when specifying this type\r\n v\r\n else\r\n @type = :string\r\n # TODO find a better way to do this as it accounts for 30% of\r\n # processing time in benchmarking...\r\n Axlsx::trust_input ? v.to_s : ::CGI.escapeHTML(v.to_s)\r\n end\r\n end",
"def value_for(value)\n return value.to_s(:db) if value.kind_of?(Time) \n return value.to_s(:db) if value.kind_of?(Date)\n return value.to_s\n end",
"def to_timestamp(string)\n Time.parse(string).strftime(\"%s\")\nend",
"def bound_variable_arg(arg, conn)\n case arg\n when JSONObject, JSONBObject\n Sequel.object_to_json(arg)\n else\n super\n end\n end",
"def from_application_timestamp(v)\n Sequel.convert_output_timestamp(v, timezone)\n end",
"def convert(value) value end",
"def date_time_to_db_format(date, time)\n finish_date_time = date + \" \" + time\n # format datetime for the database\n postgrestimestamp = DateTime::strptime(finish_date_time, '%d %b %Y %H:%M').to_time\n return postgrestimestamp\n end",
"def create_custom_function\n # puts \"Creating a custom function to make queries with timestamp as a string...\".cyan\n @session.execute('CREATE OR REPLACE FUNCTION timefstring(somearg text)\n RETURNS NULL ON NULL INPUT\n RETURNS timestamp\n LANGUAGE java\n AS $$\n java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss.SSS\");\n try {\n Date date = formatter.parse(somearg);\n return date;\n } catch(java.text.ParseException e) {\n return new Date();\n }\n $$')\n end",
"def pto_time(user_id)\n db_params = {\n host: ENV['host'],\n port: ENV['port'],\n dbname: ENV['dbname'],\n user: ENV['user'],\n password: ENV['password']\n }\n db = PG::Connection.new(db_params)\n user_pto = db.exec(\"SELECT pto FROM pto WHERE user_id = '#{user_id}'\").values\n db.close \n user_pto.flatten.first\nend",
"def prepare_parameters(params)\n @report_params = (params || {}).transform_keys(&:to_s).transform_values do |val|\n if val.is_a?(Integer)\n java.lang.Integer.new(val) # Avoid running into Long vs Int problem\n elsif val.is_a?(Time)\n java.sql.Timestamp.new(val.to_java.time)\n elsif val.is_a?(DateTime)\n java.sql.Timestamp.new(val.to_java.time)\n else\n val\n end\n end\n end",
"def conversion_precision=(_arg0); end",
"def convert_to(time_as_float)\n Duration.create(time_as_float.to_s, '%S.%N')\n end",
"def to_timestamp(time = '00:00')\n DateTime.parse([self, time].join(' ')).to_time.to_i\n end",
"def convert_numeric_strings\n @interval = @interval.to_i if @interval\n @timeout = @timeout.to_i if @timeout\n @maximum_reconnects = @maximum_reconnects.to_i if @maximum_reconnects\n end",
"def type_literal_generic_only_time(column)\n :time\n end",
"def test_formatting_time_according_to_precision_coerced\n skip unless @connection # Avoids arunit2 suite run errors.\n @connection.create_table(:foos, force: true) do |t|\n t.time :start, precision: 0\n t.time :finish, precision: 4\n end\n time = ::Time.utc(2000, 1, 1, 12, 30, 0, 999999)\n Foo.create!(start: time, finish: time)\n assert foo = Foo.find_by(start: time)\n assert_equal 1, Foo.where(finish: time).count\n assert_equal time.to_s, foo.start.to_s\n assert_equal time.to_s, foo.finish.to_s\n assert_equal 000000, foo.start.usec\n assert_equal 999000, foo.finish.usec\n end",
"def timestamp(row)\n row[0].to_f\nend",
"def cast_value\n value.mongoize\n end",
"def time_transformer(time)\n if time < 10\n \"0\" + time.to_s\n else\n time.to_s\n end\nend",
"def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end",
"def normalize_time(time)\n # if the time param is a `Date` / `String` convert it to a `Time` object\n if time.is_a?(Date)\n normalized_time = time.to_time\n elsif time.is_a?(String)\n normalized_time = Time.parse(time)\n else\n normalized_time = time\n end\n\n # convert the `Time` object to a float (if necessary)\n normalized_time = normalized_time.to_f unless normalized_time.is_a?(Numeric)\n\n normalized_time\n end",
"def typecast(value)\n if value.kind_of?(Range) then Range.new(typecast(value.first), typecast(value.last))\n elsif value.kind_of?(Array) then value.map{|v| typecast(v)}\n elsif primitive == BigDecimal then super(value).to_f\n elsif primitive == DateTime then Time.parse(super(value).to_s).to_i\n elsif primitive == Date then Time.parse(super(value).to_s).to_i\n elsif primitive == Time then super(value).to_i\n else\n super(value) # Good luck\n end\n end",
"def convert(value) \n return value.to_formatted_s(:db) if value.respond_to?(:to_formatted_s)\n value.to_s\n end",
"def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend",
"def to_time()\n #This is a stub, used for indexing\n end",
"def cast(value, type)\n case type\n when :string\n value\n when :integer\n value.to_i\n when :float\n value.to_f\n when :percent\n value.to_f\n when :currency\n BigDecimal(value)\n when :time\n value.to_i\n when :date\n parse_date(value)\n end\n end",
"def convert_timestamp(value, capture_definition)\n DateTime.parse(value).strftime('%Y%m%d%H%M%S').to_i unless value.nil?\n end",
"def convert tag, val\n return val unless val.kind_of?(String)\n case tag\n when 'partofset', 'track'\n return val\n end\n case val\n when REGEXP_TIMESTAMP\n year, month, day, hour, minute = $~.captures[0,5].map {|cap| cap.to_i}\n if month == 0 || day == 0\n return nil\n end\n second = $6.to_f\n zone = $7\n zone = '+00:00' if zone == 'Z'\n begin\n Time.new(year, month, day, hour, minute, second, zone)\n rescue ArgumentError\n val\n end\n when REGEXP_RATIONAL\n return val if $2.to_i == 0\n Rational($1, $2)\n else\n val\n end\n end",
"def type_cast(value, type = self.type)\n case type\n when :counter\n type_cast(value, :integer).to_i\n when :integer\n Kernel::Integer(value) rescue nil if value\n when :float\n Kernel::Float(value) rescue nil if value\n when :timestamp\n value = type_cast(value, :integer)\n Time.at(value) if value\n else\n value\n end\n end",
"def time_to_conversion\n converted? ? -1 : 10 - (Time.now.min % 10) # assumes a cron job runs every 10 minutes\n end",
"def to_time\n raise NotImplementedError\n end",
"def type_literal_generic_time(column)\n column[:only_time] ? :time : :datetime\n end",
"def type_cast_code( var_name )\n case type \n when :datetime then \"#{self.class.name}.datetime_to_time(#{var_name})\"\n else\n super\n end\n end",
"def encode_value(value)\n case value\n when Time\n value.to_i\n else\n value\n end\n end",
"def normalize_time(time, debug)\n begin\n time = time if(time.is_a?(Time))\n time = Time.parse(\"#{time.to_s}\") if(!time.is_a?(Time))\n rescue\n time = Time.now # Upon failure use the current time value\n end\n\n return time\nend",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def convert_time time\n proto = Google::Protobuf::Timestamp.new\n proto.from_time(time)\n proto\n end",
"def bind_timestamp(i, value)\n case value\n when Time\n time = value\n else\n begin\n time = Time.parse(value)\n rescue => e\n raise(ArgumentError, \"Cannot parse argument value to time. #{e.message}\")\n end\n end\n\n _bind_timestamp(i, time.year, time.month, time.day, time.hour, time.min, time.sec, time.usec)\n end",
"def quote_value(col)\n case column_detail(col).data_type\n when 'CHAR', 'VARCHAR2', 'CLOB', 'RAW'\n \"'#{@column_values[col]}'\"\n when 'DATE', 'DATETIME'\n \"to_date('#{@column_values[col].strftime('%Y%m%d %H:%M:%S')}', 'YYYYMMDD HH24:MI:SS')\"\n else\n @column_values[col].to_s\n end\n end",
"def typecast_value(column, value)\n return value unless typecast_on_assignment && db_schema && (col_schema = db_schema[column])\n value = nil if '' == value and typecast_empty_string_to_nil and col_schema[:type] and ![:string, :blob].include?(col_schema[:type])\n raise(InvalidValue, \"nil/NULL is not allowed for the #{column} column\") if raise_on_typecast_failure && value.nil? && (col_schema[:allow_null] == false)\n begin\n model.db.typecast_value(col_schema[:type], value)\n rescue InvalidValue\n raise_on_typecast_failure ? raise : value\n end\n end",
"def typecast_value(column, value)\n return value unless typecast_on_assignment && db_schema && (col_schema = db_schema[column])\n value = nil if '' == value and typecast_empty_string_to_nil and col_schema[:type] and ![:string, :blob].include?(col_schema[:type])\n raise(InvalidValue, \"nil/NULL is not allowed for the #{column} column\") if raise_on_typecast_failure && value.nil? && (col_schema[:allow_null] == false)\n begin\n model.db.typecast_value(col_schema[:type], value)\n rescue InvalidValue\n raise_on_typecast_failure ? raise : value\n end\n end",
"def oracle_data_type_conversion(in_var, data_type, data_scale)\n \n case\n when data_type == \"VARCHAR2\"\n if in_var.nil? or in_var.empty?\n in_var = \"\"\n end\n this_in_var = in_var.to_s\n this_data_type = String\n \n when data_type == \"CHAR\"\n if in_var.nil? or in_var.empty?\n in_var = \"\"\n end\n this_in_var = in_var.to_s\n this_data_type = String\n \n when data_type == \"NUMBER\"\n if !data_scale.nil? and data_scale > 0\n \n this_in_var = in_var.to_f\n this_data_type = Float\n else\n this_in_var = in_var.to_i\n this_data_type = Fixnum\n end\n \n when data_type == \"TIMESTAMP\"\n this_in_var = in_var\n this_data_type = DateTime\n \n when data_type == \"DATE\"\n this_in_var = in_var\n this_data_type = DateTime\n \n else nil\n end \n \n return this_in_var, this_data_type \n end",
"def to_timestamp(obj, default = Time.now)\n case obj\n when String then Time.parse(obj)\n when Date then obj.to_time\n when Time then obj\n when Numeric then Time.at(obj)\n else default\n end\n rescue ArgumentError => e\n default\n end",
"def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n return super unless type.to_s == 'integer'\n \n if limit.nil? || limit == 4\n 'integer'\n elsif limit < 4\n 'smallint'\n else\n 'bigint'\n end\n end",
"def adapter_initialize\n @use_iso_date_format = typecast_value_boolean(@opts.fetch(:use_iso_date_format, Postgres.instance_variable_get(:@use_iso_date_format))) # , true)) # SEQUEL5\n initialize_postgres_adapter\n add_conversion_proc(17, method(:unescape_bytea)) if USES_PG\n add_conversion_proc(1082, TYPE_TRANSLATOR.method(:date)) if @use_iso_date_format\n self.convert_infinite_timestamps = @opts[:convert_infinite_timestamps]\n end",
"def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n case type.to_s\n when 'binary'\n # PostgreSQL doesn't support limits on binary (bytea) columns.\n # The hard limit is 1Gb, because of a 32-bit size field, and TOAST.\n case limit\n when nil, 0..0x3fffffff; super(type)\n else raise(ActiveRecordError, \"No binary type has byte size #{limit}.\")\n end\n when 'text'\n # PostgreSQL doesn't support limits on text columns.\n # The hard limit is 1Gb, according to section 8.3 in the manual.\n case limit\n when nil, 0..0x3fffffff; super(type)\n else raise(ActiveRecordError, \"The limit on text can be at most 1GB - 1byte.\")\n end\n when 'integer'\n return 'integer' unless limit\n\n case limit\n when 1, 2; 'smallint'\n when 3, 4; 'integer'\n when 5..8; 'bigint'\n else raise(ActiveRecordError, \"No integer type has byte size #{limit}. Use a numeric with precision 0 instead.\")\n end\n when 'datetime'\n return super unless precision\n\n case precision\n when 0..6; \"timestamp(#{precision})\"\n else raise(ActiveRecordError, \"No timestamp type has precision of #{precision}. The allowed range of precision is from 0 to 6\")\n end\n else\n super\n end\n end",
"def convert_db_time(date)\n \treturn date.strftime(\"%m/%d/%Y | %I:%M %P\")\n end",
"def value_to_uuid(value)\n if value.is_a?(::Cql::Uuid)\n value\n else\n ::Cql::TimeUuid.new(value) rescue nil\n end\n end",
"def timeConversion(s)\n timeArr = s.split(\":\");\n hours = timeArr[0];\n minutes = timeArr[1];\n seconds = timeArr[2][0...-2]\n am_or_pm = timeArr[2][-2..-1]\n\n if am_or_pm == \"PM\" && hours != \"12\"\n hours = (hours.to_i + 12).to_s\n elsif am_or_pm == \"AM\" && hours == \"12\"\n hours = \"00\"\n end\n\n hours + \":\" + minutes + \":\" + seconds\nend",
"def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:\n # MSSQL's NVARCHAR(n | max) column supports either a number between 1 and\n # 4000, or the word \"MAX\", which corresponds to 2**30-1 UCS-2 characters.\n #\n # It does not accept NVARCHAR(1073741823) here, so we have to change it\n # to NVARCHAR(MAX), even though they are logically equivalent.\n #\n # See: http://msdn.microsoft.com/en-us/library/ms186939.aspx\n #\n type = type.to_sym if type\n native = native_database_types[type]\n\n if type == :string && limit == 1_073_741_823\n 'nvarchar(max)'\n elsif NO_LIMIT_TYPES.include?(type)\n super(type)\n elsif %i[int integer].include?(type)\n if limit.nil? || limit == 4\n 'int'\n elsif limit == 2\n 'smallint'\n elsif limit == 1\n 'tinyint'\n else\n 'bigint'\n end\n elsif type == :uniqueidentifier\n 'uniqueidentifier'\n elsif %i[datetime time].include?(type)\n precision ||= 7\n column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup\n if (0..7).include?(precision)\n column_type_sql << \"(#{precision})\"\n else\n raise(\n ArgumentError,\n \"No #{native[:name]} type has precision of #{precision}. The \" \\\n 'allowed range of precision is from 0 to 7, even though the ' \\\n 'sql type precision is 7 this adapter will persist up to 6 ' \\\n 'precision only.'\n )\n end\n else\n super\n end\n end",
"def typecast_to_primitive(value)\n if value.respond_to?(:to_date)\n value.to_date\n elsif value.is_a?(::Hash) || value.respond_to?(:to_mash)\n typecast_hash_to_date(value)\n else\n ::Date.parse(value.to_s)\n end\n rescue ArgumentError\n value\n end",
"def to_timestamp(val)\n return if val.nil?\n\n case val\n when String\n (date = Time.parse(val)) && date.to_i\n when Date\n val.to_time.to_i\n else\n val.to_i\n end\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def revert_postgres_type( type )\n case type\n when /\\Acharacter varying/\n return :String, :default_size => 255\n when /\\Acharacter/\n return :String, :fixed => true, :default_size => 255\n when /\\Atext\\z/\n return :String, :text => true\n when /\\Abytea\\z/\n return :blob\n when /\\Atimestamp/\n return :timestamp\n end\n end",
"def as_val(s)\n if s < 1_000\n s\n elsif s >= 1_000_000_000_000\n (s / 1_000_000_000_000.0).round(1).to_s + 'T'\n elsif s >= 1_000_000_000\n (s / 1_000_000_000.0).round(1).to_s + 'B'\n elsif s >= 1_000_000\n (s / 1_000_000.0).round(1).to_s + 'M'\n elsif s >= 1_000\n (s / 1_000.0).round(1).to_s + 'K'\n end\nend",
"def time_conversion( minutes )\n\n# https://ruby-doc.org/stdlib-2.1.1/libdoc/time/rdoc/Time.html\n#\n# must require 'time' to work\n#\n# t = Time.now\n# puts(t.iso8601)\n# puts(t.rfc2822)\n# puts(t.httpdate)\n#\n# output:\n#\n# 2018-01-18T17:36:58-08:00\n# Thu, 18 Jan 2018 17:36:58 -0800\n# Fri, 19 Jan 2018 01:36:58 GMT\n\n if( minutes < 60 )\n time = minutes.to_s()\n time = \"0:\" + time\n #puts(time)\n return time\n else\n\n hours = minutes / 60\n minutes = minutes % 60 # to get remainning minutes\n\n # puts ( hours )\n # puts( minutes )\n\n time = hours.to_s()\n minutes = minutes.to_s()\n\n if( minutes.length() == 1 )\n minutes += \"0\"\n end\n\n time = time + \":\" + minutes\n\n return time\n end\n\nend",
"def convert_invalid_date_time=(v)\n m0 = ::Sequel.method(:string_to_time)\n @conversion_procs[11] = (v != false) ? lambda{|val| convert_date_time(val, &m0)} : m0\n m1 = ::Sequel.method(:string_to_date) \n m = (v != false) ? lambda{|val| convert_date_time(val, &m1)} : m1\n [10, 14].each{|i| @conversion_procs[i] = m}\n m2 = method(:to_application_timestamp)\n m = (v != false) ? lambda{|val| convert_date_time(val, &m2)} : m2\n [7, 12].each{|i| @conversion_procs[i] = m}\n @convert_invalid_date_time = v\n end",
"def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end",
"def normalize_time\n if time.present?\n Time::DATE_FORMATS[:ms] = \"%M:%S\"\n self.time = \"0:#{time.to_formatted_s(:ms)}\".to_time\n end\n end",
"def typecast_value(column, value)\n return value unless typecast_on_assignment && db_schema && (col_schema = db_schema[column]) && !model.serialized?(column)\n value = nil if value == '' and typecast_empty_string_to_nil and col_schema[:type] and ![:string, :blob].include?(col_schema[:type])\n raise(Error::InvalidValue, \"nil/NULL is not allowed for the #{column} column\") if raise_on_typecast_failure && value.nil? && (col_schema[:allow_null] == false)\n begin\n model.db.typecast_value(col_schema[:type], value)\n rescue Error::InvalidValue\n if raise_on_typecast_failure\n raise\n else\n value\n end\n end\n end",
"def to_sql\n self.to_datetime.to_sql\n \tend",
"def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n return super if defined?(::Jdbc::H2) || type.to_s != 'integer' || limit == nil\n\n type\n end",
"def convertStringToTime(s)\r\n\t$logger.debug { \"convertStringToTime: converting '\" + s + \"'...\" }\r\n\tt = Chronic.parse(s)\r\n\t$logger.debug { \" ... to \" + t.to_s }\r\n\treturn t\r\nend"
] |
[
"0.64404684",
"0.6386962",
"0.61356",
"0.5956805",
"0.592637",
"0.59039587",
"0.58744115",
"0.5859715",
"0.582636",
"0.5805587",
"0.5797189",
"0.57115",
"0.5707423",
"0.57020915",
"0.566127",
"0.55909127",
"0.55830276",
"0.55764776",
"0.5537971",
"0.55216724",
"0.55148417",
"0.550752",
"0.54997915",
"0.5492276",
"0.544665",
"0.5422834",
"0.54205924",
"0.54069567",
"0.53910446",
"0.5388677",
"0.53870916",
"0.5361299",
"0.5351349",
"0.534724",
"0.5328449",
"0.5321288",
"0.5304998",
"0.530372",
"0.5303557",
"0.5299062",
"0.5285316",
"0.5279632",
"0.5279603",
"0.5266617",
"0.5253098",
"0.5252722",
"0.5235286",
"0.5230607",
"0.5227124",
"0.52226037",
"0.5216658",
"0.52120167",
"0.52105355",
"0.5209645",
"0.52059764",
"0.52047396",
"0.52033436",
"0.51984274",
"0.5197824",
"0.51911885",
"0.5189548",
"0.51875013",
"0.51871294",
"0.5186745",
"0.5177619",
"0.5168634",
"0.51581734",
"0.51532966",
"0.51516974",
"0.51283616",
"0.5122479",
"0.5116488",
"0.5115749",
"0.5115749",
"0.51064545",
"0.5086058",
"0.507919",
"0.507919",
"0.50532734",
"0.50385386",
"0.5037392",
"0.5026658",
"0.50241107",
"0.5020401",
"0.5017543",
"0.501688",
"0.5011381",
"0.50048774",
"0.500141",
"0.49973783",
"0.49879104",
"0.49846235",
"0.49781102",
"0.4971603",
"0.49698818",
"0.49696347",
"0.49676704",
"0.49659348",
"0.4964349",
"0.49637213"
] |
0.6654411
|
0
|
Connects to the database. In addition to the standard database options, using the :encoding or :charset option changes the client encoding for the connection, :connect_timeout is a connection timeout in seconds, :sslmode sets whether postgres's sslmode, and :notice_receiver handles server notices in a proc. :connect_timeout, :driver_options, :sslmode, and :notice_receiver are only supported if the pg driver is used.
|
def connect(server)
opts = server_opts(server)
if USES_PG
connection_params = {
:host => opts[:host],
:port => opts[:port] || 5432,
:dbname => opts[:database],
:user => opts[:user],
:password => opts[:password],
:connect_timeout => opts[:connect_timeout] || 20,
:sslmode => opts[:sslmode],
:sslrootcert => opts[:sslrootcert]
}.delete_if { |key, value| blank_object?(value) }
connection_params.merge!(opts[:driver_options]) if opts[:driver_options]
conn = Adapter.connect(connection_params)
conn.instance_variable_set(:@prepared_statements, {})
if receiver = opts[:notice_receiver]
conn.set_notice_receiver(&receiver)
end
else
unless typecast_value_boolean(@opts.fetch(:force_standard_strings, Postgres.instance_variable_get(:@force_standard_strings))) # , true)) # SEQUEL5
raise Error, "Cannot create connection using postgres-pr unless force_standard_strings is set"
end
conn = Adapter.connect(
(opts[:host] unless blank_object?(opts[:host])),
opts[:port] || 5432,
nil, '',
opts[:database],
opts[:user],
opts[:password]
)
end
conn.instance_variable_set(:@db, self)
if encoding = opts[:encoding] || opts[:charset]
if conn.respond_to?(:set_client_encoding)
conn.set_client_encoding(encoding)
else
conn.async_exec("set client_encoding to '#{encoding}'")
end
end
connection_configuration_sqls.each{|sql| conn.execute(sql)}
conn
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def connect\n PG::Connection.new(:host => host, :port => port, :user => user, :password => password, :sslmode => sslmode, :dbname => dbname)\n end",
"def initialize options\n host = options['host'] || 'localhost'\n port = options['port'] || 5432\n database = options['database']\n username = options['username']\n\n # always reuse an existing connection if it matches on these connection options\n conn_options = {:host => host, :port => port, :database => database, :username => username}\n existing_connection = self.class.persisted_connection(conn_options)\n\n if existing_connection.nil?\n # create and persist a new connection\n @connection = PG::Connection.new(\n host,\n port,\n nil,\n nil,\n database,\n username,\n options['password'] || ''\n )\n @connection.set_notice_processor do |msg|\n if msg =~ /^ERROR:/\n LOG.error('psql') { msg.gsub(/\\n/,'; ') }\n else\n LOG.info('psql') { msg.gsub(/\\n/,'; ') }\n end\n end\n self.class.persist_connection(@connection, conn_options)\n else\n # reuse an existing connection\n @connection = existing_connection\n end\n\n # set up trackig if it isn't set up already\n set_up_tracking if !tracking_tables?\n end",
"def connect_to_database(options)\n connection_hash = {:adapter => 'postgres',\n :database => options[:database_name],\n :user => options[:database_user],\n :password => options[:database_password],\n :test => true}\n\n if options[:database_host]\n connection_hash[:host] = options[:database_host]\n end\n\n @connection = Sequel.connect(connection_hash)\n end",
"def _connect_database\n _send_command(\"db_connect #{@options[:db_user]}:#{@options[:db_pass]}@#{@options[:db_host]}/#{@options[:db_name]}\")\n end",
"def connect\n config = @connection_options\n @connection = case config[:mode]\n when :dblib\n appname = config[:appname] || configure_application_name || Rails.application.class.name.split('::').first rescue nil\n login_timeout = config[:login_timeout].present? ? config[:login_timeout].to_i : nil\n timeout = config[:timeout].present? ? config[:timeout].to_i/1000 : nil\n encoding = config[:encoding].present? ? config[:encoding] : nil\n TinyTds::Client.new({\n :dataserver => config[:dataserver],\n :host => config[:host],\n :port => config[:port],\n :username => config[:username],\n :password => config[:password],\n :database => config[:database],\n :appname => appname,\n :login_timeout => login_timeout,\n :timeout => timeout,\n :encoding => encoding,\n :azure => config[:azure]\n }).tap do |client|\n if config[:azure]\n client.execute(\"SET ANSI_NULLS ON\").do\n client.execute(\"SET CURSOR_CLOSE_ON_COMMIT OFF\").do\n client.execute(\"SET ANSI_NULL_DFLT_ON ON\").do\n client.execute(\"SET IMPLICIT_TRANSACTIONS OFF\").do\n client.execute(\"SET ANSI_PADDING ON\").do\n client.execute(\"SET QUOTED_IDENTIFIER ON\")\n client.execute(\"SET ANSI_WARNINGS ON\").do\n else\n client.execute(\"SET ANSI_DEFAULTS ON\").do\n client.execute(\"SET CURSOR_CLOSE_ON_COMMIT OFF\").do\n client.execute(\"SET IMPLICIT_TRANSACTIONS OFF\").do\n end\n client.execute(\"SET TEXTSIZE 2147483647\").do\n end\n when :odbc\n if config[:dsn].include?(';')\n driver = ODBC::Driver.new.tap do |d|\n d.name = config[:dsn_name] || 'Driver1'\n d.attrs = config[:dsn].split(';').map{ |atr| atr.split('=') }.reject{ |kv| kv.size != 2 }.inject({}){ |h,kv| k,v = kv ; h[k] = v ; h }\n end\n ODBC::Database.new.drvconnect(driver)\n else\n ODBC.connect config[:dsn], config[:username], config[:password]\n end.tap do |c|\n begin\n c.use_time = true\n c.use_utc = ActiveRecord::Base.default_timezone == :utc\n rescue Exception => e\n warn \"Ruby ODBC v0.99992 or higher is required.\"\n end\n end\n end\n @spid = _raw_select('SELECT @@SPID', fetch: :rows).first.first\n configure_connection\n rescue\n raise unless @auto_connecting\n end",
"def db_connect\n @dbh and db_close\n puts \"DEBUG: Opening DB\" if $DEBUG\n @dbh = DBI.connect(\"dbi:Pg:#{@database[:database]}:#{@database[:host]}\",\n @database[:user],\n @database[:password])\n end",
"def db_connect\n @dbh and db_close\n puts \"DEBUG: Opening DB\" if $DEBUG\n @dbh = DBI.connect(\"dbi:Pg:#{@database[:database]}:#{@database[:host]}\",\n @database[:user],\n @database[:password])\n end",
"def connect_to_database\n # If no input parameters are defined then read the database params\n # from the command line or the default ones\n unless @db_params then self.database_params= DB_PARAMS end\n\n PGconn.connect( @db_params[:host],\n @db_params[:port],\n @db_params[:options],\n @db_params[:tty],\n @db_params[:dbname],\n @db_params[:login],\n @db_params[:password] )\n end",
"def conn\n config = YAML.load_file('db/pg_config.yml')[Rails.env]\n PG.connect(host: config['host'], port: 5432, dbname: config['dbname'],\n user: config['user'], password: config['password'])\n end",
"def establish_connection(database_url_or_options = {}, options = {})\n\n case database_url_or_options\n when String\n uri = URI.parse(database_url_or_options)\n @table_name = options.fetch(:table_name, \"application_cache\").freeze\n @pg = PG::Connection.new(\n host: uri.host,\n port: uri.port,\n user: uri.user,\n password: uri.password,\n dbname: uri.path.tr(\"/\",\"\"),\n sslmode: \"prefer\",\n )\n else\n @table_name = database_url_or_options.fetch(:table_name, \"application_cache\").freeze\n @pg = PG::Connection.new(\n host: database_url_or_options[:host],\n port: database_url_or_options[:port],\n user: database_url_or_options[:username],\n password: database_url_or_options[:password],\n dbname: database_url_or_options[:database],\n sslmode: \"prefer\",\n )\n end\n\n end",
"def connect\n PG::Connection.new(:host => host, :port => port, :user => user, :password => password, :dbname => dbname)\n end",
"def connect_database\n logger.debug \"Connecting to database(#{@config.persist_username}#{@config.persist_host}:#{@config.persist_port}) with timeout(#{@config.persist_timeout})\"\n @database.connect(@config.persist_host, @config.persist_port, @config.persist_username, @config.persist_password, @config.persist_timeout)\n end",
"def connect(opts={})\n\n\t\treturn false if not @usable\n\n\t\tnopts = opts.dup\n\t\tif (nopts['port'])\n\t\t\tnopts['port'] = nopts['port'].to_i\n\t\tend\n\n\t\tnopts['pool'] = 256\n\n\t\tbegin\n\t\t\tcreate_db(nopts)\n\n\t\t\t# Configure the database adapter\n\t\t\tActiveRecord::Base.establish_connection(nopts)\n\n\t\t\t# Migrate the database, if needed\n\t\t\tmigrate\n\n\t\t\t# Set the default workspace\n\t\t\tframework.db.workspace = framework.db.default_workspace\n\t\trescue ::Exception => e\n\t\t\tself.error = e\n\t\t\telog(\"DB.connect threw an exception: #{e}\")\n\t\t\tdlog(\"Call stack: #{$@.join\"\\n\"}\", LEV_1)\n\t\t\treturn false\n\t\tensure\n\t\t\t# Database drivers can reset our KCODE, do not let them\n\t\t\t$KCODE = 'NONE' if RUBY_VERSION =~ /^1\\.8\\./\n\t\tend\n\n\tend",
"def connect\n @connection = ::NB::DB::PooledDBConnection.new(@connection_parameters[0]) do\n conn = ::NB::DB::FiberedPostgresConnection.connect(*@connection_parameters[1..(@connection_parameters.length-1)])\n=begin\n ::NB::DB::FiberedPostgresConnection.translate_results = false if ::NB::DB::FiberedPostgresConnection.respond_to?(:translate_results=)\n # Ignore async_exec and async_query when using postgres-pr.\n @async = @config[:allow_concurrency] && @connection.respond_to?(:async_exec)\n # Use escape string syntax if available. We cannot do this lazily when encountering\n # the first string, because that could then break any transactions in progress.\n # See: http://www.postgresql.org/docs/current/static/runtime-config-compatible.html\n # If PostgreSQL doesn't know the standard_conforming_strings parameter then it doesn't\n # support escape string syntax. Don't override the inherited quoted_string_prefix.\n NB.neverblock(false) do\n if supports_standard_conforming_strings?\n self.class.instance_eval do\n define_method(:quoted_string_prefix) { 'E' }\n end\n end\n # Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of\n # PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision\n # should know about this but can't detect it there, so deal with it here.\n money_precision = (postgresql_version >= 80300) ? 19 : 10\n ::ActiveRecord::ConnectionAdapters::PostgreSQLColumn.module_eval(<<-end_eval)\n def extract_precision(sql_type)\n if sql_type =~ /^money$/\n #{money_precision}\n else\n super\n end\n end\n end_eval\n #configure_connection\n end\n\t conn\n=end\n end\n end",
"def connect(username=DEFAULT_USERNAME, password=DEFAULT_PASSWORD, lang=DEFAULT_LANG, host=DEFAULT_HOST, port=DEFAULT_PORT, db_name=DEFAULT_DATABASE, auth_type=DEFAULT_AUTHTYPE)\n # TODO: handle pools of connections\n \n @username = username\n @password = password\n @lang = lang\n @host = host\n @port = port\n @db_name = db_name\n @auth_type = auth_type\n \n @connection = MonetDBConnection.new(user = @username, passwd = @password, lang = @lang, host = @host, port = @port)\n @connection.connect(@db_name, @auth_type)\n end",
"def db_connect\n dsn = sequel_dsn\n\n is_postgres = dsn.start_with?('postgres') ||\n dsn.start_with?('jdbc:postgres')\n\n is_jruby = RUBY_PLATFORM =~ /java/\n\n if is_postgres\n Sequel.extension :pg_array_ops\n Sequel::Database.extension :pg_array\n Sequel::Database.extension :pg_hstore\n Sequel::Database.extension :pg_json\n Sequel::Database.extension :pg_inet\n\n unless is_jruby\n Sequel::Database.extension :pg_streaming\n end\n end\n\n Sequel.connect(dsn)\n end",
"def db_connect_postgresql(*args)\n\t\t\tif(args[0] == nil or args[0] == \"-h\" or args[0] == \"--help\")\n\t\t\t\tprint_status(\" Usage: db_connect <user:pass>@<host:port>/<database>\")\n\t\t\t\tprint_status(\"Examples:\")\n\t\t\t\tprint_status(\" db_connect user@metasploit3\")\n\t\t\t\tprint_status(\" db_connect user:pass@192.168.0.2/metasploit3\")\n\t\t\t\tprint_status(\" db_connect user:pass@192.168.0.2:1500/metasploit3\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tinfo = db_parse_db_uri_postgresql(args[0])\n\t\t\topts = { 'adapter' => 'postgresql' }\n\n\t\t\topts['username'] = info[:user] if (info[:user])\n\t\t\topts['password'] = info[:pass] if (info[:pass])\n\t\t\topts['database'] = info[:name]\n\t\t\topts['host'] = info[:host] if (info[:host])\n\t\t\topts['port'] = info[:port] if (info[:port])\n\n\t\t\topts['pass'] ||= ''\n\n\t\t\t# Do a little legwork to find the real database socket\n\t\t\tif(! opts['host'])\n\t\t\t\twhile(true)\n\t\t\t\t\tdone = false\n\t\t\t\t\tdirs = %W{ /var/run/postgresql /tmp }\n\t\t\t\t\tdirs.each do |dir|\n\t\t\t\t\t\tif(::File.directory?(dir))\n\t\t\t\t\t\t\td = ::Dir.new(dir)\n\t\t\t\t\t\t\td.entries.grep(/^\\.s\\.PGSQL.(\\d+)$/).each do |ent|\n\t\t\t\t\t\t\t\topts['port'] = ent.split('.')[-1].to_i\n\t\t\t\t\t\t\t\topts['host'] = dir\n\t\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tbreak if done\n\t\t\t\t\tend\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Default to loopback\n\t\t\tif(! opts['host'])\n\t\t\t\topts['host'] = '127.0.0.1'\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\t\tend",
"def connect(username=DEFAULT_USERNAME, password=DEFAULT_PASSWORD, lang=DEFAULT_LANG, host=DEFAULT_HOST, port=DEFAULT_PORT, db_name=DEFAULT_DATABASE, auth_type=DEFAULT_AUTHTYPE)\n\t\t# TODO: handle pools of connections\n\n\t\t@username = username\n\t\t@password = password\n\t\t@lang = lang\n\t\t@host = host\n\t\t@port = port\n\t\t@db_name = db_name\n\t\t@auth_type = auth_type\n\n\t\t@connection = MonetDBConnection.new(user = @username, passwd = @password, lang = @lang, host = @host, port = @port)\n\t\t@connection.connect(@db_name, @auth_type)\n\tend",
"def activerecord_connect\n Sequel.connect(\n adapter: activerecord_config.fetch(\"adapter\"),\n database: activerecord_config.fetch(\"database\"),\n )\n end",
"def connect()\r\n begin\r\n raise InvalidOperationException, 'connection is already open' unless @conn.nil?\r\n load_driver\r\n uri =\r\n if @host.nil?\r\n nil\r\n elsif running_on_windows\r\n \"tcp://#{ @host }:#{ @port }\"\r\n else\r\n \"tcp://#{ @host }:#{ @port }\"\r\n #\"unix:#{ @host }/.s.PGSQL.#{ @port }\"\r\n end\r\n @conn = PostgresPR::Connection.new( @catalog, @user, @pass, uri ) \r\n rescue Exception => ex\r\n on_connect_error( ex, self )\r\n end\r\n end",
"def connect_database\n options_file = @config.persist_options_file\n logger.debug \"Loading options from file '#{$config_file_path}/#{options_file}'\"\n # if a persist_options_file parameter was included in the server configuration,\n # then load it (as YAML) into the 'options' Hash map\n options = {}\n if options_file && !(options_file.empty?)\n full_path_to_file = \"#{$app_root}/config/#{options_file}\"\n raise RuntimeError.new \"Options file '#{full_path_to_file}' from server configuration does not exist\" unless File.file?(full_path_to_file)\n begin\n options = YAML::load(File.open(full_path_to_file))\n rescue Error => e\n raise RuntimeError.new \"Failed to load options file (#{e.class}): #{e.message}\"\n end\n raise RuntimeError.new \"Options file '#{full_path_to_file}' from server configuration is not a YAML file\" unless options.class == Hash\n end\n # now, check for any \"old-style\" configuration parameters, and merge them\n # with any options that may have been read from an options file (above).\n # Note that values specified in an options file (read above) will override\n # the \"old-style\" options read here\n if @config.persist_mode == :cassandra\n options = { 'hosts' => @config.persist_host, 'username' => @config.persist_username,\n 'password' => @config.persist_password, 'port' => @config.persist_port,\n 'timeout' => @config.persist_timeout, 'keyspace' => @config.persist_dbname}.merge(options)\n elsif [:mongo, :postgres].include?(@config.persist_mode)\n options = { 'host' => @config.persist_host, 'username' => @config.persist_username,\n 'password' => @config.persist_password, 'port' => @config.persist_port,\n 'timeout' => @config.persist_timeout, 'dbname' => @config.persist_dbname}.merge(options)\n end\n @database.connect(options)\n end",
"def connection\n PG.connect(\n dbname: @dbname, host: @host, port: @port,\n user: @user, password: @password\n )\n end",
"def configure_connection\n #if encoding = config[:encoding]\n # The client_encoding setting is set by the driver and should not be altered.\n # If the driver detects a change it will abort the connection.\n # see http://jdbc.postgresql.org/documentation/91/connect.html\n # self.set_client_encoding(encoding)\n #end\n self.client_min_messages = config[:min_messages] || 'warning'\n self.schema_search_path = config[:schema_search_path] || config[:schema_order]\n\n # Use standard-conforming strings if available so we don't have to do the E'...' dance.\n set_standard_conforming_strings\n\n # If using Active Record's time zone support configure the connection to return\n # TIMESTAMP WITH ZONE types in UTC.\n # (SET TIME ZONE does not use an equals sign like other SET variables)\n if ActiveRecord::Base.default_timezone == :utc\n execute(\"SET time zone 'UTC'\", 'SCHEMA')\n elsif tz = local_tz\n execute(\"SET time zone '#{tz}'\", 'SCHEMA')\n end unless redshift?\n\n # SET statements from :variables config hash\n # http://www.postgresql.org/docs/8.3/static/sql-set.html\n (config[:variables] || {}).map do |k, v|\n if v == ':default' || v == :default\n # Sets the value to the global or compile default\n execute(\"SET SESSION #{k} TO DEFAULT\", 'SCHEMA')\n elsif ! v.nil?\n execute(\"SET SESSION #{k} TO #{quote(v)}\", 'SCHEMA')\n end\n end\n end",
"def configure_connection\n #if encoding = config[:encoding]\n # The client_encoding setting is set by the driver and should not be altered.\n # If the driver detects a change it will abort the connection.\n # see http://jdbc.postgresql.org/documentation/91/connect.html\n # self.set_client_encoding(encoding)\n #end\n self.client_min_messages = config[:min_messages] || 'warning'\n self.schema_search_path = config[:schema_search_path] || config[:schema_order]\n\n # Use standard-conforming strings if available so we don't have to do the E'...' dance.\n set_standard_conforming_strings\n\n # If using Active Record's time zone support configure the connection to return\n # TIMESTAMP WITH ZONE types in UTC.\n # (SET TIME ZONE does not use an equals sign like other SET variables)\n if ActiveRecord::Base.default_timezone == :utc\n execute(\"SET time zone 'UTC'\", 'SCHEMA')\n elsif tz = local_tz\n execute(\"SET time zone '#{tz}'\", 'SCHEMA')\n end unless redshift?\n\n # SET statements from :variables config hash\n # http://www.postgresql.org/docs/8.3/static/sql-set.html\n (config[:variables] || {}).map do |k, v|\n if v == ':default' || v == :default\n # Sets the value to the global or compile default\n execute(\"SET SESSION #{k} TO DEFAULT\", 'SCHEMA')\n elsif ! v.nil?\n execute(\"SET SESSION #{k} TO #{quote(v)}\", 'SCHEMA')\n end\n end\n end",
"def initialize(options = {})\n reset_values\n\n @options = {}\n options.each { |key, value| @options[key.to_s.to_sym] = value }\n @options[:port] ||= 5433\n\n @row_style = @options[:row_style] ? @options[:row_style] : :hash\n unless options[:skip_startup]\n startup_connection\n initialize_connection\n end\n end",
"def connect( *args )\n return PG::Connection.new( *args )\n end",
"def connect\n Alf::Tools::friendly_require('sequel')\n @db ||= ::Sequel.connect(@uri, @options)\n end",
"def connect(options = {})\n return @pool = options[:pool] if options[:pool]\n options = options.dup\n timeout = options.delete(:timeout) || 5\n pool_size = options.delete(:pool_size) || 1\n @pool = Squirm::Pool.new(timeout)\n pool_size.times do\n conn = PG::Connection.open(options)\n yield conn if block_given?\n @pool.checkin conn\n end\n end",
"def connect\n @conn = PG.connect(\n :dbname => 'HackerNewsAppDB1',\n :user => 'paul',\n :password => 'password')\n end",
"def initialize(db, opts)\n connect_opts = {\n :host => opts[:host] || 'localhost',\n :port => opts[:port] || 15432,\n :dbname => opts[:database],\n :user => opts[:user],\n :password => opts[:password],\n :hostaddr => opts[:hostaddr],\n :connect_timeout => opts[:connect_timeout] || 20,\n :sslmode => opts[:sslmode]\n }.delete_if{|key, value| value.nil? or (value.respond_to?(:empty?) and value.empty?)}\n\tsuper(connect_opts)\n\n @db = db\n @prepared_statements = {}\n\n if opts[:notice_receiver]\n set_notice_receiver(opts[:notice_receiver])\n else\n # Swallow warnings\n set_notice_receiver{|proc| }\n end\n end",
"def makeDBConnection()\n\n if ( !@db_conn.nil? && @db_conn.status == PGconn::CONNECTION_OK)\n return\n end\n\n # trying anyway to release the connection just in case\n closeDBConn()\n\n begin\n @db_conn = PGconn.open(\n :host => @db_conf['host'],\n :port => @db_conf['port'],\n :options => @db_conf['options'],\n :tty => @db_conf['tty'],\n :dbname => @db_conf['dbname'],\n :user => @db_conf['user'],\n :password => @db_conf['password']\n )\n\n @db_conn.prepare(\"mypreparedinsert\", @db_conf['queryinsert'])\n # @db_conn.prepare(\"mypreparedupdate\", @db_conf['queryupdate'])\n\n rescue PGError => e\n $stderr.puts \"ERROR: while connecting to Postgres server, class: #{e.class.name}, message: #{e.message}\"\n\n if @byebye\n return nil\n end\n\n $stderr.puts \"Sleep #{@db_conf['sleep']} seconds and retry\"\n slept = sleep @db_conf['sleep']\n $stderr.puts \"Slept #{slept} seconds\"\n retry\n end\n\n return\n end",
"def connect(*args)\n @@connection = FluidDB::Connection.new(*args)\n end",
"def connect(server)\n opts = server_opts(server)\n\n if !RUBY_MYSQL_3\n conn = Mysql.init\n conn.options(Mysql::READ_DEFAULT_GROUP, opts[:config_default_group] || \"client\")\n conn.options(Mysql::OPT_LOCAL_INFILE, opts[:config_local_infile]) if opts.has_key?(:config_local_infile)\n if encoding = opts[:encoding] || opts[:charset]\n # Set encoding before connecting so that the mysql driver knows what\n # encoding we want to use, but this can be overridden by READ_DEFAULT_GROUP.\n conn.options(Mysql::SET_CHARSET_NAME, encoding)\n end\n if read_timeout = opts[:read_timeout] and defined? Mysql::OPT_READ_TIMEOUT\n conn.options(Mysql::OPT_READ_TIMEOUT, read_timeout)\n end\n if connect_timeout = opts[:connect_timeout] and defined? Mysql::OPT_CONNECT_TIMEOUT\n conn.options(Mysql::OPT_CONNECT_TIMEOUT, connect_timeout)\n end\n else\n # ruby-mysql 3+ API\n conn = Adapter.new\n # no support for default group\n conn.local_infile = opts[:config_local_infile] if opts.has_key?(:config_local_infile)\n if encoding = opts[:encoding] || opts[:charset]\n conn.charset = encoding\n end\n if read_timeout = opts[:read_timeout]\n conn.read_timeout = read_timeout\n end\n if connect_timeout = opts[:connect_timeout]\n conn.connect_timeout = connect_timeout\n end\n opts[:compress] = false\n end\n\n conn.ssl_set(opts[:sslkey], opts[:sslcert], opts[:sslca], opts[:sslcapath], opts[:sslcipher]) if opts[:sslca] || opts[:sslkey]\n conn.real_connect(\n opts[:host] || 'localhost',\n opts[:user],\n opts[:password],\n opts[:database],\n (opts[:port].to_i if opts[:port]),\n opts[:socket],\n Mysql::CLIENT_MULTI_RESULTS +\n Mysql::CLIENT_MULTI_STATEMENTS +\n (opts[:compress] == false ? 0 : Mysql::CLIENT_COMPRESS)\n )\n sqls = mysql_connection_setting_sqls\n\n # Set encoding a slightly different way after connecting,\n # in case the READ_DEFAULT_GROUP overrode the provided encoding.\n # Doesn't work across implicit reconnects, but Sequel doesn't turn on\n # that feature.\n sqls.unshift(\"SET NAMES #{literal(encoding.to_s)}\") if encoding\n\n sqls.each{|sql| log_connection_yield(sql, conn){conn.query(sql)}}\n\n add_prepared_statements_cache(conn)\n conn\n end",
"def db_connect\n database_connect_options = @options['database']\n db_connector = DatabaseConnector.new(database_connect_options)\n return db_connector.client\n end",
"def connect_to_db(db='thesis')\n ActiveRecord::Base.establish_connection(\n :adapter => \"postgresql\",\n :host => \"localhost\",\n :username => \"thesis\",\n :password => \"thesis\",\n :database => db.to_s,\n :encoding => \"utf8\"\n )\nend",
"def connect\n @connection = Vertica::Connection.new(@config)\n Vertica.translate_results = false if Vertica.respond_to?(:translate_results=)\n\n # Ignore async_exec and async_query when using postgres-pr.\n @async = @config[:allow_concurrency] && @connection.respond_to?(:async_exec)\n\n # All vertica money columns have precision 18\n VerticaColumn.money_precision = 18\n\n configure_connection\n end",
"def setup_connection(conn)\n conn = super(conn)\n conn.extend(Sequel::Swift::Postgres::AdapterMethods)\n conn.db = self\n conn.apply_connection_settings\n conn\n end",
"def get_db_connection\n config = read_database_config\n if config.dig(:adapter) == 'postgresql'\n config[:user] = config.delete(:username) if config[:username]\n config[:dbname] = config.delete(:database) if config[:database]\n config.delete(:adapter)\n valid_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]\n config.slice!(*valid_param_keys)\n @db ||= PG::Connection.new(config)\n elsif config.dig(:adapter) == 'mysql2'\n @db ||= Mysql2::Client.new(config)\n else\n @db ||= SQLite3::Database.open(\"spectacles-#{Rails.env}.db\")\n end\n end",
"def connect_local\n ActiveRecord::Base.establish_connection(\n :adapter => 'postgresql',\n :encoding => 'unicode',\n :database => ENV['DB_NAME'], # accessmon\n :username => ENV['DB_USERNAME'], # accessmon\n :password => ENV['DB_PASSWORD'],\n :pool => POOL_COUNT,\n :port => PORT_NUMBER,\n :host => 'localhost')\n end",
"def new_connection(params)\n Pod4.logger.info(__FILE__){ \"Connecting to DB\" }\n client = TinyTds::Client.new(params)\n raise \"Bad Connection\" unless client.active?\n\n client.execute(\"use [#{self.class.db}]\").do\n\n client\n\n rescue => e\n handle_error(e)\n end",
"def connect(dbname, user, auth, attr)\n connection = factory.create_connection\n connection.connection_string = dbname\n connection.open\n return create_database(connection, attr);\n rescue RuntimeError, System::Data::SqlClient::SqlException => err\n raise DBI::DatabaseError.new(err.message)\n end",
"def conn\n @conn ||=\n begin\n if @@require_pg\n require 'pg'\n @@require_pg = false\n end\n initialize_copy nil\n c = PG.connect(arguments)\n @conn_owned = true if c\n c\n end\n end",
"def connect_db_method\n begin\n self.con = PG.connect :dbname => self.dbname, :user => self.username, :password => self.password\n return true\n rescue PG::Error => e\n puts e.message\n puts \"Sorry Connection cannot be established\"\n # => Forceful exit from the program\n Kernel.exit(0)\n end\n end",
"def open_connection\n if @sslca then\n @db = Mysql2::Client.new(\n host: @host, \n username: @username, \n password: @password, \n port: @port, \n database: @database_name,\n sslca: @sslca)\n else\n @db = Mysql2::Client.new(\n host: @host, \n username: @username, \n password: @password, \n port: @port, \n database: @database_name)\n end\n end",
"def connect\n if (@type == \"db2\")\n @config\n Models::Databases::SiteDatabase::Base.setup_connection(@config)\n elsif (@type == \"bops\")\n @config\n Models::Databases::Bops::Base.setup_connection(@config)\n else\n Models::Databases::Dyces::Base.setup_connection(@config)\n end\n\n @connection = @type\n\n Log.instance.debug \"Connected to #@db_url\"\n self\n end",
"def configure_connection\n if @config[:encoding]\n @connection.set_client_encoding(@config[:encoding])\n end\n self.client_min_messages = @config[:min_messages] || \"warning\"\n self.schema_search_path = @config[:schema_search_path] || @config[:schema_order]\n\n # Use standard-conforming strings so we don't have to do the E'...' dance.\n set_standard_conforming_strings\n\n variables = @config.fetch(:variables, {}).stringify_keys\n\n # If using Active Record's time zone support configure the connection to return\n # TIMESTAMP WITH ZONE types in UTC.\n unless variables[\"timezone\"]\n if ActiveRecord.default_timezone == :utc\n variables[\"timezone\"] = \"UTC\"\n elsif @local_tz\n variables[\"timezone\"] = @local_tz\n end\n end\n\n # NOTE(joey): This is a workaround as CockroachDB 1.1.x\n # supports SET TIME ZONE <...> and SET \"time zone\" = <...> but\n # not SET timezone = <...>.\n if variables.key?(\"timezone\")\n tz = variables.delete(\"timezone\")\n execute(\"SET TIME ZONE #{quote(tz)}\", \"SCHEMA\")\n end\n\n # SET statements from :variables config hash\n # https://www.postgresql.org/docs/current/static/sql-set.html\n variables.map do |k, v|\n if v == \":default\" || v == :default\n # Sets the value to the global or compile default\n\n # NOTE(joey): I am not sure if simply commenting this out\n # is technically correct.\n # execute(\"SET #{k} = DEFAULT\", \"SCHEMA\")\n elsif !v.nil?\n execute(\"SET SESSION #{k} = #{quote(v)}\", \"SCHEMA\")\n end\n end\n end",
"def initialize(host: nil, port: 5433, username: nil, password: nil, database: nil, interruptable: false, ssl: false, read_timeout: 600, debug: false, role: nil, search_path: nil, timezone: nil, autocommit: false, skip_startup: false, skip_initialize: false, user: nil)\n reset_state\n @notice_handler = nil\n\n @options = {\n host: host,\n port: port.to_i,\n username: username || user,\n password: password,\n database: database,\n debug: debug,\n ssl: ssl,\n interruptable: interruptable,\n read_timeout: read_timeout,\n role: role,\n search_path: search_path,\n timezone: timezone,\n autocommit: autocommit,\n }\n\n boot_connection(skip_initialize: skip_initialize) unless skip_startup\n end",
"def connection_options\n opts = {}\n\n if @wtimeout\n warn \"Using wtimeout in a URI is deprecated, please use wtimeoutMS. It will be removed in v2.0.\"\n opts[:wtimeout] = @wtimeout\n end\n opts[:wtimeout] = @wtimeoutms if @wtimeoutms\n\n opts[:w] = 1 if @safe\n opts[:w] = @w if @w\n opts[:j] = @journal if @journal\n opts[:fsync] = @fsync if @fsync\n\n opts[:connect_timeout] = @connecttimeoutms if @connecttimeoutms\n opts[:op_timeout] = @sockettimeoutms if @sockettimeoutms\n opts[:pool_size] = @pool_size if @pool_size\n opts[:read] = @readpreference if @readpreference\n\n if @slaveok && !@readpreference\n unless replicaset?\n opts[:slave_ok] = true\n else\n opts[:read] = :secondary_preferred\n end\n end\n\n if replicaset.is_a?(String)\n opts[:name] = replicaset\n end\n\n opts[:db_name] = @db_name if @db_name\n opts[:auths] = @auths if @auths\n opts[:ssl] = @ssl if @ssl\n opts[:connect] = connect?\n\n opts\n end",
"def reconnect\n if @connection != nil\n self.close\n \n @connection = MonetDBConnection.new(user = @username, passwd = @password, lang = @lang, host = @host, port = @port)\n @connection.connect(db_name = @db_name, auth_type = @auth_type)\n end\n end",
"def conn\n unless @conn\n # open the database config file\n db_config = YAML.load(ERB.new(File.read(\"config/ourstage_database.yml\")).result )\n database = db_config[environment]['database']\n @conn = EventMachine::Postgres.new(:database => database)\n @conn.setnonblocking(true) # may not be needed? \n end\n @conn\n end",
"def connect\n @db = Sequel.mysql(@database,\n :user => @db_user,\n :password => @db_password,\n :host => @host,\n :encoding => 'utf8')\n end",
"def connect_database\n\n\t\t@db = Redis.new\n\n\t\t@db = Redis.connect(\n\t\t\t:db => \"#{Settings.redis.db}\",\n\t\t\t:host => \"#{Settings.redis.host}\",\n\t\t\t:port => Settings.redis.port,\n\t\t\t:password => Settings.redis.password\n\t\t)\n\t\t\n\tend",
"def connect\n url = ENV['CIDB_DATABASE_URL']\n fatal! 'CIDB_DATABASE_URL not set' if url.nil? || url.empty?\n\n CIDB.connect\n rescue NoMethodError\n fatal! 'CIDB_DATABASE_URL malformed, no adapter name'\n rescue Sequel::Error => err\n fatal! \"Database connection failed (#{err.class}): #{err}\"\n end",
"def configure_connection\n if @config[:encoding]\n @connection.set_client_encoding(@config[:encoding])\n end\n # self.client_min_messages = @config[:min_messages] || 'warning'\n self.schema_search_path = @config[:schema_search_path] || @config[:schema_order]\n\n # Use standard-conforming strings so we don't have to do the E'...' dance.\n # set_standard_conforming_strings\n\n # If using Active Record's time zone support configure the connection to return\n # TIMESTAMP WITH ZONE types in UTC.\n # (SET TIME ZONE does not use an equals sign like other SET variables)\n # if ActiveRecord::Base.default_timezone == :utc\n # execute(\"SET time zone 'UTC'\", 'SCHEMA')\n # elsif @local_tz\n # execute(\"SET time zone '#{@local_tz}'\", 'SCHEMA')\n # end\n\n # SET statements from :variables config hash\n # http://www.postgresql.org/docs/8.3/static/sql-set.html\n variables = @config[:variables] || {}\n variables.map do |k, v|\n if v == ':default' || v == :default\n # Sets the value to the global or compile default\n execute(\"SET SESSION #{k} TO DEFAULT\", 'SCHEMA')\n elsif !v.nil?\n execute(\"SET SESSION #{k} TO #{quote(v)}\", 'SCHEMA')\n end\n end\n end",
"def postgres_ssl_connection(ip)\n FileUtils.chmod 0600, %w(ssl/client.crt ssl/client.key ssl/root.crt)\n\n PG::Connection.new(\n host: ip,\n user: DB_USER,\n dbname: DB_NAME,\n port: DB_PORT,\n password: DB_PASSWORD,\n sslmode: \"require\",\n sslcert: \"ssl/client.crt\",\n sslkey: \"ssl/client.key\",\n sslrootcert: \"ssl/root.crt\",\n connect_timeout: \"1\",\n )\nend",
"def connect(server)\n opts = server_opts(server)\n opts[:database] = ':memory:' if blank_object?(opts[:database])\n db = ::Amalgalite::Database.new(opts[:database])\n db.busy_handler(::Amalgalite::BusyTimeout.new(opts.fetch(:timeout, 5000)/50, 50))\n db.type_map = SequelTypeMap.new(self)\n connection_pragmas.each{|s| log_connection_yield(s, db){db.execute_batch(s)}}\n db\n end",
"def postgres_plain_connection(ip)\n PG::Connection.new(\n host: ip,\n user: DB_USER,\n dbname: DB_NAME,\n port: DB_PORT,\n password: DB_PASSWORD,\n connect_timeout: \"1\",\n )\nend",
"def connect(server)\n opts = server_opts(server)\n\n connection_params = if opts[:host].nil? && opts[:port].nil? && opts[:database]\n # use a cataloged connection\n opts.values_at(:database, :user, :password)\n else\n # use uncataloged connection so that host and port can be supported\n 'Driver={IBM DB2 ODBC DRIVER};' \\\n \"Database=#{opts[:database]};\" \\\n \"Hostname=#{opts[:host]};\" \\\n \"Port=#{opts[:port] || 50000};\" \\\n 'Protocol=TCPIP;' \\\n \"Uid=#{opts[:user]};\" \\\n \"Pwd=#{opts[:password]};\" \\\n end \n\n Connection.new(connection_params)\n end",
"def connect\n return unless configuration\n @database = @@connections[name][db_name]\n return true if connected?\n\n begin\n @database = case name\n when \"mongodb\" then MongoDB.new(credentials)\n when \"postgresql\" then Postgres.new(credentials)\n when /^mysql(2)?$/ then Mysql.new(credentials)\n when /^sqlite(2|3)?$/ then Sqlite.new(sqlite_credentials)\n when \"rethinkdb\" then Labrador::RethinkDB.new(credentials)\n else\n add_error(I18n.t('adapters.unsupported_adapter', adapter: name))\n nil\n end\n rescue Exception => e\n add_error(e.to_s)\n end\n\n @@connections[name][db_name] = @database\n end",
"def establish_postgres_connection(name = 'default')\n if database_config[name]\n ActiveRecord::Base.establish_connection(database_config[name][env].merge('database' => 'postgres',\n 'schema_search_path' => 'public'))\n end\n end",
"def configure_connection\n if @config[:encoding]\n if @connection.respond_to?(:set_client_encoding)\n @connection.set_client_encoding(@config[:encoding])\n else\n execute(\"SET client_encoding TO '#{@config[:encoding]}'\")\n end\n end\n self.schema_search_path = @config[:schema_search_path] || @config[:schema_order]\n\n # Use standard-conforming strings if available so we don't have to do the E'...' dance.\n set_standard_conforming_strings\n\n # If using Active Record's time zone support configure the connection to return\n # TIMESTAMP WITH ZONE types in UTC.\n if ActiveRecord::Base.default_timezone == :utc\n execute(\"SET time zone 'UTC'\")\n elsif @local_tz\n execute(\"SET time zone '#{@local_tz}'\")\n end\n end",
"def establish_master_connection\n establish_connection(configuration.merge(\n \"database\" => \"postgres\",\n \"password\" => su_password,\n \"schema_search_path\" => \"public\",\n \"username\" => su_username\n ))\n end",
"def database_params= params\n # Checks the presence of the postgres extension\n begin\n require 'postgres'\n rescue LoadError\n @db_params = nil\n raise\n end\n\n begin\n #check if database connection works\n conn = PGconn.connect( params[:host],\n params[:port],\n params[:options],\n params[:tty],\n params[:dbname],\n params[:login],\n params[:password] )\n conn.close\n rescue PGError\n @db_params = nil\n raise\n end\n\n # If everything went ok, assigns the parameters\n @db_params = params\n return true\n end",
"def connect_remote\n #ENV['DATABASE_URL'] ||= \"postgres://glue.pumpingstationone.org/?pool=5\"\n #ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])\n ActiveRecord::Base.establish_connection(\n :adapter => 'postgresql',\n :encoding => 'unicode',\n :database => ENV['DB_NAME'], # accessmon\n :username => ENV['DB_USERNAME'], # accessmon\n :password => ENV['DB_PASSWORD'],\n :pool => POOL_COUNT,\n :port => PORT_NUMBER,\n :host => ENV['DB_HOST'])\n end",
"def mysql_connection(config) # :nodoc:\n config = config.symbolize_keys\n host = config[:host]\n port = config[:port]\n socket = config[:socket]\n username = config[:username] ? config[:username].to_s : 'root'\n password = config[:password].to_s\n database = config[:database]\n\n require_mysql\n mysql = Mysql.init\n mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslkey]\n\n ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config)\n end",
"def connect_to_migration_db\n ActiveRecord::Base.establish_connection(\n adapter: 'postgresql',\n encoding: 'unicode',\n pool: 10,\n url: ENV['MIGRATION_DB_URL']\n )\n ActiveRecord::Base.connection.execute(\n \"SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;\"\n )\n end",
"def new_connection(config)\n username = nil\n\n if config[:jndi]\n jndi = config[:jndi].to_s\n ctx = javax.naming.InitialContext.new\n ds = nil\n\n # tomcat needs first lookup method, oc4j (and maybe other application servers) need second method\n begin\n env = ctx.lookup(\"java:/comp/env\")\n ds = env.lookup(jndi)\n rescue\n ds = ctx.lookup(jndi)\n end\n\n # check if datasource supports pooled connections, otherwise use default\n if ds.respond_to?(:pooled_connection)\n @raw_connection = ds.pooled_connection\n else\n @raw_connection = ds.connection\n end\n\n # get Oracle JDBC connection when using DBCP in Tomcat or jBoss\n if @raw_connection.respond_to?(:getInnermostDelegate)\n @pooled_connection = @raw_connection\n @raw_connection = @raw_connection.innermost_delegate\n elsif @raw_connection.respond_to?(:getUnderlyingConnection)\n @pooled_connection = @raw_connection\n @raw_connection = @raw_connection.underlying_connection\n end\n\n # Workaround FrozenError (can't modify frozen Hash):\n config = config.dup\n config[:driver] ||= @raw_connection.meta_data.connection.java_class.name\n username = @raw_connection.meta_data.user_name\n else\n # to_s needed if username, password or database is specified as number in database.yml file\n username = config[:username] && config[:username].to_s\n password = config[:password] && config[:password].to_s\n database = config[:database] && config[:database].to_s || \"XE\"\n host, port = config[:host], config[:port]\n privilege = config[:privilege] && config[:privilege].to_s\n\n # connection using TNS alias, or connection-string from DATABASE_URL\n using_tns_alias = !host && !config[:url] && ENV[\"TNS_ADMIN\"]\n if database && (using_tns_alias || host == \"connection-string\")\n url = \"jdbc:oracle:thin:@#{database}\"\n else\n unless database.match?(/^(:|\\/)/)\n # assume database is a SID if no colon or slash are supplied (backward-compatibility)\n database = \"/#{database}\"\n end\n url = config[:url] || \"jdbc:oracle:thin:@//#{host || 'localhost'}:#{port || 1521}#{database}\"\n end\n\n prefetch_rows = config[:prefetch_rows] || 100\n # get session time_zone from configuration or from TZ environment variable\n time_zone = config[:time_zone] || ENV[\"TZ\"] || java.util.TimeZone.default.getID\n\n properties = java.util.Properties.new\n raise \"username not set\" unless username\n raise \"password not set\" unless password\n properties.put(\"user\", username)\n properties.put(\"password\", password)\n properties.put(\"defaultRowPrefetch\", \"#{prefetch_rows}\") if prefetch_rows\n properties.put(\"internal_logon\", privilege) if privilege\n\n if config[:jdbc_connect_properties] # arbitrary additional properties for JDBC connection\n raise \"jdbc_connect_properties should contain an associative array / hash\" unless config[:jdbc_connect_properties].is_a? Hash\n config[:jdbc_connect_properties].each do |key, value|\n properties.put(key, value)\n end\n end\n\n begin\n @raw_connection = java.sql.DriverManager.getConnection(url, properties)\n rescue\n # bypass DriverManager to work in cases where ojdbc*.jar\n # is added to the load path at runtime and not on the\n # system classpath\n @raw_connection = ORACLE_DRIVER.connect(url, properties)\n end\n\n # Set session time zone to current time zone\n if ActiveRecord.default_timezone == :local\n @raw_connection.setSessionTimeZone(time_zone)\n elsif ActiveRecord.default_timezone == :utc\n @raw_connection.setSessionTimeZone(\"UTC\")\n end\n\n if config[:jdbc_statement_cache_size]\n raise \"Integer value expected for :jdbc_statement_cache_size\" unless config[:jdbc_statement_cache_size].instance_of? Integer\n @raw_connection.setImplicitCachingEnabled(true)\n @raw_connection.setStatementCacheSize(config[:jdbc_statement_cache_size])\n end\n\n # Set default number of rows to prefetch\n # @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows\n end\n\n cursor_sharing = config[:cursor_sharing] || \"force\"\n exec \"alter session set cursor_sharing = #{cursor_sharing}\" if cursor_sharing\n\n # Initialize NLS parameters\n OracleEnhancedAdapter::DEFAULT_NLS_PARAMETERS.each do |key, default_value|\n value = config[key] || ENV[key.to_s.upcase] || default_value\n if value\n exec \"alter session set #{key} = '#{value}'\"\n end\n end\n\n OracleEnhancedAdapter::FIXED_NLS_PARAMETERS.each do |key, value|\n exec \"alter session set #{key} = '#{value}'\"\n end\n\n self.autocommit = true\n\n schema = config[:schema] && config[:schema].to_s\n if schema.blank?\n # default schema owner\n @owner = username.upcase unless username.nil?\n else\n exec \"alter session set current_schema = #{schema}\"\n @owner = schema\n end\n\n @raw_connection\n end",
"def connect(opts)\n c = super\n connection_pragmas.each{|s| log_connection_yield(s, c){c.execute(s)}}\n c\n end",
"def connect_db\n ActiveRecord::Base.establish_connection($config)\n log(\"Connected to database\")\nrescue => e\n fatal(\"Failed to connect to the database: #{e}\")\n exit\nend",
"def connect(server)\n opts = server_opts(server)\n force_database(::Impala.connect(opts[:host]||'localhost', (opts[:port]||21000).to_i, opts), opts[:database])\n end",
"def reconnect\n @mutex.synchronize do\n require \"mysql2\" unless ::Object.const_defined?(:Mysql2)\n\n args = {\n host: @db.opts[:host],\n username: @db.opts[:user],\n password: @db.opts[:pass],\n database: @db.opts[:db],\n port: @port,\n symbolize_keys: true,\n cache_rows: false,\n encoding: encoding\n }\n\n # Symbolize keys should also be given here, else table-data wont be symbolized for some reason - knj.\n @query_args = {symbolize_keys: true}\n @query_args[:cast] = false unless @db.opts[:type_translation]\n @query_args.merge!(@db.opts[:query_args]) if @db.opts[:query_args]\n\n pos_args = [:as, :async, :cast_booleans, :database_timezone, :application_timezone, :cache_rows, :connect_flags, :cast]\n pos_args.each do |key|\n args[key] = @db.opts[key] if @db.opts.key?(key)\n end\n\n args[:as] = :array\n\n if @db.opts[:conn]\n @conn = @db.opts[:conn]\n else\n @conn = ::Mysql2::Client.new(args)\n end\n\n query(\"SET NAMES '#{esc(encoding)}'\") if encoding\n end\n end",
"def connect\n return if @connected\n\n @logger.info('Connecting...')\n sql_logger = Logging::Logger[\"#{self.class.name}::SQL\"]\n sql_logger.level = db_config('logging', default: @config_manager[\"database.#{@component_name}.logging\"])\n # Establish the connection.\n base_model.logger = sql_logger\n base_model.establish_connection(@connection_config)\n # Mark as connected.\n @connected = true\n end",
"def reconnect\n @mutex.synchronize do\n if @db.opts[:conn]\n @jdbc_loaded = true\n @conn = @db.opts.fetch(:conn)\n else\n com.mysql.cj.jdbc.Driver\n @conn = java.sql::DriverManager.getConnection(jdbc_connect_command)\n end\n\n query_no_result_set(\"SET SQL_MODE = ''\")\n query_no_result_set(\"SET NAMES '#{esc(@encoding)}'\") if @encoding\n end\n end",
"def setup( opts = {} )\n\n @db.disconnect if @db\n\n log = RJack::SLF4J[ \"iudex.da.sequel\" ]\n conf = CONFIG.merge( opts )\n conf = Hooker.merge( [ :iudex, :connect_props ], conf )\n\n conf[ :loggers ] = [ log ] if conf[ :log ]\n\n cstr = ( \"%s://%s/%s?%s\" %\n [ conf[ :adapter ],\n [ conf[ :host ], conf[ :port ] ].compact.join( ':' ),\n conf[ :database ],\n params( conf ) ] )\n\n log.info { \"Connecting: #{cstr}\" }\n log.debug { \"Full Params: #{ conf.inspect }\" }\n\n @db = Sequel.connect( cstr, conf )\n\n end",
"def reconnect\n\t\tif @connection != nil\n\t\t\tself.close\n\n\t\t\t@connection = MonetDBConnection.new(user = @username, passwd = @password, lang = @lang, host = @host, port = @port)\n\t\t\t@connection.connect(db_name = @db_name, auth_type = @auth_type)\n\t\tend\n\tend",
"def makeDBConnection(conf, dbConn)\n\n if ( !dbConn.nil? && dbConn.status == PGconn::CONNECTION_OK)\n return dbConn\n end\n\n # trying anyway to release the connection just in case\n closeDBConn(dbConn)\n\n begin\n dbConn = PGconn.open(\n :host => conf['airqdb']['host'],\n :port => conf['airqdb']['port'],\n :options => conf['airqdb']['options'],\n :tty => conf['airqdb']['tty'],\n :dbname => conf['airqdb']['dbname'],\n :user => conf['airqdb']['user'],\n :password => conf['airqdb']['password']\n )\n\n dbConn.prepare(\"sensordata\", \"INSERT INTO #{conf['airqdb']['measurestable']} \" +\n \"(id, srv_ts, topic, rssi, temp, pm10, pm25, no2a, no2b, humidity, message) \" +\n \"VALUES ($1::bigint, $2::timestamp with time zone, $3::text, $4::smallint, $5::numeric, \" +\n \"$6::numeric, $7::numeric, $8::numeric, $9::numeric, $10::numeric, $11::text)\")\n\n rescue PGError => e\n $stderr.puts \"ERROR: while connecting to Postgres server, class: #{e.class.name}, message: #{e.message}\"\n\n if $byebye\n return nil\n end\n\n $stderr.puts \"Sleep #{conf['airqdb']['retry']} seconds and retry\"\n sleep conf['airqdb']['retry']\n retry\n end\n\n return dbConn\nend",
"def connect\n \n require \"sequel\"\n require \"sequel_model\"\n\n if File.exists?(config_file)\n Merb.logger.info!(\"Connecting to the '#{config[:database]}' database on '#{config[:host]}' using '#{config[:adapter]}' ...\")\n connection = ::Sequel.connect(config_options(config))\n Merb.logger.error!(\"Connection Error: #{e}\") unless connection\n connection\n else\n copy_sample_config\n Merb.logger.set_log(STDERR)\n Merb.logger.error! \"No database.yml file found in #{Merb.root}/config.\"\n Merb.logger.error! \"A sample file was created called config/database.sample.yml for you to copy and edit.\"\n exit(1)\n end\n \n end",
"def database_connection\n\t\t\tPG.connect(dbname: \"Kung_Fu\")\n\t\tend",
"def connect config\n @db = ::Sequel.connect config\n rescue ::Sequel::DatabaseError => e\n retry if on_error e\n end",
"def dbconnect(db=nil, host=nil, username=nil, password=nil)\n config = $mydbi_config[:default] \n\n # optionally reset the config to a named datasource\n if db.instance_of?(Symbol)\n if $mydbi_config.key?(db)\n config = $mydbi_config[db] \n db = nil\n else\n throw ArgumentError.new(\"No database connection named ':#{db}' is configured\")\n end\n end\n\n db = config[:db] if db.nil?\n host = config[:host] if host.nil?\n username = config[:username] if username.nil?\n password = config[:password] if password.nil?\n\n $mydbi_db = DBI.connect(\"DBI:Mysql:#{db}:#{host}\", username, password)\nend",
"def connect_using conn\n @connection = conn\n end",
"def setup_connection\n db = ENV['DB'].blank?? 'mysql' : ENV['DB']\n\n configurations = YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'spec', 'database.yml'))\n raise \"no configuration for '#{db}'\" unless configurations.key? db\n configuration = configurations[db]\n\n ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb'\n puts \"using #{configuration['adapter']} adapter\" unless ENV['DB'].blank?\n\n gem 'sqlite3-ruby' if 'sqlite3' == db\n\n ActiveRecord::Base.establish_connection(configuration)\n ActiveRecord::Base.configurations = { db => configuration }\n #prepare ActiveRecord::Base.connection\n\n unless Object.const_defined?(:QUOTED_TYPE)\n Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')\n end\nend",
"def connect\n \n if !self.connected?\n \n # connect to the MySQL server\n @dbh = DBI.connect(\"DBI:Mysql:#{@dataBase}:#{@host}\", \n\t \"#{@user}\", \"#{@password}\")\n @connected=true\n \n end\n end",
"def connect_database\n begin\n db = PG.connect( :dbname => 'artdb' )\n rescue PGError\n puts 'Failed to connect to artdb database.'\n end\n return db\nend",
"def connect \n\t\t\tfirst_tentative = true\n\t\t\tbegin\n\t\t\t\tdatabase = ActiveOrient.database\n\t\t\t\tlogger.progname = 'OrientDB#Connect'\n\t\t\t\tr = ActiveOrient.db_pool.checkout do | conn |\n\t\t\t\t\tr = conn[\"/connect/#{database}\"].get\n\t\t\t\tend\n\t\t\t\tif r.code == 204\n\t\t\t\t\tlogger.info{\"Connected to database #{database}\"}\n\t\t\t\t\ttrue\n\t\t\t\telse\n\t\t\t\t\tlogger.error{\"Connection to database #{database} could NOT be established\"}\n\t\t\t\t\tnil\n\t\t\t\tend\n\t\t\trescue RestClient::Unauthorized => e\n\t\t\t\tif first_tentative\n\t\t\t\t\tlogger.info{\"Database #{database} NOT present --> creating\"}\n\t\t\t\t\tfirst_tentative = false\n\t\t\t\t\tcreate_database database: database\n\t\t\t\t\tretry\n\t\t\t\telse\n\t\t\t\t\tKernel.exit\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def dyna_connect\n puts \"\\n\\n *** CONNECT ** \\n\\n\"\n # TODO Add some checking in here to make sure the given config even exists in the db.yml file.\n # Also make sure its not nil, etc. If validation fails forward to a common error page and\n # throw error.\n if ! session[:cur_company].nil?\n logger.info \"\\n>** Connecting to customer db: #{session[:cur_company].db_config} **<\\n\\n\"\n # for script_console copy this in there: ActiveRecord::Base.establish_connection('klaratee_development_default' )\n return ActiveRecord::Base.establish_connection( session[:cur_company].db_config )\n end\n \n false\n end",
"def establish_config_database_connection(database_path)\n RFlow.logger.debug \"Establishing connection to config database (#{Dir.getwd}) '#{database_path}'\"\n ActiveRecord::Base.logger = RFlow.logger\n ConfigurationItem.establish_connection(:adapter => 'sqlite3', :database => database_path)\n end",
"def connect\n \n if !self.connected?\n \n # connect to the MySQL server\n \n @dbh = DBI.connect(\"DBI:Mysql:#{@dataBase}:#{@host}\", \n\t \"#{@user}\", \"#{@password}\")\n \n @connected=true\n \n end\n end",
"def open_db\n if Config.db =~ /^sqlite:\\/{3}(.+)$/\n dir = File.dirname($1)\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n end\n\n Sequel.datetime_class = Time\n\n @db = Sequel.connect(Config.db, :encoding => 'utf8')\n @db.test_connection\n\n if trait[:sql_log]\n require 'logger'\n @db.logger = Logger.new(trait[:sql_log])\n end\n\n rescue => e\n Ramaze::Log.error(\"Unable to connect to database: #{e}\")\n exit(1)\n end",
"def initialize(connect_options)\n connect_options = keys_to_symbol(connect_options)\n\n raise ArgumentError, 'database adapter is required' unless connect_options.has_key?(:adapter)\n raise ArgumentError, 'database host is required' unless connect_options.has_key?(:host)\n raise ArgumentError, 'database port is required' unless connect_options.has_key?(:port)\n raise ArgumentError, 'database username is required' unless connect_options.has_key?(:username)\n raise ArgumentError, 'database password is required' unless connect_options.has_key?(:password)\n raise ArgumentError, 'database database is required' unless connect_options.has_key?(:database)\n\n if connect_options[:adapter].eql? \"mysql2\"\n @client = Mysql2::Client.new(\n host: connect_options[:host],\n port: connect_options[:port],\n username: connect_options[:username],\n password: connect_options[:password],\n database: connect_options[:database]\n )\n else\n raise ArgumentError, 'for a while only mysql2 adapter is supported'\n end\n \n end",
"def connect\n ::Informix.connect(@opts[:database], @opts[:user], @opts[:password])\n end",
"def connect(server)\n opts = server_opts(server)\n rc, dbc = DB2CLI.SQLAllocHandle(DB2CLI::SQL_HANDLE_DBC, @@env) \n check_error(rc, \"Could not allocate database connection\")\n \n rc = DB2CLI.SQLConnect(dbc, opts[:database], opts[:user], opts[:password]) \n check_error(rc, \"Could not connect to database\")\n \n dbc\n end",
"def connect_to_old_db\n ActiveRecord::Base.establish_connection(\n :adapter => \"postgresql\",\n :host => \"localhost\",\n :username => \"postgres\",\n :password => \"vegpuf\",\n :database => \"affluence_staging_25_june\"\n )\nend",
"def connect(options = {})\n conn = self.connection(options[:handler])\n conn.container = self.container_id || generate_uuid\n connector = Connector.new(conn)\n conn.overrides = connector\n if !options[:url].nil?\n connector.address = URLs.new([options[:url]])\n elsif !options[:urls].nil?\n connector.address = URLs.new(options[:urls])\n elsif !options[:address].nil?\n connector.address = URLs.new([Qpid::Proton::URL.new(options[:address])])\n else\n raise ::ArgumentError.new(\"either :url or :urls or :address required\")\n end\n\n connector.heartbeat = options[:heartbeat] if !options[:heartbeat].nil?\n if !options[:reconnect].nil?\n connector.reconnect = options[:reconnect]\n else\n connector.reconnect = Backoff.new()\n end\n\n connector.ssl_domain = SessionPerConnection.new # TODO seems this should be configurable\n\n conn.open\n\n return conn\n end",
"def cmd_poortego_connect(*args)\n ## TODO: add logic from Constructor\n if (args[0] == nil)\n cmd_poortego_connect_help\n return\n end\n \n connection_config = Hash.new()\n \n @@connect_opts.parse(args) {|opt, idx, val|\n #print_line \"[DEBUG] opt #{opt} idx #{idx} val #{val}\"\n #print_line \"[DEBUG] opt class: #{opt.class}\"\n #print_line \"[DEBUG] Arg #{args[idx]}\"\n #case opt # Change this to opt if \"-h\" style arguments are being passed\n # Change this to val if \"help\" style arguments are being passed\n case (args[idx-1])\n when \"-h\", \"-?\"\n cmd_poortego_connect_help\n when \"-adapter\"\n connection_config['adapter'] = val\n puts \"[DEBUG] Setting adapter to #{val}\"\n when \"-database\"\n connection_config['database'] = val\n puts \"[DEBUG] Setting database to #{val}\"\n when \"-username\"\n connection_config['username'] = val\n puts \"[DEBUG] Setting username to #{val}\"\n when \"-password\"\n connection_config['password'] = val\n puts \"[DEBUG] Setting password to #{val}\"\n when \"-host\"\n connection_config['host'] = val\n puts \"[DEBUG] Setting host to #{val}\" \n else\n print_error(\"Invalid option.\")\n return\n end \n }\n \n if (connection_config.length > 1)\n begin\n ActiveRecord::Base.establish_connection(connection_config)\n rescue Exception => e\n puts \"Exception establishing activerecord connection\"\n puts self.inspect\n puts e.message \n end\n end\n \n end",
"def connectDB\n \t#config = YAML.load_file( '/home/ubuntu/DB-Performance-Testing/config/db.yml' )['DB2']\n config = YAML.load_file( @@path + '../config/db.yml' )['DB2']\n\t cstring = \"DATABASE=#{config['db']};HOSTNAME=#{config['hostname']};\"\n\t cstring += \"PORT=#{config['port']};PROTOCOL=#{config['protocol']};UID=#{config['uid']};PWD=#{config['pwd']};\"\n\t @conn = IBM_DB.connect(cstring,\"\",\"\")\n end",
"def connect_to_database(validate_schema)\n require 'cloud_crowd/models'\n CloudCrowd.configure_database(\"#{@options[:config_path]}/database.yml\", validate_schema)\n end",
"def connect(db_config)\n if db_config.instance_of?(Hash)\n sym = db_config.transform_keys(& :to_sym )\n db_config = Struct.new(*(k = sym.keys)).new(*sym.values_at(*k))\n end\n\n begin\n @my = Mysql2::Client.new( host: db_config.host,\n database: db_config.db,\n username: db_config.dbuser,\n password: db_config.key,\n socket: db_config.respond_to?(:socket) ? db_config.socket : nil,\n port: db_config.respond_to?(:port) ? db_config.port : nil,\n flags: 'SESSION_TRACK',\n init_command: 'SET @@SESSION.session_track_schema=ON'\n )\n rescue StandardError => e\n @my = nil\n raise e\n end\n raise Mysql2::Error, 2002 if @my.nil?\n\n # @@my.reconnect = true\n if block_given?\n yield\n return close\n end\n return @my\n end",
"def connect\n first_tentative = true\n begin\n\tdatabase = ActiveOrient.database\n logger.progname = 'OrientDB#Connect'\n r = @res[\"/connect/#{database}\"].get\n if r.code == 204\n \t logger.info{\"Connected to database #{database}\"}\n \t true\n \t else\n \t logger.error{\"Connection to database #{database} could NOT be established\"}\n \t nil\n \t end\n rescue RestClient::Unauthorized => e\n if first_tentative\n \t logger.info{\"Database #{database} NOT present --> creating\"}\n \t first_tentative = false\n \t create_database database: database\n \t retry\n else\n \t Kernel.exit\n end\n end\n end",
"def configure_connection(config, connection)\n variables = config.fetch(:variables, {}).stringify_keys\n\n # By default, MySQL 'where id is null' selects the last inserted id.\n # Turn this off. http://dev.rubyonrails.org/ticket/6778\n variables['sql_auto_is_null'] = 0\n\n # Increase timeout so the server doesn't disconnect us.\n wait_timeout = config[:wait_timeout]\n wait_timeout = 2147483 unless wait_timeout.is_a?(Fixnum)\n variables['wait_timeout'] = self.type_cast_config_to_integer(wait_timeout)\n\n # Make MySQL reject illegal values rather than truncating or blanking them, see\n # http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_all_tables\n # If the user has provided another value for sql_mode, don't replace it.\n unless variables.has_key?('sql_mode')\n variables['sql_mode'] = strict_mode?(config) ? 'STRICT_ALL_TABLES' : ''\n end\n\n # NAMES does not have an equals sign, see\n # http://dev.mysql.com/doc/refman/5.0/en/set-statement.html#id944430\n # (trailing comma because variable_assignments will always have content)\n encoding = \"NAMES #{config[:encoding]}, \" if config[:encoding]\n\n # Gather up all of the SET variables...\n variable_assignments = variables.map do |k, v|\n if v == ':default' || v == :default\n \"@@SESSION.#{k.to_s} = DEFAULT\" # Sets the value to the global or compile default\n elsif !v.nil?\n \"@@SESSION.#{k.to_s} = #{connection.escape(v.to_s)}\"\n end\n # or else nil; compact to clear nils out\n end.compact.join(', ')\n\n # ...and send them all in one query\n connection.query \"SET #{encoding} #{variable_assignments}\", async: false\n end"
] |
[
"0.73320276",
"0.70448613",
"0.7007973",
"0.69815606",
"0.6863588",
"0.6848689",
"0.6848689",
"0.68261606",
"0.6744137",
"0.67378205",
"0.67165136",
"0.66200817",
"0.6610611",
"0.6599768",
"0.6572738",
"0.6564431",
"0.6520831",
"0.65082985",
"0.6462121",
"0.6445565",
"0.6342648",
"0.6333204",
"0.63321984",
"0.63321984",
"0.6331366",
"0.63170564",
"0.6281703",
"0.62767434",
"0.6264266",
"0.6224299",
"0.62056994",
"0.62052774",
"0.62019324",
"0.6196101",
"0.61352473",
"0.61316466",
"0.6116287",
"0.61098",
"0.6101282",
"0.6095234",
"0.6083065",
"0.60588",
"0.60318214",
"0.603002",
"0.6009859",
"0.59779215",
"0.59641355",
"0.5963213",
"0.5933361",
"0.59188247",
"0.5915939",
"0.5878256",
"0.5874433",
"0.58688575",
"0.5863979",
"0.5837406",
"0.58363676",
"0.5818826",
"0.58174133",
"0.5798237",
"0.5776141",
"0.576052",
"0.57592887",
"0.57543796",
"0.57472295",
"0.5727702",
"0.5726696",
"0.57259685",
"0.57226825",
"0.5710911",
"0.5698294",
"0.5697244",
"0.5689008",
"0.5670855",
"0.5661265",
"0.56474066",
"0.56451404",
"0.56371605",
"0.5628314",
"0.5622327",
"0.56086713",
"0.5600727",
"0.5576014",
"0.5573409",
"0.5573395",
"0.55697066",
"0.5569506",
"0.5567586",
"0.55557233",
"0.5547915",
"0.5544649",
"0.5544474",
"0.5539325",
"0.5536539",
"0.55291915",
"0.5528686",
"0.55159146",
"0.55101955",
"0.54982364",
"0.54854107"
] |
0.7335289
|
0
|
Set whether to allow infinite timestamps/dates. Make sure the conversion proc for date reflects that setting.
|
def convert_infinite_timestamps=(v)
@convert_infinite_timestamps = case v
when Symbol
v
when 'nil'
:nil
when 'string'
:string
when 'float'
:float
when String
typecast_value_boolean(v)
else
false
end
pr = old_pr = @use_iso_date_format ? TYPE_TRANSLATOR.method(:date) : Sequel.method(:string_to_date)
if v
pr = lambda do |val|
case val
when *INFINITE_TIMESTAMP_STRINGS
infinite_timestamp_value(val)
else
old_pr.call(val)
end
end
end
add_conversion_proc(1082, pr)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def typecast_value_date(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def infinite_timestamp_value(value)\n case convert_infinite_timestamps\n when :nil\n nil\n when :string\n value\n else\n value == 'infinity' ? PLUS_INFINITY : MINUS_INFINITY\n end\n end",
"def typecast_value_datetime(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def to_application_timestamp(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(value)\n else\n super\n end\n else\n super\n end\n end",
"def use_dates\n @use_dates || true\n end",
"def convert_invalid_date_time=(v)\n m0 = ::Sequel.method(:string_to_time)\n @conversion_procs[11] = (v != false) ? lambda{|val| convert_date_time(val, &m0)} : m0\n m1 = ::Sequel.method(:string_to_date) \n m = (v != false) ? lambda{|val| convert_date_time(val, &m1)} : m1\n [10, 14].each{|i| @conversion_procs[i] = m}\n m2 = method(:to_application_timestamp)\n m = (v != false) ? lambda{|val| convert_date_time(val, &m2)} : m2\n [7, 12].each{|i| @conversion_procs[i] = m}\n @convert_invalid_date_time = v\n end",
"def map_time_limit=(new_value)\n super new_value && new_value.to_f\n end",
"def value=(value)\n if value.is_a?(Integer) && (value >= -10485761231 && value <= 10485761231)\n @bits = self.class.set_date(@bits, value)\n else\n raise PartialDateError, \"Date value must be an integer betwen -10485761231 and 10485761231\"\n end\n end",
"def supports_datetime_with_precision?\n false\n end",
"def supports_datetime_with_precision?\n false\n end",
"def adapter_initialize\n @use_iso_date_format = typecast_value_boolean(@opts.fetch(:use_iso_date_format, Postgres.instance_variable_get(:@use_iso_date_format))) # , true)) # SEQUEL5\n initialize_postgres_adapter\n add_conversion_proc(17, method(:unescape_bytea)) if USES_PG\n add_conversion_proc(1082, TYPE_TRANSLATOR.method(:date)) if @use_iso_date_format\n self.convert_infinite_timestamps = @opts[:convert_infinite_timestamps]\n end",
"def clear_timeless_option\n self.class.timestamping = true\n end",
"def sanitize_data!\n convert_datetimes_intelligently!\n end",
"def earliest_limit=( value )\n @earliest_limit = to_date( value )\n end",
"def set_validity_period(opts)\n opts = check_params(opts,[:ranges])\n super(opts)\n end",
"def expires_at=(val)\n super( parse_date(val) )\n rescue ArgumentError\n super (val)\n end",
"def date?\n false\n end",
"def disable_dates\n @expression = load_expression_instance_from_session\n @expression.expression_start = nil\n @expression.expression_finish = nil\n save_expression_instance_in_session\n end",
"def force_post_date_to_midnight\n return true if self.post_date.nil?\n self.post_date = self.post_date.to_time.midnight\n end",
"def initialize_to_correct_date_type(field_info, field)\n initialize_integer(field_info, field)\n initialize_float(field_info, field)\n end",
"def __evolve_date__\n __evolve_range_naive__.transform_values! {|v| v&.__evolve_date__ }\n end",
"def apply_validations_for_timestamp\n apply_validations_for_datetime\n end",
"def disable_date_minutes\n @expression = load_expression_instance_from_session\n logger.debug \"Setting supress times when disabling date minutes\"\n @expression.supress_times = true\n save_expression_instance_in_session\n end",
"def range_start=( value ); @range_start = value; rationalise_dates(); end",
"def supports_timestamp_usecs?\n false\n end",
"def warn_invalid_date; end",
"def set_day_if_discarded\n if @datetime && @options[:discard_day]\n @datetime = @datetime.change(day: 1)\n end\n end",
"def infinite?; end",
"def has_dates(*attrs)\n options = attrs.extract_options!\n attrs.each do |attr|\n\n attr_reader attr\n define_reader_with_options(attr,options)\n define_method(\"#{attr.to_s}=\") do |val| \n val = val.to_date unless val.nil?\n instance_variable_set(\"@#{attr}\", val )\n attributes[attr] = val\n val\n\n end\n end\n end",
"def set_renegotiation_period(opts)\n opts = check_params(opts,[:periods])\n super(opts)\n end",
"def set(value)\n super(value == :true)\n end",
"def starts_at=(date)\n super(date)\n set_ends_at\n end",
"def day?(v = nil)\n super(v || value)\n end",
"def date=(date_value)\n @date = date_value.class <= Date ? date_value : Date.parse(date_value)\n end",
"def set_MinFaveDate(value)\n set_input(\"MinFaveDate\", value)\n end",
"def set_MinFaveDate(value)\n set_input(\"MinFaveDate\", value)\n end",
"def set_MinFaveDate(value)\n set_input(\"MinFaveDate\", value)\n end",
"def set_MinFaveDate(value)\n set_input(\"MinFaveDate\", value)\n end",
"def set(value)\n case value\n when DateTime\n set(value.to_time)\n when Time\n set(value.to_i)\n when Integer\n self.val = value\n else\n self.val = value.to_i\n end\n val\n end",
"def infinite?() end",
"def set_MaxFaveDate(value)\n set_input(\"MaxFaveDate\", value)\n end",
"def set_MaxFaveDate(value)\n set_input(\"MaxFaveDate\", value)\n end",
"def set_MaxFaveDate(value)\n set_input(\"MaxFaveDate\", value)\n end",
"def set_MaxFaveDate(value)\n set_input(\"MaxFaveDate\", value)\n end",
"def set(value)\n case value\n when DateTime\n set(value.to_time)\n when Time\n time_int = value.to_i\n time_int *= NS_MULTIPLIER\n adjusted_epoch = time_int + EPOCH_DIFF_100NS\n set(adjusted_epoch)\n when Integer\n self.val = value\n else\n self.val = value.to_i\n end\n val\n end",
"def is_published=(value)\n published_date = nil\n # check if value is parsable date\n begin\n published_date = Time.parse(value.to_s)\n rescue\n # otherwise evaluate value, true or false\n published_date = Time.now.beginning_of_day if value\n end\n\n self.published_on = published_date\n end",
"def has_floating_timezone?\n false\n end",
"def value=(value)\n value = (value == \"false\" || value == false) ? false : true\n super value\n end",
"def record_timestamps\n false\n end",
"def infinity?\n @infinity == true\n end",
"def timeless\n self.class.timestamping = false\n self\n end",
"def coerce(value)\n if !value.nil? and !option.allowed_format.nil?\n case option.allowed_format\n when 'fixnum'\n value = value.to_i\n when 'float'\n value = value.to_f\n when 'boolean'\n value = true if (value == 'true' or value == 't')\n value = false if (value == 'false' or value == 'f')\n end\n end\n\n return value\n end",
"def infinite?\n end",
"def record_timestamps\n false\n end",
"def set_day_if_discarded; end",
"def shouldConvert\n false\n end",
"def tt_forever?\n ttend_at == InfinityValue\n end",
"def set_MaxUploadDate(value)\n set_input(\"MaxUploadDate\", value)\n end",
"def set_MaxUploadDate(value)\n set_input(\"MaxUploadDate\", value)\n end",
"def set_MaxUploadDate(value)\n set_input(\"MaxUploadDate\", value)\n end",
"def set_MaxUploadDate(value)\n set_input(\"MaxUploadDate\", value)\n end",
"def set_MaxUploadDate(value)\n set_input(\"MaxUploadDate\", value)\n end",
"def set_MaxUploadDate(value)\n set_input(\"MaxUploadDate\", value)\n end",
"def normalise_options\n @options[:interval] = @options[:interval].to_i\n @options[:limit] = @options[:limit].to_i if @options[:limit]\n end",
"def annual_inflation_rate=(num)\n self[:annual_inflation_rate] = sanitize_to_float(num)\n end",
"def date_is_not_ancient?(date)\n date > Date.new(1900)\n end",
"def override_all_day_based_on_duration\n starts_on = starts_at.to_date\n ends_on = ends_at.to_date\n if starts_on != ends_on\n self.all_day = true\n end\n true\n end",
"def set_MaxCommentDate(value)\n set_input(\"MaxCommentDate\", value)\n end",
"def set_MaxCommentDate(value)\n set_input(\"MaxCommentDate\", value)\n end",
"def validate_each(record, attribute, value = \"\") #:nodoc:\n @value = value\n record.errors[attribute] << 'not a valid Date or DateTime' unless is_valid?\n end",
"def disallow_currency_conversion!; end",
"def set_ToDateTime(value)\n set_input(\"ToDateTime\", value)\n end",
"def set_ToDateTime(value)\n set_input(\"ToDateTime\", value)\n end",
"def set_ToDateTime(value)\n set_input(\"ToDateTime\", value)\n end",
"def set_ToDateTime(value)\n set_input(\"ToDateTime\", value)\n end",
"def set_ToDateTime(value)\n set_input(\"ToDateTime\", value)\n end",
"def set_start_end_dates\n if new_record?\n self.start_time ||= '12:00 PM'\n self.end_time ||= '01:00 PM'\n parse_start_end\n elsif has_attribute?(:start_at) # this if is to allow custom selects on the Event module\n self.start_date = start_at.to_s(:slashes) unless start_at.blank?\n self.start_time = start_at.to_s(:time_only).strip unless start_at.blank?\n self.end_date = end_at.to_s(:slashes) unless end_at.blank?\n self.end_time = end_at.to_s(:time_only).strip unless end_at.blank?\n end\n end",
"def normalize_start_date\n self.start_date ||= Time.zone.now\n if self.start_date.to_date == Date.today\n self.start_date = Time.zone.now\n end\n self.start_date += 1.year if self.start_date < Date.today\n true\n end",
"def set_service_range\n self.service_start_date ||= (service_except_dates + service_added_dates).min\n self.service_end_date ||= (service_except_dates + service_added_dates).max\n true\n end",
"def day_number_less_than_one\n if @day < 1\n return true\n end\n return false\n end",
"def handled_at=(value)\n @values['handledAt'] = value\n end",
"def infinite?\n nil\n end",
"def infinite?\n nil\n end",
"def with_floating_timezone\n dup.set_tzid(:floating)\n end",
"def is_date\n @is_date\n end",
"def enforce_future_date_for_embargo?\n false\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end",
"def set_Date(value)\n set_input(\"Date\", value)\n end"
] |
[
"0.66383576",
"0.6420522",
"0.62761325",
"0.601918",
"0.5762987",
"0.5707895",
"0.5591486",
"0.55315447",
"0.5378172",
"0.5378172",
"0.5294206",
"0.52896124",
"0.5235742",
"0.521018",
"0.506912",
"0.5042014",
"0.4996655",
"0.49401912",
"0.49288452",
"0.49236864",
"0.49205405",
"0.48994398",
"0.48678076",
"0.48651582",
"0.48635903",
"0.4855554",
"0.48509628",
"0.48439407",
"0.47907966",
"0.47838584",
"0.47564828",
"0.4751233",
"0.47439775",
"0.4732983",
"0.4732887",
"0.4732887",
"0.4732887",
"0.4732887",
"0.47110522",
"0.47086132",
"0.47074535",
"0.47074535",
"0.47074535",
"0.47074535",
"0.46951744",
"0.46826947",
"0.4679833",
"0.46723944",
"0.46706337",
"0.4655413",
"0.4651963",
"0.46517536",
"0.46483856",
"0.46449095",
"0.46376443",
"0.46365672",
"0.46331114",
"0.4629557",
"0.4629557",
"0.4629557",
"0.4629557",
"0.4629557",
"0.4629557",
"0.46212152",
"0.46106246",
"0.4610261",
"0.46033138",
"0.45980793",
"0.45980793",
"0.45918143",
"0.45755556",
"0.45707646",
"0.45707646",
"0.45707646",
"0.45707646",
"0.45707646",
"0.456864",
"0.45603165",
"0.45527267",
"0.45367065",
"0.45343745",
"0.45297003",
"0.45297003",
"0.4529638",
"0.45209685",
"0.45167607",
"0.45144516",
"0.45144516",
"0.45144516",
"0.45144516",
"0.45144516",
"0.45144516",
"0.45144516",
"0.4497065",
"0.4497065",
"0.4497065",
"0.4497065",
"0.4497065",
"0.4497065",
"0.4497065"
] |
0.75502497
|
0
|
Execute the given SQL with the given args on an available connection.
|
def execute(sql, opts=OPTS, &block)
synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end",
"def execute(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n q = check_disconnect_errors{execute_query(sql, args)}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def execute_query(sql, args)\n\t\t\t\t\t@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def execute(*args)\n @db.execute(*args)\n end",
"def exec(sql)\n Logging.with_logged_query self, sql do\n raw_connection.exec sql\n end\n end",
"def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end",
"def execute(sql, name = nil, _binds = [])\n log(sql, name) do\n @connection.do(sql)\n end\n end",
"def execute(sql)\n @logger.debug(\"SQL: #{sql}\") if @logger\n retrieve_connection.query(sql)\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def execute *params\r\n sql = parse_args( *params )\r\n @driver.execute( sql )\r\n end",
"def query(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n check_disconnect_errors{super}\n end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def _execute(conn, sql, opts, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n conn.execute(sql, opts[:arguments], &block)\n end\n end",
"def call(*args)\n in_context do\n self.execute(*args)\n end\n end",
"def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end",
"def execute(sql, name = nil, binds = [])\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n @connection.do(sql)\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n execute(sql, name, binds)\n end",
"def execute(sql, opts={}, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute(sql)\n @database_handle.execute(sql)\n end",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def execute(sql, *bind_values)\n @pool.acquire { |conn| conn.execute(sql, *bind_values) }\n end",
"def execute(sql, name = nil, skip_logging = false)\n translate(sql) do |sql, args|\n if (name == :skip_logging) or skip_logging\n @connection.execute(sql, *args)\n else\n log(sql, args, name) do\n @connection.execute(sql, *args)\n end\n end\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end",
"def execute_query(sql, *vars)\n if vars && vars.count > 0\n @database.prepare(sql).execute(*vars.flatten)\n else\n @database.prepare(sql).execute\n end\n rescue\n puts \"MyMysql.execute_query(): #{$!}\" if @@verbose\n end",
"def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end",
"def execute(sql, args = nil, bulk_args = nil, http_options = {})\n @logger.debug sql\n req = Net::HTTP::Post.new('/_sql', headers)\n body = { 'stmt' => sql }\n body['args'] = args if args\n body['bulk_args'] = bulk_args if bulk_args\n req.body = body.to_json\n response = request(req, http_options)\n @logger.debug response.body\n\n case response.code\n when /^2\\d{2}/\n ResultSet.new response.body\n else\n @logger.info(response.body)\n raise CrateRuby::CrateError, response.body\n end\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)} \n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def execute sql\n db[sql]\n end",
"def execute(sql, *args, &block)\n @db.execute(rewrite_table_names(sql), *args, &block)\n end",
"def execute(*args)\n friendly_name = args[0]\n connection_info = args[1]\n\n return all unless friendly_name\n delegate(friendly_name, connection_info)\n end",
"def execute(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"execute: #{sql}\" }\n r = client.execute(sql)\n\n r.do\n r\n\n rescue => e\n handle_error(e)\n end",
"def execute(sql, name = nil, binds = []) #:nodoc:\r\n if name == :skip_logging\r\n query(sql, binds)\r\n else\r\n log(sql, name, binds) { query(sql, binds) }\r\n end\r\n end",
"def execute(sql)\r\n\t\t@connection.Execute(sql)\r\n\tend",
"def execute(sql, name = 'SQL')\n log(sql, name) do\n @connection.async_exec(sql)\n end\n end",
"def execute(sql)\n log_info(sql)\n @pool.hold {|c| c.immediate(sql)}\n end",
"def execute_dui(sql, opts={})\n synchronize(opts[:server]) do |conn|\n begin\n conn.execute(sql)\n rescue SwiftError => e\n raise_error(e)\n end\n end\n end",
"def ask(sql, *args, into: nil)\n catch(:ok) do\n each(sql, *args, into: into) { |row| throw :ok, row }\n nil\n end\n end",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n msg\n end\n end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def execute(sql)\n @db.send(:_execute, self, sql, :log=>false) \n end",
"def execute(*values)\n IBM_DB.execute(@stmt, values)\n end",
"def call(*args)\n params = build_params args\n cstmt = @connection.prepare_call \"{call #{name}(#{Array.new(@cols.length){'?'}.join ', '})}\"\n begin\n process_result( args, cstmt.call(*params) )\n ensure\n cstmt.close\n end\n end",
"def execute(sql, opts)\n r = synchronize(opts[:server]) do |conn|\n log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn) do\n conn.query_with_flags(sql, timezone.nil? || timezone == :local ? LOCAL_TIME_QUERY_FLAGS : QUERY_FLAGS)\n end\n end\n yield r\n rescue ::Trilogy::Error => e\n raise_error(e)\n end",
"def execute(sql, opts=OPTS)\n _execute(sql, opts) do |conn|\n begin\n yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})\n ensure\n stmt.close if stmt\n end\n end\n end",
"def exec(sql, *bindvars, &block)\n ret = nil\n thread = Thread.new { ret = super }\n thread.join\n ret\n rescue Interrupt\n self.break\n raise\n end",
"def exec(sql, rescue_exception = true)\n debug(sql) if $DBG\n exec_statement(sql)\n rescue Object => ex\n if rescue_exception\n handle_sql_exception(ex, sql)\n else\n raise\n end\n end",
"def call(query, *args)\n execute(query, *args)\n rescue *RESCUABLE_CONNECTION_ERRORS => e\n raise ConnectionError, \"#{e.class}: #{e.message}\"\n end",
"def execute(sql, name = nil)\n raise NotImplementedError, \"execute is an abstract method\"\n end",
"def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end",
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def run_sql(sql)\n #connect to the|db|\n conn = PG.connect(:dbname => 'rogbloll')\n\n\n #execute the db in the argument\n res = conn.exec(sql)\n\n #now close the db\n conn.close\n\n #now return the result of the query...\n res\n\n\n \n end",
"def exec(connection = @connection)\n connection.exec(statement)\n end",
"def execute(sql, tx = nil)\n run(:_send_query, [sql], tx)\n end",
"def execute(*args)\n bound_args = args.shift(@raw_metadata.size)\n consistency_level = args.shift\n @client.execute_statement(@connection_id, @statement_id, @raw_metadata, bound_args, consistency_level)\n end",
"def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)\n sql = transform_query(sql)\n\n if preventing_writes? && write_query?(sql)\n raise ActiveRecord::ReadOnlyError, \"Write query attempted while in readonly mode: #{sql}\"\n end\n\n materialize_transactions\n mark_transaction_written_if_write(sql)\n\n binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)\n\n if without_prepared_statement?(binds)\n log(sql, name) { @connection.execute_query(sql) }\n else\n log(sql, name, binds) do\n # this is different from normal AR that always caches\n cached_statement = fetch_cached_statement(sql) if prepare && @jdbc_statement_cache_enabled\n @connection.execute_prepared_query(sql, binds, cached_statement)\n end\n end\n end",
"def execute(sql, name = nil, &block)\n log(sql, name) do\n @connection.query(sql, &block)\n end\n end",
"def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end",
"def exec(*args, &block)\n if current = Thread.current[:squirm_connection]\n current.exec(*args, &block)\n else\n use {|conn| conn.exec(*args, &block)}\n end\n end",
"def execute_sql\n ActiveRecord::Base.connection.execute(@sql)\n end",
"def execute(sql, *args, &block)\n @db.log_yield(sql){super}\n rescue SwiftError => e\n @db.send(:raise_error, e)\n end",
"def _execute(conn, sql, opts)\n begin\n r = log_yield(sql){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif block_given?\n yield conn\n end\n rescue ::Mysql2::Error => e\n raise_error(e, :disconnect=>MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message))\n end\n end",
"def execute(sql, name = nil)\n exec_no_cache(sql, name, nil)\n end",
"def execute_dui(sql, opts=OPTS)\n _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.row_changes}\n end",
"def execute(sql, name = nil)\n # check for some DDL and DML statements\n puts \"Running sql? #{RUN_SQL}\"\n\n if /(create |alter |drop |insert |delete |update )/i.match sql.squish\n File.open(SQL_FILENAME, 'a') { |f| f.puts \"#{sql};\\n\" }\n puts \"Rails.env: #{Rails.env} - #{ENV['FPHS_POSTGRESQL_SCHEMA']}\"\n old_execute sql, name if RUN_SQL\n else\n # pass everything else to the aliased execute\n puts \"------------- (#{name}) ---------------\"\n puts sql || ''\n puts \"------------- ---------------\"\n old_execute sql, name if RUN_SQL\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end",
"def run_sql(sql, arr = []) # array is for security feature\n db = PG.connect(ENV['DATABASE_URL'] || {dbname: 'picgallary'})\n results = db.exec_params(sql, arr)\n db.close\n return results\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: 'goodfoodhunting')\n result = conn.exec(sql)\n conn.close\n return result\nend",
"def run_sql(sql)\n conn = PG.connect(dbname: \"memetube\", host: \"localhost\")\n begin\n result = conn.exec(sql)\n ensure\n conn.close\n end\n result\nend",
"def run_sql(sql)\n db = PG.connect(dbname: 'goodfoodhunting')\n results = db.exec(sql)\n db.close\n results\nend",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n @errors << msg\n false\n end\n end",
"def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end",
"def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end",
"def execute(sql, opts=OPTS, &block)\n super(sql, {:arguments=>bind_arguments}.merge(opts), &block)\n end",
"def multi_query(sql, *bind_values)\n @pool.acquire { |conn| conn.query(sql, *bind_values) }\n end",
"def execute(args=nil)\r\n puts \"Executing #{name}\"\r\n execute_base(args)\r\n end",
"def do_sql_command(sql, use_global_connection = true, close_connection = false)\n begin\n \n if use_global_connection \n dbconn = open_conn\n else\n dbconn = open_conn(false)\n end\n \n dbres = dbconn.query(sql)\n\n rescue Mysql::Error => err\n raise err\n ensure\n close_conn(dbconn) if close_connection\n end\n \n dbres\nend",
"def execute(sql)\n stmt = IBM_DB.exec(@conn, sql)\n raise Error.new(error_msg, error_sqlstate) unless stmt\n Statement.new(stmt)\n end",
"def query(sql, *bind_values)\n @pool.acquire { |conn| conn.query(sql, *bind_values).first }\n end",
"def _execute_prepared_statement(conn, ps_name, args, opts)\n conn.exec_prepared(ps_name, args)\n end",
"def run_sql(sql)\n connection = PG.connect(dbname: \"facebook_lab\", host: \"localhost\")\n result = connection.exec(sql)\n connection.close\n result\nend",
"def cti_execute_sql(sql)\n return execute(sql) if sql.is_a?(String)\n sql.map do |query|\n execute(query)\n end\n end",
"def run_sql(query)\n raw_run_sql(query)\n end",
"def run_sql(sql)\n\tdb = PG.connect(dbname: 'address_book', host: 'localhost')\n\tresult = db.exec(sql)\n\tdb.close\n\tresult\nend",
"def run_sql(sql)\n conn = PG.connect(dbname: 'movies')\n result = conn.exec(sql)\n conn.close\n result\nend",
"def execute(*args)\n executes.concat(args)\n end",
"def sql_raw(*args)\n sql, bind = parse_args(*args)\n return SQL::QueryMaker.new(nil, Proc.new { sql }, bind)\n end",
"def execute_non_query(*args)\n raise NotImplementedError.new\n end",
"def run_sql(sql)\n\tconn = PG.connect(dbname: \"video_store\", host: 'localhost')\n\tresult = conn.exec(sql)\n\tconn.close\n\tresult \nend",
"def execute\n ActiveRecord::Base.connection.execute(source)\n end",
"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 query(sql)\n database.execute2(sql)\n end",
"def run_sql(sql)\n db = PG.connect(:dbname => 'movies', :host => 'localhost')\n result = db.exec(sql)\n db.close\n result\n end",
"def escape_sql(args)\n return @text if args.empty?\n sql = @text.dup\n vars = args.dup\n\n replacements = 0\n mismatch = false\n\n sql.gsub!(/'[^']*'|\"[^\"]*\"|`[^`]*`|\\?/) do |x|\n next x unless x == '?'\n replacements += 1\n if vars.empty?\n mismatch = true\n else\n var = vars.shift\n connection.quote_value(var)\n end\n end\n\n if !vars.empty? || mismatch\n raise ArgumentError, \"Binding mismatch: #{args.size} for #{replacements}\"\n else\n sql\n end\n end",
"def run_sql(sql, arr = [])\n db = PG.connect(ENV['DATABASE_URL'] || {dbname: 'native_plants'})\n results = db.exec_params(sql, arr)\n db.close\n return results\nend",
"def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end"
] |
[
"0.7904611",
"0.78545374",
"0.78210807",
"0.7775948",
"0.7613696",
"0.74505574",
"0.72905046",
"0.717334",
"0.71629125",
"0.71615505",
"0.7148351",
"0.7138093",
"0.7137035",
"0.70270294",
"0.70190805",
"0.69488543",
"0.69486505",
"0.6940662",
"0.6926925",
"0.68820894",
"0.6878273",
"0.6876731",
"0.6868315",
"0.6858312",
"0.684833",
"0.6835504",
"0.68246335",
"0.6803341",
"0.6792015",
"0.6790646",
"0.67405516",
"0.6725882",
"0.6725829",
"0.6701113",
"0.6669885",
"0.6669177",
"0.6668942",
"0.6650703",
"0.66338915",
"0.66266406",
"0.6599651",
"0.6592571",
"0.65732193",
"0.65618175",
"0.6559588",
"0.6549946",
"0.65478265",
"0.65252745",
"0.6508877",
"0.6488042",
"0.6473236",
"0.647176",
"0.6470659",
"0.6465235",
"0.64552456",
"0.64548105",
"0.6430463",
"0.64039767",
"0.638843",
"0.6381753",
"0.63698304",
"0.6369639",
"0.63669664",
"0.63665134",
"0.63646257",
"0.63614804",
"0.6358",
"0.62988025",
"0.6291116",
"0.62904894",
"0.6271728",
"0.62602425",
"0.62577915",
"0.62487733",
"0.6233331",
"0.6232394",
"0.6214412",
"0.6188095",
"0.6187405",
"0.6186301",
"0.6181607",
"0.6181036",
"0.6174936",
"0.6173762",
"0.6164372",
"0.6162295",
"0.6139116",
"0.61119294",
"0.61011356",
"0.61006236",
"0.60822755",
"0.6076019",
"0.6074122",
"0.6068572",
"0.6060618",
"0.6055061",
"0.6017933",
"0.59877944",
"0.5974496",
"0.5958982"
] |
0.70047325
|
15
|
+copy_into+ uses PostgreSQL's +COPY FROM STDIN+ SQL statement to do very fast inserts into a table using input preformatting in either CSV or PostgreSQL text format. This method is only supported if pg 0.14.0+ is the underlying ruby driver. This method should only be called if you want results returned to the client. If you are using +COPY FROM+ with a filename, you should just use +run+ instead of this method. The following options are respected: :columns :: The columns to insert into, with the same order as the columns in the input data. If this isn't given, uses all columns in the table. :data :: The data to copy to PostgreSQL, which should already be in CSV or PostgreSQL text format. This can be either a string, or any object that responds to each and yields string. :format :: The format to use. text is the default, so this should be :csv or :binary. :options :: An options SQL string to use, which should contain comma separated options. :server :: The server on which to run the query. If a block is provided and :data option is not, this will yield to the block repeatedly. The block should return a string, or nil to signal that it is finished.
|
def copy_into(table, opts=OPTS)
data = opts[:data]
data = Array(data) if data.is_a?(String)
if block_given? && data
raise Error, "Cannot provide both a :data option and a block to copy_into"
elsif !block_given? && !data
raise Error, "Must provide either a :data option or a block to copy_into"
end
synchronize(opts[:server]) do |conn|
conn.execute(copy_into_sql(table, opts))
begin
if block_given?
while buf = yield
conn.put_copy_data(buf)
end
else
data.each{|buff| conn.put_copy_data(buff)}
end
rescue Exception => e
conn.put_copy_end("ruby exception occurred while copying data into PostgreSQL")
ensure
conn.put_copy_end unless e
while res = conn.get_result
raise e if e
check_database_errors{res.check}
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def copy_from path_or_io, options = {}\n options = { delimiter: \",\", format: :csv, header: true, quote: '\"' }.merge(options)\n options[:delimiter] = \"\\t\" if options[:format] == :tsv\n options_string = if options[:format] == :binary\n \"BINARY\"\n else\n quote = options[:quote] == \"'\" ? \"''\" : options[:quote]\n null = options.key?(:null) ? \"NULL '#{options[:null]}'\" : nil\n force_null = options.key?(:force_null) ? \"FORCE_NULL(#{options[:force_null].join(',')})\" : nil\n delimiter = options[:format] == :tsv ? \"E'\\t'\" : \"'#{options[:delimiter]}'\"\n \"WITH (\" + [\"DELIMITER #{delimiter}\", \"QUOTE '#{quote}'\", null, force_null, \"FORMAT CSV\"].compact.join(', ') + \")\"\n end\n io = path_or_io.instance_of?(String) ? File.open(path_or_io, get_file_mode('r', options[:encoding])) : path_or_io\n\n if options[:format] == :binary\n columns_list = options[:columns] || []\n elsif options[:header]\n line = io.gets\n columns_list = options[:columns] || line.strip.split(options[:delimiter])\n else\n columns_list = options[:columns]\n end\n\n table = if options[:table]\n connection.quote_table_name(options[:table])\n else\n quoted_table_name\n end\n\n columns_list = columns_list.map{|c| options[:map][c.to_s] || c.to_s } if options[:map]\n columns_string = columns_list.size > 0 ? \"(\\\"#{columns_list.join('\",\"')}\\\")\" : \"\"\n connection.raw_connection.copy_data %{COPY #{table} #{columns_string} FROM STDIN #{options_string}} do\n if options[:format] == :binary\n bytes = 0\n begin\n while line = io.readpartial(10240)\n connection.raw_connection.put_copy_data line\n bytes += line.bytesize\n end\n rescue EOFError\n end\n else\n line_buffer = ''\n\n while line = io.gets do\n next if line.strip.size == 0\n\n line_buffer += line\n\n # If line is incomplete, get the next line until it terminates\n if line_buffer =~ /\\n$/ || line_buffer =~ /\\Z/\n if block_given?\n begin\n row = CSV.parse_line(line_buffer.strip, col_sep: options[:delimiter])\n yield(row)\n next if row.all?(&:nil?)\n line_buffer = CSV.generate_line(row, col_sep: options[:delimiter])\n rescue CSV::MalformedCSVError\n next\n end\n end\n\n connection.raw_connection.put_copy_data(line_buffer)\n\n # Clear the buffer\n line_buffer = ''\n end\n end\n end\n end\n end",
"def copy_into_sql(table, opts)\n sql = String.new\n sql << \"COPY #{literal(table)}\"\n if cols = opts[:columns]\n sql << literal(Array(cols))\n end\n sql << \" FROM STDIN\"\n if opts[:options] || opts[:format]\n sql << \" (\"\n sql << \"FORMAT #{opts[:format]}\" if opts[:format]\n sql << \"#{', ' if opts[:format]}#{opts[:options]}\" if opts[:options]\n sql << ')'\n end\n sql\n end",
"def copy_statement(table_name, options = {})\n format_options = replication.csv? ? \"CSV\" : \"GZIP DELIMITER ',' ESCAPE REMOVEQUOTES\"\n sql = <<-CS\n COPY #{table_name} from '#{import_file}' #{\"NOLOAD\" if options[:noload]}\n REGION '#{RailsRedshiftReplicator.s3_bucket_params[:region]}'\n CREDENTIALS 'aws_access_key_id=#{RailsRedshiftReplicator.aws_credentials[:key]};aws_secret_access_key=#{RailsRedshiftReplicator.aws_credentials[:secret]}'\n #{format_options}\n #{copy_options}\n CS\n sql.squish\n end",
"def get_copy_data(sql, file)\n query = 'COPY (' + sql + \") TO STDOUT WITH DELIMITER ',' CSV HEADER\"\n @db.copy_data query do\n until (row = @db.get_copy_data).nil?\n file.write(row)\n end\n end\n end",
"def copy(sql, source: nil, &block)\n copy_handler = if block_given?\n block\n elsif source && File.exist?(source.to_s)\n lambda { |data| file_copy_handler(source, data) }\n elsif source.respond_to?(:read) && source.respond_to?(:eof?)\n lambda { |data| io_copy_handler(source, data) }\n end\n\n run_in_mutex(Vertica::Query.new(self, sql, copy_handler: copy_handler))\n end",
"def copy(table_name = replication.target_table, options = {})\n begin\n RailsRedshiftReplicator.logger.info I18n.t(:importing_file, file: import_file, target_table: table_name, scope: :rails_redshift_replicator)\n result = ::RailsRedshiftReplicator.connection.exec copy_statement(table_name, options)\n replication.imported! if result.result_status == 1 && options[:mark_as_imported]\n rescue => e\n drop_table(table_name) if options[:can_drop_target_on_error]\n if e.message.index(\"stl_load_errors\")\n get_redshift_error\n notify_error\n else\n replication.update_attribute :last_error, e.exception.inspect\n end\n end\n end",
"def copy(source, destination, **options); end",
"def copy_table_sql(table, opts)\n if table.is_a?(String)\n table\n else\n if opts[:options] || opts[:format]\n options = String.new\n options << \" (\"\n options << \"FORMAT #{opts[:format]}\" if opts[:format]\n options << \"#{', ' if opts[:format]}#{opts[:options]}\" if opts[:options]\n options << ')'\n end\n table = if table.is_a?(::Sequel::Dataset)\n \"(#{table.sql})\"\n else\n literal(table)\n end\n \"COPY #{table} TO STDOUT#{options}\"\n end\n end",
"def do_bulk_load(file, table_name, options={})\n q = \"COPY #{table_name} \"\n q << \"(#{options[:columns].join(',')}) \" if options[:columns]\n q << \"FROM '#{File.expand_path(file)}' \"\n if options[:fields]\n q << \"WITH \"\n q << \"DELIMITER '#{options[:fields][:delimited_by]}' \" if options[:fields][:delimited_by]\n q << \"NULL '#{options[:fields][:null_string]}'\" if options[:fields][:null_string]\n if options[:fields][:enclosed_by] || options[:ignore] && options[:ignore] > 0\n q << \"CSV \"\n q << \"HEADER \" if options[:ignore] && options[:ignore] > 0\n q << \"QUOTE '#{options[:fields][:enclosed_by]}' \" if options[:fields][:enclosed_by]\n end\n end\n \n execute(q)\n end",
"def copy_to(db, args = {})\r\n data[\"tables\"].each do |table|\r\n table_args = nil\r\n table_args = args[\"tables\"][table[\"name\"].to_s] if args and args[\"tables\"] and args[\"tables\"][table[\"name\"].to_s]\r\n next if table_args and table_args[\"skip\"]\r\n table.delete(\"indexes\") if table.key?(\"indexes\") and args[\"skip_indexes\"]\r\n db.tables.create(table[\"name\"], table)\r\n \r\n limit_from = 0\r\n limit_incr = 1000\r\n \r\n loop do\r\n ins_arr = []\r\n q_rows = self.select(table[\"name\"], {}, {\"limit_from\" => limit_from, \"limit_to\" => limit_incr})\r\n while d_rows = q_rows.fetch\r\n col_args = nil\r\n \r\n if table_args and table_args[\"columns\"]\r\n d_rows.each do |col_name, col_data|\r\n col_args = table_args[\"columns\"][col_name.to_s] if table_args and table_args[\"columns\"]\r\n d_rows[col_name] = \"\" if col_args and col_args[\"empty\"]\r\n end\r\n end\r\n \r\n ins_arr << d_rows\r\n end\r\n \r\n break if ins_arr.empty?\r\n \r\n db.insert_multi(table[\"name\"], ins_arr)\r\n limit_from += limit_incr\r\n end\r\n end\r\n end",
"def cp_into(options={})\n cmd = \"/bin/cp #{options[:src]} #{@config.ve_private}/#{options[:dst]}\"\n execute(cmd)\n end",
"def copy_table_data(from, to, remaps = [])\n old = columns(from).collect(&:name)\n current = columns(to).collect(&:name)\n remapped_columns = remaps.collect {|c| c.first.to_s}.compact\n common = (current & old).sort - remapped_columns\n from_columns = common.collect {|c| \"`#{c}`\"}\n to_columns = common.collect {|c| \"`#{c}`\"}\n remaps.each do |remap|\n remap = [remap].flatten\n next if remap.length != 2\n from_columns << remap.first\n to_columns << remap.last\n end\n from_columns_to_s = from_columns.join(', ')\n to_columns_to_s = to_columns.join(', ')\n execute \"INSERT INTO #{to}(#{to_columns_to_s}) SELECT #{from_columns_to_s} FROM #{from}\"\n end",
"def copy_table_contents(from, to, columns, rename = {})\n column_mappings = Hash[ columns.map { |name| [name, name] } ]\n rename.each { |a| column_mappings[a.last] = a.first }\n from_columns = columns(from).collect {|col| col.name}\n columns = columns.find_all{ |col| from_columns.include?(column_mappings[col]) }\n quoted_columns = columns.map { |col| quote_column_name(col) } * ','\n\n quoted_to = quote_table_name(to)\n\n raw_column_mappings = Hash[ columns(from).map { |c| [c.name, c] } ]\n\n execute(\"SELECT * FROM #{quote_table_name(from)}\", 'Copy Table').each do |row|\n sql = \"INSERT INTO #{quoted_to} (#{quoted_columns}) VALUES (\"\n\n column_values = columns.map do |col|\n quote(row[column_mappings[col]], raw_column_mappings[col])\n end\n\n sql << column_values * ', '\n sql << ')'\n exec_insert sql, 'Copy Table', []\n end\n end",
"def direct_import_from_csv(dataset, opts = {:to => nil, :delimiter => nil, :header => nil})\n delimiter = opts[:delimiter] || \",\"\n header = \"HEADER\" if opts[:header] == true\n table = opts[:to].table_name\n raise TypeError if dataset.class != String\n ActiveRecord::Base.connection.execute(\"COPY #{table} FROM '#{dataset}' DELIMITER \\'#{delimiter}\\' CSV #{header}\")\n end",
"def format table, keys, values\n <<-SQL\nCOPY #{table} (#{keys.join(', ')}) FROM stdin;\n#{values.collect { |row| row.join \"\\t\" }.join \"\\n\"}\n\\\\.\n SQL\n end",
"def copy(from, to, options = nil, binary = false)\n options ||= self.options if self.respond_to?(:options)\n if binary\n contents = File.new(from,\"rb\").read\n else\n contents = File.new(from).read\n end\n write_file to, contents, options, binary\n end",
"def copy_template(input, output)\n file = File.open(input, \"r\")\n f = File.open(output,\"w\")\n while (line = file.gets)\n f.write(line)\n end\n f.close\n file.close\n end",
"def copy(path, destination, options = {})\n opts = options.nil? ? {} : options.dup\n opts[:headers] = options[:headers].nil? ? {} : options[:headers].dup\n opts[:headers]['Destination'] = destination\n execute('COPY', path, opts)\n end",
"def copy(source, destination, db: nil, replace: false)\n command = [:copy, source, destination]\n command << \"DB\" << db if db\n command << \"REPLACE\" if replace\n\n send_command(command, &Boolify)\n end",
"def copy(from, to, options = nil, binary = false)\n options ||= self.options if self.respond_to?(:options)\n if binary\n contents = File.new(from,\"rb\").read\n else\n contents = File.new(from).read\n end \n write_file to, contents, options, binary\n end",
"def cp_file_to_file(options={})\n from = options[:from]\n to = options[:to]\n to_stdout = to.nil? || to == '-'\n index = !to_stdout\n unless to_stdout\n to = '.' if to == ''\n to = File.join(to, File.basename(from)) if File.directory?(to)\n end\n \n open(from) do |f|\n Shell.new(:quiet=>true).write to, f.read, :mode=>'w:ascii-8bit'\n # f.copy_descriptor(to) if index\n end\n end",
"def cp!( from_file, to_file, opts = {} )\r\n args = { :source => from_file, :destination => to_file }\r\n args[:source_address] = opts[:source_address] if opts[:source_address]\r\n \r\n begin\r\n got = @ndev.rpc.file_copy( args )\r\n rescue => e\r\n raise IOError, e.rsp.xpath('rpc-error/error-message').text.strip\r\n else\r\n return true\r\n end\r\n end",
"def copy from, to\n add \"cp #{from} #{to}\", check_file(to)\n end",
"def copy(from, to)\n \n end",
"def copy_backup project_id:, instance_id:, cluster_id:, backup_id:, source_backup:, expire_time:\n tables.copy_backup parent: \"projects/#{project_id}/instances/#{instance_id}/clusters/#{cluster_id}\",\n backup_id: backup_id,\n source_backup: source_backup,\n expire_time: expire_time\n end",
"def file_copy(source, dest, options={})\n\t\tFileUtils.cp source, dest, options\n\tend",
"def cp(from_location, to_location)\n @client.file_copy(from_location, to_location)\n rescue\n puts $! if @@verbose\n nil\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 build_sql(value_str)\n \"COPY #{value_str} FROM STDIN WITH (FORMAT csv, DELIMITER E'\\x0B')\"\n end",
"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 db_to_file(src, dest)\n pool = Connections.init_pool src\n query_stream = QueryStream.new pool\n file_writer = FileWriter.new dest\n\n Pipe.new from: query_stream, to: file_writer\n end",
"def copy(data)\n File.popen('pbcopy', 'w') { |p| p << data.to_s }\n $?.success?\nend",
"def create_table_from_csv(name, csv_path)\r\n # Get headers\r\n csv = CSV.open(csv_path, :headers => true)\r\n first = csv.first\r\n unless first\r\n raise \"File Empty!!!\"\r\n end\r\n \r\n # sanitize\r\n headers = first.headers\r\n headers.each_with_index {|e, index|\r\n if e.nil? or e.empty?\r\n headers[index] = \"column_#{index + 1}\"\r\n end\r\n }\r\n headers.map!{|e| e.downcase.underscore }\r\n \r\n # check if every field name is unique\r\n if headers.count != headers.uniq.count\r\n raise \"Field name must be UNIQUE: \\nPlease check your input headers: [#{headers.join(', ')}]\"\r\n end\r\n\r\n # Create table\r\n create_table_sql = headers.map{|e| e == 'id' ? \"\\\"#{e}\\\" integer\" : \"\\\"#{e}\\\" text\"}.join(\",\")\r\n create_table_sql = \"drop table if exists #{name}; create table #{name}( #{create_table_sql} );\"\r\n query(create_table_sql)\r\n\r\n # Dump data\r\n insert_data_sql = headers.map{|e| \"\\\"#{e}\\\"\"}.join(\",\")\r\n insert_data_sql = \"COPY #{name}( #{insert_data_sql} ) FROM '#{csv_path}' DELIMITER ',' CSV HEADER;\"\r\n\r\n # Change output file permission so that postgres user can read it\r\n begin\r\n FileUtils.chmod 0755, csv_path\r\n rescue Exception => ex\r\n puts \"Error while changing file permission\"\r\n end\r\n\r\n if local?\r\n query(insert_data_sql)\r\n else\r\n puts \"\\nWARNING: pushing data to remote server [#{$options[:host]}].\\nBe sure you have the correct version of `psql` command installed\\n\\n\"\r\n insert_data_sql = \"PGPASSWORD=#{$options[:username]} psql -U #{$options[:username]} -h #{$options[:host]} -p #{$options[:listen]} #{$options[:database]} -c \\\"\\\\#{insert_data_sql}\\\"\"\r\n\r\n `#{insert_data_sql}`\r\n `PGPASSWORD=\"\"`\r\n end\r\nend",
"def copy_file(src, dest, preserve = false, dereference = true)\n ent = Entry_.new(src, nil, dereference)\n ent.copy_file dest\n ent.copy_metadata dest if preserve\n end",
"def to_inserts(args={})\n args[:table] ||= Pathname.new(@filename).basename.to_s.downcase.gsub(/\\W/, '_')\n args[:before] ||= @@defaults[:before]\n args[:after] ||= @@defaults[:after]\n insert_sql = args[:ignore] ? 'insert ignore' : 'insert'\n if args[:bulk]\n args[:before] += \"#{insert_sql} into #{args[:table]} values\"\n args[:values_glue] ||= \", \"\n args[:row_format] ||= \" (%s)\"\n args[:row_glue] ||= \",\\n\"\n else\n args[:before] ||= \"\"\n args[:values_glue] ||= \", \"\n args[:row_format] ||= \"#{insert_sql} into #{args[:table]} values(%s)\"\n args[:row_glue] ||= \";\\n\"\n end\n to_any args\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 insert_into_sql(sql)\n sql << \" INTO \"\n if (f = @opts[:from]) && f.length == 1\n identifier_append(sql, server_version >= 90500 ? f.first : unaliased_identifier(f.first))\n else\n source_list_append(sql, f)\n end\n end",
"def pbcopy(input)\n str = input.to_s\n IO.popen('pbcopy', 'w') { |f| f << str }\n str\n end",
"def import_original_raster\n transaction_with_timeout do |db|\n db.run %{DROP TABLE #{base_table_fqtn}}\n end\n out_file = Shellwords.escape(raster2psql_original_filepath)\n raster_import_command = %{ printf 'SET statement_timeout TO #{statement_timeout};\\n' > #{out_file} && \\\n #{raster2pgsql_path} -t #{BLOCKSIZE} -C -x -Y -I -f #{RASTER_COLUMN_NAME} \\\n #{Shellwords.escape(filepath)} #{Shellwords.escape(SCHEMA + \".\" + table_name)} >> #{out_file}}\n\n stdout, stderr, status = Open3.capture3(raster_import_command)\n output_message = \"(#{status}) |#{stdout + stderr}| Command: #{raster_import_command}\"\n self.command_output << \"\\n#{output_message}\"\n self.exit_code = status.to_i\n raise TiffToSqlConversionError.new(output_message) if status.to_i != 0\n \n return load_sql_with_psql(raster2psql_original_filepath)\n end",
"def import_csv_file(db, encoding, file, table)\n verbose \"Reading the header row.\"\n row_num = 0\n\n # Decide whether to get the CSV data from a file or STDIN\n if file == ''\n csv = CSV($stdin)\n if table == ''\n table = 'stdin'\n end\n else\n csv = CSV.open(file, encoding:encoding)\n end\n\n # Process each line of the CSV data\n csv.each do |row|\n # header row\n if row_num == 0\n verbose \"Columns are: #{row.inspect}\"\n\n column_defs = \"\"\n column_names = \"\"\n column_placeholders = \"\"\n\n row.each do |column|\n column_defs << \"#{column} VARCHAR, \"\n column_names << \"#{column}, \"\n column_placeholders << \"?, \"\n end\n\n # Remove the comma after last column\n column_defs.sub!(/,\\ \\Z/, '')\n column_names.sub!(/,\\ \\Z/, '')\n column_placeholders.sub!(/,\\ \\Z/, '')\n\n verbose \"Creating the #{table} table:\"\n create_table_query = \"CREATE TABLE IF NOT EXISTS #{table} (#{column_defs})\"\n verbose \"#{create_table_query};\"\n db.execute create_table_query\n\n verbose \"Prepared statement is:\"\n prepared_statement = \"INSERT INTO #{table} (#{column_names}) VALUES (#{column_placeholders})\"\n verbose \"#{prepared_statement};\"\n @insert = db.prepare(prepared_statement)\n # non-header rows\n else\n verbose \"Inserting row #{row_num}.\"\n @insert.execute(row)\n end\n row_num += 1\n end\nend",
"def cp(from_path, to_path, replace=false)\n copy(from_path, to_path, nil, true, replace)\n end",
"def cp(*args, **kwargs)\n queue CopyCommand, args, kwargs\n end",
"def local_copy_file(source, options = {})\n Uploadcare::File.local_copy(source, options)\n end",
"def copy_database(from, to, from_host=\"localhost\")\n oh = OrderedHash.new\n oh[:copydb] = 1\n oh[:fromhost] = from_host\n oh[:fromdb] = from\n oh[:todb] = to\n self[\"admin\"].command(oh)\n end",
"def copy_file(src, dest, preserve = false, dereference = true)\r\n ent = Entry_.new(src, nil, dereference)\r\n ent.copy_file dest\r\n ent.copy_metadata dest if preserve\r\n end",
"def copy_file(src, dest, preserve = false, dereference = true)\r\n ent = Entry_.new(src, nil, dereference)\r\n ent.copy_file dest\r\n ent.copy_metadata dest if preserve\r\n end",
"def import_original_raster\n db.run %{DROP TABLE #{base_table_fqtn}}\n raster_import_command = [raster2pgsql_path, '-t', BLOCKSIZE, '-C', '-x', '-Y', '-I', '-f', RASTER_COLUMN_NAME,\n filepath, \"#{SCHEMA}.#{table_name}\"]\n # TODO refactor with run_raster2pgsql\n pipeline = [raster_import_command, psql_base_command]\n Open3.pipeline_r(*pipeline, err: :out) do |output_st, statuses|\n status = statuses.last.value\n output = output_st.read\n output_message = \"(#{status}) |#{output}| Command: #{pipeline}\"\n self.command_output << \"\\n#{output_message}\"\n self.exit_code = status.to_i\n\n if output =~ /canceling statement due to statement timeout/i\n raise StatementTimeoutError.new(output_message, ERRORS_MAP[StatementTimeoutError])\n end\n\n raise UnknownSridError.new(output_message) if output =~ /invalid srid/i\n raise TiffToSqlConversionError.new(output_message) if status.to_i != 0\n raise TiffToSqlConversionError.new(output_message) if output =~ /failure/i\n end\n end",
"def copy(force = false)\n yield if block_given?\n\n @force_table_create = force\n tables_count = Rmre::Source::Db.connection.tables.length\n Rmre::Source::Db.connection.tables.sort.each_with_index do |table, idx|\n info \"Copying table #{table} (#{idx + 1}/#{tables_count})...\"\n copy_table(table)\n end\n end",
"def copyFileWithSubst(from, to)\n puts \"-- Copy\"\n puts \"From: \" + from\n puts \"To: \" + to\n createFilePath(to)\n File.open(from, 'r') do |fsrc|\n File.open(to, 'w') do |fdest|\n fsrc.each_line do |line|\n fdest.puts( substString(line) )\n end\n end\n end\n end",
"def remote_copy_file(source, target, options = {})\n Uploadcare::File.remote_copy(source, target, options)\n end",
"def copy_file(src, dst)\n File.open(src) do |fin|\n File.open(dst, 'w') do |fout|\n fout.write(fin.read)\n end\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 copy(from, to)\n @ctx.cp(@path + from, @path + to)\n end",
"def copy(uri, destination, options = {})\n opts = options.nil? ? {} : options.dup\n # also copy headers!\n opts[:headers] = options[:headers].nil? ? {} : options[:headers].dup\n opts[:headers]['Destination'] = destination\n execute(uri, :copy, opts)\n end",
"def copy(str = nil)\n clipboard_copy(:string => (!$stdin.tty? ? $stdin.read : str))\n end",
"def export(to = nil, opts = {}, &row_proc)\n @row_proc = row_proc\n @local_options = opts\n\n raise \":connection should be\" unless connection\n raise \":sql should be\" unless sql\n\n with_temp_file?(to, temp_file, temp_dir) do |dest|\n export_to(dest)\n end\n end",
"def copy(*froms, to)\n froms.each do |from|\n FileUtils.cp(from, to)\n end\n end",
"def csv_dump(addr, root_dir)\n filename = \"full.csv\"\n dump_dir = File.join(root_dir)\n filepath = File.join(dump_dir, filename)\n\n cmd = \"psql -c '\\\\copy (SELECT * FROM outdoor_env WHERE (apogee_w_m2 IS NOT NULL AND address=#{addr}) ORDER BY db_time DESC) To #{filepath} With CSV header\\'\"\n run_command(cmd)\nend",
"def copy(*args) IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts args.map(&:inspect) }; end",
"def copy_file(source, destination)\n FileUtils.cp(source, destination)\n destination\n end",
"def copy_file(source, destination)\n FileUtils.cp(source, destination)\n destination\n end",
"def pbcopy(input)\n str = input.to_s\n IO.popen('pbcopy', 'w') { |f| f << str }\n str\nend",
"def copy_template name, options = {}\n FileUtils.mkdir_p dest\n FileUtils.cp_r path_to_template(name), options[:to] ?\n \"#{dest}/#{options[:to]}\" :\n dest\n end",
"def copy(from, to)\n FileUtils.mkdir_p(File.dirname(to))\n # Pathname(a_path_to).mkpath # Throw Gem::LoadError (fileutils is not part of the bundle. Add it to your Gemfile.)\n\n # NOTE: Give the path regardless if is a File of Pathname\n path = from.path if from.respond_to?(:path)\n path ||= from\n\n # NOTE: See if a move, or another trick to avoid copy can be done here, for performances matter.\n FileUtils.cp(path, to)\n\n # Clean Tempfile\n from.close if from.respond_to?(:close) # Can be apply to File as well.\n from.unlink if from.respond_to?(:unlink) # Only for Tempfile\n\n nil\n end",
"def copy_table(old_table_name, new_table_name)\n transaction do\n execute \"CREATE TABLE #{new_table_name} LIKE #{old_table_name}\"\n execute \"INSERT INTO #{new_table_name} SELECT * FROM #{old_table_name}\"\n end\n end",
"def FileCopy(src, dst)\n success?(parse(cmd(with_args(src, dst))))\n end",
"def copy\n FileUtils.mkdir_p output_folder unless Dir.exists? output_folder\n \n infos = {}\n @converted_files.each do |format, input_path|\n output_path = output_path(format)\n # se il percorso del file è uguale a quello vecchio è lo stesso file; per cui non copio\n # (è un caso che si verifica p.e. nel caso di un errore nel Composer, che ripristina il file vecchio)\n FileUtils.cp input_path, output_path if input_path != output_path\n\n model.send :\"#{format}_duration=\", \n if durations?\n durations[format]\n else\n info = Info.new(output_path)\n infos[format] = info\n info.duration\n end\n end\n\n extract_versions(infos)\n\n model.converted = true\n model.send :\"rename_#{column}=\", true\n model.send :\"#{column}=\", processed_original_filename_without_extension\n model[column] = processed_original_filename_without_extension\n model.save!\n\n model.send :\"rename_#{column}=\", nil\n model.skip_conversion = nil\n model.send :\"reload_#{column}\"\n\n true\n end",
"def cp srcpath, dstpath\n end",
"def copy_table(old_table_name, new_table_name)\n transaction do\n execute \"CREATE TABLE #{new_table_name} LIKE #{old_table_name}\"\n execute \"INSERT INTO #{new_table_name} SELECT * FROM #{old_table_name}\"\n end\n end",
"def copy(source, destination, query = {})\n\n # get the list of properties that exist in the source and destination\n destination_properties = properties(destination)\n fields = query[:fields] ||= properties(source).select { |property| destination_properties.include?(property) }\n\n repository(destination) do\n all(query.merge(:repository => source)).map do |resource|\n create(fields.map { |property| [ property.name, property.get(resource) ] }.to_hash)\n end\n end\n end",
"def copy_to(other); 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 copy_rows( field, \n table_struct, \n src_table_name = TABLE_NAME, \n dest_table_name = NEW_TABLE_NAME, \n num_rows = ROWS_PER_TRANSACTION)\n rows = grab_rows(field, src_table_name, num_rows)\n keys_for_delete = insert_rows(rows, field, table_struct, dest_table_name)\n keys_for_delete\nend",
"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 copy(from_path, to_path, opts = {})\n input_json = {\n from_path: from_path,\n to_path: to_path,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/copy\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def pbcopy(input)\n str = input.to_s\n IO.popen('pbcopy', 'w') { |f| f << str }\n str\nend",
"def copy(options = {})\n copy_object(options)\n end",
"def query(sql, file)\n return if sql.nil? || file.nil?\n sql.strip!\n get_copy_data(sql.chomp(';'), file)\n end",
"def copy(text)\n IO.popen('pbcopy', 'w') {|f| f << text}\nend",
"def preform_copy_file\n @destination_files.each do |destination|\n copy_file(@sources.pop, destination)\n end\n end",
"def copy(from=nil,to=nil)\n if from.class == String && to.class == String && block_given?\n @j_del.java_method(:copy, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(from,to,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling copy(from,to)\"\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 copy\n if args.dest.instance_of?(Pathname)\n n = args.dest.to_s.delete_prefix(project.write_path(:services).to_s).delete_prefix('/')\n w = project.write_path(:services).join(service.name)\n w.join(Pathname.new(n).split.first).mkpath\n @args = args.merge('dest' => w.join(n).to_s)\n end\n cmd = service.copy(args.src, args.dest)\n Cnfs.logger.info cmd.join(\"\\n\")\n result = command.run!(*cmd)\n raise Cnfs::Error, result.err if result.failure?\n\n # Signal.trap('INT') do\n # warn(\"\\n#{caller.join(\"\\n\")}: interrupted\")\n # # exit 1\n # end\n end",
"def copy(target, source)\n write target, read(source)\n end",
"def copy_stream(src, dest)\n IO.copy_stream(src, dest)\n end",
"def move_table(from, to, options = {}, &block)\n copy_table(from, to, options, &block)\n drop_table(from)\n end",
"def stream_copy(file)\n # Create a pipe to link the get / store commands\n read_pipe, write_pipe = IO.pipe\n\n # Fork a child process to write to the pipe\n Process.fork do\n read_pipe.close\n @source_mogile.get_file_data(file.dkey, write_pipe)\n write_pipe.close\n end\n\n # Read info off the pipe that the child is writing to\n write_pipe.close\n @dest_mogile.store_file(file.dkey, file.classname, read_pipe)\n read_pipe.close\n\n # Wait for the child to exit\n Process.wait\n\n # Throw an exception if the child process exited non-zero\n if $?.exitstatus.nonzero?\n Log.instance.error(\"Child exited with a status of [ #{$?.exitstatus} ].\")\n raise \"Error getting file data from [ #{@source_mogile.domain} ]\"\n end\n end",
"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 to_copy\n @to_copy ||= \"#{to_var( '_copy' )} = #{to_arg};\"\n end",
"def copy(io, context)\n storage.upload(io, context[:location], context[:metadata])\n ensure\n io.close rescue nil\n end",
"def copyfile from, to\n FileUtils.mkdir_p File.dirname to\n cp from, to\n end",
"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 copy_file(source_file, dest_file, settings)\n\tFileUtils.cp_r(source_file, dest_file)\nend",
"def copy_stream(src, dest)\r\n fu_copy_stream0 src, dest, fu_stream_blksize(src, dest)\r\n end",
"def copy_stream(src, dest)\r\n fu_copy_stream0 src, dest, fu_stream_blksize(src, dest)\r\n end",
"def copy\n FileUtils.cp_r(@src, @dest)\n end",
"def file_copy(from_path, to_path)\n params = {\n \"root\" => @root,\n \"from_path\" => format_path(from_path, false),\n \"to_path\" => format_path(to_path, false),\n }\n response = @session.do_post build_url(\"/fileops/copy\", params)\n parse_response(response)\n end",
"def copy_table(old_table_name, new_table_name)\n execute add_select_into_table(new_table_name, \"SELECT * FROM #{old_table_name}\")\n end",
"def copy_blob(destination_container, destination_blob, source_container, source_blob, options={})\n source_blob_uri = blob_uri(source_container, source_blob, options[:source_snapshot] ? { 'snapshot' => options[:source_snapshot] } : {}).to_s\n\n return copy_blob_from_uri(destination_container, destination_blob, source_blob_uri, options)\n end"
] |
[
"0.7032002",
"0.6770422",
"0.66057664",
"0.6383086",
"0.62767667",
"0.60340726",
"0.58851403",
"0.5839566",
"0.5807533",
"0.57698584",
"0.57081026",
"0.5655016",
"0.5653409",
"0.5566205",
"0.5379597",
"0.5323078",
"0.5316464",
"0.5315271",
"0.5310676",
"0.52876455",
"0.51784873",
"0.51702046",
"0.5166479",
"0.5150207",
"0.50638837",
"0.50617313",
"0.50226516",
"0.50013936",
"0.49763656",
"0.49617213",
"0.49565533",
"0.49513534",
"0.4941714",
"0.48676863",
"0.48456627",
"0.48439294",
"0.48439294",
"0.48438323",
"0.4841429",
"0.4828968",
"0.4822587",
"0.48187461",
"0.48152536",
"0.4811412",
"0.4801497",
"0.4798005",
"0.4798005",
"0.47816977",
"0.47763312",
"0.47694236",
"0.47691882",
"0.4768234",
"0.47639206",
"0.4761916",
"0.47529075",
"0.4752712",
"0.47479",
"0.4741438",
"0.4725621",
"0.4722783",
"0.47042638",
"0.47042638",
"0.4697635",
"0.46893203",
"0.46840212",
"0.46815112",
"0.46756437",
"0.46756244",
"0.46613505",
"0.46515217",
"0.46370468",
"0.46321994",
"0.46223375",
"0.4621823",
"0.4620516",
"0.46198392",
"0.460929",
"0.46084616",
"0.46008563",
"0.4599603",
"0.45885724",
"0.45882136",
"0.45853323",
"0.45796683",
"0.457958",
"0.457918",
"0.45685354",
"0.45652652",
"0.4561026",
"0.45561576",
"0.45490482",
"0.4548968",
"0.4545388",
"0.4542005",
"0.45256832",
"0.45256832",
"0.45214474",
"0.45153537",
"0.45131546",
"0.44961417"
] |
0.7367899
|
0
|
Listens on the given channel (or multiple channels if channel is an array), waiting for notifications. After a notification is received, or the timeout has passed, stops listening to the channel. Options: :after_listen :: An object that responds to +call+ that is called with the underlying connection after the LISTEN statement is sent, but before the connection starts waiting for notifications. :loop :: Whether to continually wait for notifications, instead of just waiting for a single notification. If this option is given, a block must be provided. If this object responds to +call+, it is called with the underlying connection after each notification is received (after the block is called). If a :timeout option is used, and a callable object is given, the object will also be called if the timeout expires. If :loop is used and you want to stop listening, you can either break from inside the block given to listen, or you can throw :stop from inside the :loop object's call method or the block. :server :: The server on which to listen, if the sharding support is being used. :timeout :: How long to wait for a notification, in seconds (can provide a float value for fractional seconds). If this object responds to +call+, it will be called and should return the number of seconds to wait. If the loop option is also specified, the object will be called on each iteration to obtain a new timeout value. If not given or nil, waits indefinitely. This method is only supported if pg is used as the underlying ruby driver. It returns the channel the notification was sent to (as a string), unless :loop was used, in which case it returns nil. If a block is given, it is yielded 3 arguments: the channel the notification was sent to (as a string) the backend pid of the notifier (as an integer), and the payload of the notification (as a string or nil).
|
def listen(channels, opts=OPTS, &block)
check_database_errors do
synchronize(opts[:server]) do |conn|
begin
channels = Array(channels)
channels.each do |channel|
sql = "LISTEN ".dup
dataset.send(:identifier_append, sql, channel)
conn.execute(sql)
end
opts[:after_listen].call(conn) if opts[:after_listen]
timeout = opts[:timeout]
if timeout
timeout_block = timeout.respond_to?(:call) ? timeout : proc{timeout}
end
if l = opts[:loop]
raise Error, 'calling #listen with :loop requires a block' unless block
loop_call = l.respond_to?(:call)
catch(:stop) do
loop do
t = timeout_block ? [timeout_block.call] : []
conn.wait_for_notify(*t, &block)
l.call(conn) if loop_call
end
end
nil
else
t = timeout_block ? [timeout_block.call] : []
conn.wait_for_notify(*t, &block)
end
ensure
conn.execute("UNLISTEN *")
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def listen_to_channel(connection, channel, &block)\n connection.execute(\"LISTEN #{channel}\")\n\n loop do\n connection.raw_connection.wait_for_notify(10) do |event, pid, payload|\n return if yield payload\n end\n end\n ensure\n connection.execute(\"UNLISTEN *\")\n end",
"def notify_channel(connection, channel, payload)\n connection.execute(\"NOTIFY #{channel}, #{payload}\")\n end",
"def on(channel, &block)\n @actions[channel] = block\n @connection.exec(\"LISTEN #{channel}\")\n @logger.info \"Listener listening on #{channel}\"\n end",
"def listen(channel, action)\n actions[channel] = action\n pg_connection.exec(%[LISTEN \"#{channel}\";])\n end",
"def listen_on(channel)\n sns.subscribe(\n topic_arn: channel.arn,\n protocol: 'application',\n endpoint: channel.endpoint\n )\n end",
"def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end",
"def subscribe_with_timeout(timeout, *channels, &block); end",
"def onotify (channel, *args)\n\n do_notify(:all, channel, *args)\n do_notify(channel, channel, *args)\n end",
"def discover\n @socket ||= new_socket\n\n listen\n\n if block_given? then\n loop do\n notification = @queue.pop\n\n yield notification\n end\n else\n sleep @timeout\n\n notifications = []\n notifications << @queue.pop until @queue.empty?\n notifications\n end\n ensure\n stop_listening\n @socket.close if @socket and not @socket.closed?\n @socket = nil\n end",
"def subscribe_to(channel, &block)\n subscriptions[channel].subscribe(&block)\n end",
"def psubscribe_with_timeout(timeout, *channels, &block); end",
"def subscribe( channel, &callback )\n fail NotImplementedError\n end",
"def subscribe(channel, *channels, &block); end",
"def notify(channel, opts=OPTS)\n sql = String.new\n sql << \"NOTIFY \"\n dataset.send(:identifier_append, sql, channel)\n if payload = opts[:payload]\n sql << \", \"\n dataset.literal_append(sql, payload.to_s)\n end\n execute_ddl(sql, opts)\n end",
"def listen(&block)\n loop do\n block.call receive\n end\n end",
"def subscribe_with_timeout(timeout, *channels, &block)\n _subscription(:subscribe_with_timeout, timeout, channels, block)\n end",
"def subscribe( channel, callback )\n if @channels.include?(channel)\n @channels[channel] << callback\n else\n @channels[channel]=[callback]\n @client.subscribe channel\n end\n end",
"def listen &block\n register_accept_listener &block if block_given?\n \n @accept_thread ||= Thread.new do\n loop do\n # Package in an Ionian::Socket\n begin\n client = Ionian::Socket.new @server.accept\n @accept_listeners.each { |listener| listener.call client }\n rescue Errno::EBADF\n # This ignores the connection if the client closed it before it\n # could be accepted.\n rescue IOError\n # This ignores the connection if the client closed it before it\n # could be accepted.\n end\n end\n end\n end",
"def subscribe(channel, &block)\n faye.subscribe \"/topic/#{channel}\", &block\n end",
"def psubscribe_with_timeout(timeout, *channels, &block)\n _subscription(:psubscribe_with_timeout, timeout, channels, block)\n end",
"def listen(&block)\n queue.bind(exchange).subscribe do |delivery_info, metadata, event|\n block.call(event)\n end\n nil\n end",
"def listen_wait\n\t\t\tif block_given?\n\t\t\t\t@conn.sit { yield }\n\t\t\telse\n\t\t\t\t@conn.sit\n\t\t\tend\n\t\tend",
"def listen\n @inbound = @socket.gets\n puts '>> ' << @inbound\n\n # Stay connected to the server.\n if @inbound =~ /^PING (?<msg>.*)$/\n pong = Regexp.last_match[:msg]\n send \"PONG #{pong}\"\n end\n\n # Respond to messages in the channel.\n @listeners.each do |listener|\n listener.response.call if @inbound.match listener.pattern\n end\n end",
"def subscribe(channel, *channels, &block)\n if channels.empty?\n @subscribed_node = node_for(channel)\n @subscribed_node.subscribe(channel, &block)\n else\n ensure_same_node(:subscribe, [channel] + channels) do |node|\n @subscribed_node = node\n node.subscribe(channel, *channels, &block)\n end\n end\n end",
"def notifier\n @reactor_notify = if block_given?\n Proc.new\n else\n @reactor_notify_default\n end\n self\n end",
"def subscribe(topic, channel, options={}, &block)\n Util.assert_topic_and_channel_valid(topic, channel)\n subscriber = nil\n name = \"#{topic}:#{channel}\"\n @subscriber_mutex.synchronize do\n raise \"Already subscribed to #{name}\" if @subscribers[name]\n subscriber_class = block_given? ? Subscriber : QueueSubscriber\n subscriber = @subscribers[name] = subscriber_class.new(self, topic, channel, options, &block)\n end\n\n @nsqd_tcp_addresses.each do |addr|\n address, port = addr.split(':')\n subscriber.add_connection(address, port.to_i)\n end\n subscriber\n end",
"def monitor channel, type\n channel.starting do\n if session = @sessions[channel.id]\n log.error \"Session already monitored: #{channel.id}\"\n return\n end\n\n session = MonitorSession.new channel, type\n\n # provide the session to any already connected clients.\n @clients.each do |peer, client|\n session.register peer, client\n end\n\n @sessions[channel.id] = session\n end\n\n channel.stopping do\n @sessions.delete channel.id\n end\n end",
"def listen(options = {}, server = nil)\n server ||= create_server(options)\n Reactor.queue_task do\n monitor = Reactor.selector.register(server, :r)\n monitor.value = proc do\n accept_socket server, options do |io| # this next block won't run until ssl (if enabled) has started\n adapter = SERVER_ADAPTER.new(io, options)\n yield(adapter.driver, adapter) if block_given?\n Reactor.queue_task do\n adapter.add_to_reactor\n end\n logger.info \"Host accepted client connection #{io} on port #{options[:port]}\"\n end\n end\n end\n Reactor.start\n logger.info \"Host listening for new connections on port \" + options[:port].to_s\n server\n end",
"def broadcast_to_channel\n if Setting.first.reminders_enabled\n ActionCable.server.broadcast 'notification_channel', notification: self.to_serialize\n end\n end",
"def on_notification(&block)\n @callback = block\n end",
"def subscribe(*channels, &block); end",
"def listen(&block)\n block ||= self.class.for_client\n Supernova.logger.info { \"Server started.\" }\n while run\n next unless IO.select [server], nil, nil, 1\n thread_list << Thread.start(server.accept) do |client|\n Supernova.logger.info { \"Client accepted.\" }\n begin\n protocol = Protocol.new(\n @protocol_options.merge(:type => :server))\n\n @protocols << protocol\n\n protocol.socket = client\n protocol.handshake\n\n block.call(protocol)\n rescue ExitError => e\n Supernova.logger.error { \"Closing while client is connected. Notifying...\" }\n if protocol\n protocol.close(:shutdown)\n else\n client.close unless client.closed?\n end\n rescue RemoteCloseError\n rescue ProtocolError => e\n Supernova.logger.error { \"Client failed: #{e.message} #{e.backtrace.join(\"\\n\")}\" }\n client.close unless client.closed?\n end\n\n thread_list.delete(Thread.current)\n Supernova.logger.info { \"Client disconnected.\" }\n protocol.close(false)\n end\n end\n end",
"def initialize(channel, &callback)\n @channel = channel\n @redis = Connection.new\n subscribe &callback\n end",
"def set_notification_channel\n @notification_channel = NotificationChannel.find(params[:id])\n end",
"def send_notification *args, &block\n if args.length == 1 && args.first.kind_of?( Rpc::Notification )\n _send_request args.first\n elsif args.length == 1 && args.first.kind_of?( Hash )\n h = args.first\n send_notification( h[\"method\"], h[\"params\"], &block )\n elsif args.length == 2\n _send_request Rpc::Notification.new(self, *args)\n else\n raise Rpc::ServerError(-1, extra_msg: \"in Rpc::Connection.send_notification : Wrong number of argument.\", args: args)\n end\n end",
"def handle_monitor request, *channels\n channels.map(&:to_sym).each do |channel|\n @node.subscribe(channel) {|*data| respond(request, [channel, *data]) }\n name, *params = channel.to_s.split(\"_\")\n send(\"handle_monitor_#{name}\", request, *params)\n log.info { \"Client subscribed to channel #{channel}\" }\n end\n nil\n end",
"def channel(name)\n arn = self.fetch(name)\n region = arn.split(':')[3]\n notifier_builder.new(region: region).topics[arn]\n end",
"def subscribe(*args, &block)\n listener = Listener.new(*args)\n listener.on_delivery(&block)\n @listeners << listener\n end",
"def listen(&block)\n AMQP.start(:host => @host) do\n exchange = MQ.direct(@x_request)\n reply = MQ.direct(@x_response)\n queue = MQ.queue(@server_q)\n notify = MQ.fanout(@x_notify)\n \n puts \"request xchange =#{@x_request}\"\n puts \"reply xchange =#{@x_response}\"\n puts \"server queue =#{@server_q}\"\n \n @do_notify = proc do |msg|\n notify.publish(Blix.to_binary_data(msg))\n puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n end\n \n queue.bind( exchange).subscribe do |header,body|\n \n # extract the headers and create a transport for this\n # client. the reply_to field may be in the application\n # headers field so check for it there also.\n \n reply_to = header.reply_to || ( header.headers && header.headers[:reply_to])\n message_id = header.message_id || ( header.headers && header.headers[:message_id])\n \n if reply_to && message_id\n # process the call\n response = block && block.call(body)\n \n # publish the reply only if there is a response\n \n if response\n options = {}\n options[:key] = reply_to\n options[:message_id] = message_id\n data = Blix.to_binary_data(response)\n \n puts \"[AmqpServer] response: data=#{data}, options=#{options}\" if $DEBUG\n \n reply.publish(data, options )\n end\n else\n puts \"missing reply-to /message_id field .....#{header.inspect}\"\n end\n end\n \n# # send any notifications that are waiting.\n# while !@notify_queue.empty?\n# message = @notify_queue.pop\n# channel.fanout(@x_notify).publish(Blix.to_binary_data(message))\n# puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n# end\n end\n \n end",
"def find_channel(channel_name, server_name = nil, type: nil)\n results = []\n\n if /<#(?<id>\\d+)>?/ =~ channel_name\n # Check for channel mentions separately\n return [channel(id)]\n end\n\n @servers.each_value do |server|\n server.channels.each do |channel|\n results << channel if channel.name == channel_name && (server_name || server.name) == server.name && (!type || (channel.type == type))\n end\n end\n\n results\n end",
"def listen(_deprecated_messages=nil, &block)\n raise Error.new(\"Beetle::Client#listen no longer works with arguments. Please use #listen_queues(['queue1', 'queue2']) instead\") if _deprecated_messages\n listen_queues(&block)\n end",
"def notifier\n @loop_notify.promise\n end",
"def notify(context)\n \n context.connection_listeners.each do |connection_listener|\n yield connection_listener\n end\n \n end",
"def channel_update(attributes = {}, &block)\n register_event(ChannelUpdateEvent, attributes, block)\n end",
"def on_subscribed(&block)\n return unless block\n\n call_now = false\n @lock.synchronize do\n if @subscribed\n call_now = true\n else\n @on_subscribed_handlers << block\n end\n end\n if call_now\n after(0, &block)\n end\n end",
"def subscribe_to_channel; end",
"def getNotificationChannel(channel_id)\n cid = CGI.escape(channel_id)\n url = \"#{@fqdn}#{NOTIFICATION_RESOURCE}/#{cid}\"\n\n begin\n r = self.get(url)\n rescue RestClient::Exception => e\n raise(ServiceException, e.response || e.message, e.backtrace)\n end\n Model::NotificationChannel.from_response(r)\n end",
"def listen\n amqp_listen do |msg|\n do_handle(msg)\n end\n end",
"def watch_notification( notification_name, sender = nil, notification_center = NSNotificationCenter.defaultCenter )\n\n selector_name = \"handle_#{notification_name}:\"\n\n if block_given?\n\n # define a wrapper method that yields\n self.def_method_once selector_name do |notification|\n yield notification\n end\n\n elsif ! self.respond_to? selector_name\n \n self.def_method_once selector_name do |notification|\n # define a handle_* that sends to an on_*, working around compile-time wiring to selector implementation (breaking hotload)\n on_method = \"on_#{notification_name}:\"\n if self.respond_to? on_method\n self.send on_method, notification\n else\n # define the logging handler\n pe_log \"#{notification_name} received with #{notification.description}\"\n end\n end\n\n end\n\n notification_center.addObserver(self, selector:selector_name, name:notification_name, object:sender)\n \n pe_log \"#{self} registered for notification: #{notification_name} from sender #{sender}\"\n\n self\nend",
"def listen(&block)\n while @_run do\n request = @responder.recv #(ZMQ::NOBLOCK)\n if request\n response = block && block.call(request)\n @responder.send( response )\n end\n end\n end",
"def channel\n # Create new channel if closed\n if @channel.nil? || @channel.closed?\n @channel = connection.create_channel\n end\n @channel\n end",
"def channel\n metadata&.dig('event', 'channel')\n end",
"def subscribe(channel, data = {})\n log_to_file(\"#{self.class} tries to subscribe to channel #{channel} with #{data.inspect}\")\n send_action('subscribe', channel, data)\n end",
"def channel\n @channel ||= Proletariat.connection.create_channel\n end",
"def channel\n @channel ||= Proletariat.connection.create_channel\n end",
"def listen\n @queue.subscribe(block: true) do |delivery_info, properties, body|\n puts(body)\n end\n end",
"def websocket(channel, *args, &block)\n get channel, *args do\n # Let some other action try to handle the request if it's not a WebSocket.\n throw :pass unless request.env['rack.hijack']\n\n event_context = self\n ws_channel = params[:channel] || channel\n\n # It's a WebSocket. Get the libuv promise and manage its events\n request.env['rack.hijack'].call.then do |hijacked|\n ws = ::SpiderGazelle::Websocket.new hijacked.socket, hijacked.env\n\n set_websocket_user\n\n Padrino::WebSockets::SpiderGazelle::EventManager.new(\n ws_channel, session['websocket_user'], ws, event_context, &block)\n ws.start\n end\n end\n end",
"def _fwd_channel(channel)\n result = channel.fwd_channel\n while result.nil? do\n timeout = 0.001\n debug { \"waiting for fwd hannel \"}\n if @event_loop\n @event_loop.process_only(@fwd_conn,timeout)\n else\n @fwd_conn.process(timeout)\n end\n result = channel.fwd_channel\n end\n return result\n end",
"def subscribe(args)\n ## Capture User Input\n channel = args['channel']\n callback = args['callback']\n timetoken = args['timetoken'] ? args['timetoken'] : 0\n\n ## Fail if missing channel\n if !channel\n puts \"Missing Channel.\\n\"\n return false\n end\n\n ## Fail if missing callback\n if !callback\n puts \"Missing Callback.\\n\"\n return false\n end\n\n ## Begin Recusive Subscribe\n begin\n ## Wait for Message\n response = self._request([\n 'subscribe',\n @subscribe_key,\n channel,\n '0',\n timetoken.to_s\n ])\n\n messages = response[0]\n args['timetoken'] = response[1]\n\n \n ## If it was a timeout\n if !messages.length\n return self.subscribe(args)\n end\n\n ## Run user Callback and Reconnect if user permits.\n messages.each do |message|\n if !callback.call(message)\n return\n end\n end\n\n ## Keep Listening.\n return self.subscribe(args)\n rescue Timeout::Error\n return self.subscribe(args)\n rescue\n sleep(1)\n return self.subscribe(args)\n end\n end",
"def on_open_channel(type, &block); end",
"def channel=(channel)\n @channel = channel\n true\n end",
"def subscribe_to_channel(channel)\n\n details = read_server_conf()\n client = XMLRPC::Client.new2(details[:server])\n\n # Enable SSL certificate verification; we don't want to login to some other Satellite server!\n client.instance_variable_get(\"@http\").verify_mode = OpenSSL::SSL::VERIFY_PEER\n client.instance_variable_get(\"@http\").ca_file = \"/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT\"\n\n # Get systemid; up2date API uses this to auth a client\n systemid = read_systemid\n\n # Call API and subscribe us to a channel\n client.call(\"up2date.subscribeChannels\", systemid, [channel], details[:username], details[:password])\n\n end",
"def connect(channel)\r\n $LOG.info(\"Connecting to #{channel} channel.\")\r\n @channel = channel\r\n @pubNub.subscribe(\r\n :channel => @channel,\r\n :callback => method(:msgHandler),\r\n :http_sync => true\r\n )\r\n @pubNub.subscribe(\r\n :channel => @channel,\r\n :callback => method(:msgHandler),\r\n :http_sync => false\r\n )\r\n end",
"def subscribe(client_id, channel, &callback)\n if @subscriptions.containsEntry(client_id, channel)\n callback.call(true) if callback\n return\n end\n @subscriptions.put(client_id, channel)\n @channels.put(channel, client_id)\n @server.debug 'Subscribed client ? to channel ?', client_id, channel\n @server.trigger(:subscribe, client_id, channel)\n callback.call(true) if callback\n end",
"def subscribe(*channels, &block)\n _subscription(:subscribe, 0, channels, block)\n end",
"def amqp_listen\n @listener = \"client.#{::Kernel.rand(999_999_999_999)}\"\n Thread.new(self) do \n AMQP.start(:host => @host) do\n _notify = MQ.fanout(@x_notify)\n puts \"[amqp_listen] starting listener on #{Thread.current}\" if $DEBUG\n MQ.queue(@listener, :auto_delete => true).bind(_notify).subscribe{ |msg| yield msg }\n end \n end\n end",
"def notify_game_change\n connection.execute \"NOTIFY #{channel}, #{connection.quote self.to_s}\"\n end",
"def listen\n Thread.new do\n while true\n retrieve_messages\n sleep (0.1)\n end\n end\n end",
"def psubscribe(*channels, &block)\n raise NotImplementedError\n end",
"def channel_handlers(channel, event)\n # trace __FILE__, __LINE__, self, __method__, \" : channel=#{channel} event=#{event}\"\n r = (@handlers[channel.to_sym] || {})[event.to_sym] || []\n if r.empty?\n msg = \"#{self.class.name} : no channel handlers(s) for channel=#{channel} event=#{event}\"\n # trace __FILE__, __LINE__, self, __method__, \" : #{msg}\"\n raise RuntimeError, msg\n end\n r\n end",
"def listen_for_messages\n queue = @channel.queue(\"\")\n\n queue.bind(@exchange).subscribe do |delivery_info, metadata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end",
"def notify(&block)\n @notify_blocks << block\n end",
"def mq_listen(&block)\n Thread.new {\n begin\n logger.info \"New messaging thread created for RabbitMQ #{opt.mq_host} / #{opt.mq_queue}\"\n AMQP.start(:host => opt.mq_host) do |connection|\n q = AMQP::Channel.new(connection).queue(opt.mq_queue)\n q.subscribe do |msg|\n Videoreg::Base.logger.info \"Received message from RabbitMQ #{msg}...\"\n block.call(connection, msg) if block_given?\n end\n Signal.add_trap(\"TERM\") { q.delete; mq_disconnect(connection) }\n Signal.add_trap(0) { q.delete; mq_disconnect(connection) }\n end\n rescue => e\n logger.error \"Error during establishing the connection to RabbitMQ: #{e.message}\"\n @dante_runner.stop if @dante_runner\n end\n }\n end",
"def subscribe(channel)\n @ws.send(get_subscribe_object(channel, increment_cnt).to_json)\n @channels << channel unless @channels.include?(channel)\n end",
"def notify(step, options = {})\n notifiers.each do |notifier|\n notifier.notify(step, default_payload.merge(options))\n end\n end",
"def notification=(options = {})\n if options.respond_to?(:keys)\n notification.port = options[:port] if options[:port]\n notification.host = options[:host] if options[:host]\n end\n end",
"def listen\n raise NotImplementedError.new(\"Implement listen() in your Invoker. \")\n end",
"def listen(patch, &callback)\n if !@listener.nil?\n @listener.listen_for(:class => [MIDIMessage::ControlChange]) do |event|\n handle_event_received(patch, event, &callback)\n end\n true\n else\n false\n end\n end",
"def do_listening\n in_dir @config.base_path do\n\n # Notify people if we are using fallback mode\n if @config.force_poll\n puts statusbar \"Using polling fallback listener\", &:yellow\n end\n\n # Force a change to start with\n run_command\n\n params = {\n latency: 0.5,\n }\n\n params[:only] = Regexp.new(@config.filters.join(\"|\")) unless @config.filters.empty?\n params[:ignore] = Regexp.new(@config.ignored.join(\"|\")) unless @config.ignored.empty?\n\n if @config.force_poll\n params[:latency] = @config.force_poll\n params[:force_poll] = true\n end\n\n @listener = Listen.to(*@config.paths, params) do |*args|\n self.on_change *args\n end\n \n @listener.start\n end\n end",
"def subscribe_to_channel\n run_callbacks :subscribe do\n subscribed\n end\n\n reject_subscription if subscription_rejected?\n ensure_confirmation_sent\n end",
"def notify_change(input_channel)\n\n $test_logger.log(\"Notify change #{input_channel}\")\n\n case input_channel\n\n #If XML is changed\n when InputChannel::XML\n\n if @is_reply_ilv == true\n $test_logger.log(\"XML to hex/raw not processed as current ILV is reply ILV!\")\n else\n @ilv_hex_str = xml_to_hex(@xml_ilv_node)\n @ilv_raw_str = ILVMessage.hex_to_raw(@ilv_hex_str)\n end\n\n #If HEX string is changed\n when InputChannel::HEX\n @ilv_raw_str = ILVMessage.hex_to_raw(@ilv_hex_str)\n raw_to_xml(@xml_ilv_node, @ilv_raw_str)\n\n #If RAW string is changed\n when InputChannel::RAW\n @ilv_hex_str = ILVMessage.raw_to_hex(@ilv_raw_str)\n raw_to_xml(@xml_ilv_node, @ilv_raw_str)\n\n else\n raise \"Invalid channel specified '#{input_channel}'!\"\n end\n end",
"def listen_ticker(pair=\"BTCUSD\", &block)\n raise BlockMissingError unless block_given?\n register_channel pair: pair, channel: \"ticker\", &block\n end",
"def subscribe(params = {})\n @connection ||= stub_connection\n @subscription = self.class.channel_class.new(connection, CHANNEL_IDENTIFIER, params.with_indifferent_access)\n @subscription.singleton_class.include(ChannelStub)\n @subscription.subscribe_to_channel\n @subscription\n end",
"def monitor_redis\n # redis.dup.subscribe(REDIS_CHANNEL) do |on|\n redis.subscribe(REDIS_CHANNEL) do |on|\n on.message do |_, message|\n l = REDIS_HEAD_FIELD_LENGTH\n channel = message[0, l].strip\n client_id = message[l, l].strip\n json = message[(l * 2)..-1]\n send_json_message(client_id: client_id, channel: channel, json: json)\n end\n end\n end",
"def listen(p=nil, &block)\n @listeners.unshift p if p\n @listeners.unshift block if block\n end",
"def listen(m)\n return if m.message.to_s =~ /^\\.[a-zA-Z]/ # Don't sed a call to any commands\n return if m.user == @bot\n\n json = { :nick => m.user.nick, :message => m.message }.to_json\n\n #@bot.redis.lpush \"#{m.channel}:#{m.user.nick}:messages\", json\n #@bot.redis.lpush \"#{m.channel}:messages\", json\n bot.redis.lpush \"#{m.channel}:#{m.user.nick}:messages\", json\n bot.redis.lpush \"#{m.channel}:messages\", json\n\n if bot.redis.llen(\"#{m.channel}:#{m.user.nick}:messages\").to_i > config[:user_messages]\n bot.redis.rpop \"#{m.channel}:#{m.user.nick}:messages\"\n end\n\n if bot.redis.llen(\"#{m.channel}:messages\").to_i > config[:channel_messages]\n bot.redis.rpop \"#{m.channel}:messages\"\n end\n end",
"def listen\n Thread.new { EventMachine.run } unless EventMachine.reactor_running?\n jack.each_job(2) do |job|\n job = Job.new(job.conn, job.jobid, job.body)\n EventMachine.defer proc { process(job) }, proc {|res| raise(res) if res.kind_of?(Exception) }\n end\n end",
"def register(channel)\n channel.subscribe(&method(:handle_response))\n end",
"def subscribe(client_id, channel, &callback)\n super\n publish_awaiting_messages(channel)\n end",
"def subscribe(&callback)\n redis.subscribe(channel) do |on|\n on.message do |channel, payload|\n data = JSON.parse(payload) rescue payload\n callback.call channel, data, self\n end\n end\n end",
"def listening\n make_promise(@core.web3.JS[:net], 'getListening')\n end",
"def listen(patch, &callback)\n ensure_socket.on_message do |data|\n handle_input(patch, data, &callback)\n end\n true\n end",
"def notify(subscriber, *args, &block)\n if subscriber.respond_to? MESSAGE\n subscriber.public_send(MESSAGE, self, *args, &block)\n end\n end",
"def use_portchannel?(server, interface)\n false\n end",
"def listen(callback)\n log.debug \"carbon listener on #{@bind}:#{@port}\"\n Coolio::TCPServer.new(@bind, @port, TCPUnbufferedSocket, log, @delimiter, callback)\n end",
"def add_channel( channel )\n\t\tserver = @servers[channel.server_name]\n\t\t@channels[channel.name] = channel\n\t\tserver.add_channel( channel )\n\t\tshift_server_pos( server.number, 1 )\n\t\t@length += 1\n\tend",
"def get_callbacks( channel )\n cbs = Array.new\n # First, fetch all the channel-specific callbacks...\n cbs.concat(@channels[channel]) if @channels.has_key? channel\n # ...then fetch the callbacks the channel matches\n cbs.concat(get_wildcard_callbacks(channel))\n cbs\n end",
"def receive(channel = mailbox)\n channel.pop_op\n end",
"def on_connection_listener_fetch_loop_received(event)\n listener = event[:caller]\n time = event[:time]\n messages_count = event[:messages_buffer].size\n\n message = \"[#{listener.id}] Polled #{messages_count} messages in #{time}ms\"\n\n # We don't want the \"polled 0\" in dev as it would spam the log\n # Instead we publish only info when there was anything we could poll and fail over to the\n # zero notifications when in debug mode\n messages_count.zero? ? debug(message) : info(message)\n end",
"def createNotificationChannel(channel_type, content_type, version=1.0)\n url = \"#{@fqdn}#{NOTIFICATION_RESOURCE}\"\n headers = { \n :accept => 'application/json', \n :content_type => \"application/json\",\n }\n body = Webhooks.createChannel(channel_type, content_type, version)\n\n begin\n r = self.post(url, body.to_json, headers)\n rescue RestClient::Exception => e\n raise(ServiceException, e.response || e.message, e.backtrace)\n end\n Model::NotificationChannel.from_response(r)\n end"
] |
[
"0.734112",
"0.61051863",
"0.60600615",
"0.5844702",
"0.5599413",
"0.5572211",
"0.55013776",
"0.5444815",
"0.5353724",
"0.5312384",
"0.52903867",
"0.52607447",
"0.5257268",
"0.5238882",
"0.522982",
"0.5066929",
"0.5061401",
"0.4985596",
"0.4924846",
"0.49017558",
"0.48918104",
"0.4891487",
"0.48723403",
"0.4870192",
"0.48443344",
"0.4824522",
"0.47912422",
"0.47912186",
"0.4790785",
"0.4789496",
"0.47378975",
"0.4720504",
"0.46975288",
"0.46280032",
"0.46219504",
"0.46152392",
"0.45951772",
"0.45613816",
"0.4560493",
"0.45565793",
"0.45548004",
"0.45528266",
"0.4549502",
"0.45348185",
"0.4526279",
"0.45255905",
"0.45186436",
"0.45150116",
"0.45080847",
"0.45048153",
"0.44910797",
"0.44814265",
"0.44737825",
"0.44399804",
"0.44399804",
"0.4439368",
"0.4432724",
"0.44276476",
"0.4423239",
"0.44058314",
"0.4399776",
"0.43896344",
"0.43867362",
"0.4385683",
"0.43666053",
"0.43612108",
"0.43515277",
"0.43372035",
"0.4318827",
"0.4315101",
"0.43124297",
"0.4307762",
"0.43026882",
"0.43015298",
"0.42914018",
"0.42728522",
"0.42709318",
"0.42702368",
"0.42645684",
"0.42635247",
"0.42615113",
"0.42457345",
"0.42443886",
"0.4240298",
"0.4235835",
"0.42323068",
"0.4231056",
"0.4229586",
"0.4228352",
"0.42248285",
"0.42238578",
"0.42231718",
"0.42166483",
"0.421505",
"0.42111444",
"0.4209879",
"0.41900244",
"0.41898286",
"0.418545",
"0.4181039"
] |
0.6936913
|
1
|
If convert_infinite_timestamps is true and the value is infinite, return an appropriate value based on the convert_infinite_timestamps setting.
|
def to_application_timestamp(value)
if convert_infinite_timestamps
case value
when *INFINITE_TIMESTAMP_STRINGS
infinite_timestamp_value(value)
else
super
end
else
super
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def infinite_timestamp_value(value)\n case convert_infinite_timestamps\n when :nil\n nil\n when :string\n value\n else\n value == 'infinity' ? PLUS_INFINITY : MINUS_INFINITY\n end\n end",
"def convert_infinite_timestamps=(v)\n @convert_infinite_timestamps = case v\n when Symbol\n v\n when 'nil'\n :nil\n when 'string'\n :string\n when 'float'\n :float\n when String\n typecast_value_boolean(v)\n else\n false\n end\n\n pr = old_pr = @use_iso_date_format ? TYPE_TRANSLATOR.method(:date) : Sequel.method(:string_to_date)\n if v\n pr = lambda do |val|\n case val\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(val)\n else\n old_pr.call(val)\n end\n end\n end\n add_conversion_proc(1082, pr)\n end",
"def typecast_value_datetime(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def typecast_value_date(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def convert_timestamp(value, capture_definition)\n DateTime.parse(value).strftime('%Y%m%d%H%M%S').to_i unless value.nil?\n end",
"def convert_timestamp(ts)\n return ts.to_i - @@seconds_1900_1970\n end",
"def time_to_conversion\n converted? ? -1 : 10 - (Time.now.min % 10) # assumes a cron job runs every 10 minutes\n end",
"def to_f\n\t\tseconds_since_unix_epoch.to_f\n\tend",
"def typecast_value_datetime(value)\n Sequel.typecast_to_application_timestamp(value)\n end",
"def convert_to_internal_value value\n value = fix_ambigious_value value, true\n\n if day_unit?\n (BigDecimal(value.to_time.to_i) / SECONDS_PER_DAY)\n elsif values_unit == Integer\n value.to_i\n else\n raise \"Unexpected unit: #{values_unit()}\"\n end\n end",
"def to_timestamp(val)\n return if val.nil?\n\n case val\n when String\n (date = Time.parse(val)) && date.to_i\n when Date\n val.to_time.to_i\n else\n val.to_i\n end\n end",
"def tiny_from_timestamp\n tiny(Time.now.to_f - TINY_EPOCH)\n end",
"def to_i\n seconds_since_unix_epoch.to_i\n end",
"def to_i\n\t\tseconds_since_unix_epoch.to_i\n\tend",
"def translate_timestamp(timestamp)\n # seconds -> milliseconds\n timestamp.to_i * 1000\n end",
"def convert_timestamp(value, definition)\n \"#{value[7,4]}#{MONTHS[value[3,3]]}#{value[0,2]}#{value[12,2]}#{value[15,2]}#{value[18,2]}\".to_i\n end",
"def convert_timestamp(value, definition)\n \"#{value[7,4]}#{MONTHS[value[3,3]]}#{value[0,2]}#{value[12,2]}#{value[15,2]}#{value[18,2]}\".to_i\n end",
"def convert_timestamp(value, _definition)\n \"#{value[7, 4]}#{MONTHS[value[3, 3]]}#{value[0, 2]}#{value[12, 2]}#{value[15, 2]}#{value[18, 2]}\".to_i\n end",
"def convert_timestamp(value, definition)\n \"#{value[26,4]}#{MONTHS[value[4,3]]}#{value[8,2]}#{value[11,2]}#{value[14,2]}#{value[17,2]}\".to_i\n end",
"def map_time_limit=(new_value)\n super new_value && new_value.to_f\n end",
"def timestamp_value\n @timestamp_value ||=\n ((@time_hi_and_version & 0b1111_1111_1111) << 48) |\n (@time_mid << 32) | @time_low\n end",
"def timestamp\n #data[\"timestamp\"] as? TimeInterval ?? 0\n timestamp = data[\"timestamp\"]\n timestamp.to_i || 0\n end",
"def timestamp\n (Time.now.to_f * 1000).ceil.to_s[-5..-1]\nend",
"def coerce_time_milli(value)\n case value\n when Integer then value * 1000\n when Float then (value * 1000).floor\n else\n if value.respond_to?(:to_f)\n coerce_time_milli(value.to_f)\n elsif value.respond_to?(:to_i)\n coerce_time_milli(value.to_i)\n else\n 0\n end\n end\n end",
"def to_i\n # Thread-safety: It is possible that the value of @timestamp may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @timestamp is only\n # calculated once.\n\n unless @timestamp\n if @timestamp_with_offset\n @timestamp = @timestamp_with_offset.timestamp + @timestamp_with_offset.utc_offset\n else\n time = to_time\n @timestamp = time.to_i + time.utc_offset\n end\n end\n\n @timestamp\n end",
"def must_convert?\n self.big_query_conversion_column.present? && self.unit != 'seconds'\n end",
"def tt_forever?\n ttend_at == InfinityValue\n end",
"def day_in_secs day_timelimit\n case day_timelimit\n when 1\n return 1209600\n when 2\n return 604800\n when 3\n return 432000\n when 4\n return 259200\n when 5\n return 172800\n when 6\n return 86400\n when 7\n return 43200\n when 8\n return 21600\n when 9\n return 10800\n when 10\n return 7200\n when 11\n return 3600\n when 12\n return 1800\n when 13\n return 900\n when 14\n return 600\n when 15\n return 300\n else\n return -1\n end\n end",
"def pred_timestamp(options = {})\n if historical?\n options[:before] ||= as_of_time\n timeline(options.merge(:limit => 1, :reverse => true)).first\n else\n timeline(options.merge(:limit => 2, :reverse => true)).second\n end\n end",
"def ruby_value\n to_datetime\n end",
"def succ_timestamp(options = {})\n return nil unless historical?\n\n options[:after] ||= as_of_time\n timeline(options.merge(:limit => 1, :reverse => false)).first\n end",
"def to_i\n # Thread-safety: It is possible that the value of @timestamp may be \n # calculated multiple times in concurrently executing threads. It is not \n # worth the overhead of locking to ensure that @timestamp is only \n # calculated once.\n \n unless @timestamp\n result = to_time.to_i\n return result if frozen?\n @timestamp = result\n end\n \n @timestamp\n end",
"def coerce_timestamp(timestamp)\n # bug in JRuby prevents correcly parsing a BigDecimal fractional part, see https://github.com/elastic/logstash/issues/4565\n timestamp.is_a?(BigDecimal) ? LogStash::Timestamp.at(timestamp.to_i, timestamp.frac * 1000000) : LogStash::Timestamp.at(timestamp)\n end",
"def normalize_time(value)\n return Time.at(value).utc.iso8601 if value.kind_of?(Integer)\n\n value.respond_to?(:utc) ? value.utc.iso8601 : value\n end",
"def time_conversion_factor\n @time_conversion_factor ||= dut_version < '0.8.0' ? 1 : 1000\n end",
"def convert_invalid_date_time=(v)\n m0 = ::Sequel.method(:string_to_time)\n @conversion_procs[11] = (v != false) ? lambda{|val| convert_date_time(val, &m0)} : m0\n m1 = ::Sequel.method(:string_to_date) \n m = (v != false) ? lambda{|val| convert_date_time(val, &m1)} : m1\n [10, 14].each{|i| @conversion_procs[i] = m}\n m2 = method(:to_application_timestamp)\n m = (v != false) ? lambda{|val| convert_date_time(val, &m2)} : m2\n [7, 12].each{|i| @conversion_procs[i] = m}\n @convert_invalid_date_time = v\n end",
"def pred_timestamp(options = {})\n if historical?\n options[:before] ||= as_of_time\n timeline(options.merge(limit: 1, reverse: true)).first\n else\n timeline(options.merge(limit: 2, reverse: true)).second\n end\n end",
"def day_number_utc\n\t\tself.to_i / 86400\n\tend",
"def utc\n unless @_utc then\n @_utc = true\n @vals = LIBC.new.c_gmtime(@tv_sec)\n end\n return self # .to_i # TOTAL FUCKING HACK\n end",
"def timestamp2date(t)\n Time.at(t.to_i).utc\nend",
"def datetime_convert(v)\n case v\n when nil, 0 then nil\n when Numeric then day_convert(v)\n when IsoYear then day_convert(v)\n when IsoDay then day_convert(v)\n when IsoDate then v.to_s\n when START_PATTERN[:complete] then datetime_clean($1)\n when START_PATTERN[:day] then $1\n when START_PATTERN[:year] then day_convert(v)\n else datetime_parse(v)\n end\n end",
"def timestamp(value)\n merge(timestamp: value.iso8601)\n end",
"def must_convert?\n big_query_conversion_column.present? && unit != 'seconds'\n end",
"def updated_at_in_float\n updated_at.to_f\n end",
"def convert_for_timestamp_shape(arg)\n return nil if arg.nil?\n\n time_value = case arg\n when Time\n arg\n when Date, DateTime\n arg.to_time\n when Integer, Float\n Time.at(arg)\n else\n Time.parse(arg.to_s)\n end\n time_value.utc.iso8601\n end",
"def supports_timestamp_usecs?\n false\n end",
"def timestampFormat(value)\n _timestampFormat(value) or fail ArgumentError, \"Unknown value for timestampFormat: #{value}\"\n end",
"def monotonic_timestamp\n return nil unless @ctx.key?(:monotonic_ts)\n @monotonic_timestamp ||= Time.at(0, @ctx[:monotonic_ts].first)\n end",
"def from_application_timestamp(v)\n Sequel.convert_output_timestamp(v, timezone)\n end",
"def get_timestamp\n # Appending integer timestamp including second decimals\n now = Time.now.to_f * 10\n return now.round.to_s\n end",
"def milis_from_1970\n self.day.to_time.to_i * 1000\n end",
"def to_timestamp_with_offset\n # Thread-safety: It is possible that the value of @timestamp_with_offset\n # may be calculated multiple times in concurrently executing threads. It\n # is not worth the overhead of locking to ensure that\n # @timestamp_with_offset is only calculated once.\n\n unless @timestamp_with_offset\n time = to_time\n @timestamp_with_offset = TimestampWithOffset.new(time.to_i, time.utc_offset)\n end\n\n @timestamp_with_offset\n end",
"def to_application_timestamp(v)\n Sequel.convert_timestamp(v, timezone)\n end",
"def type_cast(value, type = self.type)\n case type\n when :counter\n type_cast(value, :integer).to_i\n when :integer\n Kernel::Integer(value) rescue nil if value\n when :float\n Kernel::Float(value) rescue nil if value\n when :timestamp\n value = type_cast(value, :integer)\n Time.at(value) if value\n else\n value\n end\n end",
"def timestamp_to_time num\n Time.at(num / 1000.0 + AssumedTimezoneAdjust, num % 1000).utc\n end",
"def timestamp_to_time_slow num\n AssumedTimezone.utc_to_local(Time.at(num / 1000.0, num % 1000).utc)\n end",
"def datetime_clean(value)\n value.to_s.strip.sub(/[+-]00?(:00?)?$/, ZULU).sub(/\\d+\\.\\d+/) do |sec|\n '%02d' % [sec.to_f.round, 59].min\n end\n end",
"def sent_at_seconds_since_epoch\n Time.current.utc.to_i\n end",
"def to_seconds; @val end",
"def timestamps\n @timestamps ||= bytes[T_BYTES].each_slice(4).map do |t_bytes|\n ByteArray.to_i(t_bytes)\n end.reject{ |t| t == 0 }\n end",
"def to_db(value)\n value = value.new_offset(0) if value.respond_to?(:new_offset)\n\n args = [value.year, value.month, value.day]\n args += (value.class == Date ? [0, 0, 0] : [value.hour, value.min, value.sec])\n\n Time.utc(*args).to_i\n end",
"def unixtime\n Time.now.to_i.to_s\n end",
"def default_timestamp_format\n \"{ts '%Y-%m-%d %H:%M:%S%N'}\"\n end",
"def vt_forever?\n vtend_at == InfinityValue\n end",
"def timestamp\n begin\n max=model.max(:updated_at)\n #rescue PG::Error => err\n rescue => err\n # puts \" error was #{err}\"\n # if we get an error, just assume we need to update the table\n return Rake::EARLY\n end\n # this is embarassing, but rake doesn't have a way to say\n # that this thing is more recently updated than anything else\n max.nil? ? Time.parse('Dec 31, 9999') : max\n end",
"def timestamp_parse(_timestamp)\n _undefined\n end",
"def to_i\n # Thread-safety: It is possible that the value of @timestamp may be\n # calculated multiple times in concurrently executing threads. It is not\n # worth the overhead of locking to ensure that @timestamp is only\n # calculated once.\n\n unless @timestamp\n @timestamp = to_time.to_i\n end\n\n @timestamp\n end",
"def last_epoch_time; end",
"def at\n Timestamp.utc(@timestamp_value)\n end",
"def set(value)\n case value\n when DateTime\n set(value.to_time)\n when Time\n time_int = value.to_i\n time_int *= NS_MULTIPLIER\n adjusted_epoch = time_int + EPOCH_DIFF_100NS\n set(adjusted_epoch)\n when Integer\n self.val = value\n else\n self.val = value.to_i\n end\n val\n end",
"def to_millis( timestamp )\n (timestamp.sec * 10**3) + (timestamp.nsec / 10**6)\n end",
"def old_events_date\n # 86400 seconds == 1 day\n DateTime.now - @threshold / 86400.0\n end",
"def epoch_now()\n Time.now.to_i\n end",
"def to_value\n timemap.first\n end",
"def cast_default(value)\n @format_string = iso8601\n cast_fmt(value)\n end",
"def to_timestamp(obj, default = Time.now)\n case obj\n when String then Time.parse(obj)\n when Date then obj.to_time\n when Time then obj\n when Numeric then Time.at(obj)\n else default\n end\n rescue ArgumentError => e\n default\n end",
"def transform_property_value(value)\n case value\n when /^0/\n # when it is a zero leading value like \"0777\" don't turn\n # it into a number (this is a mode flag)\n value\n when /^\\d+$/\n value.to_i\n when /(^(\\d+)(\\.)?(\\d+)?)|(^(\\d+)?(\\.)(\\d+))/\n value.to_f\n when /true/i\n true\n when /false/i\n false\n else\n value\n end\n end",
"def format_long_timestamp(timestamp)\n Time.at(timestamp/1000).utc.iso8601\n end",
"def transform_property_value(value)\n case value\n when /^0/\n # when it is a zero leading value like \"0777\" don't turn\n # it into a number (this is a mode flag)\n value\n when /^\\d+$/\n value.to_i\n when /(^(\\d+)(\\.)?(\\d+)?)|(^(\\d+)?(\\.)(\\d+))/\n value.to_f\n when /true/i\n true\n when /false/i\n false\n else\n value\n end\n end",
"def load(value)\n return value unless value.respond_to?(:to_int)\n ::Time.at((value.to_i/10**6)-11644473600)\n end",
"def get_business_utc n=0\n #if future\n if n >= 0\n return (n).business_day.from_now.to_date.utc\n else\n # if past\n return (-n).business_day.ago.to_date.utc\n end\nend",
"def result\n DateTime.iso8601(value).utc\n end",
"def parse_date(number)\n EPOCH + number\n end",
"def convert_value(value)\n value\n end",
"def supports_datetime_with_precision?\n false\n end",
"def supports_datetime_with_precision?\n false\n end",
"def to_nanos( seconds, nsec )\n (seconds * 10**9) + nsec\n end",
"def convert_value\n # Do nothing if value has not changed\n return true unless value_changed?\n # Cast the value and return success\n return parse_string_value(@uncast_value) if @uncast_value.is_a? String\n # Convert the value to yaml otherwise\n v = @uncast_value.to_yaml unless @uncast_value.nil?\n self[:value] = v\n end",
"def convert_timestamp(timestamp)\n timestamp = db.to_application_timestamp(timestamp) if timestamp.is_a?(String)\n timestamp\n end",
"def typecast_to_primitive(value)\n \n if value.kind_of?(::DateTime)\n result = value.to_time\n else\n result = ::DateTime.parse(value.to_s).to_time \n end\n \n return result\n \n rescue ArgumentError\n value\n end",
"def timestamp_to_date(timestamp)\n\t\tTime.at(timestamp/1000).utc #This is a time instance, it should go straight ot ruby\n\tend",
"def disable_timestamp_callback\n if self.respond_to?(\"updated_at\")\n self.class.skip_callback(:save, :before, :update_timestamps ) if @@_disable_timestamp_count == 0\n @@_disable_timestamp_count += 1\n end\n end",
"def to_i\n utc.to_i\n end",
"def valid_to\n utc_timestamp_from('valid_to')\n end",
"def convert_to_sec\n duration = @@fetch_interval.split(' ')\n\n if duration.length != 2\n raise \"Invalid @@fetch_interval(=#{@@fetch_interval}) in config.rb.\"\n end\n\n case duration[1]\n when /seconds?/\n multiply = 1\n when /minutes?/\n multiply = 60\n when /hours?/\n multiply = 3600\n else\n raise \"Invalid @@fetch_interval(=#{@@fetch_interval}) in config.rb.\"\n end\n\n @sec_interval = duration[0].to_i * multiply\n end",
"def timestamp(row)\n row[0].to_f\nend",
"def transform_created_at\n if id == latest_answer.id || created_at < latest_answer.created_at\n created_at\n else\n latest_answer.created_at - 1.second\n end\n end",
"def tempo_max\n @tempo_max ||= data[:tempo_max].to_i\n end",
"def value_to_integer(value)\n case value\n when TrueClass, FalseClass\n value ? 1 : 0\n else\n value.blank? ? nil : value.to_i rescue nil\n end\n end",
"def value_from_s(value)\n a = value.scanf(@format)\n t = 0\n t += a[0] * 3600 if a.size > 0 # hours * seconds-per-hour\n t += a[1] * 60 if a.size > 1 # minutes * seconds-per-minute\n t += a[2] if a.size > 2 # seconds\n t.to_i\n end"
] |
[
"0.80368084",
"0.80133283",
"0.70136845",
"0.6849377",
"0.58645356",
"0.54939365",
"0.5489207",
"0.53575116",
"0.5332459",
"0.5319376",
"0.52651",
"0.519344",
"0.513212",
"0.51072586",
"0.5035853",
"0.49878493",
"0.498601",
"0.49508008",
"0.49464825",
"0.49182823",
"0.4910782",
"0.48999733",
"0.48295465",
"0.48247212",
"0.48209256",
"0.48019913",
"0.4782921",
"0.47776577",
"0.4765091",
"0.47596088",
"0.4755859",
"0.47541538",
"0.47511193",
"0.4746168",
"0.4740814",
"0.47375736",
"0.4730792",
"0.47199073",
"0.47159284",
"0.47099614",
"0.47099045",
"0.4707747",
"0.46938628",
"0.46904424",
"0.46853405",
"0.4679885",
"0.46625793",
"0.46578315",
"0.46565494",
"0.46560818",
"0.46463794",
"0.46440676",
"0.46292272",
"0.46153212",
"0.46039838",
"0.45882747",
"0.4581572",
"0.45682636",
"0.45632303",
"0.45447466",
"0.45434475",
"0.4526902",
"0.45223176",
"0.44942278",
"0.44913936",
"0.4484131",
"0.44808587",
"0.44792777",
"0.44760293",
"0.4474011",
"0.4473802",
"0.44644296",
"0.44594023",
"0.44543797",
"0.44490388",
"0.44392237",
"0.44387484",
"0.4430628",
"0.44154325",
"0.44152692",
"0.4408503",
"0.44069523",
"0.4406008",
"0.4404983",
"0.43969208",
"0.43969208",
"0.43967763",
"0.43851337",
"0.43836397",
"0.43773392",
"0.43767136",
"0.43698627",
"0.43564436",
"0.43419114",
"0.43411905",
"0.433487",
"0.43344074",
"0.43339503",
"0.43323368",
"0.43275228"
] |
0.7542807
|
2
|
Execute the given SQL string or prepared statement on the connection object.
|
def _execute(conn, sql, opts, &block)
if sql.is_a?(Symbol)
execute_prepared_statement(conn, sql, opts, &block)
else
conn.execute(sql, opts[:arguments], &block)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def execute(sql, name = nil, binds = [])\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n @connection.do(sql)\n end\n end",
"def execute(sql, name = nil, _binds = [])\n log(sql, name) do\n @connection.do(sql)\n end\n end",
"def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end",
"def execute(sql)\n stmt = IBM_DB.exec(@conn, sql)\n raise Error.new(error_msg, error_sqlstate) unless stmt\n Statement.new(stmt)\n end",
"def exec(sql)\n Logging.with_logged_query self, sql do\n raw_connection.exec sql\n end\n end",
"def exec(sql, rescue_exception = true)\n debug(sql) if $DBG\n exec_statement(sql)\n rescue Object => ex\n if rescue_exception\n handle_sql_exception(ex, sql)\n else\n raise\n end\n end",
"def exec(connection = @connection)\n connection.exec(statement)\n end",
"def execute(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"execute: #{sql}\" }\n r = client.execute(sql)\n\n r.do\n r\n\n rescue => e\n handle_error(e)\n end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def execute(sql)\r\n\t\t@connection.Execute(sql)\r\n\tend",
"def exec_query(sql, name = 'SQL', binds = [])\n execute(sql, name, binds)\n end",
"def execute(sql)\n @logger.debug(\"SQL: #{sql}\") if @logger\n retrieve_connection.query(sql)\n end",
"def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end",
"def execute *params\r\n sql = parse_args( *params )\r\n @driver.execute( sql )\r\n end",
"def execute(sql, opts={}, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute(sql)\n @database_handle.execute(sql)\n end",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def execute(sql, *bind_values)\n @pool.acquire { |conn| conn.execute(sql, *bind_values) }\n end",
"def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end",
"def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def execute(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n q = check_disconnect_errors{execute_query(sql, args)}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def execute(sql_statement)\n parse(sql_statement)\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}\n end",
"def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)\n sql = transform_query(sql)\n\n if preventing_writes? && write_query?(sql)\n raise ActiveRecord::ReadOnlyError, \"Write query attempted while in readonly mode: #{sql}\"\n end\n\n materialize_transactions\n mark_transaction_written_if_write(sql)\n\n binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)\n\n if without_prepared_statement?(binds)\n log(sql, name) { @connection.execute_query(sql) }\n else\n log(sql, name, binds) do\n # this is different from normal AR that always caches\n cached_statement = fetch_cached_statement(sql) if prepare && @jdbc_statement_cache_enabled\n @connection.execute_prepared_query(sql, binds, cached_statement)\n end\n end\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def execute_query(sql, *vars)\n if vars && vars.count > 0\n @database.prepare(sql).execute(*vars.flatten)\n else\n @database.prepare(sql).execute\n end\n rescue\n puts \"MyMysql.execute_query(): #{$!}\" if @@verbose\n end",
"def execute(sql, tx = nil)\n run(:_send_query, [sql], tx)\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)} \n end",
"def execute_statement(sql)\n results = ActiveRecord::Base.connection.execute(sql)\n if results.present?\n return results\n else\n return nil\n end\n end",
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def execute(sql)\n log_info(sql)\n @pool.hold {|c| c.immediate(sql)}\n end",
"def _execute_prepared_statement(conn, ps_name, args, opts)\n conn.exec_prepared(ps_name, args)\n end",
"def execute(sql)\n @db.send(:_execute, self, sql, :log=>false) \n end",
"def execute(sql, name = nil, skip_logging = false)\n translate(sql) do |sql, args|\n if (name == :skip_logging) or skip_logging\n @connection.execute(sql, *args)\n else\n log(sql, args, name) do\n @connection.execute(sql, *args)\n end\n end\n end\n end",
"def execute(sql, name = nil)\n raise NotImplementedError, \"execute is an abstract method\"\n end",
"def execute(sql, name = nil, &block)\n log(sql, name) do\n @connection.query(sql, &block)\n end\n end",
"def execute(*values)\n IBM_DB.execute(@stmt, values)\n end",
"def execute(sql, name = 'SQL')\n log(sql, name) do\n @connection.async_exec(sql)\n end\n end",
"def execute(sql, opts=OPTS)\n _execute(sql, opts) do |conn|\n begin\n yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})\n ensure\n stmt.close if stmt\n end\n end\n end",
"def execute(query)\n # use exec_params instead of exec for security\n #\n # Unlike PQexec, PQexecParams allows at most one SQL command in the given string.\n # (There can be semicolons in it, but not more than one nonempty command.)\n # This is a limitation of the underlying protocol, but has some usefulness\n # as an extra defense against SQL-injection attacks.\n # https://www.postgresql.org/docs/current/static/libpq-exec.html\n query = squish(query)\n log \"SQL: #{query}\" if @log_sql\n conn.exec_params(query, []).to_a\n end",
"def execute_statement(statement, *arguments)\n if arguments.length > 5\n raise ArgumentError, 'Too many arguments, prepared statement with only upto 5 arguments is supported for simplicity'\n elsif arguments.length == 0\n @session.execute(\"#{statement}\")\n else\n prepared_statement = @session.prepare(\"#{statement}\")\n @session.execute(prepared_statement, arguments: arguments)\n end\n end",
"def execute(statement, *bind_values)\n with_connection do |connection|\n command = connection.create_command(statement)\n command.execute_non_query(*bind_values)\n end\n end",
"def execute sql\n db[sql]\n end",
"def execute(sql, name = nil)\n exec_no_cache(sql, name, nil)\n end",
"def execute_sql\n ActiveRecord::Base.connection.execute(@sql)\n end",
"def query(statement, *params)\n @logger.info \"#{statement}: #{params}\"\n @db.exec_params(statement, params)\n end",
"def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end",
"def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end",
"def run_sql(statement, params)\n @low_card_model.connection.execute(@low_card_model.send(:sanitize_sql, [ statement, params ]))\n end",
"def execute_prepared_statement(conn, name, opts=OPTS, &block)\n ps = prepared_statement(name)\n sql = ps.prepared_sql\n ps_name = name.to_s\n\n if args = opts[:arguments]\n args = args.map{|arg| bound_variable_arg(arg, conn)}\n end\n\n unless conn.prepared_statements[ps_name] == sql\n conn.execute(\"DEALLOCATE #{ps_name}\") if conn.prepared_statements.include?(ps_name)\n conn.check_disconnect_errors{log_connection_yield(\"PREPARE #{ps_name} AS #{sql}\", conn){conn.prepare(ps_name, sql)}}\n conn.prepared_statements[ps_name] = sql\n end\n\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n\n q = conn.check_disconnect_errors{log_connection_yield(log_sql, conn, args){_execute_prepared_statement(conn, ps_name, args, opts)}}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def execute(sql, name = nil, binds = []) #:nodoc:\r\n if name == :skip_logging\r\n query(sql, binds)\r\n else\r\n log(sql, name, binds) { query(sql, binds) }\r\n end\r\n end",
"def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end",
"def cti_execute_sql(sql)\n return execute(sql) if sql.is_a?(String)\n sql.map do |query|\n execute(query)\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def execute(sql, args = nil, bulk_args = nil, http_options = {})\n @logger.debug sql\n req = Net::HTTP::Post.new('/_sql', headers)\n body = { 'stmt' => sql }\n body['args'] = args if args\n body['bulk_args'] = bulk_args if bulk_args\n req.body = body.to_json\n response = request(req, http_options)\n @logger.debug response.body\n\n case response.code\n when /^2\\d{2}/\n ResultSet.new response.body\n else\n @logger.info(response.body)\n raise CrateRuby::CrateError, response.body\n end\n end",
"def execute(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end",
"def executeSQL(qStr, *params, &block)\n @statement_cache ||= {}\n #@statement_cache[qStr] ||= @db.prepare(qStr)\n @statement_cache[qStr] ||= qStr\n\n puts \"executeSQL: '#{qStr}', '#{params.join(\"', '\")}'\" if ::RdfContext::debug?\n if block_given?\n @db.execute(@statement_cache[qStr], *params) do |row|\n puts \"executeSQL res: #{row.inspect}\" if ::RdfContext::debug?\n row = row.keys.select{|k| k.is_a?(Integer)}.sort.map{|k| row[k]} if row.is_a?(Hash)\n yield(row)\n end\n else\n puts \"executeSQL no block given\" if ::RdfContext::debug?\n @db.execute(@statement_cache[qStr], *params)\n end\n rescue SQLite3::SQLException => e\n puts \"SQL Exception (ignored): #{e.message}\" if ::RdfContext::debug?\n end",
"def execute\n @result = session.execute(statement)\n execution_successful?\n end",
"def execute_prepared(ps_name, *values)\n stmt = @prepared_statements[ps_name].last\n res = stmt.execute(*values)\n unless res\n raise Error.new(\"Error executing statement #{ps_name}: #{error_msg}\", error_sqlstate)\n end\n stmt\n end",
"def execute(stmt, bindvars={})\n sanity_check(stmt)\n\n if @convert_types\n bindvars = DBI::Utils::ConvParam.conv_param(driver_name, bindvars)\n end\n\n sth = StatementHandle.new(@handle.execute(stmt, bindvars), true, true, @convert_types, true)\n # FIXME trace sth.trace(@trace_mode, @trace_output)\n sth.dbh = self\n sth.raise_error = raise_error\n\n if block_given?\n begin\n yield sth\n ensure\n sth.finish unless sth.finished?\n end\n else\n return sth\n end\n end",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n msg\n end\n end",
"def execute(*args)\n @db.execute(*args)\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end",
"def _execute(statement, tx = nil)\n @statement = statement\n super\n end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def execute_query(sql, args)\n\t\t\t\t\t@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def execute_dui(sql, opts={})\n synchronize(opts[:server]) do |conn|\n begin\n conn.execute(sql)\n rescue SwiftError => e\n raise_error(e)\n end\n end\n end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def execute(query, *binds)\n res = nil\n\n mutex.synchronize do\n self.last_query = query\n self.last_statement = sth = new_statement(query)\n res = sth.execute(*binds)\n sth.finish\n yield res if block_given?\n end\n\n return res\n end",
"def exec_query(sql, name = 'SQL', binds = [], prepare: false) # rubocop:disable Lint/UnusedMethodArgument\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n stmt = @connection.run(sql)\n\n columns = stmt.columns\n values = stmt.to_a\n stmt.drop\n\n values = dbms_type_cast(columns.values, values)\n column_names = columns.keys.map { |key| format_case(key) }\n ActiveRecord::Result.new(column_names, values)\n end\n end",
"def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end",
"def query_statement(statement, *arguments)\n if arguments.length > 5\n raise ArgumentError, 'Too many arguments, prepared statement with only upto 5 arguments is supported for simplicity'\n elsif arguments.length == 0\n query_results = @session.execute(\"#{statement}\")\n else\n prepared_statement = @session.prepare(\"#{statement}\")\n query_results = @session.execute(prepared_statement, arguments: arguments)\n end\n return query_results\n end",
"def exec(sql, *bindvars, &block)\n ret = nil\n thread = Thread.new { ret = super }\n thread.join\n ret\n rescue Interrupt\n self.break\n raise\n end",
"def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @mysql.charset.convert v}\n @protocol.synchronize do\n begin\n @sqlstate = \"00000\"\n @protocol.reset\n @protocol.send_packet Protocol::ExecutePacket.new(@statement_id, CURSOR_TYPE_NO_CURSOR, values)\n res_packet = @protocol.read_result_packet\n raise ProtocolError, \"invalid field_count\" unless res_packet.field_count == @fields.length\n @fieldname_with_table = nil\n if res_packet.field_count == 0\n @affected_rows, @insert_id, @server_status, @warning_conut =\n res_packet.affected_rows, res_packet.insert_id, res_packet.server_status, res_packet.warning_count\n return nil\n end\n @fields = Array.new(res_packet.field_count).map{Field.new @protocol.read_field_packet}\n @protocol.read_eof_packet\n return StatementResult.new(@mysql, @fields)\n rescue ServerError => e\n @sqlstate = e.sqlstate\n raise\n end\n end\n end",
"def execute\n ActiveRecord::Base.connection.execute(source)\n end",
"def query(sql, *bind_values)\n @pool.acquire { |conn| conn.query(sql, *bind_values).first }\n end",
"def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def query(sql, rescue_exception = true)\n debug(sql) if $DBG\n return query_statement(sql)\n rescue Object => ex\n if rescue_exception\n handle_sql_exception(ex, sql)\n else\n raise\n end\n end",
"def _execute(conn, sql, opts)\n begin\n r = log_yield(sql){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif block_given?\n yield conn\n end\n rescue ::Mysql2::Error => e\n raise_error(e, :disconnect=>MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message))\n end\n end",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n @errors << msg\n false\n end\n end",
"def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @charset.convert v}\n begin\n @sqlstate = \"00000\"\n nfields = @protocol.stmt_execute_command @statement_id, values\n if nfields\n @fields = @protocol.retr_fields nfields\n @result = StatementResult.new @fields, @protocol, @charset\n else\n @affected_rows, @insert_id, @server_status, @warning_count, @info =\n @protocol.affected_rows, @protocol.insert_id, @protocol.server_status, @protocol.warning_count, @protocol.message\n end\n return self\n rescue ServerError => e\n @last_error = e\n @sqlstate = e.sqlstate\n raise\n end\n end",
"def execute(sql, *args, &block)\n @db.execute(rewrite_table_names(sql), *args, &block)\n end",
"def execute(sql, opts=OPTS, &block)\n super(sql, {:arguments=>bind_arguments}.merge(opts), &block)\n end",
"def execute( sql, backwards_compat=false )\r\n result = @conn.query( sql )\r\n if backwards_compat\r\n return PGresult.new( result )\r\n else\r\n ResultSet.new result\r\n end\r\n rescue Exception => e\r\n raise DataAccessException.new( e.message, e ), $!, caller\r\n end",
"def execute(sql, name = nil)\n # check for some DDL and DML statements\n puts \"Running sql? #{RUN_SQL}\"\n\n if /(create |alter |drop |insert |delete |update )/i.match sql.squish\n File.open(SQL_FILENAME, 'a') { |f| f.puts \"#{sql};\\n\" }\n puts \"Rails.env: #{Rails.env} - #{ENV['FPHS_POSTGRESQL_SCHEMA']}\"\n old_execute sql, name if RUN_SQL\n else\n # pass everything else to the aliased execute\n puts \"------------- (#{name}) ---------------\"\n puts sql || ''\n puts \"------------- ---------------\"\n old_execute sql, name if RUN_SQL\n end\n end",
"def execute_prepared_statement(ps_name, opts)\n args = opts[:arguments]\n ps = prepared_statement(ps_name)\n sql = ps.prepared_sql\n synchronize(opts[:server]) do |conn|\n unless conn.prepared_statements.fetch(ps_name, []).first == sql\n log_connection_yield(\"PREPARE #{ps_name}: #{sql}\", conn){conn.prepare(sql, ps_name)}\n end\n args = args.map{|v| v.nil? ? nil : prepared_statement_arg(v)}\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n begin\n stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free_result if stmt\n end\n end\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def query(string)\r\n if @debug\r\n print \"SQL: #{string}\\n\"\r\n \r\n if @debug.is_a?(Fixnum) and @debug >= 2\r\n print caller.join(\"\\n\")\r\n print \"\\n\"\r\n end\r\n end\r\n \r\n self.conn_exec do |driver|\r\n return driver.query(string)\r\n end\r\n end",
"def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end",
"def execute_prepared(sql,params_arr)\n prepared_statement = @database_handle.prepare(sql)\n params_arr.each_with_index do |param,index|\n prepared_statement.bind_param(index+1,param)\n end \n prepared_statement.execute\n end",
"def execute(sql, name = nil)\n #log(sql, name) do\n # TODO: @async\n begin\n table_name = get_table_name_from_sql(sql)\n set_identity_insert_on(table_name) if (is_insert_sql(sql) and includes_id_field(sql))\n \n command = System::Data::SqlClient::SqlCommand.new sql, @connection\n command.transaction = @transaction\n command.command_timeout = @config[:command_timeout] if @config.has_key?(:command_timeout)\n command.execute_non_query \n rescue System::Data::SqlClient::SqlException => e\n raise_statement_invalid_error sql, e\n ensure\n set_identity_insert_off(table_name) if (is_insert_sql(sql) and includes_id_field(sql))\n end\n end",
"def execute(string)\n conn = @hibernate_session.connection\n stmt = conn.create_statement\n stmt.execute_update(string)\n conn.commit\n ensure\n stmt.close rescue nil\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def exec_query(sql, name = nil, binds = [])\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n result_array = result_as_array(result)\n if ArVer::GTEQ_4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end",
"def execute(raw_query, options = {})\n raise ConnectionError.new(\"Connection closed\") unless open?\n\n query = sanitize_query(raw_query)\n handle = send_query(query, options)\n\n Cursor.new(handle, self)\n end"
] |
[
"0.7445554",
"0.7422908",
"0.7357486",
"0.7246502",
"0.7226507",
"0.71983963",
"0.71972597",
"0.71766317",
"0.71016574",
"0.70863456",
"0.7083009",
"0.70563096",
"0.7035786",
"0.70321035",
"0.70274603",
"0.69948757",
"0.697758",
"0.69380987",
"0.69369465",
"0.6917853",
"0.68952763",
"0.68787295",
"0.6848677",
"0.6812822",
"0.6809928",
"0.68080026",
"0.67937845",
"0.67312294",
"0.6714543",
"0.67034906",
"0.66930765",
"0.6686074",
"0.6682085",
"0.6654533",
"0.6638037",
"0.6588098",
"0.6581756",
"0.65781444",
"0.6577074",
"0.65672475",
"0.65592486",
"0.6535227",
"0.6531887",
"0.65178186",
"0.65159863",
"0.6510768",
"0.6485356",
"0.64234805",
"0.64226437",
"0.6420341",
"0.6419751",
"0.6404036",
"0.63616776",
"0.63571924",
"0.6355262",
"0.6323162",
"0.63196623",
"0.6275175",
"0.6270958",
"0.6265049",
"0.6261722",
"0.6233504",
"0.62321216",
"0.6220636",
"0.6204248",
"0.61993235",
"0.6182641",
"0.6177451",
"0.6151375",
"0.61121094",
"0.6111681",
"0.6108704",
"0.6083427",
"0.6041551",
"0.60214937",
"0.60123694",
"0.6012318",
"0.59919494",
"0.5991128",
"0.59814996",
"0.5971968",
"0.5963316",
"0.59597033",
"0.59512085",
"0.593622",
"0.5927062",
"0.59159726",
"0.5912336",
"0.59048295",
"0.5892706",
"0.5872943",
"0.5872641",
"0.5865424",
"0.5854188",
"0.5826313",
"0.5816955",
"0.5810834",
"0.58030814",
"0.5802866",
"0.5800574"
] |
0.7483042
|
0
|
Execute the prepared statement name with the given arguments on the connection.
|
def _execute_prepared_statement(conn, ps_name, args, opts)
conn.exec_prepared(ps_name, args)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end",
"def execute(sql, name = nil, binds = [])\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n @connection.do(sql)\n end\n end",
"def execute_prepared(ps_name, *values)\n stmt = @prepared_statements[ps_name].last\n res = stmt.execute(*values)\n unless res\n raise Error.new(\"Error executing statement #{ps_name}: #{error_msg}\", error_sqlstate)\n end\n stmt\n end",
"def execute_prepared_statement(ps_name, opts)\n args = opts[:arguments]\n ps = prepared_statement(ps_name)\n sql = ps.prepared_sql\n synchronize(opts[:server]) do |conn|\n unless conn.prepared_statements.fetch(ps_name, []).first == sql\n log_connection_yield(\"PREPARE #{ps_name}: #{sql}\", conn){conn.prepare(sql, ps_name)}\n end\n args = args.map{|v| v.nil? ? nil : prepared_statement_arg(v)}\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n begin\n stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free_result if stmt\n end\n end\n end",
"def execute(sql, name = nil, _binds = [])\n log(sql, name) do\n @connection.do(sql)\n end\n end",
"def execute_prepared_statement(conn, name, opts=OPTS, &block)\n ps = prepared_statement(name)\n sql = ps.prepared_sql\n ps_name = name.to_s\n\n if args = opts[:arguments]\n args = args.map{|arg| bound_variable_arg(arg, conn)}\n end\n\n unless conn.prepared_statements[ps_name] == sql\n conn.execute(\"DEALLOCATE #{ps_name}\") if conn.prepared_statements.include?(ps_name)\n conn.check_disconnect_errors{log_connection_yield(\"PREPARE #{ps_name} AS #{sql}\", conn){conn.prepare(ps_name, sql)}}\n conn.prepared_statements[ps_name] = sql\n end\n\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n\n q = conn.check_disconnect_errors{log_connection_yield(log_sql, conn, args){_execute_prepared_statement(conn, ps_name, args, opts)}}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def execute(sql, *bind_values)\n @pool.acquire { |conn| conn.execute(sql, *bind_values) }\n end",
"def _execute(conn, sql, opts, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n conn.execute(sql, opts[:arguments], &block)\n end\n end",
"def execute_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return perform_select(query_string).get_rows()\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def execute *params\r\n sql = parse_args( *params )\r\n @driver.execute( sql )\r\n end",
"def execute_statement(statement, *arguments)\n if arguments.length > 5\n raise ArgumentError, 'Too many arguments, prepared statement with only upto 5 arguments is supported for simplicity'\n elsif arguments.length == 0\n @session.execute(\"#{statement}\")\n else\n prepared_statement = @session.prepare(\"#{statement}\")\n @session.execute(prepared_statement, arguments: arguments)\n end\n end",
"def execute(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def execute(*values)\n IBM_DB.execute(@stmt, values)\n end",
"def execute(statement, *bind_values)\n with_connection do |connection|\n command = connection.create_command(statement)\n command.execute_non_query(*bind_values)\n end\n end",
"def execute(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n q = check_disconnect_errors{execute_query(sql, args)}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def execute(*args)\n @db.execute(*args)\n end",
"def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end",
"def execute_prepared(sql,params_arr)\n prepared_statement = @database_handle.prepare(sql)\n params_arr.each_with_index do |param,index|\n prepared_statement.bind_param(index+1,param)\n end \n prepared_statement.execute\n end",
"def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n execute(sql, name, binds)\n end",
"def call(*)\n raise Error, \"Cannot call prepared statement without a name\" if prepared_statement_name.nil?\n super\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def execute(sql, opts=OPTS)\n _execute(sql, opts) do |conn|\n begin\n yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})\n ensure\n stmt.close if stmt\n end\n end\n end",
"def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)\n sql = transform_query(sql)\n\n if preventing_writes? && write_query?(sql)\n raise ActiveRecord::ReadOnlyError, \"Write query attempted while in readonly mode: #{sql}\"\n end\n\n materialize_transactions\n mark_transaction_written_if_write(sql)\n\n binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)\n\n if without_prepared_statement?(binds)\n log(sql, name) { @connection.execute_query(sql) }\n else\n log(sql, name, binds) do\n # this is different from normal AR that always caches\n cached_statement = fetch_cached_statement(sql) if prepare && @jdbc_statement_cache_enabled\n @connection.execute_prepared_query(sql, binds, cached_statement)\n end\n end\n end",
"def call(*args)\n params = build_params args\n cstmt = @connection.prepare_call \"{call #{name}(#{Array.new(@cols.length){'?'}.join ', '})}\"\n begin\n process_result( args, cstmt.call(*params) )\n ensure\n cstmt.close\n end\n end",
"def execute_query(sql, *vars)\n if vars && vars.count > 0\n @database.prepare(sql).execute(*vars.flatten)\n else\n @database.prepare(sql).execute\n end\n rescue\n puts \"MyMysql.execute_query(): #{$!}\" if @@verbose\n end",
"def execute(sql, name = nil, binds = []) #:nodoc:\r\n if name == :skip_logging\r\n query(sql, binds)\r\n else\r\n log(sql, name, binds) { query(sql, binds) }\r\n end\r\n end",
"def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end",
"def execute(sql)\n @database_handle.execute(sql)\n end",
"def call(bind_vars={}, &block)\n sql = prepared_sql\n prepared_args.freeze\n ps = bind(bind_vars)\n ps.clone(:bind_arguments=>ps.map_to_prepared_args(ps.opts[:bind_vars]), :sql=>sql, :prepared_sql=>sql).run(&block)\n end",
"def execute(sql, opts=OPTS, &block)\n super(sql, {:arguments=>bind_arguments}.merge(opts), &block)\n end",
"def execute_dui(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end",
"def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @charset.convert v}\n begin\n @sqlstate = \"00000\"\n nfields = @protocol.stmt_execute_command @statement_id, values\n if nfields\n @fields = @protocol.retr_fields nfields\n @result = StatementResult.new @fields, @protocol, @charset\n else\n @affected_rows, @insert_id, @server_status, @warning_count, @info =\n @protocol.affected_rows, @protocol.insert_id, @protocol.server_status, @protocol.warning_count, @protocol.message\n end\n return self\n rescue ServerError => e\n @last_error = e\n @sqlstate = e.sqlstate\n raise\n end\n end",
"def prepared_statement(name)\n Sequel.synchronize{prepared_statements[name]}\n end",
"def execute(stmt, bindvars={})\n sanity_check(stmt)\n\n if @convert_types\n bindvars = DBI::Utils::ConvParam.conv_param(driver_name, bindvars)\n end\n\n sth = StatementHandle.new(@handle.execute(stmt, bindvars), true, true, @convert_types, true)\n # FIXME trace sth.trace(@trace_mode, @trace_output)\n sth.dbh = self\n sth.raise_error = raise_error\n\n if block_given?\n begin\n yield sth\n ensure\n sth.finish unless sth.finished?\n end\n else\n return sth\n end\n end",
"def execute(sql, name = nil, skip_logging = false)\n translate(sql) do |sql, args|\n if (name == :skip_logging) or skip_logging\n @connection.execute(sql, *args)\n else\n log(sql, args, name) do\n @connection.execute(sql, *args)\n end\n end\n end\n end",
"def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @mysql.charset.convert v}\n @protocol.synchronize do\n begin\n @sqlstate = \"00000\"\n @protocol.reset\n @protocol.send_packet Protocol::ExecutePacket.new(@statement_id, CURSOR_TYPE_NO_CURSOR, values)\n res_packet = @protocol.read_result_packet\n raise ProtocolError, \"invalid field_count\" unless res_packet.field_count == @fields.length\n @fieldname_with_table = nil\n if res_packet.field_count == 0\n @affected_rows, @insert_id, @server_status, @warning_conut =\n res_packet.affected_rows, res_packet.insert_id, res_packet.server_status, res_packet.warning_count\n return nil\n end\n @fields = Array.new(res_packet.field_count).map{Field.new @protocol.read_field_packet}\n @protocol.read_eof_packet\n return StatementResult.new(@mysql, @fields)\n rescue ServerError => e\n @sqlstate = e.sqlstate\n raise\n end\n end\n end",
"def execute(sql, name = nil)\n raise NotImplementedError, \"execute is an abstract method\"\n end",
"def execute(sql)\r\n\t\t@connection.Execute(sql)\r\n\tend",
"def select_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return select_cached(query_string)\n end",
"def execute(sql, name = nil)\n exec_no_cache(sql, name, nil)\n end",
"def execute(sql, opts={}, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def exec(connection = @connection)\n connection.exec(statement)\n end",
"def query_statement(statement, *arguments)\n if arguments.length > 5\n raise ArgumentError, 'Too many arguments, prepared statement with only upto 5 arguments is supported for simplicity'\n elsif arguments.length == 0\n query_results = @session.execute(\"#{statement}\")\n else\n prepared_statement = @session.prepare(\"#{statement}\")\n query_results = @session.execute(prepared_statement, arguments: arguments)\n end\n return query_results\n end",
"def execute(*args)\n bound_args = args.shift(@raw_metadata.size)\n consistency_level = args.shift\n @client.execute_statement(@connection_id, @statement_id, @raw_metadata, bound_args, consistency_level)\n end",
"def execute(sql, args = nil, bulk_args = nil, http_options = {})\n @logger.debug sql\n req = Net::HTTP::Post.new('/_sql', headers)\n body = { 'stmt' => sql }\n body['args'] = args if args\n body['bulk_args'] = bulk_args if bulk_args\n req.body = body.to_json\n response = request(req, http_options)\n @logger.debug response.body\n\n case response.code\n when /^2\\d{2}/\n ResultSet.new response.body\n else\n @logger.info(response.body)\n raise CrateRuby::CrateError, response.body\n end\n end",
"def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end",
"def execute(sql, name = nil)\n # check for some DDL and DML statements\n puts \"Running sql? #{RUN_SQL}\"\n\n if /(create |alter |drop |insert |delete |update )/i.match sql.squish\n File.open(SQL_FILENAME, 'a') { |f| f.puts \"#{sql};\\n\" }\n puts \"Rails.env: #{Rails.env} - #{ENV['FPHS_POSTGRESQL_SCHEMA']}\"\n old_execute sql, name if RUN_SQL\n else\n # pass everything else to the aliased execute\n puts \"------------- (#{name}) ---------------\"\n puts sql || ''\n puts \"------------- ---------------\"\n old_execute sql, name if RUN_SQL\n end\n end",
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def exec_query(sql, name = 'SQL', binds = [], prepare: false) # rubocop:disable Lint/UnusedMethodArgument\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n stmt = @connection.run(sql)\n\n columns = stmt.columns\n values = stmt.to_a\n stmt.drop\n\n values = dbms_type_cast(columns.values, values)\n column_names = columns.keys.map { |key| format_case(key) }\n ActiveRecord::Result.new(column_names, values)\n end\n end",
"def execute(sql, name = 'SQL')\n log(sql, name) do\n @connection.async_exec(sql)\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end",
"def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end",
"def execute(sql, *args, &block)\n @db.execute(rewrite_table_names(sql), *args, &block)\n end",
"def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end",
"def execute( *bind_vars )\n reset! if active? || done?\n\n bind_params(*bind_vars) unless bind_vars.empty?\n @results = ResultSet.new(@connection, self)\n\n step if 0 == column_count\n\n yield @results if block_given?\n @results\n end",
"def execute(sql)\n log_info(sql)\n @pool.hold {|c| c.immediate(sql)}\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)} \n end",
"def execute(*args)\n friendly_name = args[0]\n connection_info = args[1]\n\n return all unless friendly_name\n delegate(friendly_name, connection_info)\n end",
"def set_prepared_statement(name, ps)\n Sequel.synchronize{prepared_statements[name] = ps}\n end",
"def execute_query(sql, args)\n\t\t\t\t\t@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end",
"def execute(sql, name = nil, &block)\n log(sql, name) do\n @connection.query(sql, &block)\n end\n end",
"def query(statement, *params)\n @logger.info \"#{statement}: #{params}\"\n @db.exec_params(statement, params)\n end",
"def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def execute(sql)\n stmt = IBM_DB.exec(@conn, sql)\n raise Error.new(error_msg, error_sqlstate) unless stmt\n Statement.new(stmt)\n end",
"def do(stmt, bindvars={})\n sanity_check(stmt)\n @handle.do(stmt, bindvars)\n #@handle.do(stmt, DBI::Utils::ConvParam.conv_param(driver_name, bindvars))\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def execute(sql)\n @logger.debug(\"SQL: #{sql}\") if @logger\n retrieve_connection.query(sql)\n end",
"def run_sql(statement, params)\n @low_card_model.connection.execute(@low_card_model.send(:sanitize_sql, [ statement, params ]))\n end",
"def execute(sql)\n @db.send(:_execute, self, sql, :log=>false) \n end",
"def call(*args)\n in_context do\n self.execute(*args)\n end\n end",
"def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def execute sql\n db[sql]\n end",
"def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(JDBC::Dataset::PreparedStatementMethods)\n ps.extend(::Sequel::Fdbsql::DatasetMethods::PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end",
"def query(sql, *bind_values)\n @pool.acquire { |conn| conn.query(sql, *bind_values).first }\n end",
"def exec(sql)\n Logging.with_logged_query self, sql do\n raw_connection.exec sql\n end\n end",
"def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def prepare(sql, ps_name)\n if stmt = IBM_DB.prepare(@conn, sql)\n ps_name = ps_name.to_sym\n stmt = Statement.new(stmt)\n @prepared_statements[ps_name] = [sql, stmt]\n else\n err = error_msg\n err = \"Error preparing #{ps_name} with SQL: #{sql}\" if error_msg.nil? || error_msg.empty?\n raise Error.new(err, error_sqlstate)\n end\n end",
"def call(type, bind_vars=OPTS, *values, &block)\n ps = to_prepared_statement(type, values)\n ps.extend(BindArgumentMethods)\n ps.call(bind_vars, &block)\n end",
"def exec(sql, *bindvars, &block)\n ret = nil\n thread = Thread.new { ret = super }\n thread.join\n ret\n rescue Interrupt\n self.break\n raise\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end",
"def prepare(*)\n raise Error, \"cannot prepare an already prepared statement\" unless allow_preparing_prepared_statements?\n super\n end",
"def execute(query, *binds)\n res = nil\n\n mutex.synchronize do\n self.last_query = query\n self.last_statement = sth = new_statement(query)\n res = sth.execute(*binds)\n sth.finish\n yield res if block_given?\n end\n\n return res\n end",
"def exec(sql, rescue_exception = true)\n debug(sql) if $DBG\n exec_statement(sql)\n rescue Object => ex\n if rescue_exception\n handle_sql_exception(ex, sql)\n else\n raise\n end\n end",
"def execute_statement(sql)\n results = ActiveRecord::Base.connection.execute(sql)\n if results.present?\n return results\n else\n return nil\n end\n end",
"def bind_params( *bind_vars )\n @statement.bind_params( *bind_vars )\n end",
"def execute(sql, name = nil)\n #log(sql, name) do\n # TODO: @async\n begin\n table_name = get_table_name_from_sql(sql)\n set_identity_insert_on(table_name) if (is_insert_sql(sql) and includes_id_field(sql))\n \n command = System::Data::SqlClient::SqlCommand.new sql, @connection\n command.transaction = @transaction\n command.command_timeout = @config[:command_timeout] if @config.has_key?(:command_timeout)\n command.execute_non_query \n rescue System::Data::SqlClient::SqlException => e\n raise_statement_invalid_error sql, e\n ensure\n set_identity_insert_off(table_name) if (is_insert_sql(sql) and includes_id_field(sql))\n end\n end",
"def execute_sql\n ActiveRecord::Base.connection.execute(@sql)\n end",
"def execute(sql, opts={}, &block)\n super(@sproc_name, {:args=>@sproc_args, :sproc=>true}.merge(opts), &block)\n end",
"def execute(sql_statement)\n parse(sql_statement)\n end"
] |
[
"0.8060444",
"0.7714628",
"0.76499593",
"0.7505872",
"0.7403695",
"0.7378101",
"0.7176152",
"0.7082819",
"0.7076367",
"0.704002",
"0.703833",
"0.70047003",
"0.68566793",
"0.6823273",
"0.6779913",
"0.67718613",
"0.6749446",
"0.67423135",
"0.67368865",
"0.67130417",
"0.664596",
"0.66323304",
"0.6612541",
"0.65894014",
"0.6583728",
"0.65563595",
"0.65533566",
"0.6461716",
"0.6431242",
"0.6426027",
"0.63915753",
"0.6391375",
"0.6378024",
"0.63397753",
"0.6329809",
"0.630089",
"0.6279827",
"0.62745035",
"0.627253",
"0.6267646",
"0.62646884",
"0.62629557",
"0.6238793",
"0.62257975",
"0.62116987",
"0.62095547",
"0.618661",
"0.61787957",
"0.6174571",
"0.61560863",
"0.6140651",
"0.61302644",
"0.6120052",
"0.6117093",
"0.6107138",
"0.6103032",
"0.6096179",
"0.6092089",
"0.6074681",
"0.60544634",
"0.6048452",
"0.6047569",
"0.6035583",
"0.60293394",
"0.6017323",
"0.5996637",
"0.5996402",
"0.5992278",
"0.5969689",
"0.5961936",
"0.5952718",
"0.5951545",
"0.5945776",
"0.59409416",
"0.5935832",
"0.5921347",
"0.59173644",
"0.5896173",
"0.5854529",
"0.5840592",
"0.58380026",
"0.58293736",
"0.58114135",
"0.5806028",
"0.5795165",
"0.5794392",
"0.5793763",
"0.5785361",
"0.57209337",
"0.56877196",
"0.5680438",
"0.56773996",
"0.5669932",
"0.56682354",
"0.56612927",
"0.56548136",
"0.5651764",
"0.5645215",
"0.56338227",
"0.5632075"
] |
0.8195851
|
0
|
Add the primary_keys and primary_key_sequences instance variables, so we can get the correct return values for inserted rows.
|
def adapter_initialize
@use_iso_date_format = typecast_value_boolean(@opts.fetch(:use_iso_date_format, Postgres.instance_variable_get(:@use_iso_date_format))) # , true)) # SEQUEL5
initialize_postgres_adapter
add_conversion_proc(17, method(:unescape_bytea)) if USES_PG
add_conversion_proc(1082, TYPE_TRANSLATOR.method(:date)) if @use_iso_date_format
self.convert_infinite_timestamps = @opts[:convert_infinite_timestamps]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_primary_keys(klazz, string)\n string << \" set_primary_key #{klazz.fields.select {|f| f[:primarykey]}.map {|pk| pk.name.to_sym}.inspect}\\n\\n\"\n string\n end",
"def primary_keys\n ::Kernel.raise Errors::NotImplemented\n end",
"def insert_sequenced(row)\n sql = row.type.insert_sql_minus_key\n vals = row.field_values_minus_key\n#$stderr.puts sql\n#$stderr.puts vals.inspect\n\n db.do(sql, *vals)\n insert_id = db.select_one(row.type.get_insert_id_sql)[0]\n row.send(row.type.primary_key.setter_name, insert_id)\n row.reset_changed\n end",
"def primary_keys\n cached_fetch(:primary_keys){Array(primary_key)}\n end",
"def primary_key(*attributes)\n if attributes.size == 1 and String===attributes[0]\n @relvar.set_primary_key(@relvar.candidate_key(attributes[0], true))\n else\n name = String===attributes[0] ? attributes.shift : \"pk_#{@relvar.name}\"\n attributes.unshift(name)\n @relvar.set_primary_key(candidate_key(*attributes))\n end\n end",
"def primary_key_names\n @primary_key_names ||= session.left.primary_key_names(left_table)\n end",
"def primary_key!\n @primary_keys << @name\n end",
"def insert(values)\n primary_key_value = nil\n\n if primary_key && Hash === values\n primary_key_value = values[values.keys.find { |k|\n k.name == primary_key\n }]\n\n if !primary_key_value && connection.prefetch_primary_key?(klass.table_name)\n primary_key_value = connection.next_sequence_value(klass.sequence_name)\n values[klass.arel_table[klass.primary_key]] = primary_key_value\n end\n end\n\n im = arel.create_insert\n\n # ****** BEGIN PARTITIONED PATCH ******\n actual_arel_table = @klass.dynamic_arel_table(Hash[*values.map{|k,v| [k.name,v]}.flatten]) if @klass.respond_to?(:dynamic_arel_table)\n actual_arel_table = @table unless actual_arel_table\n # Original line:\n # im.into @table\n im.into actual_arel_table\n # ****** END PARTITIONED PATCH ******\n\n conn = @klass.connection\n\n substitutes = values.sort_by { |arel_attr,_| arel_attr.name }\n binds = substitutes.map do |arel_attr, value|\n [@klass.columns_hash[arel_attr.name], value]\n end\n\n substitutes.each_with_index do |tuple, i|\n tuple[1] = conn.substitute_at(binds[i][0], i)\n end\n\n if values.empty? # empty insert\n im.values = Arel.sql(connection.empty_insert_statement_value)\n else\n im.insert substitutes\n end\n\n conn.insert(\n im,\n 'SQL',\n primary_key,\n primary_key_value,\n nil,\n binds)\n end",
"def primary_key(_table_name)\n []\n end",
"def get_primary_keys \r\n return {\"KtoNr\" => self.KtoNr}\r\n end",
"def multi_insert(tuples)\n pks = relation.multi_insert(tuples, return: :primary_key)\n relation.where(relation.primary_key => pks).to_a\n end",
"def primary_key_sequence(table, opts=OPTS)\n quoted_table = quote_schema_table(table)\n Sequel.synchronize{return @primary_key_sequences[quoted_table] if @primary_key_sequences.has_key?(quoted_table)}\n cond = {Sequel[:t][:oid] => regclass_oid(table, opts)}\n value = if pks = _select_serial_sequence_ds.first(cond)\n literal(SQL::QualifiedIdentifier.new(pks[:schema], pks[:sequence]))\n elsif pks = _select_custom_sequence_ds.first(cond)\n literal(SQL::QualifiedIdentifier.new(pks[:schema], LiteralString.new(pks[:sequence])))\n end\n\n Sequel.synchronize{@primary_key_sequences[quoted_table] = value} if value\n end",
"def generate_primary_key\n self[self.class.primary_key] ||= self.class.new_primary_key(10_000)\n end",
"def primary_keys_cleanup\n primary_keys = []\n\n # Removes the ADD CONSTRAINT statements for primary keys and stores the info of which statements have been removed.\n dump.gsub!(/^-- Name: [\\w\\s]+?(?<name>\\w+_pkey); Type: CONSTRAINT[\\s-]+ALTER TABLE ONLY (?<table>[\\w.]+)\\s+ADD CONSTRAINT \\k<name> PRIMARY KEY \\((?<column>[^,\\)]+)\\);$/) do\n primary_keys.push([$LAST_MATCH_INFO[:table], $LAST_MATCH_INFO[:column]])\n\n ''\n end\n\n # Adds the PRIMARY KEY property to each column for which it's statement has just been removed.\n primary_keys.each do |table, column|\n dump.gsub!(/^(?<statement>CREATE TABLE #{table} \\(.*?\\s+#{column}\\s+[^,\\n]+)/m) do\n \"#{$LAST_MATCH_INFO[:statement].remove(/ NOT NULL\\z/)} PRIMARY KEY\"\n end\n end\n end",
"def right_primary_keys\n cached_fetch(:right_primary_keys){Array(right_primary_key)}\n end",
"def pk_and_sequence_for(table) #:nodoc:\n result = query(<<-end_sql, 'PK and serial sequence')[0]\n SELECT columns.column_name, columns.column_default \n FROM primary_keys \n LEFT JOIN columns \n USING(table_name, column_name)\n WHERE primary_keys.table_name = '#{table_name.gsub(/(^\"|\"$)/,'')}'\n end_sql\n \n if result.length == 0\n return nil\n elsif result[0][1].nil?\n return nil\n else\n default_value = result[0][1]\n seq_name = default_value.match(/\\(\\'(\\w+)\\'\\)/).to_a.last\n return [result[0][0], seq_name]\n end\n rescue\n nil\n end",
"def autoincrementing_primary_key\n primary_key\n end",
"def autoincrementing_primary_key\n primary_key\n end",
"def save_primary_key_grip; end",
"def serial_primary_key_options\n {:primary_key => true, :type => Integer, :auto_increment => true}\n end",
"def serial_primary_key_options\n {:primary_key => true, :type => Integer, :auto_increment => true}\n end",
"def atomic_inserts\n { atomic_insert_modifier => { atomic_position => as_attributes }}\n end",
"def insert(*values)\n if @opts[:returning]\n # Already know which columns to return, let the standard code handle it\n super\n elsif @opts[:sql] || @opts[:disable_insert_returning]\n # Raw SQL used or RETURNING disabled, just use the default behavior\n # and return nil since sequence is not known.\n super\n nil\n else\n # Force the use of RETURNING with the primary key value,\n # unless it has been disabled.\n returning(*insert_pk).insert(*values){|r| return r.values.first}\n end\n end",
"def serial_primary_key_options\n {:primary_key => true, :type => :integer, :auto_increment => true}\n end",
"def serial_primary_key_options\n {:primary_key => true, :type => :integer, :auto_increment => true}\n end",
"def insert(*values)\n if @opts[:returning]\n # Already know which columns to return, let the standard code handle it\n super\n elsif @opts[:sql] || @opts[:disable_insert_returning]\n # Raw SQL used or RETURNING disabled, just use the default behavior\n # and return nil since sequence is not known.\n super\n nil\n else\n # Force the use of RETURNING with the primary key value,\n # unless it has been disabled.\n returning(insert_pk).insert(*values){|r| return r.values.first}\n end\n end",
"def primary_key\n unless @primary_key\n pk_column_names = Set.new( primary_key_columns.collect { |c| c.name } )\n unique_indexes = indexes.values.find_all { |i| i.unique? }\n\n pk_result = []\n\n unique_indexes.each do |idx|\n idx_column_names = Set.new( idx.columns.collect { |c| c.name } )\n r = idx_column_names ^ pk_column_names\n if r.size == 0 then\n pk_result = idx.columns\n break\n end\n end\n\n # no joy, see about just using all the columns that say the are primary\n # keys\n if pk_result.empty? then\n pk_result = self.primary_key_columns\n end\n @primary_key = pk_result\n end\n return @primary_key\n end",
"def _insert\n return super if model.cti_tables.length == 1\n model.cti_models.each do |m|\n v = {}\n m.cti_table_columns.each{|c| v[c] = @values[c] if @values.include?(c)}\n ds = use_server(m.cti_instance_dataset)\n if ds.supports_insert_select? && (h = ds.insert_select(v))\n @values.merge!(h)\n else\n nid = ds.insert(v)\n @values[primary_key] ||= nid\n end\n end\n db.dataset.supports_insert_select? ? nil : @values[primary_key]\n end",
"def _insert_values\n identifier_hash(super)\n end",
"def pk_and_sequence_for(table)\n # try looking for a seq with a dependency on the table's primary key :\n result = select(<<-end_sql, 'PK and Serial Sequence')[0]\n SELECT attr.attname, seq.relname\n FROM pg_class seq,\n pg_attribute attr,\n pg_depend dep,\n pg_constraint cons\n WHERE seq.oid = dep.objid\n AND seq.relkind = 'S'\n AND attr.attrelid = dep.refobjid\n AND attr.attnum = dep.refobjsubid\n AND attr.attrelid = cons.conrelid\n AND attr.attnum = cons.conkey[1]\n AND cons.contype = 'p'\n AND dep.refobjid = '#{quote_table_name(table)}'::regclass\n end_sql\n\n if result.nil? || result.empty?\n # if that fails, try parsing the primary key's default value :\n result = select(<<-end_sql, 'PK and Custom Sequence')[0]\n SELECT attr.attname,\n CASE\n WHEN pg_get_expr(def.adbin, def.adrelid) !~* 'nextval' THEN NULL\n WHEN split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2) ~ '.' THEN\n substr(split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2),\n strpos(split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2), '.')+1)\n ELSE split_part(pg_get_expr(def.adbin, def.adrelid), '''', 2)\n END as relname\n FROM pg_class t\n JOIN pg_attribute attr ON (t.oid = attrelid)\n JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)\n JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])\n WHERE t.oid = '#{quote_table_name(table)}'::regclass\n AND cons.contype = 'p'\n AND pg_get_expr(def.adbin, def.adrelid) ~* 'nextval|uuid_generate'\n end_sql\n end\n\n [ result['attname'], result['relname'] ]\n rescue\n nil\n end",
"def pk_and_sequence_for(table) #:nodoc:\n # First try looking for a sequence with a dependency on the\n # given table's primary key.\n result = select(<<-end_sql, 'PK and serial sequence')[0]\n SELECT attr.attname, seq.relname\n FROM pg_class seq,\n pg_attribute attr,\n pg_depend dep,\n pg_namespace name,\n pg_constraint cons\n WHERE seq.oid = dep.objid\n AND seq.relkind = 'S'\n AND attr.attrelid = dep.refobjid\n AND attr.attnum = dep.refobjsubid\n AND attr.attrelid = cons.conrelid\n AND attr.attnum = cons.conkey[1]\n AND cons.contype = 'p'\n AND dep.refobjid = '#{quote_table_name(table)}'::regclass\n end_sql\n\n if result.nil? or result.empty?\n # If that fails, try parsing the primary key's default value.\n # Support the 7.x and 8.0 nextval('foo'::text) as well as\n # the 8.1+ nextval('foo'::regclass).\n result = select(<<-end_sql, 'PK and custom sequence')[0]\n SELECT attr.attname,\n CASE\n WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN\n substr(split_part(def.adsrc, '''', 2),\n strpos(split_part(def.adsrc, '''', 2), '.')+1)\n ELSE split_part(def.adsrc, '''', 2)\n END as relname\n FROM pg_class t\n JOIN pg_attribute attr ON (t.oid = attrelid)\n JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)\n JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])\n WHERE t.oid = '#{quote_table_name(table)}'::regclass\n AND cons.contype = 'p'\n AND def.adsrc ~* 'nextval'\n end_sql\n end\n\n [result[\"attname\"], result[\"relname\"]]\n rescue\n nil\n end",
"def reset_primary_key_sequence(table)\n return unless seq = primary_key_sequence(table)\n pk = SQL::Identifier.new(primary_key(table))\n db = self\n s, t = schema_and_table(table)\n table = Sequel.qualify(s, t) if s\n\n if server_version >= 100000\n seq_ds = metadata_dataset.from(:pg_sequence).where(:seqrelid=>regclass_oid(LiteralString.new(seq)))\n increment_by = :seqincrement\n min_value = :seqmin\n # :nocov:\n else\n seq_ds = metadata_dataset.from(LiteralString.new(seq))\n increment_by = :increment_by\n min_value = :min_value\n # :nocov:\n end\n\n get{setval(seq, db[table].select(coalesce(max(pk)+seq_ds.select(increment_by), seq_ds.select(min_value))), false)}\n end",
"def pk_and_sequence_for(table_name)\n (owner, table_name) = @connection.describe(table_name)\n\n # RSI: changed select from all_constraints to user_constraints - much faster in large data dictionaries\n pks = select_values(<<-SQL, 'Primary Key')\n select cc.column_name\n from user_constraints c, user_cons_columns cc\n where c.owner = '#{owner}'\n and c.table_name = '#{table_name}'\n and c.constraint_type = 'P'\n and cc.owner = c.owner\n and cc.constraint_name = c.constraint_name\n SQL\n\n # only support single column keys\n pks.size == 1 ? [oracle_downcase(pks.first), nil] : nil\n end",
"def primary_key(*names)\n names.each do |name|\n attributes[name] = attributes[name].meta(primary_key: true)\n end\n self\n end",
"def set_primary_key_attribute\n base = {}\n base[primary_key] = id\n\n attributes.update(base)\n end",
"def key(*fields)\n @primary_key = fields\n before_save :generate_key\n end",
"def primary_key\n self[:primary_key]\n end",
"def primary_key(table)\n t = dataset.send(:input_identifier, table)\n @primary_keys.fetch(t) do\n pk = fetch(\"SELECT RDB$FIELD_NAME FROM RDB$INDEX_SEGMENTS NATURAL JOIN RDB$RELATION_CONSTRAINTS WHERE RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' AND RDB$RELATION_NAME = ?\", t).single_value\n @primary_keys[t] = dataset.send(:output_identifier, pk.rstrip) if pk\n end\n end",
"def primary_key\n @primary_key\n end",
"def serial_primary_key_options\n {:primary_key => true, :serial => true, :type=>Integer}\n end",
"def primary_key_columns\n @columns.values.find_all { |c| c.primary_key? }\n end",
"def primary_key\n @primary_key ||= :id\n end",
"def primary_key=(key)\n @primary_key = key\n end",
"def _insert\n ds = _insert_dataset\n if _use_insert_select?(ds) && (h = _insert_select_raw(ds))\n _save_set_values(h)\n nil\n else\n iid = _insert_raw(ds)\n # if we have a regular primary key and it's not set in @values,\n # we assume it's the last inserted id\n if (pk = autoincrementing_primary_key) && pk.is_a?(Symbol) && !(vals = @values)[pk]\n vals[pk] = iid\n end\n pk\n end\n end",
"def _insert\n ds = _insert_dataset\n if _use_insert_select?(ds) && (h = _insert_select_raw(ds))\n _save_set_values(h)\n nil\n else\n iid = _insert_raw(ds)\n # if we have a regular primary key and it's not set in @values,\n # we assume it's the last inserted id\n if (pk = autoincrementing_primary_key) && pk.is_a?(Symbol) && !(vals = @values)[pk]\n vals[pk] = iid\n end\n pk\n end\n end",
"def primary_key(*names)\n names.each do |name|\n attributes[name][:type] = attributes[name][:type].meta(primary_key: true)\n end\n self\n end",
"def insert_sql(sql, name = nil, pri_key = nil, id_value = nil, sequence_name = nil)\n unless pri_key\n table_ref = extract_table_ref_from_insert_sql(sql)\n pri_key = primary_key(table_ref) if table_ref\n end\n\n if pri_key\n select_value(\"#{sql} RETURNING #{quote_column_name(pri_key)}\")\n else\n super\n end\n end",
"def get_primary_key_value_map\n # {{{\n return @primary_key_value_map if (@primary_key_value_map && !@touched)\n \n accessor = self.class\n base_models = accessor.__associations__.base_klasses()\n table_name = accessor.table_name\n pkey_fields = accessor.get_primary_keys\n \n if !pkey_fields[table_name] then\n raise ::Exception.new(\"Unable to resolve pkey fields for #{self.class.to_s}. Known fields are: #{pkey_fields.inspect}\")\n end\n\n @primary_key_value_map = { table_name => {} }\n pkey_fields[table_name].each { |own_pkey|\n @primary_key_value_map[table_name][own_pkey] = @attribute_values_flat[own_pkey]\n }\n \n # Map own foreign key values back to foreign primary key \n # values. This is necessary as joined primary key field names are \n # shadowed. \n accessor.__associations__.pkey_value_lookup.each { |mapping|\n foreign_pkeys = {}\n mapping.at(1).each_with_index { |fkey,idx|\n value = @attribute_values_flat[fkey]\n foreign_pkeys[mapping.at(2).at(idx)] = value \n }\n @primary_key_value_map[mapping.at(0)] = foreign_pkeys\n }\n return @primary_key_value_map\n end",
"def primary_key\n self[:primary_key] ||= self[:model].primary_key\n end",
"def sql_for_insert(sql, pk, id_value, sequence_name, binds)\n unless pk\n table_ref = extract_table_ref_from_insert_sql(sql)\n pk = primary_key(table_ref) if table_ref\n end\n\n sql = \"#{sql} RETURNING #{quote_column_name(pk)}\" if pk\n\n [sql, binds]\n end",
"def primary_key(table_name)\n pk_and_sequence = pk_and_sequence_for(table_name)\n pk_and_sequence && pk_and_sequence.first\n end",
"def allocate_ids *incomplete_keys\n service.allocate_ids project_id: project, database_id: database, keys: incomplete_keys\n end",
"def insert_pk\n if (f = opts[:from]) && !f.empty?\n case t = f.first\n when Symbol, String, SQL::Identifier, SQL::QualifiedIdentifier\n if pk = db.primary_key(t)\n pk\n end\n end\n end\n end",
"def primary_key(table)\n pk_and_sequence = pk_and_sequence_for(table)\n pk_and_sequence && pk_and_sequence.first\n end",
"def primary_key(table_name)\n pk_and_sequence_for(table_name)[0]\n rescue\n nil\n end",
"def pk_and_sequence_for(table_name, with_seq_schema = false)\n result = select_rows(\n \"SELECT kc.column_name, \"+\n (with_seq_schema ? \"c.sequence_schema, \" : \"\") +\n \" c.sequence_name \"+\n \"FROM information_schema.table_constraints tc \"+\n \"INNER JOIN information_schema.key_column_usage kc \"+\n \" ON tc.table_schema = kc.table_schema \"+\n \" AND tc.table_name = kc.table_name \"+\n \" AND tc.constraint_name = kc.constraint_name \"+\n \"LEFT JOIN information_schema.columns c \"+\n \" ON kc.table_schema = c.table_schema \"+\n \" AND kc.table_name = c.table_name \"+\n \" AND kc.column_name = c.column_name \"+\n \"WHERE tc.table_schema = CURRENT_SCHEMA \"+\n \" AND tc.table_name = '#{table_name}' \"+\n \" AND tc.constraint_type = 'PRIMARY KEY'\",\n SCHEMA_LOG_NAME\n )\n (result.length == 1) ? result[0] : nil\n rescue\n nil\n end",
"def primary_key\n self[:primary_key] ||= associated_class.primary_key\n end",
"def _import(columns, values, opts=OPTS)\n if @opts[:returning]\n # no transaction: our multi_insert_sql_strategy should guarantee\n # that there's only ever a single statement.\n sql = multi_insert_sql(columns, values)[0]\n returning_fetch_rows(sql).map{|v| v.length == 1 ? v.values.first : v}\n elsif opts[:return] == :primary_key\n returning(insert_pk)._import(columns, values, opts)\n else\n super\n end\n end",
"def master_pk(h)\n x = @master_primary_keys\n if x.is_a?(Array)\n unless x == []\n x = x.map{|ca| h[ca]}\n x if x.all?\n end\n else\n h[x]\n end\n end",
"def serial_primary_key_options\n # :nocov:\n auto_increment_key = server_version >= 100002 ? :identity : :serial\n # :nocov:\n {:primary_key => true, auto_increment_key => true, :type=>Integer}\n end",
"def primary_key\n select(&:primary_key?)\n end",
"def primary_key_and_all_references_to_uuid(table, seed: nil)\n fk_specs = foreign_keys_into(table)\n\n drop_foreign_keys(fk_specs)\n\n primary_key_to_uuid(table, seed: seed)\n\n fk_specs.each do |fk_spec|\n columns_to_uuid fk_spec[:from_table], fk_spec[:column], seed: seed\n end\n\n create_foreign_keys(fk_specs.deep_dup)\n end",
"def set_primary_key(key)\n clear_setter_methods_cache\n if key.is_a?(Array)\n if key.length < 2\n key = key.first\n else\n key = key.dup.freeze\n end\n end\n self.simple_pk = if key && !key.is_a?(Array)\n (@dataset || db).literal(key).freeze\n end\n @primary_key = key\n end",
"def set_primary_key(key)\n clear_setter_methods_cache\n if key.is_a?(Array)\n if key.length < 2\n key = key.first\n else\n key = key.dup.freeze\n end\n end\n self.simple_pk = if key && !key.is_a?(Array)\n (@dataset || db).literal(key).freeze\n end\n @primary_key = key\n end",
"def primary_key\n self.class.primary_key\n end",
"def primary_key\n self.class.primary_key\n end",
"def primary_key\n self.class.primary_key\n end",
"def id\n if primary_key.is_a?(Array)\n id = Array.new\n primary_key.each do |key|\n sub_id = self.send(key)\n return nil if (id == \"\")\n id << sub_id\n end\n else\n id = self.send(self.class.primary_key)\n return nil if (id == \"\")\n end\n return id\n end",
"def primary_key\n @primary_key || 'id'\n end",
"def primary_keys(table)\n pks = query(<<-end_sql, 'SCHEMA')\n SELECT DISTINCT attr.attname\n FROM pg_attribute attr\n INNER JOIN pg_depend dep ON attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid\n INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = any(cons.conkey)\n WHERE cons.contype = 'p'\n AND dep.refobjid = '#{quote_table_name(table)}'::regclass\n end_sql\n pks.present? ? pks[0] : pks\n end",
"def class_primary_key_fields(klass)\n fields = []\n if klass.primary_key.class == Array || klass.primary_key.class == CompositePrimaryKeys::CompositeKeys\n klass.primary_key.each do |pk|\n fields << [klass.table_name, pk.to_s]\n end\n else\n fields << [klass.table_name, klass.primary_key]\n end\n fields\n end",
"def insert(*values)\n if @opts[:sql] || @opts[:returning]\n super\n else\n returning(insert_pk).insert(*values){|r| return r.values.first}\n end\n end",
"def insert\n col_names = self.class.columns.join(\", \")\n question_marks = ([\"?\"] * self.class.columns.length).join(\", \")\n DBConnection.execute(<<-SQL, *attribute_values)\n INSERT INTO\n #{self.class.table_name} (#{col_names})\n VALUES\n (#{question_marks})\n SQL\n\n self.id = DBConnection.last_insert_row_id\n end",
"def keys\n @keys ||= [column_for_order_by(relation), primary_key].compact.uniq\n end",
"def insert(tuples)\n pks = tuples.map { |tuple| relation.insert(tuple) }\n relation.where(relation.primary_key => pks).to_a\n end",
"def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:\n unless pk && sequence\n default_pk, default_sequence = pk_and_sequence_for(table)\n\n pk ||= default_pk\n sequence ||= default_sequence\n end\n\n if @logger && pk && !sequence\n @logger.warn \"#{table} has primary key #{pk} with no default sequence.\"\n end\n\n if pk && sequence\n quoted_sequence = quote_table_name(sequence)\n max_pk = query_value(\"SELECT MAX(#{quote_column_name pk}) FROM #{quote_table_name(table)}\", \"SCHEMA\")\n if max_pk.nil?\n if postgresql_version >= 100000\n minvalue = query_value(\"SELECT seqmin FROM pg_sequence WHERE seqrelid = #{quote(quoted_sequence)}::regclass\", \"SCHEMA\")\n else\n minvalue = query_value(\"SELECT min_value FROM #{quoted_sequence}\", \"SCHEMA\")\n end\n end\n if max_pk\n # NOTE(joey): This is done to replace the call:\n #\n # SELECT setval(..., max_pk, false)\n #\n # with\n #\n # SELECT setval(..., max_pk-1)\n #\n # These two statements are semantically equivilant, but\n # setval(string, int, bool) is not supported by CockroachDB.\n #\n # FIXME(joey): This is incorrect if the sequence is not 1\n # incremented. We would need to pull out the custom increment value.\n max_pk - 1\n end\n query_value(\"SELECT setval(#{quote(quoted_sequence)}, #{max_pk ? max_pk : minvalue})\", \"SCHEMA\")\n end\n end",
"def primary_key(value=nil)\n self.primary_key = value unless value.nil?\n \n @primary_key ||= :id\n end",
"def primary_key_names(table_name, options = {})\n return connection.primary_key_names(table_name) if options[:raw]\n \n self.primary_key_names_cache ||= {}\n result = primary_key_names_cache[table_name]\n unless result\n result = manual_primary_keys[table_name] || connection.primary_key_names(table_name)\n primary_key_names_cache[table_name] = result\n end\n result\n end",
"def generate_aasequences\n (0..self.sequence.length-1).each do |i|\n AAsequence.create(:seq_id=> self.seq_id,\n :amino_acid=>self.sequence[i],\n :original_position=>i)\n end\n end",
"def pk_and_sequence_for(table_name, owner = nil, desc_table_name = nil) # :nodoc:\n (owner, desc_table_name) = @raw_connection.describe(table_name)\n\n seqs = select_values_forcing_binds(<<~SQL.squish, \"SCHEMA\", [bind_string(\"owner\", owner), bind_string(\"sequence_name\", default_sequence_name(desc_table_name))])\n select us.sequence_name\n from all_sequences us\n where us.sequence_owner = :owner\n and us.sequence_name = upper(:sequence_name)\n SQL\n\n # changed back from user_constraints to all_constraints for consistency\n pks = select_values_forcing_binds(<<~SQL.squish, \"SCHEMA\", [bind_string(\"owner\", owner), bind_string(\"table_name\", desc_table_name)])\n SELECT cc.column_name\n FROM all_constraints c, all_cons_columns cc\n WHERE c.owner = :owner\n AND c.table_name = :table_name\n AND c.constraint_type = 'P'\n AND cc.owner = c.owner\n AND cc.constraint_name = c.constraint_name\n SQL\n\n warn <<~WARNING if pks.count > 1\n WARNING: Active Record does not support composite primary key.\n\n #{table_name} has composite primary key. Composite primary key is ignored.\n WARNING\n\n # only support single column keys\n pks.size == 1 ? [oracle_downcase(pks.first),\n oracle_downcase(seqs.first)] : nil\n end",
"def insert_invoices(transaction, foreign_keys)\n arguments = [\n transaction[:invoice_no],\n transaction[:sale_amount],\n transaction[:units_sold],\n transaction[:sale_date],\n transaction[:invoice_frequency],\n foreign_keys[:customer_id],\n foreign_keys[:employee_id],\n foreign_keys[:product_id],\n]\n\n db_connection do |conn|\n sql = <<-eos\n INSERT INTO invoices (invoice_no, sale_amount, units_sold, sale_date, invoice_frequency,\n customer_id, employee_id, product_id)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n eos\n conn.exec_params(sql, arguments)\n end\nend",
"def primary_keys(table)\n row = exec_query(<<-end_sql, 'SCHEMA').rows.map do |row|\n SELECT DISTINCT(attr.attname)\n FROM pg_attribute attr\n INNER JOIN pg_depend dep ON attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid\n INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]\n WHERE cons.contype = 'p'\n AND dep.refobjid = '#{quote_table_name(table)}'::regclass\n end_sql\n row && row.first\n end\n end",
"def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)\n exec_query(sql, name, binds)\n end",
"def insert\n \n attributes = []\n instance_variables.each do |i|\n attributes << i.to_s.delete(\"@\") if (i != :@id && i != :@table)\n end\n \n values = []\n attributes.each do |a|\n value = self.send(a)\n \n if value.is_a?(Integer)\n values << \"#{value}\"\n else values << \"'#{value}'\"\n end\n end\n \n DATABASE.execute(\"INSERT INTO students (#{attributes.join(\", \")}) \n VALUES (#{values.join(\", \")})\")\n @id = DATABASE.last_insert_row_id\n\n end",
"def pre_process_batch_insert(docs)\n docs.map do |doc|\n next unless doc\n append(doc)\n if persistable? && !_assigning?\n self.path = doc.atomic_path unless path\n if doc.valid?(:create)\n doc.run_before_callbacks(:save, :create)\n else\n self.inserts_valid = false\n end\n end\n doc.send(:as_attributes)\n end\n end",
"def insert\n # the array of ::columns of the class joined with commas, drop id\n col_names = self.class.columns[1..-1].join(\", \") \n # an array of question marks\n question_marks = ([\"?\"] * col_names.split.size).join(\", \")\n\n DBConnection.execute(<<-SQL, *attribute_values[1..-1])\n INSERT INTO\n #{self.class.table_name} (#{col_names})\n VALUES\n (#{question_marks})\n SQL\n\n self.id = DBConnection.last_insert_row_id\n end",
"def to_key\n new_record? ? nil : [ self.send(self.class.primary_key) ]\n end",
"def primary_key(table_name)\n table_name = table_name.to_s\n\n @primary_keys ||= {}\n @primary_keys[table_name] ||= if @registration[:primary_key].present?\n @registration[:primary_key].call(@connection, table_name)\n else\n @connection.primary_key(table_name)\n end\n end",
"def primary_key\n \"#{quoted_table_name}.#{model_class.send :primary_key}\"\n end",
"def primary_key\n \"#{quoted_table_name}.#{model_class.send :primary_key}\"\n end",
"def key(*fields)\n self.primary_key = fields\n identity(:type => String)\n set_callback :save, :before, :identify\n end",
"def _primary_key_order\n if @opts[:order].nil? && model && (pk = model.primary_key)\n cached_dataset(:_pk_order_ds){order(*pk)}\n end\n end",
"def _primary_key_order\n if @opts[:order].nil? && model && (pk = model.primary_key)\n cached_dataset(:_pk_order_ds){order(*pk)}\n end\n end",
"def add_sequences(repository, model)\n model.properties(repository.name).each do |property|\n create_sequence(repository, property) if property.serial?\n end\n end",
"def primary_key\n @primary_key ||= @klass.primary_key.to_s\n end",
"def pkey\n table = self.class.table_name\n key = get_primary_key_values.first\n return key\n end",
"def assign_objectid_primary_key\n self.class.objectid_columns_manager.assign_objectid_primary_key(self)\n end",
"def create\n values = attribute_hash\n DBConnection.execute(<<-SQL, values)\n INSERT INTO\n #{self.class.table_name} (#{values.keys.join(', ')})\n VALUES\n (:#{values.keys.join(', :')})\n SQL\n self.id = DBConnection.last_insert_row_id\n end",
"def orchestrate_primary_key\n id\n end",
"def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:\n unless pk and sequence\n default_pk, default_sequence = pk_and_sequence_for(table)\n pk ||= default_pk\n sequence ||= default_sequence\n end\n if pk\n if sequence\n quoted_sequence = quote_column_name(sequence)\n\n select_value <<-end_sql, 'Reset sequence'\n SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false)\n end_sql\n else\n @logger.warn \"#{table} has primary key #{pk} with no default sequence\" if @logger\n end\n end\n end",
"def to_key\nnew_record? ? nil : [ self.send(self.class.primary_key) ]\nend"
] |
[
"0.639773",
"0.63902473",
"0.63513935",
"0.63435245",
"0.6161881",
"0.61553204",
"0.6145978",
"0.6143075",
"0.60911965",
"0.6079128",
"0.6012031",
"0.5986647",
"0.59766793",
"0.5942253",
"0.5938634",
"0.59175503",
"0.590662",
"0.590662",
"0.58845913",
"0.58803105",
"0.58803105",
"0.58719915",
"0.5868549",
"0.5852508",
"0.5852508",
"0.58487487",
"0.5843949",
"0.5840906",
"0.58356816",
"0.5820889",
"0.57995075",
"0.57950217",
"0.57627976",
"0.5745957",
"0.5738744",
"0.5738118",
"0.5724224",
"0.5721107",
"0.5714069",
"0.5699196",
"0.56910765",
"0.5673965",
"0.56635886",
"0.5633401",
"0.5633401",
"0.5606554",
"0.5586696",
"0.5571208",
"0.5568523",
"0.5507075",
"0.5500723",
"0.54865485",
"0.54826",
"0.5465574",
"0.54597604",
"0.54530543",
"0.54506326",
"0.5442574",
"0.5425817",
"0.54176116",
"0.54121184",
"0.5400399",
"0.5399902",
"0.5399902",
"0.539579",
"0.539579",
"0.539579",
"0.5391264",
"0.5362399",
"0.53622794",
"0.53542864",
"0.5352754",
"0.5345188",
"0.5341052",
"0.5332282",
"0.5317372",
"0.53088313",
"0.530673",
"0.52886695",
"0.5281204",
"0.52786195",
"0.5277936",
"0.52643883",
"0.52596676",
"0.5259468",
"0.5254442",
"0.5250728",
"0.5237625",
"0.5225363",
"0.5225363",
"0.5223499",
"0.5214859",
"0.5214859",
"0.5203383",
"0.52028584",
"0.52005124",
"0.51987046",
"0.5188284",
"0.51872116",
"0.5179242",
"0.5172597"
] |
0.0
|
-1
|
Set the DateStyle to ISO if configured, for faster date parsing.
|
def connection_configuration_sqls
sqls = super
sqls << "SET DateStyle = 'ISO'" if @use_iso_date_format
sqls
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def date_style\n @date_style if [:date, :date_range, :month_and_year, :only_year, :date_disabled].include? @date_style.to_sym\n end",
"def use_euro_formats\n self.current_date_format = :euro\n end",
"def format_date\n begin\n self.eob_date = Date.strptime(self.unformatted_eob_date, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_eob_date.blank?\n self.dos = Date.strptime(self.unformatted_dos, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_dos.blank?\n self.check_date = Date.strptime(self.unformatted_check_date, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_check_date.blank?\n rescue\n errors.add :base, \"Invalid Date(s)\"\n end\n end",
"def set_date_format(format)\n @date_format = format\n end",
"def isoify_dates!(hash)\n hash.replace isoify_dates hash\n end",
"def update_date_formats!\n Date::DATE_FORMATS.update(\n :db => '%Y-%m-%d %H:%M:%S',\n :ui => '%d.%m.%Y',\n :yaml => '%Y-%m-%d', # For Dates\n :default => '%d.%m.%Y'\n )\n end",
"def cast_default(value)\n @format_string = iso8601\n cast_fmt(value)\n end",
"def format_date\n begin\n if !self.unformatted_license_date.blank?\n self.license_date = Date.strptime(self.unformatted_license_date, \"%m/%d/%Y\").to_time(:utc)\n end\n rescue\n errors.add :base, \"Invalid Date\"\n end\n end",
"def init_style=(style)\n java_style = case style\n when :decorated then\n StageStyle::DECORATED\n when :undecorated then\n StageStyle::UNDECORATED\n when :transparent then\n StageStyle::TRANSPARENT\n when :utility then\n StageStyle::UTILITY\n else\n style # Assume real Java value\n end\n initStyle(java_style)\n end",
"def use_style=(style)\n end",
"def normalize_date( object, attribute, params )\n value = params[object][attribute]\n if value.match('\\d\\d\\d\\d-\\d\\d-\\d\\d')\n # all fine - iso format used\n return\n elsif value.size == 4\n # only year given\n params[object][attribute] = value + \"-01-01\"\n elsif value.match('\\d\\d?\\.\\d\\d?\\.\\d\\d$')\n # wrong format, probably something like 20.10.84\n date = value.split('.')\n year = (date[2].to_i < 10) ? date[2].to_i + 2000 : date[2].to_i + 1900\n date = Date.new( year, date[1].to_i, date[0].to_i ) \n params[object][attribute] = date.to_s\n elsif value.match('\\d?\\d\\.\\d?\\d\\.\\d\\d\\d\\d')\n # wrong format\n date = value.split('.')\n params[object][attribute] = date[2] + \"-\" + date[1] + \"-\" + date[0]\n else\n date = ParseDate.parsedate( value, true )\n params[object][attribute] = date[0].to_s + \"-\" + date[1].to_s + \"-\" + date[2].to_s\n end\n end",
"def normalize_dates!\n pub_date = self.emma_publicationDate&.to_s\n pub_year = pub_date&.first(4)\n if pub_date&.end_with?('-01-01')\n self.dcterms_dateCopyright ||= IsoYear.new(pub_year)\n cpr_date = self.dcterms_dateCopyright.to_s\n self.emma_publicationDate = nil if cpr_date == pub_year\n elsif (cpr_date = self.dcterms_dateCopyright&.to_s)\n self.dcterms_dateCopyright = nil if cpr_date == pub_year\n end\n end",
"def format_date\n begin\n self.dos = Date.strptime(self.unformatted_dos, \"%m/%d/%Y\").to_time(:utc) if !self.unformatted_dos.blank?\n rescue\n errors.add :base, \"Invalid Date(s)\"\n return false\n end\n end",
"def use_us_formats\n self.current_date_format = :us\n end",
"def _format_date(date)\n return unless date\n\n DateTime.parse(date.to_s).iso8601\n end",
"def use_default_style!\n @use_default_style = true\n end",
"def style=(value)\n @style = value\n end",
"def use_dates\n @use_dates || true\n end",
"def set_date_format(format)\n @date_format = format\n end",
"def atos_style=(atos_style)\n if !atos_style.nil? && atos_style.to_s.length > 255\n fail ArgumentError, 'invalid value for \"atos_style\", the character length must be smaller than or equal to 255.'\n end\n\n if !atos_style.nil? && atos_style.to_s.length < 0\n fail ArgumentError, 'invalid value for \"atos_style\", the character length must be great than or equal to 0.'\n end\n\n @atos_style = atos_style\n end",
"def iso_date(date)\n case date\n when Date, Time\n date.strftime(\"%Y-%m-%d\")\n when String\n return nil if date.empty?\n date = Date.parse(date)\n date.strftime(\"%Y-%m-%d\")\n else\n nil\n end\n end",
"def set_formatted_dates\n @clienttransaction.update_attribute(:duedate, formatted_date(clienttransaction_params[:duedate])) if clienttransaction_params[:duedate].present?\n @clienttransaction.update_attribute(:transaction_date, formatted_date(clienttransaction_params[:transaction_date])) if clienttransaction_params[:transaction_date].present?\n end",
"def date_format=(value)\n @date_format = value\n end",
"def set_no_style\n @no_style = NoStyle.find(params[:id])\n end",
"def default_options_date_format(format)\n format || '%Y-%m-%d - %l:%M:%S%p'\n end",
"def format_date\n if @opts[:as] == :select\n values = {}\n if v = @attr[:value]\n v = Date.parse(v) unless v.is_a?(Date)\n values[:year], values[:month], values[:day] = v.year, v.month, v.day\n end\n _format_date_select(values, @opts[:order] || DEFAULT_DATE_ORDER)\n else\n _format_input(:date)\n end\n end",
"def _date_parse(string)\n super(handle_date_parse_input(string))\n end",
"def set_iso\n @iso = Iso.find(params[:id])\n end",
"def date_format_set\n instance_variable_get(:\"@#{current_date_format}_date_format_set\")\n end",
"def set_date_before_save\n self.date = Chronic.parse(self.human_date)\n end",
"def style=(style)\n each_with_index do |cell, index|\n cell.style = style.is_a?(Array) ? style[index] : style\n end\n end",
"def iso8601\n utc.strftime DATE_FORMATS[:iso8601]\n end",
"def set_sighted_at\n\t\tif @sighted_date.present?\n\t\t\tself[:sighted_at] = Time.zone.parse(\"#{@sighted_date} #{@sighted_time}\")\n\t\tend\n\t\tif self[:sighted_at].blank?\n\t\t\tself[:sighted_at] = Time.zone.now\n\t\tend\n\tend",
"def parse_iso_8601_date(string)\n if string =~ ISO_8601_DATE\n Date.parse(string) rescue nil\n end\n end",
"def typus_date_format(attribute = :default)\n options = read_model_config['fields']['options']\n if options && options['date_formats'] && options['date_formats'][attribute.to_s]\n options['date_formats'][attribute.to_s].to_sym\n else\n :default\n end\n end",
"def reset_format!\n self.format = @default_format\n end",
"def iso8601(p1 = v1)\n #This is a stub, used for indexing\n end",
"def string_to_date(string)\n super(handle_date_parse_input(string))\n end",
"def rolls_date= date\n return super(date) unless date.is_a? String\n\n date = Date.strptime(date, \"%m%d%Y\") if date =~ /\\d{8}/\n date = Date.strptime(date, \"%m/%d/%Y\") if date =~ /\\d{1,2}\\/\\d{1,2}\\/\\d{4}/\n date = Date.parse(date) if date =~ /\\d{4}-\\d{1,2}-\\d{1,2}/\n\n super date\n end",
"def style=(style)\n cells.each_with_index do | cell, index |\n s = style.is_a?(Array) ? style[index] : style\n cell.style = s\n end\n end",
"def normalize_date(date)\n if zone = active_workspace_configuration[\"TimeZone\"]\n Time.parse(date).in_time_zone(zone).to_date rescue Date.parse(date)\n else\n Date.parse(date)\n end\n end",
"def typus_date_format(attribute = :default)\n Typus::Configuration.config[name]['fields']['options']['date_formats'][attribute.to_s].to_sym\n rescue\n :db\n end",
"def date=(date)\n @date = parse_date(date)\n end",
"def set_formatted_dates\n @vendortransaction.update_attribute(:duedate, formatted_date(vendortransaction_params[:duedate])) if vendortransaction_params[:duedate].present?\n @vendortransaction.update_attribute(:transaction_date, formatted_date(vendortransaction_params[:transaction_date])) if vendortransaction_params[:transaction_date].present?\n end",
"def to_iso8601(date)\n return nil unless(date)\n date = DateTime.parse(date) unless(date.respond_to?(:strftime))\n date.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def isoify_dates(hash)\n hash.each_with_object({}) do |(k, v), memo|\n memo[k] = maybe_datetime_in_iso8601(v)\n end\n end",
"def style(options)\n @styles = options\n end",
"def datetime_format=(format)\n end",
"def datetime_format=(datetime_format)\n @default_formatter.datetime_format = datetime_format\n end",
"def sanitize_data!\n convert_datetimes_intelligently!\n end",
"def generate_iso_8601_date\n date = self.to_formatted_s(:response_format)\n iso8601_date = Time.parse(date).utc.iso8601\n\n return iso8601_date\n end",
"def style=(_); end",
"def date_overwrite(original, overwrite)\n date_present?(original) ? original : overwrite\n end",
"def safe_datetime_string\n safe_date = nil\n if self =~ US_DATE_REGEX\n safe_date = us_date_to_iso_str\n elsif self =~ JSON_DATE_REGEX\n safe_date = json_date_to_time.to_s\n else\n safe_date = self\n end\n safe_date\n end",
"def toggle_picker_style(sender)\n case (sender.selectedSegmentIndex)\n when 0 # Time\n @date_picker_view.datePickerMode = UIDatePickerModeTime\n @segment_label.text = 'UIDatePickerModeTime'\n when 1 # Date\n @date_picker_view.datePickerMode = UIDatePickerModeDate\n @segment_label.text = 'UIDatePickerModeDate'\n when 2 # Date & Time\n @date_picker_view.datePickerMode = UIDatePickerModeDateAndTime\n @segment_label.text = 'UIDatePickerModeDateAndTime'\n when 3 # Counter\n @date_picker_view.datePickerMode = UIDatePickerModeCountDownTimer\n @segment_label.text = 'UIDatePickerModeCountDownTimer'\n end\n\n # in case we previously chose the Counter style picker, make sure\n # the current date is restored\n @date_picker_view.date = NSDate.date\n end",
"def set_date_options\n @date_start = !@params[:date_start].blank? ? DateTime.parse(@params[:date_start]).to_date : Order.first_datetime.to_date\n @date_end = !@params[:date_end].blank? ? DateTime.parse(@params[:date_end]).to_date : Date.today\n @date_unit = @params[:date_unit] || 'month'\n @date_start_db = @date_start.to_datetime.to_s(:db)\n @date_end_db = @date_end.to_datetime.to_s(:db)\n\n case @date_unit\n when 'day'\n @date_values = date_range_to_single_dates(@date_start, @date_end)\n when 'week'\n @date_values = date_range_to_weeks(@date_start, @date_end).map { |d| d[0] }\n when 'month'\n @date_values = date_range_to_months(@date_start, @date_end)\n end\n end",
"def set_style()\n style = @yaml['html']['style'] || @yaml['style']\n case\n when style.nil? then ''\n when style.class == String then \"style=\\\"#{style}\\\"\"\n when style.class == Hash then\n value = style.to_a.inject([]) {|r,v| r << \"#{v[0]}: #{v[1]}\" }.join(';')\n \"style=\\\"#{value}\\\"\" \n else ''\n end \nend",
"def set_style()\n style = @yaml['html']['style'] || @yaml['style']\n case\n when style.nil? then ''\n when style.class == String then \"style=\\\"#{style}\\\"\"\n when style.class == Hash then\n value = style.to_a.inject([]) {|r,v| r << \"#{v[0]}: #{v[1]}\" }.join(';')\n \"style=\\\"#{value}\\\"\" \n else ''\n end \nend",
"def set_style(style_id = 2)\n style_id = 2 if style_id < 1 || style_id > 48\n @style_id = style_id\n end",
"def format(formatter = DateTimeFormatter::ISO_LOCAL_TIME)\n formatter.format self\n end",
"def defined_style_conversions; end",
"def style=(style)\n if !style.nil? && style.to_s.length > 255\n fail ArgumentError, 'invalid value for \"style\", the character length must be smaller than or equal to 255.'\n end\n\n if !style.nil? && style.to_s.length < 0\n fail ArgumentError, 'invalid value for \"style\", the character length must be great than or equal to 0.'\n end\n\n @style = style\n end",
"def solrize_date(date)\n date.strftime('%Y-%m-%dT00:00:00Z')\n end",
"def call(format_type: DEFAULT_NEWS_FORMAT_TYPE)\n self.combined_options = defaults.merge(\n format_type: validate_format_type(format_type)\n )\n super\n end",
"def chronic_published_on=(str)\n @chronic_published_on = str\n if str.blank?\n self.published_on = nil\n else\n self.published_on = Chronic.parse(str) || Date.parse(str)\n end\n end",
"def calendar_date_select_stylesheets(options = {})\n return [] if @cds_stylesheets_loaded\n\n @cds_stylesheets_loaded = true\n\n options.assert_valid_keys(:style)\n \"calendar_date_select/#{options[:style] || \"default\"}\"\n end",
"def datepicker_options(format, value = nil)\n datepicker_options = {:value => value.try(:strftime, format), :input_html => {:class => 'ui-datepicker'}}\n end",
"def price_date=(date_string)\n if !date_string.blank? && date_string.split(\"/\")[2].length == 2\n date = Date.strptime(date_string, \"%m/%d/%y\") rescue nil\n else\n date = Date.strptime(date_string, \"%m/%d/%Y\") rescue nil\n end\n write_attribute(:price_date, date)\n end",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def datetime_format_set\n instance_variable_get(:\"@#{current_date_format}_datetime_format_set\")\n end",
"def defined_style_conversions=(_arg0); end",
"def default_year_built\n\t\t\tself.year_built = '2016' if self.year_built.empty?\n\t\tend",
"def set_search_style(style = nil)\n valid_values = SearchModesHelper::SEARCH_STYLES\n set_search_feature(:style, style, valid_values, meth: __method__)\n end",
"def set_style(style_id = 2)\n style_id = 2 if style_id < 0 || style_id > 42\n @style_id = style_id\n end",
"def change_date_format\n params[:audit][:period_start] = DateTime.strptime(params[:audit][:period_start], \"%m/%d/%Y %H:%M\")\n params[:audit][:period_end] = DateTime.strptime(params[:audit][:period_end], \"%m/%d/%Y %H:%M\")\n end",
"def parse_date(date)\n Icalendar::Values::DateOrDateTime.new(date)\n end",
"def configure_connection\n super\n execute(\"SET SESSION IntervalStyle TO 'iso_8601'\", 'SCHEMA')\n end",
"def opportunity_date_ini_type_friendly(opportunity)\n if opportunity.date_ini_type == 0\n 'Indefinido'\n elsif opportunity.date_ini_type == 1\n 'Lo antes posible'\n else\n 'Fijar fecha'\n end\n end",
"def date=(date)\n @date = case date\n when String\n Date.parse(date)\n else\n date\n end\n end",
"def set_date_format(format) \n unless format.nil?\n return format\n else\n return @@db_format\n end\n end",
"def datetime_format=(datetime_format)\n @default_formatter.datetime_format = datetime_format\n end",
"def iso_format(time)\n time.getutc.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def strptime(str=\"-4712-01-01\", fmt='%F', sg=nil)\n super(str, fmt)\n end",
"def clean_date\n read_attribute :date\n end",
"def set_style(style)\n if(!style.eql?(\"HOSTS\") and !style.eql?(\"LOGIN\") and !style.eql?(\"CERTIFICATE\"))\n fail_response(13001, \"NaServer::set_style: bad style \\\"\" + style + \"\\\"\")\n end\n if (style.eql?(\"CERTIFICATE\"))\n ret = set_transport_type(\"HTTPS\")\n if (ret)\n ret\n end\n @enable_server_cert_verification = true\n @enable_hostname_verification = true\n else\n @enable_server_cert_verification = false\n @enable_hostname_verification = false\n end\n @style = style\n end",
"def date_format\n return @date_format\n end",
"def ris_date\n return @ris_date if defined?(@ris_date)\n\n @ris_date ||= begin\n if start_d = @citable_attributes.date && @citable_attributes.date.parts.first\n self.class.formatted_ris_date(year: start_d.year, month: start_d.month, day: start_d.day)\n end\n end\n end",
"def expected_format\n options[:expected_format] || 'yyyy-mm-dd'\n end",
"def to_date\n begin\n super\n rescue\n Date.null_date\n end\n end",
"def parse(aeries_data, aeries_attributes_list, setters_list)\n super\n self.start_date = DateTime.parse(start_date) unless start_date.nil?\n self.end_date = DateTime.parse(end_date) unless end_date.nil?\n end",
"def setStyleName(style)\n styleNameHelper(MODE_SET, style)\n end",
"def style\n @style ||= Style.new(attributes[:style])\n end",
"def iso_time\n @iso_time ||= Time.now.utc.iso8601\n end",
"def date=(date_value)\n @date = date_value.class <= Date ? date_value : Date.parse(date_value)\n end",
"def format_date_nicely(date)\nend",
"def iso?; end",
"def enforce_iso8601_date(api_attribute, table_column = api_attribute)\n define_method(api_attribute) do\n object.send(table_column).strftime('%F') unless object.send(table_column).nil?\n end\n end",
"def date=(date)\n if date && date.is_a?(String)\n @date = date.strip\n end\n end",
"def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? spent_on.cweek : nil\n end",
"def set_style\n @style = Style.find(params[:id])\n end"
] |
[
"0.6048192",
"0.5229943",
"0.5126543",
"0.501055",
"0.49447453",
"0.4936957",
"0.4936076",
"0.48847598",
"0.48566493",
"0.48507422",
"0.4844862",
"0.48273945",
"0.48191088",
"0.4818787",
"0.48047313",
"0.47984964",
"0.47938967",
"0.47908103",
"0.478097",
"0.4746114",
"0.47351113",
"0.4711085",
"0.4710333",
"0.46937436",
"0.4684259",
"0.46752056",
"0.46276626",
"0.46211106",
"0.45898277",
"0.45761392",
"0.4576059",
"0.4558743",
"0.45462915",
"0.45424214",
"0.45284307",
"0.45030814",
"0.44931892",
"0.44775516",
"0.44702193",
"0.4465584",
"0.44489443",
"0.44407633",
"0.44185758",
"0.44178095",
"0.4417237",
"0.44058883",
"0.43937945",
"0.43936342",
"0.43792653",
"0.4378993",
"0.4375739",
"0.43722215",
"0.43572018",
"0.4349558",
"0.43470305",
"0.43445304",
"0.43409574",
"0.43409574",
"0.4339267",
"0.43337247",
"0.43257198",
"0.43249118",
"0.43152726",
"0.43124443",
"0.43049195",
"0.43048826",
"0.43026972",
"0.4300434",
"0.4289587",
"0.4288131",
"0.42873263",
"0.42739785",
"0.4273023",
"0.42673403",
"0.42601594",
"0.42597488",
"0.42586833",
"0.42429292",
"0.4239326",
"0.4236956",
"0.423559",
"0.42317262",
"0.4223978",
"0.42235798",
"0.42149654",
"0.42128265",
"0.41985065",
"0.4196083",
"0.4195993",
"0.41916358",
"0.41901913",
"0.41854125",
"0.41838038",
"0.4181377",
"0.41763183",
"0.41754046",
"0.41754037",
"0.41748136",
"0.41720292",
"0.41666654"
] |
0.5452926
|
1
|
Execute the prepared statement with the given name on an available connection, using the given args. If the connection has not prepared a statement with the given name yet, prepare it. If the connection has prepared a statement with the same name and different SQL, deallocate that statement first and then prepare this statement. If a block is given, yield the result, otherwise, return the number of rows changed.
|
def execute_prepared_statement(conn, name, opts=OPTS, &block)
ps = prepared_statement(name)
sql = ps.prepared_sql
ps_name = name.to_s
if args = opts[:arguments]
args = args.map{|arg| bound_variable_arg(arg, conn)}
end
unless conn.prepared_statements[ps_name] == sql
conn.execute("DEALLOCATE #{ps_name}") if conn.prepared_statements.include?(ps_name)
conn.check_disconnect_errors{log_connection_yield("PREPARE #{ps_name} AS #{sql}", conn){conn.prepare(ps_name, sql)}}
conn.prepared_statements[ps_name] = sql
end
log_sql = "EXECUTE #{ps_name}"
if ps.log_sql
log_sql += " ("
log_sql << sql
log_sql << ")"
end
q = conn.check_disconnect_errors{log_connection_yield(log_sql, conn, args){_execute_prepared_statement(conn, ps_name, args, opts)}}
begin
block_given? ? yield(q) : q.cmd_tuples
ensure
q.clear if q && q.respond_to?(:clear)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end",
"def execute_prepared_statement(ps_name, opts)\n args = opts[:arguments]\n ps = prepared_statement(ps_name)\n sql = ps.prepared_sql\n synchronize(opts[:server]) do |conn|\n unless conn.prepared_statements.fetch(ps_name, []).first == sql\n log_connection_yield(\"PREPARE #{ps_name}: #{sql}\", conn){conn.prepare(sql, ps_name)}\n end\n args = args.map{|v| v.nil? ? nil : prepared_statement_arg(v)}\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n begin\n stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free_result if stmt\n end\n end\n end",
"def _execute_prepared_statement(conn, ps_name, args, opts)\n conn.exec_prepared(ps_name, args)\n end",
"def execute_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return perform_select(query_string).get_rows()\n end",
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def execute_prepared(ps_name, *values)\n stmt = @prepared_statements[ps_name].last\n res = stmt.execute(*values)\n unless res\n raise Error.new(\"Error executing statement #{ps_name}: #{error_msg}\", error_sqlstate)\n end\n stmt\n end",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def execute(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n q = check_disconnect_errors{execute_query(sql, args)}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def open_cursor_with_sql(name, *sql_and_args, &block)\n connection.cursor_eachrow(sql_and_args, name, &block)\n end",
"def execute_and_free(sql, name = nil, async: false) # :nodoc:\n sql = transform_query(sql)\n check_if_write_query(sql)\n\n mark_transaction_written_if_write(sql)\n yield raw_execute(sql, name, async: async)\n end",
"def prepared_statement(name)\n Sequel.synchronize{prepared_statements[name]}\n end",
"def select_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return select_cached(query_string)\n end",
"def execute(sql, name = nil, binds = [])\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n @connection.do(sql)\n end\n end",
"def call(*args)\n params = build_params args\n cstmt = @connection.prepare_call \"{call #{name}(#{Array.new(@cols.length){'?'}.join ', '})}\"\n begin\n process_result( args, cstmt.call(*params) )\n ensure\n cstmt.close\n end\n end",
"def execute(sql, opts=OPTS)\n _execute(sql, opts) do |conn|\n begin\n yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})\n ensure\n stmt.close if stmt\n end\n end\n end",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def find_cursor(name, transaction, *findargs)\n count = 0\n begin\n connection.begin_db_transaction if transaction\n open_cursor(name, *findargs)\n while (row = ActiveRecord::Base.fetch_cursor(name)) do\n count+= 1\n yield row\n end\n close_cursor(name)\n ensure\n connection.commit_db_transaction if transaction\n end\n count\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)\n sql = transform_query(sql)\n\n if preventing_writes? && write_query?(sql)\n raise ActiveRecord::ReadOnlyError, \"Write query attempted while in readonly mode: #{sql}\"\n end\n\n materialize_transactions\n mark_transaction_written_if_write(sql)\n\n binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)\n\n if without_prepared_statement?(binds)\n log(sql, name) { @connection.execute_query(sql) }\n else\n log(sql, name, binds) do\n # this is different from normal AR that always caches\n cached_statement = fetch_cached_statement(sql) if prepare && @jdbc_statement_cache_enabled\n @connection.execute_prepared_query(sql, binds, cached_statement)\n end\n end\n end",
"def execute(sql, name = nil, &block)\n log(sql, name) do\n @connection.query(sql, &block)\n end\n end",
"def execute\n conn = connection\n Benchmark.bm { |x| x.report { yield conn } }\n conn.close\n end",
"def _execute(conn, sql, opts, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n conn.execute(sql, opts[:arguments], &block)\n end\n end",
"def run(&block)\n case prepared_type\n when :select, :all\n # Most common scenario, so listed first\n all(&block)\n when :each\n each(&block)\n when :insert_select\n with_sql(prepared_sql).first\n when :first\n first\n when :insert, :update, :delete\n if opts[:returning] && supports_returning?(prepared_type)\n returning_fetch_rows(prepared_sql)\n elsif prepared_type == :delete\n delete\n else\n send(prepared_type, *prepared_modify_values)\n end\n when :insert_pk\n fetch_rows(prepared_sql){|r| return r.values.first}\n when Array\n case prepared_type[0]\n when :map, :as_hash, :to_hash, :to_hash_groups\n send(*prepared_type, &block) \n end\n else\n Sequel::Deprecation.deprecate(\"Using an unsupported prepared statement type (#{prepared_type.inspect})\", 'Switch to using :select as the prepared statement type')\n all(&block)\n end\n end",
"def call(*)\n raise Error, \"Cannot call prepared statement without a name\" if prepared_statement_name.nil?\n super\n end",
"def execute(sql, name = nil, _binds = [])\n log(sql, name) do\n @connection.do(sql)\n end\n end",
"def execute(stmt, bindvars={})\n sanity_check(stmt)\n\n if @convert_types\n bindvars = DBI::Utils::ConvParam.conv_param(driver_name, bindvars)\n end\n\n sth = StatementHandle.new(@handle.execute(stmt, bindvars), true, true, @convert_types, true)\n # FIXME trace sth.trace(@trace_mode, @trace_output)\n sth.dbh = self\n sth.raise_error = raise_error\n\n if block_given?\n begin\n yield sth\n ensure\n sth.finish unless sth.finished?\n end\n else\n return sth\n end\n end",
"def exec_query(sql, name = 'SQL', _binds = [], prepare: false)\n log(sql, name) do\n result = @connection.run(sql)\n ActiveRecord::Result.new(result.columns, result.rows)\n end\n end",
"def execute( *params )\n bind( *params )\n begin\n # save the error state at the beginning of the execution. We only want to\n # reraise the error if it was raised during this execution.\n s_before = $!\n if block_given? then\n while row = next_row\n yield row\n end\n else\n all_rows\n end\n ensure\n s = $!\n begin\n reset_for_next_execute!\n rescue\n # rescuing nothing on purpose\n end\n raise s if s != s_before\n end\n end",
"def cursor_eachrow(sql, name='csr', transaction=true, buffer_size=10000)\n count = 0\n begin\n begin_db_transaction if transaction\n open_cursor(sql, name, buffer_size)\n while (row = fetch_cursor(name)) do\n count+= 1\n #puts \"EACH CSR #{row.inspect}\"\n yield row\n end\n close_cursor(name)\n ensure\n commit_db_transaction if transaction\n end\n count\n end",
"def call(bind_vars={}, &block)\n sql = prepared_sql\n prepared_args.freeze\n ps = bind(bind_vars)\n ps.clone(:bind_arguments=>ps.map_to_prepared_args(ps.opts[:bind_vars]), :sql=>sql, :prepared_sql=>sql).run(&block)\n end",
"def _execute(conn, sql, opts)\n begin\n r = log_yield(sql){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif block_given?\n yield conn\n end\n rescue ::Mysql2::Error => e\n raise_error(e, :disconnect=>MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message))\n end\n end",
"def execute_all( sql ) # :yields: row\n loop do\n stmt = prepare( sql )\n stmt.execute do |result|\n result.each { |row| yield row if block_given? }\n end\n sql = stmt.remainder\n if sql.length > 0\n yield nil if block_given? # notify of new query starting\n else\n break\n end\n end\n end",
"def take(name,*args)\n @connection < name.new(*args)\n $active_connections << @connection.current\n if block_given?\n yield @connection.current\n drop\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end",
"def exec_delete(sql, name = nil, binds = [])\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n affected = result.cmd_tuples\n result.clear\n affected\n end",
"def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def exec_delete(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n affected = result.cmd_tuples\n result.clear\n affected\n end\n end",
"def execute_and_clear(sql, name, binds)\n ret = nil\n if sql.include? \"SELECT \\\"users\\\".* FROM \\\"users\\\"\" and sql.include? 'LIMIT'\n logger.debug \"Returning in-memory users\"\n # instrumentation is inserted at #log, so we fake the call here\n log(sql, name, binds) { io_sleep }\n count = sql.scan(/LIMIT\\s(\\d+)/).last.last.to_i\n ret = ActiveRecord::Result.new(users[:cols],users[:rows][0..(count-1)])\n elsif sql.include? \"SELECT \\\"cities\\\".* FROM \\\"cities\\\"\" and sql.include? 'LIMIT'\n logger.debug \"Returning in-memory cities\"\n # instrumentation is inserted at #log, so we fake the call here\n log(sql, name, binds) { io_sleep } \n count = sql.scan(/LIMIT\\s(\\d+)/).last.last.to_i\n ret = ActiveRecord::Result.new(cities[:cols],cities[:rows][0..(count-1)])\n else\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n ret = yield result\n result.clear\n end\n ret\n end",
"def execute(sql, *bind_values)\n @pool.acquire { |conn| conn.execute(sql, *bind_values) }\n end",
"def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end",
"def exec_query(sql, name = 'SQL', binds = [], prepare: false) # rubocop:disable Lint/UnusedMethodArgument\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n stmt = @connection.run(sql)\n\n columns = stmt.columns\n values = stmt.to_a\n stmt.drop\n\n values = dbms_type_cast(columns.values, values)\n column_names = columns.keys.map { |key| format_case(key) }\n ActiveRecord::Result.new(column_names, values)\n end\n end",
"def set_prepared_statement(name, ps)\n Sequel.synchronize{prepared_statements[name] = ps}\n end",
"def execute( *bind_vars )\n reset! if active? || done?\n\n bind_params(*bind_vars) unless bind_vars.empty?\n @results = ResultSet.new(@connection, self)\n\n step if 0 == column_count\n\n yield @results if block_given?\n @results\n end",
"def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute_query(sql, args)\n\t\t\t\t\t@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def cloned_conn(args = nil, &block)\r\n clone_conn_args = {\r\n :threadsafe => false\r\n }\r\n \r\n clone_conn_args.merge!(args[:clone_args]) if args and args[:clone_args]\r\n dbconn = self.clone_conn(clone_conn_args)\r\n \r\n begin\r\n yield(dbconn)\r\n ensure\r\n dbconn.close\r\n end\r\n end",
"def each\n @pool.with do |conn|\n conn.send_query @sql\n conn.set_single_row_mode\n loop do\n res = conn.get_result\n break unless res\n res.check\n res.stream_each { |row| yield row }\n end\n end\n end",
"def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end",
"def exec(*args, &block)\n if current = Thread.current[:squirm_connection]\n current.exec(*args, &block)\n else\n use {|conn| conn.exec(*args, &block)}\n end\n end",
"def execute(sql, name = nil)\n exec_no_cache(sql, name, nil)\n end",
"def execute(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end",
"def prepare(stmt)\n sanity_check(stmt)\n sth = StatementHandle.new(@handle.prepare(stmt), false, true, @convert_types)\n # FIXME trace sth.trace(@trace_mode, @trace_output)\n sth.dbh = self\n sth.raise_error = raise_error\n\n if block_given?\n begin\n yield sth\n ensure\n sth.finish unless sth.finished?\n end\n else\n return sth\n end\n end",
"def execute(*args)\n friendly_name = args[0]\n connection_info = args[1]\n\n return all unless friendly_name\n delegate(friendly_name, connection_info)\n end",
"def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end",
"def execute(query, *binds)\n res = nil\n\n mutex.synchronize do\n self.last_query = query\n self.last_statement = sth = new_statement(query)\n res = sth.execute(*binds)\n sth.finish\n yield res if block_given?\n end\n\n return res\n end",
"def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"def exec_query(sql, name = nil, binds = [])\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n result_array = result_as_array(result)\n if ArVer::GTEQ_4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end",
"def execute(sql, name = 'SQL')\n log(sql, name) do\n @connection.async_exec(sql)\n end\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def exec(sql, *bindvars, &block)\n ret = nil\n thread = Thread.new { ret = super }\n thread.join\n ret\n rescue Interrupt\n self.break\n raise\n end",
"def execute2( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n yield result.columns\n result.each { |row| yield row }\n else\n return result.inject( [ result.columns ] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def execute(&block)\n TempTableContext.with_context(db) {|context| execute_in_context(context, &block)}\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def execute(sql)\n begin\n db = SQLite3::Database.new(@@db_file)\n @@_set_db_handler.call(db)\n if block_given?\n db.execute(sql) do |row|\n yield row\n end\n else\n return db.execute(sql)\n end\n ensure\n db.close\n end\n end",
"def execute(sql, *args, &block)\n @db.execute(rewrite_table_names(sql), *args, &block)\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n execute(sql, name, binds)\n end",
"def execute(async)\n f = Fiber.current\n begin\n conn = acquire(f)\n conn.acquired_for_connection_pool += 1\n yield conn\n ensure\n conn.acquired_for_connection_pool -= 1\n conn.run_postponed_queries if conn.acquired_for_connection_pool == 0\n release(f) if !async && conn.acquired_for_connection_pool == 0\n end\n end",
"def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end",
"def query(name, *args)\n fiber, yielding = Fiber.current, true\n req = connection.send(name, *args)\n req.errback { fiber.resume rescue yielding = false }\n req.callback {|response| fiber.resume(response) }\n Fiber.yield if yielding\n end",
"def execute(sql, opts={}, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end",
"def execute(sql, name = nil, skip_logging = false)\n translate(sql) do |sql, args|\n if (name == :skip_logging) or skip_logging\n @connection.execute(sql, *args)\n else\n log(sql, args, name) do\n @connection.execute(sql, *args)\n end\n end\n end\n end",
"def query(sql, *bind_values)\n @pool.acquire { |conn| conn.query(sql, *bind_values).first }\n end",
"def call(*args)\n in_context do\n self.execute(*args)\n end\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)} \n end",
"def executeSQL(qStr, *params, &block)\n @statement_cache ||= {}\n #@statement_cache[qStr] ||= @db.prepare(qStr)\n @statement_cache[qStr] ||= qStr\n\n puts \"executeSQL: '#{qStr}', '#{params.join(\"', '\")}'\" if ::RdfContext::debug?\n if block_given?\n @db.execute(@statement_cache[qStr], *params) do |row|\n puts \"executeSQL res: #{row.inspect}\" if ::RdfContext::debug?\n row = row.keys.select{|k| k.is_a?(Integer)}.sort.map{|k| row[k]} if row.is_a?(Hash)\n yield(row)\n end\n else\n puts \"executeSQL no block given\" if ::RdfContext::debug?\n @db.execute(@statement_cache[qStr], *params)\n end\n rescue SQLite3::SQLException => e\n puts \"SQL Exception (ignored): #{e.message}\" if ::RdfContext::debug?\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}\n end",
"def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend",
"def prepare(name, sql)\n check_disconnect_errors{super}\n end",
"def ask(sql, *args, into: nil)\n catch(:ok) do\n each(sql, *args, into: into) { |row| throw :ok, row }\n nil\n end\n end",
"def each(*args, &block)\n @stmt.each(*args, &block)\n end",
"def process_row(connection, row)\n Array(task.execute_sql(connection, row)).each do |sql|\n connection.execute(sql)\n end\n end",
"def exec(connection = @connection)\n connection.exec(statement)\n end",
"def execute(sql, *args, &block)\n @db.log_yield(sql){super}\n rescue SwiftError => e\n @db.send(:raise_error, e)\n end",
"def query(sql, name, binds)\n \n rs = SA.instance.api.sqlany_execute_direct(@connection, sql)\n raise ActiveRecord::StatementInvalid.new(\"#{SA.instance.api.sqlany_error(@connection)}:#{sql}\") if rs.nil?\n \n max_cols = SA.instance.api.sqlany_num_cols(rs)\n fields = {}\n max_cols.times do |i|\n fields[i] = SA.instance.api.sqlany_get_column_info(rs, i)[2]\n end\n \n rows = []\n while SA.instance.api.sqlany_fetch_next(rs) == 1\n result = Array.new(max_cols)\n max_cols.times do |cols|\n result[cols] = SA.instance.api.sqlany_get_column(rs, cols)[1]\n end\n rows << result\n end\n @affected_rows = SA.instance.api.sqlany_affected_rows(rs)\n SA.instance.api.sqlany_free_stmt(rs)\n\n return rows, fields\n end",
"def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end",
"def execute(*args)\n bound_args = args.shift(@raw_metadata.size)\n consistency_level = args.shift\n @client.execute_statement(@connection_id, @statement_id, @raw_metadata, bound_args, consistency_level)\n end",
"def execute_prepared(sql,params_arr)\n prepared_statement = @database_handle.prepare(sql)\n params_arr.each_with_index do |param,index|\n prepared_statement.bind_param(index+1,param)\n end \n prepared_statement.execute\n end",
"def execute_block(statements, environment)\n previous = @environment\n begin\n @environment = environment\n\n statements.each do |statement|\n execute statement\n end\n ensure\n @environment = previous\n end\n nil\n end",
"def run_cursor_loop(connection, &block)\n Backfiller.log 'Start cursor loop'\n\n total_count = 0\n cursor = build_cursor(connection)\n\n loop do\n finished, count = cursor.transaction do\n run_fetch_loop(cursor, &block)\n end\n\n total_count += count\n\n Backfiller.log \"Total processed #{total_count}\"\n break if finished\n end\n end",
"def prepare(*)\n raise Error, \"cannot prepare an already prepared statement\" unless allow_preparing_prepared_statements?\n super\n end",
"def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end",
"def execute(sql, name = nil)\n # check for some DDL and DML statements\n puts \"Running sql? #{RUN_SQL}\"\n\n if /(create |alter |drop |insert |delete |update )/i.match sql.squish\n File.open(SQL_FILENAME, 'a') { |f| f.puts \"#{sql};\\n\" }\n puts \"Rails.env: #{Rails.env} - #{ENV['FPHS_POSTGRESQL_SCHEMA']}\"\n old_execute sql, name if RUN_SQL\n else\n # pass everything else to the aliased execute\n puts \"------------- (#{name}) ---------------\"\n puts sql || ''\n puts \"------------- ---------------\"\n old_execute sql, name if RUN_SQL\n end\n end",
"def exec_update(sql, name = nil, binds = []) #:nodoc:\r\n log(sql, \"update\", binds) { query(sql, binds) }\r\n end",
"def execute(&nameofblock)\n nameofblock.call\nend",
"def exec_delete(sql, name, binds)\n execute to_sql(sql, binds), name\n self.affected_rows\n end"
] |
[
"0.6955069",
"0.6580697",
"0.63122255",
"0.6284847",
"0.62554204",
"0.6185766",
"0.59890246",
"0.5971333",
"0.5964543",
"0.59414786",
"0.5874059",
"0.58605134",
"0.58355135",
"0.57717687",
"0.57630914",
"0.57173634",
"0.5708109",
"0.56787074",
"0.56594557",
"0.5647648",
"0.55918056",
"0.5585714",
"0.5527216",
"0.55172753",
"0.5503489",
"0.54783744",
"0.54686886",
"0.54669976",
"0.5463148",
"0.54310673",
"0.54118985",
"0.5411115",
"0.53979003",
"0.5387662",
"0.53649986",
"0.5334601",
"0.53187335",
"0.529077",
"0.5273057",
"0.5266982",
"0.52516025",
"0.52505463",
"0.51758206",
"0.5166117",
"0.5161794",
"0.5156271",
"0.5095299",
"0.5086468",
"0.5060914",
"0.5057307",
"0.5051088",
"0.5050997",
"0.5044376",
"0.50349057",
"0.50254786",
"0.50168407",
"0.5012098",
"0.5010837",
"0.4993627",
"0.49630094",
"0.4938194",
"0.49303854",
"0.49254864",
"0.49055976",
"0.4899932",
"0.48714378",
"0.48710865",
"0.48636317",
"0.48460925",
"0.4843203",
"0.4826623",
"0.48187068",
"0.48005515",
"0.47980145",
"0.4786288",
"0.47838193",
"0.47830266",
"0.4782488",
"0.47764593",
"0.47731388",
"0.4769673",
"0.47604895",
"0.47417456",
"0.47399846",
"0.47395948",
"0.47263917",
"0.47229445",
"0.4715204",
"0.471082",
"0.47051656",
"0.46977744",
"0.4694159",
"0.46838227",
"0.46732095",
"0.4660916",
"0.46558294",
"0.46485248",
"0.46389386",
"0.46325147",
"0.46319434"
] |
0.7185684
|
0
|
Return an appropriate value for the given infinite timestamp string.
|
def infinite_timestamp_value(value)
case convert_infinite_timestamps
when :nil
nil
when :string
value
else
value == 'infinity' ? PLUS_INFINITY : MINUS_INFINITY
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_timestamp(string)\n DateTime.parse(string).to_i\n end",
"def timestamp_parse(_timestamp)\n _undefined\n end",
"def value_from_s(value)\n a = value.scanf(@format)\n t = 0\n t += a[0] * 3600 if a.size > 0 # hours * seconds-per-hour\n t += a[1] * 60 if a.size > 1 # minutes * seconds-per-minute\n t += a[2] if a.size > 2 # seconds\n t.to_i\n end",
"def test_timestamp_valid\n parser = Parser::new\n timestamp = \"1518893687.562508000\"\n assert_equal([1518893687, 562508000], parser.parse_timestamp(timestamp))\n end",
"def s_to_time(string)\n if string.to_s.blank? || !string.to_s[/\\d/]\n nil\n else\n string = string.tr(\",\", \".\")\n parts = string.to_s.split(\":\").reverse\n t = 0.0\n parts.each_with_index do |part, index|\n t += part.to_f * (60.0**index)\n end\n if parts.last&.starts_with?(\"-\")\n -t\n else\n t\n end\n end\n end",
"def convert_timestamp(value, capture_definition)\n DateTime.parse(value).strftime('%Y%m%d%H%M%S').to_i unless value.nil?\n end",
"def convert_infinite_timestamps=(v)\n @convert_infinite_timestamps = case v\n when Symbol\n v\n when 'nil'\n :nil\n when 'string'\n :string\n when 'float'\n :float\n when String\n typecast_value_boolean(v)\n else\n false\n end\n\n pr = old_pr = @use_iso_date_format ? TYPE_TRANSLATOR.method(:date) : Sequel.method(:string_to_date)\n if v\n pr = lambda do |val|\n case val\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(val)\n else\n old_pr.call(val)\n end\n end\n end\n add_conversion_proc(1082, pr)\n end",
"def to_application_timestamp(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(value)\n else\n super\n end\n else\n super\n end\n end",
"def a_timestamp\n proc { |t| t.to_s =~ /^\\d{10}$/ }\n end",
"def to_timestamp(string)\n Time.parse(string).strftime(\"%s\")\nend",
"def process_stamp(stamp_string)\n # Server gives us miliseconds, which we drop before converting.\n stamp_val = stamp_string.to_i() / 1000\n utc_time = Time.at(stamp_val).utc().to_datetime()\n return utc_time\n end",
"def fast_string_to_time(string)\n if string =~ Format::ISO_DATETIME\n microsec = ($7.to_f * 1_000_000).to_i\n res = new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec\n res\n end\n end",
"def to_epoch s\n\t\t\treturn \"\" if s.nil?\n\t\t\treturn s.to_i if is_epoch(s)\n\t\t\ts = \"0h\" if s == \"now\"\n\t\t\tmult, time = nicetime_split s\n\n\t\t\ttime_scale = (case time\n\t\t\t\twhen \"min\"; \"minutes\"\n\t\t\t\twhen \"h\"; \"hours\"\n\t\t\t\twhen \"d\"; \"days\"\n\t\t\t\twhen \"w\"; \"weeks\"\n\t\t\t\tend )\n\t\t\teval(\"#{mult}.#{time_scale}.ago.to_i\")\n\t\tend",
"def tiny_from_timestamp\n tiny(Time.now.to_f - TINY_EPOCH)\n end",
"def to_timestamp(val)\n return if val.nil?\n\n case val\n when String\n (date = Time.parse(val)) && date.to_i\n when Date\n val.to_time.to_i\n else\n val.to_i\n end\n end",
"def extract_ts(chunks)\n ts = chunks[fmt.index('t')]\n return parse_time(ts) if valid_timestamp?(ts)\n rescue TypeError\n Time.now.utc.to_i\n end",
"def test_valid_timestamp\n billcoin = BillCoin::new\n parser = Minitest::Mock.new('Parser')\n def parser.parse_timestamp timestamp\n timestamp.split('.').map! {|x| Integer(x)}\n end\n refute billcoin.verify_valid_timestamp('1518893687.562508000', '1518893687.562508100', 0, parser)\n end",
"def test_timestamp_invalid_types\n parser = Parser::new\n timestamp = \"1518893687.twenty\"\n assert_raises SystemExit do\n parser.parse_timestamp timestamp\n end\n end",
"def as_val(s)\n if s < 1_000\n s\n elsif s >= 1_000_000_000_000\n (s / 1_000_000_000_000.0).round(1).to_s + 'T'\n elsif s >= 1_000_000_000\n (s / 1_000_000_000.0).round(1).to_s + 'B'\n elsif s >= 1_000_000\n (s / 1_000_000.0).round(1).to_s + 'M'\n elsif s >= 1_000\n (s / 1_000.0).round(1).to_s + 'K'\n end\nend",
"def after_midnight(string)\n (string[0, 2].to_i * 60 + string[3, 2].to_i) % 1440\nend",
"def test_timestamp_invalid_format\n parser = Parser::new\n timestamp = \"15188.93687-562508000\"\n assert_raises SystemExit do\n parser.parse_timestamp timestamp\n end\n end",
"def convert tag, val\n return val unless val.kind_of?(String)\n case tag\n when 'partofset', 'track'\n return val\n end\n case val\n when REGEXP_TIMESTAMP\n year, month, day, hour, minute = $~.captures[0,5].map {|cap| cap.to_i}\n if month == 0 || day == 0\n return nil\n end\n second = $6.to_f\n zone = $7\n zone = '+00:00' if zone == 'Z'\n begin\n Time.new(year, month, day, hour, minute, second, zone)\n rescue ArgumentError\n val\n end\n when REGEXP_RATIONAL\n return val if $2.to_i == 0\n Rational($1, $2)\n else\n val\n end\n end",
"def fast_string_to_time(string)\n return unless string =~ Format::ISO_DATETIME\n microsec = (Regexp.last_match[7].to_r * 1_000_000).to_i\n new_time(Regexp.last_match[1].to_i,\n Regexp.last_match[2].to_i,\n Regexp.last_match[3].to_i,\n Regexp.last_match[4].to_i,\n Regexp.last_match[5].to_i,\n Regexp.last_match[6].to_i,\n microsec\n )\n end",
"def parse_date(str) \n Time.at(str[/([0-9]+)-([0-9]+)/,1].to_i/1000)\n end",
"def parse(time_string)\n Time.at(\"#{time_string[0,10]}.#{time_string[10,13]}\".to_f)\n end",
"def valid_timestamp?(timestamp)\n (timestamp.is_a?(Integer) ||\n (timestamp.is_a?(String) && timestamp.match(/^\\d+$/))) &&\n timestamp.to_i > 946_684_800 &&\n timestamp.to_i < (Time.now.to_i + 31_557_600)\n end",
"def timestamp\n #data[\"timestamp\"] as? TimeInterval ?? 0\n timestamp = data[\"timestamp\"]\n timestamp.to_i || 0\n end",
"def convert_timestamp(value, definition)\n \"#{value[26,4]}#{MONTHS[value[4,3]]}#{value[8,2]}#{value[11,2]}#{value[14,2]}#{value[17,2]}\".to_i\n end",
"def time_for_string(time)\n time = time.scan(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/)[0].sub(' ','T')\n Time.xmlschema(time)\n end",
"def convert_timestamp(value, definition)\n \"#{value[7,4]}#{MONTHS[value[3,3]]}#{value[0,2]}#{value[12,2]}#{value[15,2]}#{value[18,2]}\".to_i\n end",
"def convert_timestamp(value, definition)\n \"#{value[7,4]}#{MONTHS[value[3,3]]}#{value[0,2]}#{value[12,2]}#{value[15,2]}#{value[18,2]}\".to_i\n end",
"def translate_timestamp(timestamp)\n # seconds -> milliseconds\n timestamp.to_i * 1000\n end",
"def coerce_timestamp(timestamp)\n # bug in JRuby prevents correcly parsing a BigDecimal fractional part, see https://github.com/elastic/logstash/issues/4565\n timestamp.is_a?(BigDecimal) ? LogStash::Timestamp.at(timestamp.to_i, timestamp.frac * 1000000) : LogStash::Timestamp.at(timestamp)\n end",
"def timestamp_value\n @timestamp_value ||=\n ((@time_hi_and_version & 0b1111_1111_1111) << 48) |\n (@time_mid << 32) | @time_low\n end",
"def convert_timestamp(value, _definition)\n \"#{value[7, 4]}#{MONTHS[value[3, 3]]}#{value[0, 2]}#{value[12, 2]}#{value[15, 2]}#{value[18, 2]}\".to_i\n end",
"def resolve_date(date_str)\n u_count = date_str.count 'u'\n # Replace unknown digits with 0.\n date = date_str.tr('u', '0').to_i\n if u_count.positive? && date != 0\n delta = 10**u_count # 10^u_count, exponent\n date + (delta / 2) if delta <= ESTIMATE_TOLERANCE\n elsif date != 0\n date\n end\n end",
"def entity_date(str)\n Time.at(str[/\\d{6,}/].to_i / 1000)\n end",
"def parse_date(number)\n EPOCH + number\n end",
"def grabTime(str)\n if /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)\n /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)[2]\n else\n \"Ongoing\"\n end\n end",
"def validate_day day_string\r\n day_int = day_string.to_i\r\n if day_int > 19850501 && day_int < 20850501\r\n return day_string.to_s\r\n else\r\n return current_day\r\n end\r\n end",
"def load(value)\n return value unless value.respond_to?(:to_int)\n ::Time.at((value.to_i/10**6)-11644473600)\n end",
"def timezone_string_to_unixtime( str )\n if m = /([\\+\\-])(\\d\\d?)(\\d\\d)/.match(str)\n sec = (m[2].to_i * 60 + m[3].to_i) * 60\n m[1] == '-' ? -sec : sec\n else\n min = ZONESTR_TABLE[str.downcase] or\n raise SyntaxError, \"wrong timezone format '#{str}'\"\n min * 60\n end\n end",
"def to_class(s)\n if valid_date_time?(s)\n Time.strptime(s, '%Y-%m-%d.%H:%M:%S').to_i\n elsif valid_date?(s)\n Date.strptime(s, '%Y-%m-%d').to_i\n elsif valid_time?(s)\n Time.strptime(s, '%H:%M:%S').to_i\n elsif valid_integer?(s)\n s.to_i\n elsif valid_float?(s)\n s.to_f\n else\n s\n end\n end",
"def parse_time(string)\n parts = string.split(\":\").map(&:to_f)\n parts = [0] + parts if parts.length == 2\n hours, minutes, seconds = parts\n seconds = hours * 3600 + minutes * 60 + seconds\n seconds.to_i\n end",
"def timestamp(time)\n date = @file[/(\\w+ \\d+, \\d+)/]\n ASF::Board::TIMEZONE.parse(\"#{date} #{time}\").to_i * 1000\n end",
"def test_earlier_timestamp\n billcoin = BillCoin::new\n parser = Minitest::Mock.new('Parser')\n def parser.parse_timestamp timestamp\n timestamp.split('.').map! {|x| Integer(x)}\n end\n assert_raises SystemExit do\n billcoin.verify_valid_timestamp('1518893688.562508000', '1518893687.562508100', 0, parser)\n end\n end",
"def validate_and_parsetime(value)\n return unless value\n Time.iso8601(value).getutc.to_i\n rescue ArgumentError => e\n logger.error \"Couldn't parse time from '#{value}'\"\n nil\n end",
"def timestamp\n (Time.now.to_f * 1000).ceil.to_s[-5..-1]\nend",
"def validate_and_parsetime(value)\n return unless value\n Time.iso8601(value).getutc.to_i\n rescue ArgumentError => e\n logger.error \"Couldn't parse time from '#{value}'\"\n nil\n end",
"def parse(value)\n unless value.is_a?(String)\n raise TimeParseError, \"value must be string: #{value}\"\n end\n\n if @cache1_key == value\n return @cache1_time\n elsif @cache2_key == value\n return @cache2_time\n else\n begin\n time = @parse.call(value)\n rescue => e\n raise TimeParseError, \"invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}\"\n end\n @cache1_key = @cache2_key\n @cache1_time = @cache2_time\n @cache2_key = value\n @cache2_time = time\n return time\n end\n end",
"def is_epoch s \n\t\t\ts.to_i.to_s == s\n\t\tend",
"def handle_ts\n handle_at\n handle_in\n @time_special = @tokens[@index].get_tag(TimeSpecial).type\n @index += 1\n @precision = :time_special\n end",
"def extract_forecast_hour(forecast_hour_str)\n Integer(forecast_hour_str[/(\\d+) hour (\\w+ )?fcst/, 1])\nend",
"def string_as_t string\n Time.parse(string)\n end",
"def timestampFormat(value)\n _timestampFormat(value) or fail ArgumentError, \"Unknown value for timestampFormat: #{value}\"\n end",
"def parse_accept_date(string)\n parts = string.split(/[\\/:.]/)\n Time.local(*parts.values_at(2, 1, 0, 3..6))\n end",
"def parse_accept_date(string)\n parts = string.split(/[\\/:.]/)\n Time.local(*parts.values_at(2, 1, 0, 3..6))\n end",
"def create_timestamp(line)\n\t\tTime.strptime(line[1], '%Q')\n\tend",
"def is_nicetime s\n\t\t\treturn false if is_epoch(s) #fast fail\n\t\t\ta,b = nicetime_split s\n\t\t\treturn true if a.to_i.to_s == a and b.is_a? String\n\t\tend",
"def convert_timestamp(ts)\n return ts.to_i - @@seconds_1900_1970\n end",
"def tick_in_seconds\n return unless VALID_TICKS.include?(tick)\n eval(tick.sub(\" \", \".\"))\n end",
"def raw_timestamp_to_cache_version(timestamp)\n key = timestamp.delete(\"- :.\")\n if key.length < 20\n key.ljust(20, \"0\")\n else\n key\n end\n end",
"def before_midnight(str)\n hour, minute = str.split(':').map(&:to_i)\n ( (23-hour) * 60 + (60-minute) ) % 1440\nend",
"def timestamp\n time_formated = Time.now.to_i.to_s.reverse.chop.chop.chop.reverse.to_i\n return time_formated.to_s\nend",
"def test_equal_timestamp\n billcoin = BillCoin::new\n parser = Minitest::Mock.new('Parser')\n def parser.parse_timestamp timestamp\n timestamp.split('.').map! {|x| Integer(x)}\n end\n assert_raises SystemExit do\n billcoin.verify_valid_timestamp('1518893688.562508000', '1518893688.562508000', 0, parser)\n end\n end",
"def validate_timestamp(obj)\n if !obj[:timestamp].nil?\n if obj[:timestamp].match(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}/)\n return true\n end\n end\n false\nend",
"def grab_sin(string)\n sin = string.scan(/\\b\\d{3}-\\d{3}-\\d{3}\\b/)\n return sin[0]\nend",
"def timestamp\n @timestamp ||= Time.parse(self['timestamp'])\n end",
"def from_string(s)\n ::Time.parse(\"#{s}Z\")\n end",
"def get_timestamp(output)\n output.split(\"\\n\").first.match(/^\\[([^\\]]*)\\]/)[1].gsub(/\\/| |:/,'.')\n end",
"def bind_timestamp(i, value)\n case value\n when Time\n time = value\n else\n begin\n time = Time.parse(value)\n rescue => e\n raise(ArgumentError, \"Cannot parse argument value to time. #{e.message}\")\n end\n end\n\n _bind_timestamp(i, time.year, time.month, time.day, time.hour, time.min, time.sec, time.usec)\n end",
"def parse_value(value)\n if value.is_a?(String)\n if value.to_i.to_s == value\n value.to_i\n elsif value.to_f.to_s == value\n value.to_f\n elsif value.gsub(/^\\s+|\\s+$/, '') == '' || value == '(Not Specified)'\n nil\n elsif /^\\d{2}\\/\\d{2}\\/\\d{4}$/ =~ value\n Date.parse(value)\n elsif /^\\d{2}\\/\\d{2}\\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}$/ =~ value\n Time.parse(value)\n else\n value\n end\n else\n value\n end\n end",
"def parse_age(str)\n ord, word = str.split(/[. ]+/, 2)\n ord = Integer(ord)\n word.gsub!(/s$/, '')\n\n ago = nil\n\n TIME_INTERVALS.each do |pair|\n mag, term = pair.first, pair.last\n\n if term == word\n ago = Time.at(Time.now.to_i - ord * mag)\n break\n end\n end\n\n if ago\n ago\n else\n raise ArgumentError, \"Cannot parse '#{str}' as an age\"\n end\n end",
"def date_input_to_microseconds(date_input)\n DateTime.strptime(date_input.to_f.to_s, '%s').strftime(\"%s\").to_i * 1_000_000\n end",
"def get_yyyymmdd_hhnnss(s)\n return s.gsub('T', ' ').gsub('Z', '')\n end",
"def gettimetag\n ttag = to_i(@timetag)\n return ttag\n end",
"def format_long_timestamp(timestamp)\n Time.at(timestamp/1000).utc.iso8601\n end",
"def after_midnight(str)\n if str[0..1] == '24'\n hour = 0\n else\n hour = str[0..1].to_i\n end\n (hour * 60) + str[3..4].to_i\nend",
"def numeric\n if latest?\n 1_000_000_000_000_000_000_000_000_000\n elsif semantic?\n # This assumes each counter will never go > 1000\n if development?\n self =~ /v?(\\d+).(\\d+).(\\d+).(dev|pre)(\\d+)/\n (Regexp.last_match[1].to_i * 1000 * 1000 * 1000) +\n (Regexp.last_match[2].to_i * 1000 * 1000) +\n (Regexp.last_match[3].to_i * 1000) +\n Regexp.last_match[5].to_i\n else\n self =~ /v?(\\d+).(\\d+).(\\d+)/\n (Regexp.last_match[1].to_i * 1000 * 1000 * 1000) +\n (Regexp.last_match[2].to_i * 1000 * 1000) +\n (Regexp.last_match[3].to_i * 1000)\n end\n elsif timestamp?\n to_time.to_i\n else\n validate!\n end\n end",
"def parse_time_unit(time_unit)\n case time_unit\n when /[0-9]+[smhdy]/\n time = time_unit[/[0-9]+/].to_i\n unit = time_unit[/[smhdy]/]\n time * UNIT_MULTIPLIER.fetch(unit)\n when /[0-9]+/\n Integer(time_unit)\n else\n raise\n end\n rescue IndexError => e\n raise InvalidParameter, \"Invalid time specification specified: '#{time_unit}'\"\n end",
"def internal_value_of(value)\n return value if value.respond_to?(:nan?) && value.nan?\n return Float::NAN if [nil, '?'].include?(value)\n return parse_date(value.to_s) if date?\n return value.to_f if numeric?\n return index_of_value(value.to_s) if nominal? || string?\n end",
"def post_process_datetime( val )\n\t\t\treturn Time.parse( val )\n\t\trescue ArgumentError\n\t\t\treturn nil\n\t\tend",
"def datetime_clean(value)\n value.to_s.strip.sub(/[+-]00?(:00?)?$/, ZULU).sub(/\\d+\\.\\d+/) do |sec|\n '%02d' % [sec.to_f.round, 59].min\n end\n end",
"def after_midnight(str)\n str = str.split(\":\")\n h = str[0].to_i % 24\n m = str[1].to_i\n minutes = (h * 60) + m \nend",
"def strptime(str=\"-4712-01-01\", fmt='%F', sg=nil)\n super(str, fmt)\n end",
"def after_midnight(time_str)\n count = 0\n hour, min = time_str.split ':'\n hour.to_i.times { count += 60 }\n count += min.to_i\n count % 1440\nend",
"def after_midnight(str)\n hours, minutes = str.split(\":\").map(&:to_i)\n \n hours < 24 ? (hours * 60) + minutes : 0\nend",
"def timestamp_from_filename(filename)\n # First, check if we can find the file name matching a timestamp\n parts = File.split(filename)\n parts = parts[-1].split('-')\n timestamp = parts[0]\n if not TIMESTAMP_REGEX.match(timestamp)\n return\n end\n\n # Great, then fix the formatting...\n timestamp[4] = '-'\n timestamp[7] = '-'\n timestamp[13] = ':'\n timestamp[16] = ':'\n\n return Time.parse(timestamp)\nend",
"def date_s_to_i(date_str)\n require 'time'\n \n if not validate_date_str(date_str)\n raise BlankGenerationConversionException, \"Invalid date value #{date_str}\"\n end\n \n Time.parse(date_str).to_i\nend",
"def to_timestamp(obj, default = Time.now)\n case obj\n when String then Time.parse(obj)\n when Date then obj.to_time\n when Time then obj\n when Numeric then Time.at(obj)\n else default\n end\n rescue ArgumentError => e\n default\n end",
"def set_date_string(input)\n\n now = Time.new\n date = Time.new\n\n #Handle minute notation.\n if input.downcase[-1] == \"m\" then\n date = now - (60 * input[0..-2].to_f)\n return get_date_string(date)\n end\n\n #Handle hour notation.\n if input.downcase[-1] == \"h\" then\n date = now - (60 * 60 * input[0..-2].to_f)\n return get_date_string(date)\n end\n\n #Handle day notation.\n if input.downcase[-1] == \"d\" then\n date = now - (24 * 60 * 60 * input[0..-2].to_f)\n return get_date_string(date)\n end\n\n #Handle PowerTrack format, YYYYMMDDHHMM\n if input.length == 12 and numeric?(input) then\n return input\n end\n\n #Handle \"YYYY-MM-DD 00:00\"\n if input.length == 16 then\n return input.gsub!(/\\W+/, '')\n end\n\n #Handle ISO 8601 timestamps, as in Twitter payload \"2013-11-15T17:16:42.000Z\"\n if input.length > 16 then\n date = Time.parse(input)\n return get_date_string(date)\n end\n\n return 'Error, unrecognized timestamp.'\n\n end",
"def parse_time(timestr)\n return 0 if timestr.nil?\n \n h = 0\n m = 0\n\n if(not timestr.index(/(h|m)/).nil?)\n h = timestr.scan(/(\\d*)\\s*h/i).flatten.last\n m = timestr.scan(/(\\d*)\\s*m/i).flatten.last\n elsif(not timestr.index(\":\").nil?)\n h = timestr.scan(/(\\d+)\\s*?:/).flatten.last\n m = timestr.scan(/:\\s*(\\d{2})/).flatten.last\n elsif(not timestr.index(/\\d*?(\\/\\d*)?/).nil?)\n h = timestr.to_f\n if(h > 10)\n m = h\n h = 0\n end\n end\n (h.to_f * 60) + m.to_f\n end",
"def vali_date(str)\n # Define month and day variables\n month, day = str.split('/').map(&:to_i)\n\n # Case month variable and return month and day if they are valid\n case month\n when 2 # February (28 days)\n return month, day if (1..28).include? day\n when 4, 6, 9, 11 # April, June, September, November (30 days)\n return month, day if (1..30).include? day\n when 1, 3, 5, 7, 8, 10, 12 # January, March, May, July, August, October, December (31 days)\n return month, day if (1..31).include? day\n end\n\n # Return nil otherwise\n nil\n end",
"def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end",
"def parse_time(time)\n result = Struct.new(:days, :hours, :minutes).new\n time = time.to_i\n result.days = time / 86_400\n time = time % 84_600\n result.hours = time / 3_600\n time %= 3_600\n result.minutes = time / 60\n result\nend",
"def after_midnight(string)\n hours, minutes = string.split(':').map(&:to_i)\n hours.remainder(24) * 60 + minutes\nend",
"def time_parsing str\n Time.parse(str) if str && str != \"<null>\"\n end",
"def parse_value value\r\n case value\r\n when /\\d+/\r\n value.to_f\r\n else\r\n value\r\n end\r\n end",
"def parse_timestamp(unix_timestamp)\n d = Time.at(unix_timestamp.to_i)\n d.strftime(\"%l:%M:%S %p, %-m-%e-%Y\")\n end",
"def to_timestamp(time = '00:00')\n DateTime.parse([self, time].join(' ')).to_time.to_i\n end"
] |
[
"0.67301536",
"0.6327498",
"0.6100885",
"0.6039964",
"0.6016131",
"0.5899857",
"0.5820336",
"0.5796626",
"0.57559997",
"0.5623346",
"0.559958",
"0.55709267",
"0.5555473",
"0.5536436",
"0.5422841",
"0.54129356",
"0.5411092",
"0.5410207",
"0.540438",
"0.5401252",
"0.5388682",
"0.53778166",
"0.53696734",
"0.53614235",
"0.53543663",
"0.5330122",
"0.5316079",
"0.53083384",
"0.5305293",
"0.53039426",
"0.5301513",
"0.53014886",
"0.5258687",
"0.52459437",
"0.5244835",
"0.52409834",
"0.52381444",
"0.52150387",
"0.52009964",
"0.51908165",
"0.5188805",
"0.51787186",
"0.51782954",
"0.51647496",
"0.51608473",
"0.5155732",
"0.51214087",
"0.5120744",
"0.5101531",
"0.50911456",
"0.5086702",
"0.5086297",
"0.50699776",
"0.50609845",
"0.5050322",
"0.50438195",
"0.50438195",
"0.50426936",
"0.50344765",
"0.5021982",
"0.502195",
"0.5003394",
"0.50023144",
"0.49976498",
"0.49875808",
"0.4986947",
"0.49629524",
"0.49548158",
"0.4954047",
"0.49273926",
"0.49228713",
"0.49167404",
"0.49136984",
"0.4910943",
"0.49081314",
"0.48940152",
"0.48653948",
"0.48649162",
"0.48636964",
"0.48635957",
"0.48544562",
"0.48497128",
"0.48424527",
"0.48408023",
"0.48323473",
"0.48261485",
"0.48242283",
"0.48206568",
"0.48187798",
"0.48021996",
"0.47997206",
"0.47988883",
"0.4794862",
"0.47941092",
"0.47885346",
"0.4788037",
"0.47746214",
"0.47741938",
"0.47653288",
"0.47651124"
] |
0.7355437
|
0
|
Don't log, since logging is done by the underlying connection.
|
def log_connection_execute(conn, sql)
conn.execute(sql)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def disable_logging\n @session.connection.disable_logging\n end",
"def autoflush_log; end",
"def autoflush_log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log\r\n false\r\n end",
"def suppress; @write = false end",
"def log_without_running\n log\n end",
"def ignore_disconnect; end",
"def disable_logging\n @communicator_logger = nil\n end",
"def disable_logging\n @communicator_logger = nil\n end",
"def autoflush_log=(_arg0); end",
"def autoflush_log=(_arg0); end",
"def logged?; false end",
"def logged?; false end",
"def disable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 1\nend",
"def supporting_method\n logger.warn 'This does nothing'\n end",
"def disconnect! # :nodoc:\n super\n @raw_connection.logoff rescue nil\n end",
"def delete_logging_statement\n super\n end",
"def disable_logging\n @logger = nil\n end",
"def log_to(stream)\n ActiveRecord::Base.logger = Logger.new(stream)\n ActiveRecord::Base.clear_active_connections!\n end",
"def log_state\n super\n end",
"def reset_logging\n\t\tTreequel.reset_logger\n\tend",
"def disable_verbose_log()\n PureHailDB.ib_cfg_set(\"print_verbose_log\", :bool, false)\n end",
"def disable_sql_logging(&block)\n sql_logging(enabled: false, &block)\n end",
"def log!(message)\n log message if very_verbose\n end",
"def log!(message)\n log message if very_verbose\n end",
"def log\n end",
"def enable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 0\nend",
"def log\n @log || MPDClient.log\n end",
"def log_connection_yield(sql, conn, args=nil)\n if !@loggers.empty? && (external_caller = external_caller_for_log)\n sql = \"#{external_caller} #{sql}\"\n end\n super\n end",
"def log=(log); end",
"def should_log?\n return false if @skip_logging\n true\n end",
"def log_to(stream, colorize=true)\n ActiveRecord::Base.logger = Logger.new(stream)\n ActiveRecord::Base.clear_active_connections!\n ActiveRecord::Base.colorize_logging = colorize\nend",
"def quiet; end",
"def log_connection\r\n msg = \"\"\r\n msg << \"Host: #{@host.inspect}, \" unless @host.empty?\r\n msg << \"Namespace: #{@namespace.inspect}, \" unless @namespace == \"root\\\\cimv2\" && @host.empty?\r\n msg << \"User: #{@user.inspect}, \" if @user\r\n msg << \"Password: #{@password.gsub(/./,'#')}, \" if @password\r\n msg << \"Privileges: #{@privileges.inspect}\" if @privileges\r\n logger.debug msg unless msg.empty?\r\n end",
"def no_action_log\n true\n end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def fetch_log\n raise NotImplementedError\n end",
"def reset_logging\n\t\tMongrel2.reset_logger\n\tend",
"def log?\n @log ||= false\n end",
"def log!(msg)\n log_info(msg)\n puts(msg)\nend",
"def reset_log_data\n self.class.without_logging { update_column(:log_data, nil) }\n end",
"def ignore_disconnect=(_arg0); end",
"def trace_log!\n Merb.logger.auto_flush = true\n end",
"def test_disable_hip_chat_logging\n stub_request(:post, 'http://api.hipchat.com/v1/rooms/message').to_return(\n {:status => ['500', 'Server Error']}\n )\n\n CDO.hip_chat_logging = false\n\n HipChat.post_to_hipchat('fake_room', 'my_message1')\n HipChat.await_retries_for_test\n assert_not_requested :post, 'http://api.hipchat.com/v1/rooms/message'\n\n assert_equal 0, HipChat.retries_for_test\n assert_equal 0.0, HipChat.total_backoff_for_test\n end",
"def without_reasoning\n @reasoning = false\n @connection = stardog(@endpoint,@options)\n self\n end",
"def verbose_logging; end",
"def handle_bogus_message(message)\n @connection.append('bogus', message)\n end",
"def log()\n @log\n end",
"def without_reconnect(&block); end",
"def disable_logging\n stack.remove 'request.logger'\n stack.remove 'response.logger'\n self\n end",
"def log=(logger); end",
"def _roda_after_90__common_logger(result)\n super if result && _common_log_request?(result)\n end",
"def silence_logging\n Rails.logger.silence do\n yield\n end\n end",
"def logged?;\n false\n end",
"def raw_connection\n disable_lazy_transactions!\n @connection\n end",
"def logger ; @log end",
"def disable_logger_noise\n StraightServer::Config.logmaster = { 'log_level' => 'INFO', 'file' => 'straight.log' }\n @initializer.create_logger\n expect(StraightServer.logger).to receive(:info).and_return ''\n end",
"def log\n @log || Mechanize.log\n end",
"def disable_remote_exception_logging\n core.disable_remote_exception_logging\n end",
"def log_stuff\r\n log.info(\"TestLogger is here to log stuff.\")\r\n log.warn(\"TestLogger is finishged logging. Be careful.\")\r\n end",
"def reset_logging!(opts)\n Ncio::Support.reset_logging!(opts)\n end",
"def discard!\n # This should be overridden by concrete adapters.\n #\n # Prevent @connection's finalizer from touching the socket, or\n # otherwise communicating with its server, when it is collected.\n end",
"def log\n @log\n end",
"def log(log)\n raise NotImplementedError\n end",
"def disable_logging_for(name = nil)\n logging_status(bucket_name(name), Status.new)\n end",
"def do_log( msg )\n log( msg )\n end",
"def raw_connection; end",
"def log?\n @log != false\n end",
"def log?\n @log != false\n end",
"def log?\n @log != false\n end",
"def set_logging_statement(opts)\n opts = check_params(opts,[:statement])\n super(opts)\n end",
"def logging_prefs; end",
"def log(msg)\n puts msg if @verbose\n end"
] |
[
"0.69636",
"0.6710081",
"0.6710081",
"0.62483466",
"0.62483466",
"0.62483466",
"0.62483466",
"0.62483466",
"0.62483466",
"0.62483466",
"0.62483466",
"0.622024",
"0.6150888",
"0.6150197",
"0.6138706",
"0.61209404",
"0.61209404",
"0.61171275",
"0.61171275",
"0.6105711",
"0.6105711",
"0.60571676",
"0.6030844",
"0.60096955",
"0.60040575",
"0.59834033",
"0.5969884",
"0.5963782",
"0.59409606",
"0.5920667",
"0.5918809",
"0.59125453",
"0.59125453",
"0.5885278",
"0.5884476",
"0.58798826",
"0.58493507",
"0.58067095",
"0.5752878",
"0.5734537",
"0.5731784",
"0.57215625",
"0.56954736",
"0.56943256",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5665704",
"0.5664906",
"0.56618285",
"0.5659853",
"0.56546164",
"0.56479007",
"0.56317353",
"0.5628255",
"0.5587267",
"0.5581605",
"0.55787253",
"0.55761945",
"0.554738",
"0.5545233",
"0.5541373",
"0.5517252",
"0.55008537",
"0.54997",
"0.54945326",
"0.54941213",
"0.54819435",
"0.54720956",
"0.54717857",
"0.5467827",
"0.5448238",
"0.5446568",
"0.5440553",
"0.5422497",
"0.5421089",
"0.5412086",
"0.5405813",
"0.53985906",
"0.5396728",
"0.5396728",
"0.5396728",
"0.5395851",
"0.53884876",
"0.53738666"
] |
0.560382
|
70
|
If the value is an infinite value (either an infinite float or a string returned by by PostgreSQL for an infinite timestamp), return it without converting it if convert_infinite_timestamps is set.
|
def typecast_value_date(value)
if convert_infinite_timestamps
case value
when *INFINITE_DATETIME_VALUES
value
else
super
end
else
super
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def infinite_timestamp_value(value)\n case convert_infinite_timestamps\n when :nil\n nil\n when :string\n value\n else\n value == 'infinity' ? PLUS_INFINITY : MINUS_INFINITY\n end\n end",
"def convert_infinite_timestamps=(v)\n @convert_infinite_timestamps = case v\n when Symbol\n v\n when 'nil'\n :nil\n when 'string'\n :string\n when 'float'\n :float\n when String\n typecast_value_boolean(v)\n else\n false\n end\n\n pr = old_pr = @use_iso_date_format ? TYPE_TRANSLATOR.method(:date) : Sequel.method(:string_to_date)\n if v\n pr = lambda do |val|\n case val\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(val)\n else\n old_pr.call(val)\n end\n end\n end\n add_conversion_proc(1082, pr)\n end",
"def typecast_value_datetime(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def to_application_timestamp(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(value)\n else\n super\n end\n else\n super\n end\n end",
"def convert_to_internal_value value\n value = fix_ambigious_value value, true\n\n if day_unit?\n (BigDecimal(value.to_time.to_i) / SECONDS_PER_DAY)\n elsif values_unit == Integer\n value.to_i\n else\n raise \"Unexpected unit: #{values_unit()}\"\n end\n end",
"def literal_float(value)\n if value.finite?\n super\n elsif value.nan?\n \"'NaN'\"\n elsif value.infinite? == 1\n \"'Infinity'\"\n else\n \"'-Infinity'\"\n end\n end",
"def checked(value)\n value = zero() if value.respond_to?(:nan?) && value.nan?\n value = zero() if value.respond_to?(:infinity?) && value.infinity?\n value = zero() if value.nil?\n value = value.to_f if value.is_a? BigDecimal\n\n value\n end",
"def infinite?\n nil\n end",
"def infinite?\n nil\n end",
"def infinite?() end",
"def infinite?\n end",
"def internal_value_of(value)\n return value if value.respond_to?(:nan?) && value.nan?\n return Float::NAN if [nil, '?'].include?(value)\n return parse_date(value.to_s) if date?\n return value.to_f if numeric?\n return index_of_value(value.to_s) if nominal? || string?\n end",
"def type_cast(value) # :api: public\n cast_value(value) unless value.nil?\n end",
"def convert_value(value_node)\n if value_node.nil?\n return\n end\n if value_node['type'] == 'REAL' || value_node['value'].include?('.')\n return value_node['value'].to_f\n else\n return value_node['value'].to_i\n end\n end",
"def infinite?; end",
"def untypecasted_value\n read_attribute(:value)\n end",
"def cast\n return to_f if numeric? && index(\".\")\n return to_i if numeric?\n if boolean?\n return true if self =~ /\\Atrue\\z/i\n return false if self =~ /\\Afalse\\z/i\n end\n self\n end",
"def to\n @to == Float::INFINITY ? nil : @to\n end",
"def infinity?\n @infinity == true\n end",
"def converted_value\n if @converter\n @converter.call(@value)\n else\n @value\n end\n end",
"def coerce(value)\n return 0.0 unless value.respond_to?(:to_f)\n\n value.to_f\n end",
"def post_process_float( val )\n\t\t\treturn Float( val.to_s )\n\t\tend",
"def to_f\n if isFloat? then\n value = exp.to_f\n return value\n elsif exp == \"Infinity\" then return @@MAX_VALUE\n elsif exp == \"-Infinity\" then return @@MIN_VALUE\n else\n raise \"Non-float conversion in expression: \" + exp\n end\n end",
"def convert_value(value)\n value\n end",
"def to_float(value)\n return Float(value) rescue Float::NAN\n end",
"def to_string(value)\n # If we have a number that has a zero decimal (e.g. 10.0) we want to\n # get rid of that decimal. For this we'll first convert the number to\n # an integer.\n if value.is_a?(Float) and value.modulo(1).zero?\n value = value.to_i\n end\n\n return value.to_s\n end",
"def normalize_scalar_property_value(value)\n return \"NaN\" if value.kind_of?(Float) && value.nan?\n\n case value\n when true, false, nil then value\n when ActiveSupport::Duration then value.to_i\n when Numeric then value\n when String then value.strip\n when Symbol then value.to_s.strip\n when Time then value.getutc.strftime(\"%Y-%m-%dT%H:%M:%S\")\n when IPAddr then value.to_s\n when FLOAT_INFINITY then \"+infinity\"\n when -FLOAT_INFINITY then \"-infinity\"\n when Array then\n out = value.map { |e| normalize_scalar_property_value(e) }\n out = :invalid_property_value if out.detect { |e| e == :invalid_property_value }\n out\n else :invalid_property_value\n end\n end",
"def type_cast(value)\n nil\n end",
"def tt_forever?\n ttend_at == InfinityValue\n end",
"def coerce(value)\n if !value.nil? and !option.allowed_format.nil?\n case option.allowed_format\n when 'fixnum'\n value = value.to_i\n when 'float'\n value = value.to_f\n when 'boolean'\n value = true if (value == 'true' or value == 't')\n value = false if (value == 'false' or value == 'f')\n end\n end\n\n return value\n end",
"def floor(value)\n numeric_transformation(value) {|n| n.floor}\n end",
"def clean_value(value)\n case value\n when Symbol then value.to_s\n when TrueClass then 1\n when FalseClass then 0\n when /^\\d+$/ then value.to_i # Integer\n when /^\\d+(\\.\\d+)?([eE]\\d+)?$/ then value.to_f # Float\n when blank? then nil\n else value\n end \n end",
"def convert_i_f(value)\n if (value =~ /\\./)\n value = value.to_f\n elsif\n value = value.to_i\n end\n return value\nend",
"def convert_value\n # Do nothing if value has not changed\n return true unless value_changed?\n # Cast the value and return success\n return parse_string_value(@uncast_value) if @uncast_value.is_a? String\n # Convert the value to yaml otherwise\n v = @uncast_value.to_yaml unless @uncast_value.nil?\n self[:value] = v\n end",
"def transform_value(value)\n if value.to_i.to_s == value\n value = value.to_i\n else\n value = nil\n end\nend",
"def vt_forever?\n vtend_at == InfinityValue\n end",
"def must_convert?\n self.big_query_conversion_column.present? && self.unit != 'seconds'\n end",
"def finite?\n !infinite?\n end",
"def coerce_time_milli(value)\n case value\n when Integer then value * 1000\n when Float then (value * 1000).floor\n else\n if value.respond_to?(:to_f)\n coerce_time_milli(value.to_f)\n elsif value.respond_to?(:to_i)\n coerce_time_milli(value.to_i)\n else\n 0\n end\n end\n end",
"def filter_value(value)\n case value\n when Range\n filter_value(value.first).first..filter_value(value.last).first\n when Array\n value.collect { |v| filter_value(v) }.flatten\n when Time\n value.respond_to?(:in_time_zone) ? [value.utc.to_i] : [value.to_i]\n when NilClass\n 0\n else\n Array(value)\n end\n end",
"def cast(value)\n cast_value(value) unless value.nil?\n end",
"def handle_nan(result)\n result.nan? ? 0.0 : result\n end",
"def handle_nan(result)\n result.nan? ? 0.0 : result\n end",
"def drop_last_value\n if @value.to_i.to_s.length > 1\n if (@value > 0)\n @value = (@value.to_i / 10).to_r\n else\n # Negative truncations need to be rounded UP\n @value = (@value.to_i / 10 + 1).to_r\n end\n else\n @value = 0\n end\n end",
"def transform_in(value)\n return value\n end",
"def to_number(value)\n return value.to_i unless value =~ /\\./\n return value.to_f if value =~ /\\./ \n end",
"def type_cast(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\n end",
"def unpack_number(value)\n decimal.zero? ? unpack_integer(value) : value.to_f\n end",
"def normalize(value)\n return 0.0 if near_zero_or_less? value\n return 1.0 if near_one_or_more? value\n value\n end",
"def non_negative(value)\n result = to_integer(value) or return\n result unless result.negative?\n end",
"def typecast_value_datetime(value)\n Sequel.typecast_to_application_timestamp(value)\n end",
"def strip_value\n @grpc.strip_value_transformer = true\n self\n end",
"def ∞ℂ; ::Float::INFINITY_COMPLEX; end",
"def convert(value) value end",
"def time_to_conversion\n converted? ? -1 : 10 - (Time.now.min % 10) # assumes a cron job runs every 10 minutes\n end",
"def value\n @casted_value ||= type_cast_value(@value)\n end",
"def nan?(value)\n value.is_a?(Float) && value.nan?\n end",
"def typecast(value)\n case value\n when %r{\\Atrue\\z}i then true\n when %r{\\Afalse\\z}i then false\n when %r{\\A\\s*\\z}i then nil\n else\n begin\n begin\n Integer(value)\n rescue StandardError\n Float(value)\n end\n rescue StandardError\n unescape_value(value)\n end\n end\n end",
"def to_f\n\t\tseconds_since_unix_epoch.to_f\n\tend",
"def cast_value\n value.mongoize\n end",
"def typecast(value)\n if value.kind_of?(Range) then Range.new(typecast(value.first), typecast(value.last))\n elsif value.kind_of?(Array) then value.map{|v| typecast(v)}\n elsif primitive == BigDecimal then super(value).to_f\n elsif primitive == DateTime then Time.parse(super(value).to_s).to_i\n elsif primitive == Date then Time.parse(super(value).to_s).to_i\n elsif primitive == Time then super(value).to_i\n else\n super(value) # Good luck\n end\n end",
"def to_f\n Float(value)\n end",
"def transform_property_value(value)\n case value\n when /^0/\n # when it is a zero leading value like \"0777\" don't turn\n # it into a number (this is a mode flag)\n value\n when /^\\d+$/\n value.to_i\n when /(^(\\d+)(\\.)?(\\d+)?)|(^(\\d+)?(\\.)(\\d+))/\n value.to_f\n when /true/i\n true\n when /false/i\n false\n else\n value\n end\n end",
"def must_convert?\n big_query_conversion_column.present? && unit != 'seconds'\n end",
"def convert_timestamp(value, capture_definition)\n DateTime.parse(value).strftime('%Y%m%d%H%M%S').to_i unless value.nil?\n end",
"def cast_value(value)\n value\n end",
"def transform_property_value(value)\n case value\n when /^0/\n # when it is a zero leading value like \"0777\" don't turn\n # it into a number (this is a mode flag)\n value\n when /^\\d+$/\n value.to_i\n when /(^(\\d+)(\\.)?(\\d+)?)|(^(\\d+)?(\\.)(\\d+))/\n value.to_f\n when /true/i\n true\n when /false/i\n false\n else\n value\n end\n end",
"def typecast_value_boolean(value)\n case value\n when false, 0, \"0\", /\\Af(alse)?\\z/i, /\\Ano?\\z/i\n false\n else\n blank_object?(value) ? nil : true\n end\n end",
"def parse(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\nend",
"def non_negative_float(value, epsilon: nil)\n result = to_float(value) or return\n result unless epsilon ? (result < -epsilon) : result.negative?\n end",
"def convert_value(val, duping=false) #:nodoc:\n case val\n when self.class\n val.dup\n when ::Hash\n val = val.dup if duping\n self.class.new(val)\n when Array\n val.collect{ |e| convert_value(e) }\n else\n if val.class == String\n begin\n datetime_regexp = /^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}Z?$/\n return DateTime.parse(val) if datetime_regexp.match(val)\n date_regexp = /^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}Z?$/\n return Date.parse(val) if date_regexp.match(val)\n rescue\n # no Date or DateTime found, keep calm and carry on\n end\n val\n else\n val\n end\n end\n end",
"def value\n @value.to_f\n end",
"def type_cast(value, type = self.type)\n case type\n when :counter\n type_cast(value, :integer).to_i\n when :integer\n Kernel::Integer(value) rescue nil if value\n when :float\n Kernel::Float(value) rescue nil if value\n when :timestamp\n value = type_cast(value, :integer)\n Time.at(value) if value\n else\n value\n end\n end",
"def typecast_value_float(value)\n Float(value)\n end",
"def normalize(value)\n value -= value.floor \n value += 1 if value < 0\n value\n end",
"def _convert_value(val)\n v = case val\n when :nil then nil\n when :false then false\n when :true then true\n else\n val\n end\n v\n end",
"def typecast_to_primitive(value)\n \n if value.kind_of?(::DateTime)\n result = value.to_time\n else\n result = ::DateTime.parse(value.to_s).to_time \n end\n \n return result\n \n rescue ArgumentError\n value\n end",
"def infinite?\n @count.nil?\n end",
"def to_float_or_int(v)\n v.match('\\.').nil? ? Integer(v) : Float(v)\n end",
"def prepare_d(value, currency)\n value =\n if value.respond_to?(:to_d)\n value.is_a?(Rational) ? value.to_d(conversion_precision) : value.to_d\n else\n BigDecimal.new(value.to_s)\n end\n if infinite_precision\n value\n else\n value.round(currency.decimal_places, rounding_mode)\n end\n end",
"def transmogrified_value\n case param.field.options[:value_transmogrification]\n when :chronic\n Chronic.parse(value, :context => :past)\n when :chronic_date\n v = Chronic.parse(value, :context => :past)\n v ? v.to_date : nil\n when :upcase\n value.upcase\n when :downcase\n value.downcase\n else\n value\n end\n end",
"def convert_float( text_value )\r\n (!text_value.empty?) ? text_value.to_f : 0.0\r\nend",
"def allow_nan?()\n #This is a stub, used for indexing\n end",
"def typecast_value_integer(value)\n Integer(value.is_a?(String) ? value.sub(LEADING_ZERO_RE, LEADING_ZERO_REP) : value)\n end",
"def value\n self.lazy_proc?(@value) ? self.coerce(@value.call) : @value\n end",
"def infinite?\n !expires?\n end",
"def lenient_value_coercions; end",
"def ignore_value\n value_event = next_event\n\n if value_event.is_a?(Value)\n return\n end\n\n if value_event.is_a?(StartObject) || value_event.is_a?(StartArray)\n ignore_container\n return\n end\n\n raise StandardError, \"unknown value type to ignore #{value_event.class}\"\n end",
"def tiny_from_timestamp\n tiny(Time.now.to_f - TINY_EPOCH)\n end",
"def infinite?\n @count.nil?\n end",
"def infinite?\n @count.nil?\n end",
"def value_to_integer(value)\n case value\n when TrueClass, FalseClass\n value ? 1 : 0\n else\n value.blank? ? nil : value.to_i rescue nil\n end\n end",
"def format_value_to_null(_value)\n 'null'\n end",
"def normalize( value )\n value\n end",
"def infinite?\n !ends_at && !length\n end",
"def datetime_clean(value)\n value.to_s.strip.sub(/[+-]00?(:00?)?$/, ZULU).sub(/\\d+\\.\\d+/) do |sec|\n '%02d' % [sec.to_f.round, 59].min\n end\n end",
"def cast_value(value) # :api: public\n value\n end",
"def normalize_value value\n return value if value.is_a? String\n return \"0\" if value < 0\n return \"10\" if value > 10\n value.to_s\nend",
"def convert_to_boolean(value)\n value != 'no'\n end",
"def parse_value value\r\n case value\r\n when /\\d+/\r\n value.to_f\r\n else\r\n value\r\n end\r\n end"
] |
[
"0.8253026",
"0.73847604",
"0.6585878",
"0.6431471",
"0.5664912",
"0.5478505",
"0.5446751",
"0.53884166",
"0.53884166",
"0.52656746",
"0.51324284",
"0.51287585",
"0.51222444",
"0.5095602",
"0.50459206",
"0.500709",
"0.49963593",
"0.49341547",
"0.49183714",
"0.48968238",
"0.4880525",
"0.48706254",
"0.4867631",
"0.48533076",
"0.48473907",
"0.48439622",
"0.4840764",
"0.4838601",
"0.48340115",
"0.48339468",
"0.48249185",
"0.48244792",
"0.48189345",
"0.48140797",
"0.48027697",
"0.48012948",
"0.4798211",
"0.47781077",
"0.4773296",
"0.47693798",
"0.47579312",
"0.47475863",
"0.47475863",
"0.47436705",
"0.47356793",
"0.47323355",
"0.47181872",
"0.47157344",
"0.46988708",
"0.46936503",
"0.46927625",
"0.469269",
"0.46402836",
"0.463649",
"0.46316633",
"0.46272108",
"0.46253756",
"0.4614241",
"0.4613762",
"0.46122706",
"0.4610314",
"0.4607302",
"0.4597557",
"0.4597232",
"0.4595745",
"0.45898086",
"0.45705247",
"0.4564845",
"0.45520806",
"0.45496216",
"0.4542172",
"0.45407057",
"0.45343983",
"0.45143342",
"0.45125833",
"0.4506924",
"0.45061606",
"0.44998482",
"0.44996655",
"0.44967535",
"0.44936746",
"0.44763288",
"0.4469745",
"0.44672012",
"0.44657442",
"0.4461146",
"0.44570535",
"0.4456711",
"0.44562525",
"0.4453847",
"0.4453847",
"0.4452478",
"0.44494134",
"0.44482896",
"0.44461584",
"0.44449854",
"0.44434193",
"0.44421077",
"0.44395635",
"0.4425299"
] |
0.6667661
|
2
|
If the value is an infinite value (either an infinite float or a string returned by by PostgreSQL for an infinite timestamp), return it without converting it if convert_infinite_timestamps is set.
|
def typecast_value_datetime(value)
if convert_infinite_timestamps
case value
when *INFINITE_DATETIME_VALUES
value
else
super
end
else
super
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def infinite_timestamp_value(value)\n case convert_infinite_timestamps\n when :nil\n nil\n when :string\n value\n else\n value == 'infinity' ? PLUS_INFINITY : MINUS_INFINITY\n end\n end",
"def convert_infinite_timestamps=(v)\n @convert_infinite_timestamps = case v\n when Symbol\n v\n when 'nil'\n :nil\n when 'string'\n :string\n when 'float'\n :float\n when String\n typecast_value_boolean(v)\n else\n false\n end\n\n pr = old_pr = @use_iso_date_format ? TYPE_TRANSLATOR.method(:date) : Sequel.method(:string_to_date)\n if v\n pr = lambda do |val|\n case val\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(val)\n else\n old_pr.call(val)\n end\n end\n end\n add_conversion_proc(1082, pr)\n end",
"def typecast_value_date(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_DATETIME_VALUES\n value\n else\n super\n end\n else\n super\n end\n end",
"def to_application_timestamp(value)\n if convert_infinite_timestamps\n case value\n when *INFINITE_TIMESTAMP_STRINGS\n infinite_timestamp_value(value)\n else\n super\n end\n else\n super\n end\n end",
"def convert_to_internal_value value\n value = fix_ambigious_value value, true\n\n if day_unit?\n (BigDecimal(value.to_time.to_i) / SECONDS_PER_DAY)\n elsif values_unit == Integer\n value.to_i\n else\n raise \"Unexpected unit: #{values_unit()}\"\n end\n end",
"def literal_float(value)\n if value.finite?\n super\n elsif value.nan?\n \"'NaN'\"\n elsif value.infinite? == 1\n \"'Infinity'\"\n else\n \"'-Infinity'\"\n end\n end",
"def checked(value)\n value = zero() if value.respond_to?(:nan?) && value.nan?\n value = zero() if value.respond_to?(:infinity?) && value.infinity?\n value = zero() if value.nil?\n value = value.to_f if value.is_a? BigDecimal\n\n value\n end",
"def infinite?\n nil\n end",
"def infinite?\n nil\n end",
"def infinite?() end",
"def internal_value_of(value)\n return value if value.respond_to?(:nan?) && value.nan?\n return Float::NAN if [nil, '?'].include?(value)\n return parse_date(value.to_s) if date?\n return value.to_f if numeric?\n return index_of_value(value.to_s) if nominal? || string?\n end",
"def infinite?\n end",
"def type_cast(value) # :api: public\n cast_value(value) unless value.nil?\n end",
"def convert_value(value_node)\n if value_node.nil?\n return\n end\n if value_node['type'] == 'REAL' || value_node['value'].include?('.')\n return value_node['value'].to_f\n else\n return value_node['value'].to_i\n end\n end",
"def infinite?; end",
"def untypecasted_value\n read_attribute(:value)\n end",
"def cast\n return to_f if numeric? && index(\".\")\n return to_i if numeric?\n if boolean?\n return true if self =~ /\\Atrue\\z/i\n return false if self =~ /\\Afalse\\z/i\n end\n self\n end",
"def to\n @to == Float::INFINITY ? nil : @to\n end",
"def infinity?\n @infinity == true\n end",
"def converted_value\n if @converter\n @converter.call(@value)\n else\n @value\n end\n end",
"def coerce(value)\n return 0.0 unless value.respond_to?(:to_f)\n\n value.to_f\n end",
"def post_process_float( val )\n\t\t\treturn Float( val.to_s )\n\t\tend",
"def to_f\n if isFloat? then\n value = exp.to_f\n return value\n elsif exp == \"Infinity\" then return @@MAX_VALUE\n elsif exp == \"-Infinity\" then return @@MIN_VALUE\n else\n raise \"Non-float conversion in expression: \" + exp\n end\n end",
"def convert_value(value)\n value\n end",
"def to_float(value)\n return Float(value) rescue Float::NAN\n end",
"def to_string(value)\n # If we have a number that has a zero decimal (e.g. 10.0) we want to\n # get rid of that decimal. For this we'll first convert the number to\n # an integer.\n if value.is_a?(Float) and value.modulo(1).zero?\n value = value.to_i\n end\n\n return value.to_s\n end",
"def normalize_scalar_property_value(value)\n return \"NaN\" if value.kind_of?(Float) && value.nan?\n\n case value\n when true, false, nil then value\n when ActiveSupport::Duration then value.to_i\n when Numeric then value\n when String then value.strip\n when Symbol then value.to_s.strip\n when Time then value.getutc.strftime(\"%Y-%m-%dT%H:%M:%S\")\n when IPAddr then value.to_s\n when FLOAT_INFINITY then \"+infinity\"\n when -FLOAT_INFINITY then \"-infinity\"\n when Array then\n out = value.map { |e| normalize_scalar_property_value(e) }\n out = :invalid_property_value if out.detect { |e| e == :invalid_property_value }\n out\n else :invalid_property_value\n end\n end",
"def type_cast(value)\n nil\n end",
"def coerce(value)\n if !value.nil? and !option.allowed_format.nil?\n case option.allowed_format\n when 'fixnum'\n value = value.to_i\n when 'float'\n value = value.to_f\n when 'boolean'\n value = true if (value == 'true' or value == 't')\n value = false if (value == 'false' or value == 'f')\n end\n end\n\n return value\n end",
"def tt_forever?\n ttend_at == InfinityValue\n end",
"def floor(value)\n numeric_transformation(value) {|n| n.floor}\n end",
"def clean_value(value)\n case value\n when Symbol then value.to_s\n when TrueClass then 1\n when FalseClass then 0\n when /^\\d+$/ then value.to_i # Integer\n when /^\\d+(\\.\\d+)?([eE]\\d+)?$/ then value.to_f # Float\n when blank? then nil\n else value\n end \n end",
"def convert_i_f(value)\n if (value =~ /\\./)\n value = value.to_f\n elsif\n value = value.to_i\n end\n return value\nend",
"def convert_value\n # Do nothing if value has not changed\n return true unless value_changed?\n # Cast the value and return success\n return parse_string_value(@uncast_value) if @uncast_value.is_a? String\n # Convert the value to yaml otherwise\n v = @uncast_value.to_yaml unless @uncast_value.nil?\n self[:value] = v\n end",
"def transform_value(value)\n if value.to_i.to_s == value\n value = value.to_i\n else\n value = nil\n end\nend",
"def vt_forever?\n vtend_at == InfinityValue\n end",
"def must_convert?\n self.big_query_conversion_column.present? && self.unit != 'seconds'\n end",
"def finite?\n !infinite?\n end",
"def coerce_time_milli(value)\n case value\n when Integer then value * 1000\n when Float then (value * 1000).floor\n else\n if value.respond_to?(:to_f)\n coerce_time_milli(value.to_f)\n elsif value.respond_to?(:to_i)\n coerce_time_milli(value.to_i)\n else\n 0\n end\n end\n end",
"def filter_value(value)\n case value\n when Range\n filter_value(value.first).first..filter_value(value.last).first\n when Array\n value.collect { |v| filter_value(v) }.flatten\n when Time\n value.respond_to?(:in_time_zone) ? [value.utc.to_i] : [value.to_i]\n when NilClass\n 0\n else\n Array(value)\n end\n end",
"def cast(value)\n cast_value(value) unless value.nil?\n end",
"def handle_nan(result)\n result.nan? ? 0.0 : result\n end",
"def handle_nan(result)\n result.nan? ? 0.0 : result\n end",
"def drop_last_value\n if @value.to_i.to_s.length > 1\n if (@value > 0)\n @value = (@value.to_i / 10).to_r\n else\n # Negative truncations need to be rounded UP\n @value = (@value.to_i / 10 + 1).to_r\n end\n else\n @value = 0\n end\n end",
"def transform_in(value)\n return value\n end",
"def to_number(value)\n return value.to_i unless value =~ /\\./\n return value.to_f if value =~ /\\./ \n end",
"def type_cast(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\n end",
"def unpack_number(value)\n decimal.zero? ? unpack_integer(value) : value.to_f\n end",
"def normalize(value)\n return 0.0 if near_zero_or_less? value\n return 1.0 if near_one_or_more? value\n value\n end",
"def typecast_value_datetime(value)\n Sequel.typecast_to_application_timestamp(value)\n end",
"def non_negative(value)\n result = to_integer(value) or return\n result unless result.negative?\n end",
"def strip_value\n @grpc.strip_value_transformer = true\n self\n end",
"def convert(value) value end",
"def ∞ℂ; ::Float::INFINITY_COMPLEX; end",
"def time_to_conversion\n converted? ? -1 : 10 - (Time.now.min % 10) # assumes a cron job runs every 10 minutes\n end",
"def value\n @casted_value ||= type_cast_value(@value)\n end",
"def nan?(value)\n value.is_a?(Float) && value.nan?\n end",
"def typecast(value)\n case value\n when %r{\\Atrue\\z}i then true\n when %r{\\Afalse\\z}i then false\n when %r{\\A\\s*\\z}i then nil\n else\n begin\n begin\n Integer(value)\n rescue StandardError\n Float(value)\n end\n rescue StandardError\n unescape_value(value)\n end\n end\n end",
"def cast_value\n value.mongoize\n end",
"def typecast(value)\n if value.kind_of?(Range) then Range.new(typecast(value.first), typecast(value.last))\n elsif value.kind_of?(Array) then value.map{|v| typecast(v)}\n elsif primitive == BigDecimal then super(value).to_f\n elsif primitive == DateTime then Time.parse(super(value).to_s).to_i\n elsif primitive == Date then Time.parse(super(value).to_s).to_i\n elsif primitive == Time then super(value).to_i\n else\n super(value) # Good luck\n end\n end",
"def to_f\n\t\tseconds_since_unix_epoch.to_f\n\tend",
"def to_f\n Float(value)\n end",
"def transform_property_value(value)\n case value\n when /^0/\n # when it is a zero leading value like \"0777\" don't turn\n # it into a number (this is a mode flag)\n value\n when /^\\d+$/\n value.to_i\n when /(^(\\d+)(\\.)?(\\d+)?)|(^(\\d+)?(\\.)(\\d+))/\n value.to_f\n when /true/i\n true\n when /false/i\n false\n else\n value\n end\n end",
"def convert_timestamp(value, capture_definition)\n DateTime.parse(value).strftime('%Y%m%d%H%M%S').to_i unless value.nil?\n end",
"def must_convert?\n big_query_conversion_column.present? && unit != 'seconds'\n end",
"def cast_value(value)\n value\n end",
"def transform_property_value(value)\n case value\n when /^0/\n # when it is a zero leading value like \"0777\" don't turn\n # it into a number (this is a mode flag)\n value\n when /^\\d+$/\n value.to_i\n when /(^(\\d+)(\\.)?(\\d+)?)|(^(\\d+)?(\\.)(\\d+))/\n value.to_f\n when /true/i\n true\n when /false/i\n false\n else\n value\n end\n end",
"def typecast_value_boolean(value)\n case value\n when false, 0, \"0\", /\\Af(alse)?\\z/i, /\\Ano?\\z/i\n false\n else\n blank_object?(value) ? nil : true\n end\n end",
"def parse(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\nend",
"def non_negative_float(value, epsilon: nil)\n result = to_float(value) or return\n result unless epsilon ? (result < -epsilon) : result.negative?\n end",
"def convert_value(val, duping=false) #:nodoc:\n case val\n when self.class\n val.dup\n when ::Hash\n val = val.dup if duping\n self.class.new(val)\n when Array\n val.collect{ |e| convert_value(e) }\n else\n if val.class == String\n begin\n datetime_regexp = /^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}Z?$/\n return DateTime.parse(val) if datetime_regexp.match(val)\n date_regexp = /^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}Z?$/\n return Date.parse(val) if date_regexp.match(val)\n rescue\n # no Date or DateTime found, keep calm and carry on\n end\n val\n else\n val\n end\n end\n end",
"def value\n @value.to_f\n end",
"def type_cast(value, type = self.type)\n case type\n when :counter\n type_cast(value, :integer).to_i\n when :integer\n Kernel::Integer(value) rescue nil if value\n when :float\n Kernel::Float(value) rescue nil if value\n when :timestamp\n value = type_cast(value, :integer)\n Time.at(value) if value\n else\n value\n end\n end",
"def typecast_value_float(value)\n Float(value)\n end",
"def normalize(value)\n value -= value.floor \n value += 1 if value < 0\n value\n end",
"def _convert_value(val)\n v = case val\n when :nil then nil\n when :false then false\n when :true then true\n else\n val\n end\n v\n end",
"def typecast_to_primitive(value)\n \n if value.kind_of?(::DateTime)\n result = value.to_time\n else\n result = ::DateTime.parse(value.to_s).to_time \n end\n \n return result\n \n rescue ArgumentError\n value\n end",
"def to_float_or_int(v)\n v.match('\\.').nil? ? Integer(v) : Float(v)\n end",
"def infinite?\n @count.nil?\n end",
"def prepare_d(value, currency)\n value =\n if value.respond_to?(:to_d)\n value.is_a?(Rational) ? value.to_d(conversion_precision) : value.to_d\n else\n BigDecimal.new(value.to_s)\n end\n if infinite_precision\n value\n else\n value.round(currency.decimal_places, rounding_mode)\n end\n end",
"def transmogrified_value\n case param.field.options[:value_transmogrification]\n when :chronic\n Chronic.parse(value, :context => :past)\n when :chronic_date\n v = Chronic.parse(value, :context => :past)\n v ? v.to_date : nil\n when :upcase\n value.upcase\n when :downcase\n value.downcase\n else\n value\n end\n end",
"def convert_float( text_value )\r\n (!text_value.empty?) ? text_value.to_f : 0.0\r\nend",
"def typecast_value_integer(value)\n Integer(value.is_a?(String) ? value.sub(LEADING_ZERO_RE, LEADING_ZERO_REP) : value)\n end",
"def allow_nan?()\n #This is a stub, used for indexing\n end",
"def value\n self.lazy_proc?(@value) ? self.coerce(@value.call) : @value\n end",
"def ignore_value\n value_event = next_event\n\n if value_event.is_a?(Value)\n return\n end\n\n if value_event.is_a?(StartObject) || value_event.is_a?(StartArray)\n ignore_container\n return\n end\n\n raise StandardError, \"unknown value type to ignore #{value_event.class}\"\n end",
"def infinite?\n !expires?\n end",
"def lenient_value_coercions; end",
"def value_to_integer(value)\n case value\n when TrueClass, FalseClass\n value ? 1 : 0\n else\n value.blank? ? nil : value.to_i rescue nil\n end\n end",
"def tiny_from_timestamp\n tiny(Time.now.to_f - TINY_EPOCH)\n end",
"def infinite?\n @count.nil?\n end",
"def infinite?\n @count.nil?\n end",
"def normalize( value )\n value\n end",
"def format_value_to_null(_value)\n 'null'\n end",
"def cast_value(value) # :api: public\n value\n end",
"def datetime_clean(value)\n value.to_s.strip.sub(/[+-]00?(:00?)?$/, ZULU).sub(/\\d+\\.\\d+/) do |sec|\n '%02d' % [sec.to_f.round, 59].min\n end\n end",
"def normalize_value value\n return value if value.is_a? String\n return \"0\" if value < 0\n return \"10\" if value > 10\n value.to_s\nend",
"def infinite?\n !ends_at && !length\n end",
"def convert_to_boolean(value)\n value != 'no'\n end",
"def parse_value value\r\n case value\r\n when /\\d+/\r\n value.to_f\r\n else\r\n value\r\n end\r\n end"
] |
[
"0.8254243",
"0.7386384",
"0.666975",
"0.6434004",
"0.5667342",
"0.54780704",
"0.54476446",
"0.5386003",
"0.5386003",
"0.5263733",
"0.51320237",
"0.5130345",
"0.5125038",
"0.50984293",
"0.504356",
"0.50070506",
"0.49965602",
"0.49327546",
"0.49162784",
"0.4899449",
"0.48814437",
"0.4870721",
"0.48658654",
"0.48570532",
"0.48478994",
"0.48458427",
"0.48435402",
"0.48396397",
"0.48367655",
"0.48323837",
"0.48273477",
"0.48267972",
"0.48210004",
"0.48168945",
"0.48060855",
"0.48000488",
"0.4797162",
"0.47759035",
"0.4775457",
"0.4772953",
"0.47606444",
"0.4746557",
"0.4746557",
"0.4742645",
"0.473828",
"0.47349197",
"0.4719479",
"0.47182104",
"0.47012472",
"0.46959236",
"0.4694221",
"0.46930426",
"0.4639359",
"0.4637888",
"0.46313757",
"0.4629491",
"0.4625425",
"0.4616799",
"0.4615413",
"0.4613165",
"0.46120638",
"0.4607369",
"0.46008867",
"0.4597869",
"0.4596512",
"0.45933047",
"0.45738247",
"0.456743",
"0.4552669",
"0.454833",
"0.4543276",
"0.45409536",
"0.45368153",
"0.45160574",
"0.4514613",
"0.45099175",
"0.45081857",
"0.45009905",
"0.44982207",
"0.44975415",
"0.4495328",
"0.44756845",
"0.44702923",
"0.44677392",
"0.44676015",
"0.44580507",
"0.44578186",
"0.44569257",
"0.4456637",
"0.44556764",
"0.44521418",
"0.44521418",
"0.4450398",
"0.44495752",
"0.4446912",
"0.4445558",
"0.4444132",
"0.44437584",
"0.4439857",
"0.4428924"
] |
0.6588314
|
3
|
Yield all rows returned by executing the given SQL and converting the types.
|
def fetch_rows(sql)
return cursor_fetch_rows(sql){|h| yield h} if @opts[:cursor]
execute(sql){|res| yield_hash_rows(res, fetch_rows_set_cols(res)){|h| yield h}}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fetch_rows(sql)\n execute(sql) do |r|\n i = -1\n cps = db.conversion_procs\n cols = r.fetch_fields.map do |f| \n # Pretend tinyint is another integer type if its length is not 1, to\n # avoid casting to boolean if convert_tinyint_to_bool is set.\n type_proc = f.type == 1 && cast_tinyint_integer?(f) ? cps[2] : cps[f.type]\n [output_identifier(f.name), type_proc, i+=1]\n end\n self.columns = cols.map(&:first)\n if opts[:split_multiple_result_sets]\n s = []\n yield_rows(r, cols){|h| s << h}\n yield s\n else\n yield_rows(r, cols){|h| yield h}\n end\n end\n self\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n columns = []\n convert = convert_smallint_to_bool\n cps = db.conversion_procs\n stmt.num_fields.times do |i|\n k = stmt.field_name i\n key = output_identifier(k)\n type = stmt.field_type(i).downcase.to_sym\n # decide if it is a smallint from precision\n type = :boolean if type == :int && convert && stmt.field_precision(i) < 8\n type = :blob if type == :clob && db.use_clob_as_blob\n columns << [key, cps[type]]\n end\n cols = columns.map{|c| c[0]}\n self.columns = cols\n\n while res = stmt.fetch_array\n row = {}\n res.zip(columns).each do |v, (k, pr)|\n row[k] = ((pr ? pr.call(v) : v) if v)\n end\n yield row\n end\n end\n self\n end",
"def process_result_set(result, opts=OPTS)\n meta = result.getMetaData\n if fetch_size = opts[:fetch_size]\n result.setFetchSize(fetch_size)\n end\n\n converters = []\n self.columns = meta.getColumnCount.times.map do |i|\n col = i + 1\n converters << TypeConverter::MAP[meta.getColumnType(col)]\n meta.getColumnLabel(col)\n end\n\n fetch_as_array = opts[:as] == :array\n while result.next\n row = fetch_as_array ? [] : {}\n _columns.each_with_index do |column, i|\n k = fetch_as_array ? i : column\n col = i+1\n row[k] = converters[i].call(result, col, opts)\n end\n yield row\n end\n ensure\n result.close\n end",
"def all(sql, *args, into: nil, &block)\n raise ArgumentError, \"all no longer support blocks, use each instead.\" if block\n\n rows, pg_source_oid, column_info = each_without_conversion(sql, *args, into: into)\n\n result = convert_rows_to_result rows, into: into, pg_source_oid: pg_source_oid\n\n # [TODO] - resolve associations. Note that this is only possible if the type\n # is not an Array (i.e. into is nil)\n\n result.pagination_scope = sql if sql.is_a?(::Simple::SQL::Connection::Scope) && sql.paginated?\n result.column_info = column_info\n result\n end",
"def each_without_conversion(sql, *args, into: nil)\n pg_result = exec_logged(sql, *args)\n\n column_info = collect_column_info(pg_result)\n rows = []\n pg_source_oid = nil\n\n if pg_result.ntuples > 0 && pg_result.nfields > 0\n decoder = Decoder.new(pg_result, into: (into ? Hash : nil), column_info: column_info)\n pg_source_oid = pg_result.ftable(0)\n\n pg_result.each_row do |row|\n rows << decoder.decode(row)\n end\n end\n\n [rows, pg_source_oid, column_info]\n ensure\n # optimization: If we wouldn't clear here the GC would do this later.\n pg_result.clear if pg_result && !pg_result.autoclear?\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n self.columns = cols = stmt.result_fields.map{|c| output_identifier(c)}\n col_count = cols.size\n stmt.each do |result|\n row = {}\n col_count.times{|i| row[cols[i]] = result[i]}\n yield row\n end\n end\n end",
"def multiple(sql, values = [])\n r = $db.exec_params(sql, values)\n return [] if r.ntuples == 0\n r.map { |row| convert_to_ruby_types(row) }\nend",
"def exec_raw(sql, options = {})\n cursor = $connection.exec(sql)\n if(options[:return_hash])\n recordset, = pack_cursor(cursor, :return => \"hash\")\n return recordset\n else\n return_data = []\n while current_row = cursor.fetch()\n return_data.push(current_row)\n end\n return return_data\n end\n end",
"def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end",
"def fetch_rows(sql)\n execute(sql) do |res|\n columns = set_columns(res)\n yield_hash_rows(res, columns) {|h| yield h}\n end\n end",
"def execute( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n result.each { |row| yield row }\n else\n return result.inject( [] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def each\n if block_given?\n vals = []\n @query_schema.inputs.each_with_index do |input, i|\n vals << input.type.convert_from_ruby(@values[i])\n end\n @table.csv.each do |row|\n if @query_schema.inputs.zip(vals).all? {|input, val| row[input.pos] == val} and\n @query_schema.values.all? {|value| row[value.pos] == value.type.convert_from_ruby(value.value)}\n outputs = []\n cond = @query_schema.outputs.each do |output|\n val = row[output.pos]\n if output.options[:empty] == :ignore and val == \"\"\n break :break\n else\n outputs << output.type.convert_to_ruby(val)\n end\n end\n yield *outputs unless cond == :break\n end\n end\n else\n return Enumerator.new(self)\n end\n end",
"def execute_all( sql ) # :yields: row\n loop do\n stmt = prepare( sql )\n stmt.execute do |result|\n result.each { |row| yield row if block_given? }\n end\n sql = stmt.remainder\n if sql.length > 0\n yield nil if block_given? # notify of new query starting\n else\n break\n end\n end\n end",
"def each\n @pool.with do |conn|\n conn.send_query @sql\n conn.set_single_row_mode\n loop do\n res = conn.get_result\n break unless res\n res.check\n res.stream_each { |row| yield row }\n end\n end\n end",
"def fetch\n row = @result.fetch\n return row unless @bind_result\n row.zip(@bind_result).map do |col, type|\n if col.nil?\n nil\n elsif [Numeric, Integer, Fixnum].include? type\n col.to_i\n elsif type == String\n col.to_s\n elsif type == Float && !col.is_a?(Float)\n col.to_i.to_f\n elsif type == Mysql::Time && !col.is_a?(Mysql::Time)\n if col.to_s =~ /\\A\\d+\\z/\n i = col.to_s.to_i\n if i < 100000000\n y = i/10000\n m = i/100%100\n d = i%100\n h, mm, s = 0\n else\n y = i/10000000000\n m = i/100000000%100\n d = i/1000000%100\n h = i/10000%100\n mm= i/100%100\n s = i%100\n end\n if y < 70\n y += 2000\n elsif y < 100\n y += 1900\n end\n Mysql::Time.new(y, m, d, h, mm, s)\n else\n Mysql::Time.new\n end\n else\n col\n end\n end\n end",
"def execute_sql(my_sql)\n pg_result = ActiveRecord::Base.connection.execute(my_sql)\n\n # In this example we are just calling #to_a to convert the PG::Result to an\n # Array. PG::Result has a nice API for slicing and dicing itself so you may\n # want to to something clever instead. See\n # https://www.rubydoc.info/gems/pg/PG/Result for details.\n #\n # The important bit here is that we are copying all the data we care about\n # out of the PG::Result in preparation for later clearing the PG::Result\n results = pg_result.to_a\n\n # Calling #clear on the PG::Result is the important bit of cleanup and the\n # whole reason this method exists. See\n # https://www.rubydoc.info/gems/pg/PG/Result#clear-instance_method\n pg_result.clear\n\n yield results if block_given?\n\n results\nend",
"def cti_execute_sql(sql)\n return execute(sql) if sql.is_a?(String)\n sql.map do |query|\n execute(query)\n end\n end",
"def type_to_sql(*args); connection.type_to_sql(*args); end",
"def each_row_as_native\n @rows.each { |row| yield(Array.new(row.size) { |i| @columns[i].type.translate(row[i]) }) }\n self\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n translate(sql) do |sql, args|\n unless binds.empty?\n args = binds.map { |col, val| type_cast(val, col) } + args\n end\n log(expand(sql, args), name) do\n result, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }\n if result.respond_to?(:map)\n cols = result.map { |col| col.name } \n ActiveRecord::Result.new(cols, rows)\n else\n result\n end\n end\n end\n end",
"def result_to_rows(result)\n result.rows.map do |row|\n typed_row = result.columns.zip(row).map do |column_name, value|\n typed_value = result.column_types[column_name].send(:type_cast, value)\n [column_name.to_sym, typed_value]\n end\n Hash[typed_row]\n end\n end",
"def oracle_sql_results(sql, conn = VACOLS::Case.connection)\n result = conn.execute(sql)\n output = []\n while r = result.fetch_hash\n output << r\n end\n output\nend",
"def exec_query(sql, name = nil, binds = [])\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n result_array = result_as_array(result)\n if ArVer::GTEQ_4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end",
"def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end",
"def queryAndConvert() \n\t\tres = self.query()\n\t\treturn res.convert()\n end",
"def select(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"select: #{sql}\" }\n query = client.execute(sql)\n\n rows = []\n query.each do |r| \n\n if block_given? \n rows << yield(r)\n else\n rows << r\n end\n\n end\n\n query.cancel \n rows\n\n rescue => e\n handle_error(e)\n end",
"def run\n _escaped_sql = escaped_sql\n @query_logger << _escaped_sql if @query_logger\n result = @conn.exec_query _escaped_sql\n row_class = OccamsRecord::Results.klass(result.columns, result.column_types, @eager_loaders.names, model: @eager_loaders.model, modules: @use)\n rows = result.rows.map { |row| row_class.new row }\n @eager_loaders.run!(rows, query_logger: @query_logger)\n rows\n end",
"def cast_records!(*types, **options)\n where!(regclass.cast(:varchar).in(types.map(&:table_name))) if options[:filter]\n self.select_extra_values += [regclass.as(_record_class_attribute.to_s)]\n self.cast_records_value = (types.present? ? types : model.casted_dependents.values)\n self\n end",
"def each\n return unless @result\n\n @result.each(as: :hash, symbolize_keys: true) do |row|\n next unless row # This sometimes happens when streaming results...\n row = Hash[row.map { |k, v| [k, v.to_s] }] if @type_translation == :string\n yield row\n end\n end",
"def rows_as_native\n unless @rows_as_native\n @rows_as_native = @rows.collect { |row| Array.new(row.size) { |i| @columns[i].type.translate(row[i]) } }\n end\n @rows_as_native\n end",
"def execute( sql, backwards_compat=false )\r\n result = @conn.query( sql )\r\n if backwards_compat\r\n return PGresult.new( result )\r\n else\r\n ResultSet.new result\r\n end\r\n rescue Exception => e\r\n raise DataAccessException.new( e.message, e ), $!, caller\r\n end",
"def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end",
"def run(results)\n columns_names = rows.first.inject([]) {|m, kv| m << kv[0]; m}\n row_count = rows.size\n initial_data = results.all.map {|r| columns.map {|c| r[c]}}\n asrecordset = ASRecordset.new(row_count,column_names,initial_data)\n \tresult = asrecordset\n \treturn result\n end",
"def execute2( sql, *bind_vars )\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute do |result|\n if block_given?\n yield result.columns\n result.each { |row| yield row }\n else\n return result.inject( [ result.columns ] ) { |arr,row| arr << row; arr }\n end\n end\n end",
"def fetch\n row = @results[@index += 1]\n return unless row\n\n if @types\n row.map!.with_index { |value, index| translate_type(value, @types[index]) } if @types\n elsif @type_translation == :string\n row.map!(&:to_s)\n end\n\n Hash[*@columns.zip(row).flatten]\n end",
"def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n log(sql, name, binds) do\n result = without_prepared_statement?(binds) ? exec_no_cache(sql) :\n exec_cache(sql, binds)\n result_array = result_as_array(result)\n if ActiveRecord::VERSION::MAJOR >= 4\n column_types = compute_field_types(result)\n ret = ActiveRecord::Result.new(result.fields, result_array, column_types)\n else\n ret = ActiveRecord::Result.new(result.fields, result_array)\n end\n result.clear\n ret\n end\n end",
"def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n # TODO put these lines back in and create another method to turn results_as_objects array of \n # objects in to array of hashes!!!!!!!\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end",
"def each_row_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_row_batch(&block) if block_given?\n cursor.iterate_batched\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def fetch_rows(sql, &block)\n raise NotImplementedError, NOTIMPL_MSG\n end",
"def cast(arg, sql_type)\n SQL::Cast.new(arg, sql_type)\n end",
"def cast_records(*types, **options)\n spawn.cast_records!(*types, **options)\n end",
"def run(&block)\n case prepared_type\n when :select, :all\n # Most common scenario, so listed first\n all(&block)\n when :each\n each(&block)\n when :insert_select\n with_sql(prepared_sql).first\n when :first\n first\n when :insert, :update, :delete\n if opts[:returning] && supports_returning?(prepared_type)\n returning_fetch_rows(prepared_sql)\n elsif prepared_type == :delete\n delete\n else\n send(prepared_type, *prepared_modify_values)\n end\n when :insert_pk\n fetch_rows(prepared_sql){|r| return r.values.first}\n when Array\n case prepared_type[0]\n when :map, :as_hash, :to_hash, :to_hash_groups\n send(*prepared_type, &block) \n end\n else\n Sequel::Deprecation.deprecate(\"Using an unsupported prepared statement type (#{prepared_type.inspect})\", 'Switch to using :select as the prepared statement type')\n all(&block)\n end\n end",
"def query sql\n result = db[sql].all\n return result\n end",
"def fetch_rows(sql, &block)\n execute(sql) do |r|\n r.each(:symbolize_keys => true, &block)\n end\n self\n end",
"def execute( *params )\n bind( *params )\n begin\n # save the error state at the beginning of the execution. We only want to\n # reraise the error if it was raised during this execution.\n s_before = $!\n if block_given? then\n while row = next_row\n yield row\n end\n else\n all_rows\n end\n ensure\n s = $!\n begin\n reset_for_next_execute!\n rescue\n # rescuing nothing on purpose\n end\n raise s if s != s_before\n end\n end",
"def each_object(with_table=false)\n self.each_hash(with_table){|row| yield(Row.convert(row, self.fetch_fields, with_table)) }\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end",
"def convert_row(row)\n return nil if row.nil?\n row.collect do |col|\n if col.is_a? ::ODBC::Date\n DBI::Date.new(col.year, col.month, col.day)\n elsif col.is_a? ::ODBC::Time\n DBI::Time.new(col.hour, col.minute, col.second)\n elsif col.is_a? ::ODBC::TimeStamp\n DBI::Timestamp.new(col.year, col.month, col.day,\n col.hour, col.minute, col.second, col.fraction)\n else\n col\n end\n end\n end",
"def query(sql)\n path = 'query'\n io = request path, :post, {}, {query: sql}, stream: true\n io.each do |l|\n yield l\n end\n end",
"def execute( *bind_vars )\n reset! if active? || done?\n\n bind_params(*bind_vars) unless bind_vars.empty?\n @results = ResultSet.new(@connection, self)\n\n step if 0 == column_count\n\n yield @results if block_given?\n @results\n end",
"def each_instance_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_instance_batch(self, &block) if block_given?\n cursor.iterate_type(self).iterate_batched\n end",
"def ascii_query(sql,*values)\n sth = self.query(sql,*values)\n rows = sth.fetch_all\n col_names = sth.column_names\n sth.finish\n DBI::Utils::TableFormatter.ascii(col_names, rows)\n end",
"def result\n ActiveRecord::Base.connection.select_all(sql).entries\n end",
"def _execute(conn, sql, opts)\n r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif defined?(yield)\n yield conn\n end\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n if r\n r.free\n r = nil\n end\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n yield r if opts[:type] == :select\n end\n end\n rescue Mysql::Error => e\n raise_error(e)\n ensure\n r.free if r\n # Use up all results to avoid a commands out of sync message.\n if conn.respond_to?(:more_results?)\n while conn.more_results? do\n begin\n conn.next_result\n r = conn.use_result\n rescue Mysql::Error => e\n raise_error(e, :disconnect=>true) if MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message)\n break\n end\n r.free if r\n end\n end\n end",
"def next\n return nil if @eof\n\n @stmt.must_be_open!\n\n unless @first_row\n result = @driver.step( @stmt.handle )\n check result\n end\n\n @first_row = false\n\n unless @eof\n row = []\n @driver.data_count( @stmt.handle ).times do |column|\n case @driver.column_type( @stmt.handle, column )\n when Constants::ColumnType::NULL then\n row << nil\n when Constants::ColumnType::BLOB then\n row << @driver.column_blob( @stmt.handle, column )\n else\n row << @driver.column_text( @stmt.handle, column )\n end\n end\n\n if @db.type_translation\n row = @stmt.types.zip( row ).map do |type, value|\n @db.translator.translate( type, value )\n end\n end\n\n if @db.results_as_hash\n new_row = Hash[ *( @stmt.columns.zip( row ).flatten ) ]\n row.each_with_index { |value,idx| new_row[idx] = value }\n row = new_row\n else\n row.extend FieldsContainer unless row.respond_to?(:fields)\n row.fields = @stmt.columns\n end\n\n row.extend TypesContainer\n row.types = @stmt.types\n\n return row\n end\n\n nil\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects(results)\n \n end",
"def resultset; end",
"def ask(sql, *args, into: nil)\n catch(:ok) do\n each(sql, *args, into: into) { |row| throw :ok, row }\n nil\n end\n end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def query(sql)\r\n\t\trecordset = WIN32OLE.new('ADODB.Recordset')\r\n\t\trecordset.Open(sql, @connection)\r\n\t\t@fields = []\r\n\t\trecordset.Fields.each do |field|\r\n\t\t\t@fields << field.Name\r\n\t\tend\r\n\r\n\t\tbegin\r\n\t\t\t# Transpose to have array of rows\r\n\t\t\t@data = recordset.GetRows.transpose\r\n\t\trescue\r\n\t\t\t@data = []\r\n\t\tend\r\n\r\n\t\trecordset.Close\r\n\tend",
"def all_as_objects\n table_name = self.to_s.pluralize\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n \n results_as_objects << self.new(result_hash)\n \n end\n \n return results_as_objects\n \n end",
"def select(string) # :nodoc:\n chk_conn\n conn = @hibernate_session.connection\n stmt = conn.create_statement\n rs = stmt.execute_query(string)\n result = []\n meta = rs.meta_data\n cols = meta.column_count\n while rs.next\n row = []\n (1..cols).each do |n|\n row << from_database_type(rs.get_object(n))\n end\n result << row\n end\n result\n ensure\n rs.close rescue nil\n stmt.close rescue nil\n end",
"def set_values_from(result)\n @arguments = Arguments.new(result[0]['arguments'])\n @return_type = result[0]['return_type']\n @query = \"SELECT * FROM %s.%s(%s)\" % [\n quoted_schema,\n quoted_name,\n @arguments.to_params\n ]\n end",
"def run_tuples(query, options = {})\n GRel::Debugger.debug \"QUERYING SELECT...\"\n GRel::Debugger.debug query\n GRel::Debugger.debug \"** LIMIT #{@last_query_context.limit}\" if @last_query_context.limit\n GRel::Debugger.debug \"** OFFSET #{@last_query_context.offset}\" if @last_query_context.offset\n GRel::Debugger.debug \"----------------------\"\n args = {}\n args[:accept] = options[:accept] if options[:accept]\n args[:offset] = @last_query_context.offset if @last_query_context.offset\n args[:limit] = @last_query_context.limit if @last_query_context.limit\n @connection.query(@db_name,query, args).body\n end",
"def types\n @stmt.types\n end",
"def build_result(columns:, rows:, column_types: {})\n ActiveRecord::Result.new(columns, rows, column_types)\n end",
"def types\n @stmt.types\n end",
"def next_row\n row = []\n case rc = @stmt_api.step\n when ResultCode::ROW\n result_meta.each_with_index do |col, idx|\n value = nil\n column_type = @stmt_api.column_type( idx )\n case column_type\n when DataType::TEXT\n value = @stmt_api.column_text( idx )\n when DataType::FLOAT\n value = @stmt_api.column_double( idx )\n when DataType::INTEGER\n value = @stmt_api.column_int64( idx )\n when DataType::NULL\n value = nil\n when DataType::BLOB\n # if the rowid column is encountered, then we can use an incremental\n # blob api, otherwise we have to use the all at once version.\n if using_rowid_column? then\n value = Amalgalite::Blob.new( :db_blob => SQLite3::Blob.new( db.api,\n col.schema.db,\n col.schema.table,\n col.schema.name,\n @stmt_api.column_int64( @rowid_index ),\n \"r\"),\n :column => col.schema)\n else\n value = Amalgalite::Blob.new( :string => @stmt_api.column_blob( idx ), :column => col.schema )\n end\n else\n raise ::Amalgalite::Error, \"BUG! : Unknown SQLite column type of #{column_type}\"\n end\n\n row << db.type_map.result_value_of( col.schema.declared_data_type, value )\n end\n row.fields = result_fields\n when ResultCode::DONE\n row = nil\n write_blobs\n else\n self.close # must close so that the error message is guaranteed to be pushed into the database handler\n # and we can can call last_error_message on it\n msg = \"SQLITE ERROR #{rc} (#{Amalgalite::SQLite3::Constants::ResultCode.name_from_value( rc )}) : #{@db.api.last_error_message}\"\n raise Amalgalite::SQLite3::Error, msg\n end\n return row\n end",
"def fetch(sql, *params)\n rs = self.execute(sql, *params)\n self.execute(\"flush privileges\") # Always flush in case user wants to alter users\n return [] if self.interpreter.preview? && ! rs\n return rs.fetch_all rescue nil\n end",
"def get_data sql\n #$log.debug \"SQL: #{sql} \"\n columns, *rows = @db.execute2(sql)\n #$log.debug \"XXX COLUMNS #{sql}, #{rows.count} \"\n content = rows\n return content\n end",
"def to_a(cols=[])\n col_info = column_info(cols)\n rows = []\n rows << col_info.keys\n while try { @result_set.next } do\n row = []\n col_info.each do |col, info|\n obj = try{ @result_set.object(info[:index]) }\n case info[:type]\n when :string\n row << obj.to_s\n when :boolean\n row << (obj.to_s =~ /true/i ? true : false)\n when :long\n row << obj.to_i\n when :double\n row << obj.to_f\n else\n log.warning \"Unkown type: #{info[:type]} for #{col}\"\n row << obj.to_s\n end\n end\n rows << row\n end\n rows\n end",
"def typecast(obj)\n case obj \n when Array\n _typecast(convert_format(obj))\n when Hash\n unless @columns\n raise Error, 'PGRow::Parser without columns cannot typecast from a hash'\n end\n _typecast(obj)\n else\n raise Error, 'PGRow::Parser can only typecast arrays and hashes'\n end\n end",
"def exec_query(query, conn = ActiveRecord::Base.connection)\n res = conn.exec_query(query)\n puts res.rows.map { |r| r.map(&:inspect).join(\",\") }.join('\\n')\n res.to_a\nend",
"def all \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name}\")\n \n return self.results_as_objects(results)\n end",
"def run(result)\t\t\n\t\tcolumn_names = result.fields #store the column names\n\t\trow_count = result.num_tuples #get the number of rows in the result\n\t\tinitial_data = Array.new #payload holder\n result.each do |item|\n intial_data << item.to_ary\n end\t\t\n\t\tasrecordset = ASRecordset.new(row_count,column_names,initial_data)\n\t\tresult = asrecordset\n\t\tresults\n\tend",
"def queryUserTable\n @conn.exec( \"SELECT * FROM users\" ) do |result|\n result.each do |row|\n yield row if block_given?\n end\n end\nend",
"def objects(with_table=false, &block)\n hashes(with_table) do |row|\n row = Row.convert(row, self.fetch_fields, with_table)\n (block) ? yield(row) : row\n end\n end",
"def all\n table_name = self.table_name\n \n results = CONNECTION.execute(\"SELECT * FROM '#{table_name}';\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end",
"def each\n rewind\n return self.enum_for(:each) unless block_given?\n csv.each do |row|\n next unless out = convert_row(row)\n yield(out)\n end\n end",
"def query_thredis(prepare_only)\n if prepare_only\n @rows = @connection.redis.sqlprepare(@sql)\n else\n @rows = @connection.redis.sql(@sql, *@params)\n @prepare_only = false\n end\n if @rows.is_a? Integer\n @rows, @columns, @connection.changes = [], [], @rows\n else\n @columns = @rows.shift\n## @rows = convert_type(@rows, @columns)\n end\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects(results)\n\n end",
"def fetch_rows(sql, opts=OPTS, &block)\n db.execute(sql){|result| process_result_set(result, opts, &block)}\n self\n end",
"def insert_sql_each\n return enum_for(__method__) unless block_given?\n each_row do |row|\n yield table_dataset.insert_sql( row )\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = ConvertCurrencyResultSet.new(resp)\n return results\n end",
"def cursor_fetch_rows(sql)\n server_opts = {:server=>@opts[:server] || :read_only}\n cursor = @opts[:cursor]\n hold = cursor[:hold]\n cursor_name = quote_identifier(cursor[:cursor_name] || 'sequel_cursor')\n rows_per_fetch = cursor[:rows_per_fetch].to_i\n\n db.send(*(hold ? [:synchronize, server_opts[:server]] : [:transaction, server_opts])) do \n begin\n execute_ddl(\"DECLARE #{cursor_name} NO SCROLL CURSOR WITH#{'OUT' unless hold} HOLD FOR #{sql}\", server_opts)\n rows_per_fetch = 1000 if rows_per_fetch <= 0\n fetch_sql = \"FETCH FORWARD #{rows_per_fetch} FROM #{cursor_name}\"\n cols = nil\n # Load columns only in the first fetch, so subsequent fetches are faster\n execute(fetch_sql) do |res|\n cols = fetch_rows_set_cols(res)\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n loop do\n execute(fetch_sql) do |res|\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n end\n rescue Exception => e\n raise\n ensure\n begin\n execute_ddl(\"CLOSE #{cursor_name}\", server_opts)\n rescue\n raise e if e\n raise\n end\n end\n end\n end",
"def infer_types!\n types = Array.new(ncols)\n each do |row| merge_types(types, row[:*].infer_string_types) end\n types.each.with_index do |type, i|\n colname = @colnames[i]\n if type <= Integer then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Integer(@rows[rowid][colname]) end\n elsif type <= Float then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Float(@rows[rowid][colname]) end\n end\n end\n self\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = QUIZ.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end",
"def yield_hash_rows(res, cols)\n res.ntuples.times do |recnum|\n converted_rec = {}\n cols.each do |fieldnum, type_proc, fieldsym|\n value = res.getvalue(recnum, fieldnum)\n converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value\n end\n yield converted_rec\n end\n end",
"def yield_hash_rows(res, cols)\n res.ntuples.times do |recnum|\n converted_rec = {}\n cols.each do |fieldnum, type_proc, fieldsym|\n value = res.getvalue(recnum, fieldnum)\n converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value\n end\n yield converted_rec\n end\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name}\")\n\n results_as_objects = []\n\n results.each do |results_hash|\n results_as_objects << self.new(results_hash)\n end\n\n return results_as_objects\n end",
"def with_sql_each(sql)\n if row_proc\n super(sql) do |obj|\n obj.forbid_lazy_load if obj.is_a?(InstanceMethods)\n yield obj\n end\n else\n super\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def execute_query(query)\n ActiveRecord::Base.connection.select_all(query)\n end",
"def query_return_array(sql, *binds)\n mysql.fetch(sql, *binds).all\n end",
"def grab_rows(field, src_table_name = TABLE_NAME, num_rows = ROWS_PER_TRANSACTION)\n LOGGER.info \"Creating select statement based on field `#{field[:name]}` (#{field[:type]})\"\n \n if !(field[:type] =~ /int/).nil?\n LOGGER.info \"Using integer type for select.\"\n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min].to_i.to_s), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max].to_i.to_s), \n Mysql::escape_string(field[:name]), \n num_rows]\n elsif !(field[:type] =~ /datetime/).nil?\n LOGGER.info \"Using datetime type for select.\" \n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min].strftime(MYSQL_DATETIME_FORMAT)), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max].strftime(MYSQL_DATETIME_FORMAT)), \n Mysql::escape_string(field[:name]), \n num_rows]\n else\n LOGGER.info \"Using default type for select, this isn't expected.\"\n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min]), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max]), \n Mysql::escape_string(field[:name]), \n num_rows] \n end\n \n LOGGER.debug \"SQL: #{sql}\"\n dbres = do_sql_command(sql)\n dbres\nend",
"def execute(input_set = nil)\n resp = super(input_set)\n results = DietResultSet.new(resp)\n return results\n end",
"def run(*args)\n connection.execute(sanitize(*args)).tap do |res|\n res.type_map = type_map\n end\n end"
] |
[
"0.71405363",
"0.6875436",
"0.677563",
"0.6739059",
"0.6563565",
"0.6408319",
"0.64009625",
"0.63649267",
"0.6305872",
"0.6287106",
"0.6234882",
"0.6155711",
"0.6152093",
"0.6051693",
"0.59737986",
"0.5910608",
"0.5879965",
"0.58766526",
"0.58493996",
"0.58286136",
"0.5821123",
"0.580758",
"0.57958335",
"0.5793255",
"0.57137823",
"0.57045764",
"0.5703174",
"0.5683506",
"0.5674689",
"0.566416",
"0.56593555",
"0.56432074",
"0.5633276",
"0.56137294",
"0.56134456",
"0.5570312",
"0.5560703",
"0.5541878",
"0.5535848",
"0.55357957",
"0.5534565",
"0.55164397",
"0.55125964",
"0.54880553",
"0.54864925",
"0.54421824",
"0.5431021",
"0.5429139",
"0.5423493",
"0.5420696",
"0.5414729",
"0.54084843",
"0.53993016",
"0.5397541",
"0.5392444",
"0.53863114",
"0.53841513",
"0.5377186",
"0.5369497",
"0.53630364",
"0.5362114",
"0.5358766",
"0.5342901",
"0.53348815",
"0.53251415",
"0.5324192",
"0.5312106",
"0.52936965",
"0.52933425",
"0.5281209",
"0.5277133",
"0.52735955",
"0.5272082",
"0.52704996",
"0.5257163",
"0.5256555",
"0.5249971",
"0.523159",
"0.5205425",
"0.5201908",
"0.52012944",
"0.5195386",
"0.51803213",
"0.517308",
"0.51702744",
"0.51630485",
"0.51376855",
"0.5136148",
"0.5135375",
"0.51327276",
"0.5125079",
"0.5125079",
"0.5124061",
"0.5095421",
"0.50852954",
"0.5084282",
"0.5083957",
"0.5082148",
"0.5081181",
"0.5074579"
] |
0.61954874
|
11
|
Use a cursor for paging.
|
def paged_each(opts=OPTS, &block)
use_cursor(opts).each(&block)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def page_cursor\n @page_cursor ||= pages.to_enum.lazy\n end",
"def fetch(cursor: -1, count: 50, **options)\n cursor, count = cursor.to_i, count.to_i\n window = count + 2 # Fetch extra two elements for concrete next/prev links\n\n if cursor >= 0\n page = @scope.where(@cursor_key => -Float::INFINITY..cursor).limit(window)\n else\n cursor = cursor == -1 ? 0 : cursor.abs\n page = @scope.where(@cursor_key => cursor..Float::INFINITY).limit(window)\n end\n\n # Ensure result set is in correct order\n page = page.order(@cursor_key => :desc)\n\n Page.new(page, cursor, count: count)\n end",
"def pagy_cursor(collection, vars={}, options={})\n pagy = Pagy::Cursor.new(pagy_cursor_get_vars(collection, vars))\n\n items = pagy_cursor_get_items(collection, pagy, pagy.position)\n pagy.has_more = pagy_cursor_has_more?(items, pagy)\n\n return pagy, items\n end",
"def cursor\n relation = add_params(cursorMark: '*')\n\n # Sort must include a sort on unique key (id).\n if /\\bid\\b/ =~ params[:sort]\n relation\n else\n relation.sort(params[:sort], 'id ASC')\n end\n end",
"def paginate(cursor, opts)\n\n opts = Ruote.keys_to_s(opts)\n\n return cursor.count if opts['count']\n\n cursor.sort(\n '_id', opts['descending'] ? Mongo::DESCENDING : Mongo::ASCENDING)\n\n cursor.skip(opts['skip'])\n cursor.limit(opts['limit'])\n\n from_mongo(cursor.to_a)\n end",
"def begin; pager.offset page; end",
"def cursor(buffer_offset)\n new_cursor = BufferCursor.new(@buffer, buffer_offset)\n new_cursor.push_name(\"space[#{space.name}]\")\n new_cursor.push_name(\"page[#{name}]\")\n\n if block_given?\n # Call the block once and return its return value.\n yield new_cursor\n else\n # Return the cursor itself.\n new_cursor\n end\n end",
"def auto_paging_each(&blk)\n return enum_for(:auto_paging_each) unless block_given?\n\n page = self\n\n loop do\n page.each(&blk)\n page = page.next_search_result_page\n\n break if page.empty?\n end\n end",
"def cursor\n CursorProxy.new(self)\n end",
"def cursor\n Cursor.new(@meta)\n end",
"def each(query_options={}, start_page=0, limit=15) # :yields: rows, skip, page, max_page, max_rows\n pages(@default_query_options.merge(query_options), start_page, limit, true, false) do |rows, skip, page, max_page ,max_rows|\n yield [rows, skip, page, max_page ,max_rows]\n end\n end",
"def needs_cursor?; end",
"def pager(&block)\n pager = self[KEY]\n return pager unless block\n self[KEY].start(&block)\n end",
"def next_page\n set RGhost::Cursor.next_page\n end",
"def cursor\n Cursor.new(self)\n end",
"def next_cursor\n @result[:next_cursor]\n end",
"def each\n @cursor = nil\n session = client.send(:get_session, @options)\n server = cluster.next_primary(nil, session)\n result = send_initial_query(server, session, context: Operation::Context.new(client: client, session: session))\n result = send_fetch_query(server, session) unless inline?\n @cursor = Cursor.new(view, result, server, session: session)\n if block_given?\n @cursor.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def change_cursor\n cursor = text_cursor\n yield cursor\n self.text_cursor = cursor\n end",
"def step_cursor()\r\n unless @@busy_cursors \r\n self.class.send(:get_cursors)\r\n end\r\n \r\n @cursor_index = (@cursor_index + 1) % 8\r\n UI.set_cursor(@@busy_cursors[@cursor_index]) if @mouse_in_viewport\r\n end",
"def cursor!\n cursor(true)\n end",
"def cursor!\n cursor(true)\n end",
"def fetch; @data = pager.fetcher[self.begin, pager.per_page]; end",
"def open\n pager = best_available\n yield pager\n rescue StopPaging\n ensure\n pager.close if pager\n end",
"def cursor\n @application.cursor\n end",
"def cursor(value)\n attributes[:cursor] = value\n end",
"def cursor_query_for(sql, limit, offset)\n cursor = \"__arel_cursor_#{rand(0xffff)}\"\n\n return <<-eosql\n DECLARE #{cursor} SCROLL CURSOR FOR #{sql} FOR READ ONLY\n SET CURSOR ROWS #{limit} FOR #{cursor}\n OPEN #{cursor}\n FETCH ABSOLUTE #{offset+1} #{cursor}\n CLOSE #{cursor}\n DEALLOCATE #{cursor}\n eosql\n end",
"def each\n # If the caching cursor is closed and was not fully iterated,\n # the documents we have in it are not the complete result set and\n # we have no way of completing that iteration.\n # Therefore, discard that cursor and start iteration again.\n # The case of the caching cursor not being closed and not having\n # been fully iterated isn't tested - see RUBY-2773.\n @cursor = if use_query_cache? && cached_cursor && (\n cached_cursor.fully_iterated? || !cached_cursor.closed?\n )\n cached_cursor\n else\n session = client.send(:get_session, @options)\n select_cursor(session).tap do |cursor|\n if use_query_cache?\n # No need to store the cursor in the query cache if there is\n # already a cached cursor stored at this key.\n QueryCache.set(cursor, **cache_options)\n end\n end\n end\n\n if use_query_cache?\n # If a query with a limit is performed, the query cache will\n # re-use results from an earlier query with the same or larger\n # limit, and then impose the lower limit during iteration.\n limit_for_cached_query = respond_to?(:limit) ? QueryCache.normalized_limit(limit) : nil\n end\n\n if block_given?\n # Ruby versions 2.5 and older do not support arr[0..nil] syntax, so\n # this must be a separate conditional.\n cursor_to_iterate = if limit_for_cached_query\n @cursor.to_a[0...limit_for_cached_query]\n else\n @cursor\n end\n\n cursor_to_iterate.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def paginator\n per_page = @ruhoh.db.config(\"paginator\")[\"per_page\"]\n current_page = master.context[\"page\"]['current_page'].to_i rescue 0\n current_page = current_page.zero? ? 1 : current_page\n offset = (current_page-1)*per_page\n\n page_batch = all[offset, per_page]\n raise \"Page does not exist\" unless page_batch\n page_batch\n end",
"def cursor(*options)\n options = combine_options(*options)\n apply_offset(options)\n @cursor_loc ||= {}\n @cursor_loc[:x] = options[:to][:left]\n @cursor_loc[:y] = options[:to][:top]\n \n compatible_call :cursor, @cursor_loc\n end",
"def rows(opts={'start' => nil, 'limit' => nil})\n Cursor.new({'collection' => link('rows'),\n 'start' => opts['start'],\n 'limit' => opts['limit']}.update(@opts))\n end",
"def open\n pager = best_available\n yield pager\n rescue StopPaging\n ensure\n pager.close if pager\n end",
"def process(cursor, batch) end",
"def next\n return nil unless next?\n return nil if end_cursor.nil?\n ensure_service!\n query.start_cursor = cursor.to_grpc # should always be a Cursor...\n query.offset = 0 # Never carry an offset across batches\n unless query.limit.nil?\n # Reduce the limit by the number of entities returned in the current batch\n query.limit.value -= count\n end\n query_res = service.run_query query, namespace, read_time: read_time\n self.class.from_grpc query_res, service, namespace, query, read_time\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def paginate_workitems(cursor, opts)\n\n docs = paginate(cursor, opts)\n\n docs.is_a?(Array) ? docs.collect { |h| Ruote::Workitem.new(h) } : docs\n end",
"def paginator; end",
"def needs_cursor?\r\n \ttrue\r\n \t end",
"def cursor\n @data['cursor']\n end",
"def cursor\n @data['cursor']\n end",
"def solr_cursor_page_body(cursor_mark)\n retries = 0\n req = {}\n cn_fields = \"#{facet_field},title_display,title_vern_display,author_display,author_s,id,pub_created_vern_display,pub_created_display,holdings_1display\"\n loop do\n cn_request = \"#{core_url}select?q=*%3A*&fl=#{cn_fields}&wt=json&indent=true&defType=edismax&facet=false&sort=id%20asc&rows=#{rows}&cursorMark=#{cursor_mark}\"\n resp = conn.get cn_request.to_s\n req = JSON.parse(resp.body)\n break if req['response']\n Rails.logger.error \"Call number browse generation failed at iteration with cursor mark #{cursor_mark}. Response from solr was: #{resp}\"\n raise SolrResponseError if retries >= 2\n retries += 1\n end\n req\n end",
"def paginator=(_arg0); end",
"def paginate!(*args) # @private :nodoc:\n options = args.extract_options!\n self.items_per_page = options[:per_page] || 50\n self.current_page = args.first || 1\n self.limit_value = items_per_page\n self.offset_value = items_per_page * (current_page - 1)\n end",
"def browse_from(cursor, hits_per_page = 1000, request_options = {})\n client.post(Protocol.browse_uri(name), { :cursor => cursor, :hitsPerPage => hits_per_page }.to_json, :read, request_options)\n end",
"def next; pager.page(page + 1); end",
"def pagy_get_items(collection, pagy)\n # this should work with ActiveRecord, Sequel, Mongoid...\n collection.offset(pagy.offset).limit(pagy.items)\n end",
"def fetch_with_pagination(connection, entity, per_page)\n offset = 0\n records = []\n\n begin\n set = handle_timeouts(MAX_TIMEOUTS, \"loading tasks (offset: #{offset})\") { connection.send(entity, offset, \"yes\", \"owner,coworker,reporter\") }\n\n records += set\n offset += per_page\n end until set.empty?\n\n records\nend",
"def cursor_pageup\r\n end",
"def each(&block)\n if @rows\n # we've been memoized\n @rows.each(&block)\n \n elsif start_record\n # we represent a single page\n # do the fetching and iterate\n @rows = fetch_rows\n\n @rows.each(&block)\n else\n # we represent the whole set of possible records\n # fetch repeatedly, in pages\n page_number = 1\n records_per_page = 100\n \n loop {\n # create a scope for this page\n inner_scope = page(page_number, records_per_page)\n \n # fetch the records as an array\n records = inner_scope.to_a\n \n # pass them to the caller\n records.each(&block)\n \n # is this the last page?\n if records.size < records_per_page\n # was this the first page?\n if page_number == 1\n # this is the only page\n # memoize\n @rows = records\n end\n \n # regardless, we're done\n break\n end\n \n page_number += 1\n }\n \n end\n \n self\n end",
"def cursor\n @cursor ||= Vedeu::Editor::Cursor.new(y: 0,\n x: 0,\n by: by,\n bx: bx,\n byn: byn,\n bxn: bxn)\n end",
"def needs_cursor?\n true\n end",
"def process( renderer, page, input )\n # Start a new cursor for this page\n Cursor.new(renderer, page).start_for(input)\n end",
"def fetch_cursor(name)\n connection.fetch_cursor(name)\n end",
"def pager; end",
"def query_with_cursor(sql_query, limit = nil)\n places = []\n transaction do\n ActiveRecord::Base.uncached do\n cursor = connection.select_value(sql_query)\n place = nil\n begin\n results = many.next_with_attributes(cursor)\n unless results.empty?\n place = with_details(results)\n places << place\n if (limit)\n limit -= 1\n place = nil if limit == 0\n end\n else\n place = nil\n end\n end while !place.nil?\n end\n end\n places\n end",
"def needs_cursor?\n \ttrue\n end",
"def page\n GitFlow.pager\n yield\n end",
"def cursor( *args, & block )\n \n cursor_instance = ::Persistence::Cursor.new( self )\n \n if args.count > 0\n cursor_instance.persisted?( *args )\n end\n \n if block_given?\n cursor_instance = cursor_instance.instance_eval( & block )\n cursor_instance.close\n end\n \n return cursor_instance\n \n end",
"def each(&block)\n @current_page += 1\n fetch_current_page if !@fetched_current_page\n @items.each { |i| block.call i } \n @fetched_current_page = false\n end",
"def query_paging_custom(query, offset, limit)\n apply_paging(query, offset, limit)\n end",
"def paging_find(start=nil, limit=nil)\n start = start.is_a?(Integer) ? start : (params[:start] || 0).to_i\n limit = limit.is_a?(Integer) ? limit : (params[:limit] || 100).to_i\n {:offset=>start,:limit=>limit}\n end",
"def b_cursor\n Cursor.new(\n Null,\n f_each.inject(Null) { |l, data| Node.new data, l }\n )\n end",
"def create_cursor(cursor_class, table, options = {})\n cursor = cursor_class.new self, table\n cursor.prepare_fetch options\n save_cursor cursor\n cursor\n end",
"def cursor_location\n compatible_call :cursor_location\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def needs_cursor?\n true\n end",
"def cursor_pagedown\n @mode = (@mode + 1) % TABLE.size\n refresh\n end",
"def fetch_with_pagination(connection, entity, per_page)\n offset = 0\n records = []\n page = 1\n\n begin\n log.info \" Requesting set #{page} (limit #{per_page}, offset #{offset})\"\n set = handle_timeouts(MAX_CONSECUTIVE_TIMEOUTS, \"loading tasks (offset: #{offset})\") { connection.send(entity, offset, \"yes\", \"owner,coworker,reporter\") }\n log.info \" Fetched #{set.size} records\"\n\n records += set\n offset += per_page\n page += 1\n end until set.size < per_page\n\n records\n end",
"def cursor_pageup\n end",
"def cursor_pageup\n end",
"def select_cursor(options)\n cursor = ResultFetcher.new(self, options)\n unless options[:type_cast] == false\n cursor = TypeCastingCursor.new(self, options[:table], cursor)\n end\n cursor\n end",
"def run_cursor_loop(connection, &block)\n Backfiller.log 'Start cursor loop'\n\n total_count = 0\n cursor = build_cursor(connection)\n\n loop do\n finished, count = cursor.transaction do\n run_fetch_loop(cursor, &block)\n end\n\n total_count += count\n\n Backfiller.log \"Total processed #{total_count}\"\n break if finished\n end\n end",
"def parallel_scan(num_cursors, opts={})\n cmd = BSON::OrderedHash.new\n cmd[:parallelCollectionScan] = self.name\n cmd[:numCursors] = num_cursors\n result = @db.command(cmd, command_options(opts))\n\n result['cursors'].collect do |cursor_info|\n seed = {\n :cursor_id => cursor_info['cursor']['id'],\n :first_batch => cursor_info['cursor']['firstBatch'],\n :pool => @connection.pinned_pool\n }\n Cursor.new(self, seed.merge!(opts))\n end\n\n end",
"def fetch_cursor(name='csr')\n raise ArgumentError, \"Cursor #{name} not open\" unless @cursors.has_key?(name)\n fetch_buffer(name) if @cursors[name][:state] == :empty\n return nil if @cursors[name][:state] == :eof\n @cursors[name][:state] = :empty if @cursors[name][:buffer].size <= 1\n row = @cursors[name][:buffer].shift\n row.is_a?(Hash) ? row.symbolize_keys : row\n end",
"def mqlread_with_cursor(query, cursor, options={})\n params = { :query => query.to_json, :lang => \"/lang/#{@query_options[:lang]}\", :limit => @query_options[:limit], :cursor => cursor }.merge(options)\n response = get(surl('mqlread'), params, format: :json)\n {result: response['result'], cursor: response['cursor']}\n end",
"def show_cursor!\n Vedeu.bind(:_show_cursor_) do |name|\n Vedeu::Cursors::Cursor.show_cursor(name)\n end\n\n Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)\n end",
"def f_cursor\n Cursor.new(\n b_each.inject(Null) { |l, data| Node.new data, l },\n Null\n )\n end",
"def paginate(options={})\n pg_options, find_options = options.partition{|k,v| [:page, :per_page, :total_entries].include?(k)}\n \n pg_options[:page] ||= 1\n pg_options[:per_page] ||= per_page\n \n WillPaginate::Collection.create(pg_options[:page], pg_options[:per_page], pg_options[:total_entries]) do |pager|\n find_options[:params] = (find_options[:params] || {}).merge(:offset => pager.offset, :limit => pager.per_page) \n \n arr = find(:all, find_options) || []\n if pg_options[:total_entries]\n pager.total_entries = pg_options[:total_entries]\n else \n pager.total_entries = arr.size > pager.per_page ? arr.size : count(find_options[:params])\n end\n \n if arr.size > per_page\n pager.replace arr[pager.offset, pager.per_page]\n else\n pager.replace arr\n end\n end\n end",
"def needs_cursor?\n return true\n end",
"def paginated_each(options, &block)\n search = options.delete(:search)\n unless search == true\n proxy = create_collection_proxy(options)\n else\n proxy = create_search_collection_proxy(options)\n end\n proxy.paginated_each(options, &block)\n end",
"def needs_cursor?\n\t\ttrue\n\tend",
"def needs_cursor?\n\t\ttrue\n\tend",
"def load\n return self if @entity[:next].nil? || @entity[:results].length == @entity[:total]\n\n np = self\n until np.next.nil?\n np = np.next_page\n @entity[:results].concat(np.results.map(&:to_h))\n end\n @entity[:next] = nil\n @entity[:per_page] = @entity[:total]\n self\n end",
"def cursor_pagedown\r\n end",
"def page_break\n cmd :page\n end",
"def apply_paging(query, offset, limit)\n validate_paging(offset, limit)\n query.offset(offset).limit(limit)\n end",
"def each_with_attachments(query_options={}, start_page=0, limit=15) # :yields: rows, skip, page, max_page, max_rows\n pages(@default_query_options.merge(query_options), start_page, limit, true, true) do |rows, skip, page, max_page ,max_rows|\n yield [rows, skip, page, max_page ,max_rows]\n end\n end",
"def cursors\n @cursors ||= {}\n end",
"def each_page(&block); end",
"def cursor_pagedown\n end"
] |
[
"0.71513885",
"0.69717926",
"0.6739144",
"0.671059",
"0.6684843",
"0.65932316",
"0.6454364",
"0.6418386",
"0.63696945",
"0.6352421",
"0.6315126",
"0.630869",
"0.6179992",
"0.6146985",
"0.6133262",
"0.61300606",
"0.6117421",
"0.6071255",
"0.6042965",
"0.6017693",
"0.6017693",
"0.59853256",
"0.5982256",
"0.59647995",
"0.5961931",
"0.59488875",
"0.5941251",
"0.5928954",
"0.59238636",
"0.591545",
"0.59104466",
"0.58860445",
"0.58732164",
"0.5857362",
"0.5857362",
"0.5857362",
"0.5857362",
"0.5857362",
"0.5857362",
"0.5857362",
"0.5840111",
"0.58263725",
"0.5803384",
"0.57753116",
"0.57753116",
"0.5772512",
"0.5771455",
"0.5769979",
"0.57679266",
"0.5758025",
"0.5753732",
"0.5751044",
"0.57473814",
"0.5742406",
"0.5727558",
"0.5725631",
"0.57152647",
"0.5712162",
"0.5703941",
"0.5701915",
"0.56964946",
"0.5683745",
"0.5682511",
"0.5678783",
"0.56779325",
"0.5669306",
"0.5659596",
"0.5656049",
"0.5641761",
"0.560847",
"0.560847",
"0.560847",
"0.560847",
"0.560847",
"0.560847",
"0.560847",
"0.5608101",
"0.56080353",
"0.56069267",
"0.56069267",
"0.5598014",
"0.5591851",
"0.5572559",
"0.55706674",
"0.55633914",
"0.55623406",
"0.55593485",
"0.55566794",
"0.5542525",
"0.55419254",
"0.5541784",
"0.5541784",
"0.5540879",
"0.5532139",
"0.55306363",
"0.55267334",
"0.5517435",
"0.550094",
"0.54836255",
"0.5480549"
] |
0.68160516
|
2
|
Replace the WHERE clause with one that uses CURRENT OF with the given cursor name (or the default cursor name). This allows you to update a large dataset by updating individual rows while processing the dataset via a cursor: DB[:huge_table].use_cursor(:rows_per_fetch=>1).each do |row| DB[:huge_table].where_current_of.update(:column=>ruby_method(row)) end
|
def where_current_of(cursor_name='sequel_cursor')
clone(:where=>Sequel.lit(['CURRENT OF '], Sequel.identifier(cursor_name)))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_where(table, what, where, *bindvars)\n sql = \"update #{table.name}\\nset #{what} where #{where}\"\n#$stderr.puts sql\n db.do(sql, *bindvars)\n end",
"def current_to_false_sql_statement\n klass = self.class\n lock_column_name = klass.locking_column\n lock_value = current_lock_value\n lock_column = if lock_value\n klass.columns.detect { |c| c.name == lock_column_name }\n else\n nil\n end\n quoted_lock_column = klass.connection.quote_column_name(lock_column_name)\n\n \"UPDATE #{klass.quoted_table_name} \" \\\n \"SET \\\"is_current\\\" = #{klass.connection.quote(false)} \".tap do |sql|\n sql << \"WHERE #{klass.quoted_primary_key} = \" \\\n \"#{klass.connection.quote(@_before_to_new_record_values[:id])}\"\n\n if lock_value\n sql << \" AND \\\"is_current\\\" = #{klass.connection.quote(true)}\"\n sql << \" AND #{quoted_lock_column} = #{klass.connection.quote(lock_value)}\"\n end\n end\n end",
"def apply_with_context(sql,all_cols,keys_in_all_cols)\n hits = {}\n @pending_rcs.each do |rc|\n hits[rc.key] = rc\n end \n hist = []\n n = 2\n pending = 0\n skipped = false\n noted = false\n last_row = nil\n @db1.fetch(sql,all_cols + [\"__coopy_tag__\"]) do |row|\n tag = row.pop.to_i\n k = keyify(row.values_at(*keys_in_all_cols))\n if hits[k]\n emit_skip(row) if skipped\n hist.each do |row0|\n cells = row0.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"\",cells)\n rc.columns = @rc_columns\n @patch.apply_row(rc)\n end\n hist.clear\n pending = n\n @patch.apply_row(hits[k])\n hits.delete(k)\n skipped = false\n noted = true\n elsif tag == 1\n # ignore redundant row\n elsif pending>0\n emit_skip(row) if skipped\n cells = row.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"\",cells)\n rc.columns = @rc_columns\n @patch.apply_row(rc)\n pending = pending-1\n skipped = false\n else\n hist << row\n if hist.length>n\n skipped = true\n last_row = row\n hist.shift\n end\n end\n end\n emit_skip(last_row) if skipped and noted\n end",
"def apply_with_context(sql,all_cols,keys_in_all_cols)\n hits = {}\n @pending_rcs.each do |rc|\n hits[rc.key] = rc\n end \n hist = []\n n = 2\n pending = 0\n skipped = false\n noted = false\n last_row = nil\n @db1.fetch(sql,all_cols + [\"__coopy_tag__\"]) do |row|\n tag = row.pop.to_i\n k = keyify(row.values_at(*keys_in_all_cols))\n if hits[k]\n emit_skip(row) if skipped\n hist.each do |row0|\n cells = row0.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"\",cells)\n rc.columns = @rc_columns\n @patch.apply_row(rc)\n end\n hist.clear\n pending = n\n @patch.apply_row(hits[k])\n hits.delete(k)\n skipped = false\n noted = true\n elsif tag == 1\n # ignore redundant row\n elsif pending>0\n emit_skip(row) if skipped\n cells = row.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"\",cells)\n rc.columns = @rc_columns\n @patch.apply_row(rc)\n pending = pending-1\n skipped = false\n else\n hist << row\n if hist.length>n\n skipped = true\n last_row = row\n hist.shift\n end\n end\n end\n emit_skip(last_row) if skipped and noted\n end",
"def apply_with_context(sql,all_cols,keys_in_all_cols)\n hits = {}\n @pending_rcs.each do |rc|\n hits[rc.key] = rc\n end \n hist = []\n n = 2\n pending = 0\n skipped = false\n noted = false\n last_row = nil\n @db1.fetch(sql,all_cols + [\"__coopy_tag__\"]) do |row|\n tag = row.pop.to_i\n k = keyify(row.values_at(*keys_in_all_cols))\n if hits[k]\n emit_skip(row) if skipped\n hist.each do |row0|\n cells = row0.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"\",cells)\n rc.columns = @rc_columns\n @patch.apply_row(rc)\n end\n hist.clear\n pending = n\n @patch.apply_row(hits[k])\n hits.delete(k)\n skipped = false\n noted = true\n elsif tag == 1\n # ignore redundant row\n elsif pending>0\n emit_skip(row) if skipped\n cells = row.map{|v| { :txt => v, :value => v, :cell_mode => \"\" }}\n rc = RowChange.new(\"\",cells)\n rc.columns = @rc_columns\n @patch.apply_row(rc)\n pending = pending-1\n skipped = false\n else\n hist << row\n if hist.length>n\n skipped = true\n last_row = row\n hist.shift\n end\n end\n end\n emit_skip(last_row) if skipped and noted\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def exec_update(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def cursor_query_for(sql, limit, offset)\n cursor = \"__arel_cursor_#{rand(0xffff)}\"\n\n return <<-eosql\n DECLARE #{cursor} SCROLL CURSOR FOR #{sql} FOR READ ONLY\n SET CURSOR ROWS #{limit} FOR #{cursor}\n OPEN #{cursor}\n FETCH ABSOLUTE #{offset+1} #{cursor}\n CLOSE #{cursor}\n DEALLOCATE #{cursor}\n eosql\n end",
"def prepared_update(cols)\n cached_prepared_statement(:update, prepared_columns(cols)){prepare_statement(filter(prepared_statement_key_array(primary_key)), :update, prepared_statement_key_hash(cols))}\n end",
"def prepared_refresh\n # SEQUEL5: Remove\n cached_prepared_statement(:fixed, :refresh){prepare_explicit_statement(naked.clone(:server=>dataset.opts.fetch(:server, :default)).where(prepared_statement_key_array(primary_key)), :first)}\n end",
"def open_cursor_with_sql(name, *sql_and_args, &block)\n connection.cursor_eachrow(sql_and_args, name, &block)\n end",
"def exec_update(sql, name = nil, binds = []) #:nodoc:\r\n log(sql, \"update\", binds) { query(sql, binds) }\r\n end",
"def cursor_location\n compatible_call :cursor_location\n end",
"def change_cursor\n cursor = text_cursor\n yield cursor\n self.text_cursor = cursor\n end",
"def cur_row=(cur_row)\n raise('overrides detected; must use cur_raw_row= instead') if compute_cur_row(cur_row) != cur_row\n\n @cur_raw_row = cur_row\n @cur_row = cur_row\n end",
"def prepare_update_statement(o)\n if o.offset || has_group_by_and_having?(o) ||\n has_join_sources?(o) && has_limit_or_offset_or_orders?(o)\n super\n else\n o\n end\n end",
"def update\n $all_columns.each do |col|\n col[0] = col[1].call unless col[1].nil?\n end\nend",
"def current(query_date = Date.current)\n klass.where(\n current_condition(query_date: query_date, table: arel_table),\n )\n end",
"def sql_update(sql)\n exec(sql)\n # return affected rows.\n end",
"def update where: , set: {}, **arg\n\t\t# In OrientDB V.3 the database only returns the affected rid's \n\t\t# We have to update the contents manually, this is done in the execute-block\n\t\tquery( kind: :update, set: set.merge(arg), where: where).execute{|y| y[:$current].reload!}\n\tend",
"def add_limit_offset!(statement, limit, offset, bind_values)\n if limit && offset > 0\n statement.replace \"select * from (select raw_sql_.*, rownum raw_rnum_ from (#{statement}) raw_sql_ where rownum <= ?) where raw_rnum_ > ?\"\n bind_values << offset + limit << offset\n elsif limit\n statement.replace \"select raw_sql_.* from (#{statement}) raw_sql_ where rownum <= ?\"\n bind_values << limit\n elsif offset > 0\n statement.replace \"select * from (select raw_sql_.*, rownum raw_rnum_ from (#{statement}) raw_sql_) where raw_rnum_ > ?\"\n bind_values << offset\n end\n end",
"def update(sql, name = nil) end",
"def where(&block)\n if @options[:join]\n context = JoinContext.new.freeze\n else\n context = Mao::Filter::Table.new(self, false).freeze\n end\n\n with_options(:where => context.instance_exec(&block).finalize)\n end",
"def update_target_cursor\n @cursor.update_target(@active_battler, @using_skill)\n end",
"def build_cursor(connection)\n Backfiller::Cursor.new(connection, 'backfill_cursor', task.select_sql)\n end",
"def atomic_cursor( *args )\n \n return cursor( *args ).atomize\n \n end",
"def update!(**args)\n @cursor = args[:cursor] if args.key?(:cursor)\n @partition = args[:partition] if args.key?(:partition)\n end",
"def prepared_lookup\n # SEQUEL5: Remove\n cached_prepared_statement(:fixed, :lookup){prepare_explicit_statement(filter(prepared_statement_key_array(primary_key)), :first)}\n end",
"def qualify_cur(col)\n qualify(self[:model].table_name, col)\n end",
"def current_or_future_on(query_date = Date.current)\n current_cond =\n current_condition(query_date: query_date, table: arel_table)\n future_cond =\n future_condition(query_date: query_date, table: arel_table)\n\n klass.where(current_cond.or(future_cond))\n end",
"def cursor_eachrow(sql, name='csr', transaction=true, buffer_size=10000)\n count = 0\n begin\n begin_db_transaction if transaction\n open_cursor(sql, name, buffer_size)\n while (row = fetch_cursor(name)) do\n count+= 1\n #puts \"EACH CSR #{row.inspect}\"\n yield row\n end\n close_cursor(name)\n ensure\n commit_db_transaction if transaction\n end\n count\n end",
"def process(cursor, batch) end",
"def update_without_callbacks\r\n where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r\n \"(#{connection.quote_column_name(pair[0])} = #{pair[1]})\"\r\n end\r\n where_clause = where_clause_terms.join(\" AND \")\r\n connection.update(\r\n \"UPDATE #{self.class.quoted_table_name} \" +\r\n \"SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} \" +\r\n \"WHERE #{where_clause}\",\r\n \"#{self.class.name} Update\"\r\n )\r\n return true\r\n end",
"def each( & block )\n \n return atomic_cursor.each( & block )\n\n end",
"def log_current_cusiness_context_query\n qc_current_inspection = get_current_inspection_record( session[:user_id].id, session[:qc_inspection_type_code] )\n if qc_current_inspection.nil?\n ActiveRecord::Base.connection.execute(\"INSERT INTO qc_current_inspections\n (user_id, qc_inspection_type_code, qc_business_context_query, columns_list)\n VALUES(#{session[:user_id].id}, '#{session[:qc_inspection_type_code]}',\n '#{dm_session[:search_engine_query_definition].gsub(/'/, \"''\")}', '#{session[:columns_list].to_yaml}')\")\n else\n ActiveRecord::Base.connection.execute(ActiveRecord::Base.extend_update_sql_with_request(\"UPDATE qc_current_inspections\n SET qc_business_context_query = '#{dm_session[:search_engine_query_definition].gsub(/'/, \"''\")}',\n columns_list = '#{session[:columns_list].to_yaml}'\n WHERE user_id = #{session[:user_id].id} AND qc_inspection_type_code = '#{session[:qc_inspection_type_code]}' \"))\n end\n end",
"def rewrite_query # :nodoc:\n if timestamp = compute_mtime\n append_query(timestamp.to_i.to_s)\n end\n end",
"def execute_and_clear(sql, name, binds)\n ret = nil\n if sql.include? \"SELECT \\\"users\\\".* FROM \\\"users\\\"\" and sql.include? 'LIMIT'\n logger.debug \"Returning in-memory users\"\n # instrumentation is inserted at #log, so we fake the call here\n log(sql, name, binds) { io_sleep }\n count = sql.scan(/LIMIT\\s(\\d+)/).last.last.to_i\n ret = ActiveRecord::Result.new(users[:cols],users[:rows][0..(count-1)])\n elsif sql.include? \"SELECT \\\"cities\\\".* FROM \\\"cities\\\"\" and sql.include? 'LIMIT'\n logger.debug \"Returning in-memory cities\"\n # instrumentation is inserted at #log, so we fake the call here\n log(sql, name, binds) { io_sleep } \n count = sql.scan(/LIMIT\\s(\\d+)/).last.last.to_i\n ret = ActiveRecord::Result.new(cities[:cols],cities[:rows][0..(count-1)])\n else\n result = without_prepared_statement?(binds) ? exec_no_cache(sql, name, binds) :\n exec_cache(sql, name, binds)\n ret = yield result\n result.clear\n end\n ret\n end",
"def each\n # If the caching cursor is closed and was not fully iterated,\n # the documents we have in it are not the complete result set and\n # we have no way of completing that iteration.\n # Therefore, discard that cursor and start iteration again.\n # The case of the caching cursor not being closed and not having\n # been fully iterated isn't tested - see RUBY-2773.\n @cursor = if use_query_cache? && cached_cursor && (\n cached_cursor.fully_iterated? || !cached_cursor.closed?\n )\n cached_cursor\n else\n session = client.send(:get_session, @options)\n select_cursor(session).tap do |cursor|\n if use_query_cache?\n # No need to store the cursor in the query cache if there is\n # already a cached cursor stored at this key.\n QueryCache.set(cursor, **cache_options)\n end\n end\n end\n\n if use_query_cache?\n # If a query with a limit is performed, the query cache will\n # re-use results from an earlier query with the same or larger\n # limit, and then impose the lower limit during iteration.\n limit_for_cached_query = respond_to?(:limit) ? QueryCache.normalized_limit(limit) : nil\n end\n\n if block_given?\n # Ruby versions 2.5 and older do not support arr[0..nil] syntax, so\n # this must be a separate conditional.\n cursor_to_iterate = if limit_for_cached_query\n @cursor.to_a[0...limit_for_cached_query]\n else\n @cursor\n end\n\n cursor_to_iterate.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def method_missing(sym, *args, &block)\n return @cursor.send(sym, *args)\n end",
"def substitute_filter_previous(sql)\n if current_user && requested\n\n if sql.include?(':filter_previous') && filtering_ids\n # Substitute in inner join SQL to satisfy the filtering directly,\n # and handle the substitution of conditions with the id list\n clean_inner_sql = ActiveRecord::Base.send(:sanitize_sql_for_conditions,\n [\n FilterPreviousInnerSql,\n { filter_previous_ids: filtering_ids }\n ])\n\n sql = sql.gsub(':filter_previous', clean_inner_sql) if clean_inner_sql\n\n self.sql_requests_filtering = true\n end\n\n # :ids_filter_previous string may be specified in the raw SQL to allow filter previous functionality\n # to be defined explicitly in the SQL, rather than relying on the inner SQL generated by :filter_previous\n self.sql_requests_filtering = true if sql.include?(':ids_filter_previous')\n # Setup the search attribute values hash for subsequent use executing the SQL\n end\n\n # If :filter_previous or :ids_filter_previous is still set in the SQL\n # (typically no current user set when running a report as an admin, or no filtering ids found)\n # just remove the strings so the query doesn't fail\n sql.gsub(':filter_previous', '').gsub(':ids_filter_previous', '')\n end",
"def query_string_for_cursor(cursor, opts)\n qs = Hashie::Mash.new(Rack::Utils.parse_nested_query(opts[:env]['QUERY_STRING']))\n if cursor\n qs[:cursor] = cursor\n qs.delete(:offset)\n end\n \"?#{qs.to_query}\" unless qs.empty?\n end",
"def update_sql(sql, name = nil)\n execute(sql, name)\n end",
"def bind(new_params)\n fake_bound = original_statement.clone\n fake_bound.instance_variable_set :@params, new_params\n fake_bound\n end",
"def cached_find_by_statement(key, &block)\n ActiveRecord::StatementCache.create(connection, &block)\n end",
"def cursor!\n cursor(true)\n end",
"def cursor!\n cursor(true)\n end",
"def update!(**args)\n @end_cursor = args[:end_cursor] if args.key?(:end_cursor)\n @partition = args[:partition] if args.key?(:partition)\n @start_cursor = args[:start_cursor] if args.key?(:start_cursor)\n end",
"def where(field_name, operation)\n data_subject.df.where(data_subject.df[field_name.symbolize(data_subject.field_symbolizer)].recode { |v| operation.call(v) })\n end",
"def get_block_cursor(connection, table, max_row_cache_size = 1000000)\n cursor = ProxyBlockCursor.new connection, table\n cursor.max_row_cache_size = max_row_cache_size\n cursor.prepare_fetch\n cursor.checksum :proxy_block_size => 1000\n cursor\n end",
"def find_batch(cursor)\n expansion_number = 1\n cursor[:seen_ids] ||= []\n state = self.start_batch_state(cursor)\n last_scanned_positions = []\n last_updated_at = cursor.updated_at || Time.at(0)\n\n while true\n results = self.execute_batch_find(state, expansion_number)\n\n # The list of tuples identifying the records by both their id, and file hashes,\n # to compare when we see a stable set of results.\n scanned_positions = results\n .map { |r| self.result_scanned_position(r) }\n .sort\n\n # Partition our results into those that\n # have a changed hash and those who do not.\n changed_set, unchanged_set = results.partition do |result|\n file_hashes_changed?(cursor, result)\n end\n\n # After a previous scan, in which we did not yield a changed dataset, if the last_scanned_positions\n # is stable with the next one (despite a larger expansion number), we assume that we are not going to\n # find a changed set in the future, and thus commit to returning the changed_set, updating our seen_ids.\n if scanned_positions == last_scanned_positions\n update_seen_ids(cursor, changed_set)\n\n return changed_set\n end\n\n last_scanned_positions = scanned_positions\n\n if changed_set.empty?\n # Increase out paging size, see if we get new results and find a changed set.\n expansion_number += 1\n else\n # Persist all scanned records here with their last known\n # file hashes, so we can compare them against future changes.\n update_seen_ids(cursor, changed_set)\n cursor.updated_at = changed_set.map { |r| self.result_updated_at(r) }.max\n return changed_set\n end\n end\n end",
"def process db\n #verify if table exists\n table = EMMConfig[\"DB_TABLE_#{$opts[:table]}\"]\n sql=\"UPDATE #{table} SET processed=1 WHERE file_name IN \"\n sql << \"(\" << $files.map{ |k| \"'#{File.basename(k)}'\" }.join(',') << \");\"\n puts sql if $opts[:v]\n db.query(sql)\nend",
"def reload_sql(primary_keys, fetched_columns)\n sql_keys = primary_keys.collect{|pk| \"'#{pk}'\"}.join(ScroogeComma)\n cols = scrooge_select_sql(missing_columns(fetched_columns))\n \"SELECT #{cols} FROM #{@quoted_table_name} WHERE #{@quoted_primary_key} IN (#{sql_keys})\"\n end",
"def fetch_cursor(name='csr')\n raise ArgumentError, \"Cursor #{name} not open\" unless @cursors.has_key?(name)\n fetch_buffer(name) if @cursors[name][:state] == :empty\n return nil if @cursors[name][:state] == :eof\n @cursors[name][:state] = :empty if @cursors[name][:buffer].size <= 1\n row = @cursors[name][:buffer].shift\n row.is_a?(Hash) ? row.symbolize_keys : row\n end",
"def apply_condition(query, condition)\n validate_query(query)\n validate_condition(condition)\n query.where(condition)\n end",
"def apply_condition(query, condition)\n validate_query(query)\n validate_condition(condition)\n query.where(condition)\n end",
"def by_name\n Vedeu.log(type: :cursor,\n message: \"Refreshing cursor: (#{cursor.inspect})\")\n\n render\n\n Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?\n end",
"def sync\n return if @in_sync\n\n code = compile_loop_advance(\"= #{compile_cur_index}\")\n @in_sync = true\n yield code\n end",
"def save_cursor(cursor)\n cursors[cursor] = cursor\n end",
"def update_search_vector!\n ActiveRecord::Base.connection.execute(%{\n UPDATE #{self.class.table_name}\n SET search_vector = #{self.tsvector_construction_string}\n WHERE id = #{id}\n }.squish)\n end",
"def update_query(find_text, replace_text, table, field)\n return \"UPDATE #{table} SET #{field} = REPLACE(#{field}, '#{find_text}', '#{replace_text}')\"\n end",
"def execute(&block)\n TempTableContext.with_context(db) {|context| execute_in_context(context, &block)}\n end",
"def updating_all_timestamp_sql\n update_col = timestamp_attributes_for_update_in_model.first\n\n \", #{update_col} = ?\" if update_col\n end",
"def update_sql(values = {}, opts = nil, &block)\n opts = opts ? @opts.merge(opts) : @opts\n\n if opts[:group]\n raise Error::InvalidOperation, \"A grouped dataset cannot be updated\"\n elsif (opts[:from].size > 1) or opts[:join]\n raise Error::InvalidOperation, \"A joined dataset cannot be updated\"\n end\n \n sql = \"UPDATE #{source_list(@opts[:from])} SET \"\n if block\n sql << block.to_sql(self, :comma_separated => true)\n else\n set = if values.is_a?(Hash)\n # get values from hash\n values = transform_save(values) if @transform\n values.map do |k, v|\n # convert string key into symbol\n k = k.to_sym if String === k\n \"#{literal(k)} = #{literal(v)}\"\n end.join(COMMA_SEPARATOR)\n else\n # copy values verbatim\n values\n end\n sql << set\n end\n if where = opts[:where]\n sql << \" WHERE #{literal(where)}\"\n end\n\n sql\n end",
"def set_active_cursor \n if !@cursor.at?( @active_battler)\n @cursor.moveto( @active_battler)\n update_selected\n end\n end",
"def select_and_lock(relation, limit:)\n relation = upcoming(relation)\n\n # FOR UPDATE SKIP LOCKED selects and locks entries, but skips those that\n # are already locked - preventing this transaction from being locked.\n sql = relation.to_sql + \" FOR UPDATE SKIP LOCKED\"\n sql += \" LIMIT #{limit}\" if limit\n\n item_class.find_by_sql(sql)\n end",
"def query_with_cursor(sql_query, limit = nil)\n places = []\n transaction do\n ActiveRecord::Base.uncached do\n cursor = connection.select_value(sql_query)\n place = nil\n begin\n results = many.next_with_attributes(cursor)\n unless results.empty?\n place = with_details(results)\n places << place\n if (limit)\n limit -= 1\n place = nil if limit == 0\n end\n else\n place = nil\n end\n end while !place.nil?\n end\n end\n places\n end",
"def each_row_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_row_batch(&block) if block_given?\n cursor.iterate_batched\n end",
"def lock_column_instance_filter\n lc = model.lock_column\n instance_filter(lc=>Sequel.blob(get_column_value(lc)))\n end",
"def x=(value)\n super\n update_cursor\n end",
"def cursor_position!\n Vedeu.bind(:_cursor_position_) do |name|\n Vedeu.cursors.by_name(name).position\n end\n end",
"def _update_without_checking(columns)\n if use_prepared_statements_for?(:update)\n _set_prepared_statement_server(model.send(:prepared_update, columns.keys)).call(Hash[columns].merge!(pk_hash))\n else\n super\n end\n end",
"def where_column_equal(col, value)\n # substitue in virtual col fn if it exists\n vcol_info = ((DB_REL_DEF[model_name] || {})[:virtual_columns] || {})[col]\n return where(col => value) unless vcol_info\n fail Error.new(\"virtual column #{col} cannot appear in where clause unless it has a fn def\") unless vcol_info[:sql_fn]\n where(vcol_info[:sql_fn] => value)\n end",
"def update_cursor\n cursor_rect.set((@index % 2) * DELTA_X, (@index / 2) * DELTA_Y)\n $game_system.se_play($data_system.cursor_se)\n end",
"def reload!\n callsite = Callsites[@callsite_key]\n rows_hash = rows_by_key(callsite.primary_key)\n sql = callsite.reload_sql(rows_hash.keys, @fetched_columns)\n new_rows = callsite.connection.send(:select, sql, \"#{callsite.model_class_name} Reload SlimScrooged\")\n new_rows.each do |row|\n if old_row = rows_hash[row[callsite.primary_key]]\n old_row.result_set = nil\n old_row.monitored_columns.merge!(row)\n end\n end\n end",
"def where(*args, &b)\n set_parameters(args, false, &b)\n end",
"def set_timestamp_to_now\n puts 'set_timestamp_to_now'\n db_conn.prepare 'set_timestamp_to_now', \"INSERT INTO #{TABLE} (id, updated_at) VALUES (#{ROW_KEY}, $1)\n ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at\"\n db_conn.exec_prepared 'set_timestamp_to_now', [Time.now]\nend",
"def base_query(select_columns = true)\n if source_query\n if select_columns && source_select_columns\n source_query.call.select(*source_select_columns).where(source_conditions)\n else\n source_query.call.where(source_conditions)\n end\n else\n query = source_model.where(source_conditions).order(source_order_by => :asc)\n query = query.select(*source_select_columns) if select_columns && source_select_columns\n !force_full_update && highest_known_destination_order_by ? query.where(\"#{source_order_by} >= ?\", highest_known_destination_order_by) : query\n end\n end",
"def select_lock_sql(sql)\n @opts[:lock] == :update ? sql : super\n end",
"def batch(conn, sql, ctx: nil, limit: 1000, batch_wrapper: nil, silent: false, &block)\n ctx ||= {}\n ctx.update({:count => 0, :start_time => Time::now.to_f })\n\n # if no batch_wrapper is passed in, make a default that just\n # calls passed-in process_batch proc\n if batch_wrapper.nil?\n batch_wrapper = Proc.new do |process_batch|\n process_batch.call\n end\n end\n \n keep_going = true\n offset = 0\n while keep_going\n results = conn.query(sql + \" LIMIT #{limit} OFFSET #{offset}\")\n if results.count > 0\n\n # Proc closure over local vars\n process_batch = Proc.new do\n results.each do |row|\n begin\n block.call row, ctx\n rescue\n puts \"ERROR in #batch, processing row=#{row}\"\n raise\n end\n ctx[:count] += 1\n end\n end\n \n batch_wrapper.call(process_batch)\n \n elapsed = Time::now.to_f - ctx[:start_time]\n rate = 0\n if elapsed > 0\n rate = ctx[:count] / elapsed\n end\n puts \"Processed #{ctx[:count]} records so far in batch(): overall rate: #{rate} records/sec\" unless silent\n\n offset += limit\n else\n keep_going = false\n end\n end\n end",
"def cursor(value)\n attributes[:cursor] = value\n end",
"def update_sql(sql, name = nil)\n super\n end",
"def _update_without_checking(columns)\n ds = _update_dataset\n lc = model.lock_column\n rows = ds.clone(ds.send(:default_server_opts, :sql=>ds.output(nil, [Sequel[:inserted][lc]]).update_sql(columns))).all\n values[lc] = rows.first[lc] unless rows.empty?\n rows.length\n end",
"def update_sql(sql, name = nil)\n result = super\n result.length == 0 ? 0 : result.rows[0][0]\n end",
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def edit_current\n command = ENV['EDITOR'] || ENV['VISUAL'] || 'vim'\n run_on_current command\n @visited_files.insert(0, expand_path(current_file))\nend",
"def update(category, querty_term, id)\n @conn.exec(\"SELECT * FROM students WHERE #{first_name} = '#{id}';\");\nend",
"def each(&block)\n\t plan.query_each(result_set, &block)\n\t self\n\tend",
"def cursor\n @application.cursor\n end",
"def select_limit_sql(sql)\n if limit = @opts[:limit]\n if (offset = @opts[:offset]) && (offset > 0)\n sql.replace(\"SELECT * FROM (SELECT raw_sql_.*, ROWNUM raw_rnum_ FROM(#{sql}) raw_sql_ WHERE ROWNUM <= #{limit + offset}) WHERE raw_rnum_ > #{offset}\")\n else\n sql.replace(\"SELECT * FROM (#{sql}) WHERE ROWNUM <= #{limit}\")\n end\n end\n end",
"def find_cursor(name, transaction, *findargs)\n count = 0\n begin\n connection.begin_db_transaction if transaction\n open_cursor(name, *findargs)\n while (row = ActiveRecord::Base.fetch_cursor(name)) do\n count+= 1\n yield row\n end\n close_cursor(name)\n ensure\n connection.commit_db_transaction if transaction\n end\n count\n end",
"def update(table,cond,op)\n connection.update(path(table),cond,op)\n end",
"def new_column_access(name)\n if @callsite.columns_hash.has_key?(name)\n @result_set.reload! if @result_set && name != @callsite.primary_key\n Callsites.add_seen_column(@callsite, name)\n end\n @monitored_columns[name]\n end",
"def update(category, query_term, id)\n @conn.exec(\"UPDATE students SET #{category} = '#{query_term}' WHERE id = '#{id}';\")\nend",
"def update_cursor\n # if not active or blinking timer has exceeded value\n if !self.active || @frame >= 10 # 20 / 2\n # if cursor exists\n if @cursor != nil\n # delete cursor\n @cursor.dispose\n @cursor = nil\n end\n else\n # if cursor does not exist\n @cursor = Sprite.new(@v) if @cursor == nil\n if @cursor.bitmap != nil && @cursor.bitmap.height != cursor_height\n @cursor.bitmap.dispose\n @cursor.bitmap = nil\n end\n if @cursor.bitmap == nil\n # create bitmap\n @cursor.bitmap = Bitmap.new(1, cursor_height)\n @cursor.bitmap.fill_rect(0, 0, 1, cursor_height, CURSOR_COLOR)\n end\n # position the cursor\n @cursor.x, @cursor.y = cursor_x, cursor_y #@ax + cursor_x, @ay + cursor_y #self.x + cursor_x, self.y + cursor_y\n @cursor.z = self.z + 1\n end\n end",
"def cursor_value(row_idx: c_y, col_idx: c_x)\n map.value(row_idx, col_idx)\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def _update_record(values, id, id_was) # :nodoc:\n substitutes, binds = substitute_values values\n\n scope = @klass.unscoped\n\n if @klass.finder_needs_type_condition?\n scope.unscope!(where: @klass.inheritance_column)\n end\n\n # ****** BEGIN PARTITIONED PATCH ******\n if @klass.respond_to?(:dynamic_arel_table)\n using_arel_table = @klass.dynamic_arel_table(Hash[*values.inject([]) { |result, (k, v)| result += [k.name, v] }])\n relation = scope.where(using_arel_table[@klass.primary_key].eq(id_was || id))\n bvs = binds + relation.bind_values\n um = relation\n .arel\n .compile_update(substitutes, @klass.primary_key)\n\n # NOTE(hofer): The um variable got set up using\n # klass.arel_table as its arel value. So arel_table.name is\n # what gets used to construct the update statement. Here we\n # set it to the specific partition name for this record so\n # that the update gets run just on that partition, not on the\n # parent one (which can cause performance issues).\n begin\n @klass.arel_table.name = using_arel_table.name\n @klass.connection.update(\n um,\n 'SQL',\n bvs)\n ensure\n @klass.arel_table.name = @klass.table_name\n end\n else\n # Original lines:\n relation = scope.where(@klass.primary_key => (id_was || id))\n bvs = binds + relation.bind_values\n um = relation\n .arel\n .compile_update(substitutes, @klass.primary_key)\n\n @klass.connection.update(\n um,\n 'SQL',\n bvs)\n end\n # ****** END PARTITIONED PATCH ******\n end",
"def needs_cursor?; end",
"def sql\n return @incoming_sql if parameter.blank?\n\n @incoming_sql = @incoming_sql.joins(:instances)\n .joins(instances: :reference)\n .where([text_search_version,\n text_search_param(parameter)])\n @incoming_sql = @incoming_sql.where(PROTOLOGUE_CLAUSE) if @parser.protologue?\n @incoming_sql\n end",
"def cursor_origin!\n Vedeu.bind(:_cursor_origin_) do |name|\n Vedeu.cursors.by_name(name).move_origin\n end\n\n Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)\n end"
] |
[
"0.5185605",
"0.5111115",
"0.50961035",
"0.50961035",
"0.50961035",
"0.5060107",
"0.50512356",
"0.5036264",
"0.49734023",
"0.49724764",
"0.49651286",
"0.49085128",
"0.47928664",
"0.47766036",
"0.47595295",
"0.4749393",
"0.47241792",
"0.47152784",
"0.4701604",
"0.46561593",
"0.4636532",
"0.4587928",
"0.453179",
"0.45233274",
"0.4513411",
"0.4511097",
"0.45072928",
"0.45066777",
"0.45052728",
"0.44939134",
"0.44852284",
"0.44759992",
"0.44649214",
"0.4457513",
"0.4445416",
"0.44389272",
"0.44182175",
"0.44070882",
"0.43867797",
"0.43490696",
"0.43476897",
"0.43253723",
"0.43103957",
"0.43076968",
"0.42996058",
"0.42996058",
"0.4281232",
"0.427806",
"0.4272696",
"0.42638665",
"0.42531306",
"0.42493224",
"0.42489657",
"0.423993",
"0.423993",
"0.42397475",
"0.42362952",
"0.42361838",
"0.4218269",
"0.4217325",
"0.42119122",
"0.42086697",
"0.42044944",
"0.41950825",
"0.41947955",
"0.4183821",
"0.41790426",
"0.41746986",
"0.41735506",
"0.41733274",
"0.41590083",
"0.4152722",
"0.41504943",
"0.4147469",
"0.41422206",
"0.41420943",
"0.41416252",
"0.41331866",
"0.41319585",
"0.41237867",
"0.41229156",
"0.4121286",
"0.41136345",
"0.41127875",
"0.41109797",
"0.41073653",
"0.41064352",
"0.41064024",
"0.40984854",
"0.4097195",
"0.40966743",
"0.40946674",
"0.4082336",
"0.4082221",
"0.407838",
"0.40776697",
"0.40749815",
"0.40739274",
"0.40713117",
"0.40667605"
] |
0.68356913
|
0
|
An array of bound variable values for this query, in the correct order.
|
def map_to_prepared_args(hash)
prepared_args.map{|k| hash[k.to_sym]}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bind_values\n []\n end",
"def bound_variables\n @context.bound_variables\n end",
"def condensed_values\n values = []\n condensed_variables.each do |var|\n values << send(var)\n end\n values\n end",
"def values_array\n [@name, @expression.value]\n end",
"def values\n @conditions.values.map do |keys|\n keys.values\n end.compact.flatten\n end",
"def bound_variable_arg(arg, conn)\n case arg\n when ArrayRow\n \"(#{arg.map{|v| bound_variable_array(v) if v}.join(',')})\"\n when HashRow\n arg.check_columns!\n \"(#{arg.values_at(*arg.columns).map{|v| bound_variable_array(v) if v}.join(',')})\"\n else\n super\n end\n end",
"def values_array\n @_field_path.map{ |field_| @_values[field_.name] }\n end",
"def map_to_prepared_args(bind_vars)\n prepared_args.map{|v| bind_vars[v]}\n end",
"def all_variables\n @items.map(&:variables).flatten\n end",
"def conditions_array\n @conditions.to_a\n end",
"def map_to_prepared_args(bind_vars)\n prepared_args.map{|v, t| [bind_vars[v], t]}\n end",
"def cur_values\r\n @bindings[-1].values\r\n end",
"def vars\n operands.vars.flatten.compact\n end",
"def values\n self.map('lambda{|(_, value)| value}')\n end",
"def collect_variables\n []\n end",
"def values\n @values ||= []\n end",
"def dynamic_values\n if @dynamic_values.blank?\n\n if self.column.blank?\n raise \"dynamic_values column not defined for filter_param_id = #{self.id}\"\n end\n\n query_result = self.dynamic_values_query.try(:query_result, nil, nil,\n :sample_option => ::Query::Sample::REAL,\n :sql_string => \"SELECT `#{self.column}` FROM {table_name}\"\n )\n result_set = query_result.try(:result_set)\n if !result_set.nil?\n @dynamic_values = result_set.try(:results_array).collect do |row|\n result_set.value_at(row, self.column)\n end\n end\n end\n\n @dynamic_values ||= []\n end",
"def values\n @values ||= []\n end",
"def to_conditions\n [to_s] + @values\n end",
"def assigned_variables\n @variables.select {|k, v| v.is_a?(Value) }.sort_by {|pair| pair[0].to_s }\n end",
"def variable_objects()\n @var_set.values\n end",
"def values\n @@values\n end",
"def values\n @values\n end",
"def values\n []\n end",
"def variables\n format.scan(/(%\\w+)/).flatten.map {|v| v[1..v.length] }\n end",
"def values\n return @values\n end",
"def values\n return @values\n end",
"def values\n return @values\n end",
"def variables(binding)\n entries = []\n binding.eval('local_variables').each do |var|\n variable = var.to_s\n value = binding.local_variable_get(var)\n valclass = value.class.to_s\n output = (value.is_a?(Proc)) ? '#<Proc:...' : value.inspect\n\n content = Esc.send(class_colour.fetch(valclass, :white)) { output }\n\n entries << sprintf(\"%33s %-10s = %s %s\", \" \",\n Esc.green { variable },\n Esc.magenta { valclass },\n content)\n end\n entries.join(\"\\n\")\n end",
"def put_student_values_in_array\n instance_variables.map do |attribute|\n instance_variable_get(attribute)\n end\n end",
"def variables\n Variable.where(dataset_id: self.datasets.map(&:id))\n end",
"def values\n self[:values]\n end",
"def bound_parslet; end",
"def vars\n variables.values\n end",
"def vars\n variables.values\n end",
"def variables\n return @variables unless @variables.nil?\n vars = []\n dict = @instance.getDictionary\n dict.getVariables.each do |var|\n vars << {\n :name => var.getName,\n :qual => var.getQualification.toString.downcase.to_sym,\n :type => var.getType.toString.downcase.to_sym,\n :formula => var.getFormula.getValue,\n :variable => var,\n }\n end\n @variables = vars\n end",
"def var_names\n @var_names ||= eval \"local_variables\", get_binding\n end",
"def collect_variables\n @expression.collect_variables.uniq\n end",
"def variables\n EMPTY_ARRAY\n end",
"def values\n @values\n end",
"def values\n @values\n end",
"def bound_attributes\n if Torque::PostgreSQL::AR521\n visitor = ::Arel::Visitors::PostgreSQL.new(ActiveRecord::Base.connection)\n visitor.accept(self.arel.ast, ::Arel::Collectors::Bind.new).value\n else\n return super unless self.auxiliary_statements_values.present?\n bindings = self.auxiliary_statements_values.map(&:bound_attributes)\n (bindings + super).flatten\n end\n end",
"def all_bindings_in_clauses clauses\n clauses.map do |clause|\n clause.nps.map do |np|\n raise \"Noun phrase #{np.inspect} must have a binding\" unless np.binding\n [np.binding] + (np.nested_clauses ? all_bindings_in_clauses(np.nested_clauses) : [])\n end\n end.\n flatten.\n uniq\n end",
"def values(range = nil)\n result_unflatten = if !::RANGES_JRUBY_BUG\n map { |x| x.v }\n else\n self.v\n end\n result = result_unflatten.flatten\n if range\n relevant_result = []\n result.each_with_index { |row_or_column, i| relevant_result << row_or_column if range.include?(i) }\n relevant_result\n else\n result\n end\n end",
"def bindings\n @bindings\n end",
"def params_array_from(raw_params); end",
"def bindings\n @bindings ||= []\n end",
"def values(*) end",
"def values\n @observables.map{|observable| @values[observable] }\n end",
"def select_values_forcing_binds(arel, name, binds)\n # remove possible force of unprepared SQL during dictionary access\n unprepared_statement_forced = prepared_statements_disabled_cache.include?(object_id)\n prepared_statements_disabled_cache.delete(object_id) if unprepared_statement_forced\n\n select_values(arel, name, binds)\n ensure\n # Restore unprepared_statement setting for surrounding SQL\n prepared_statements_disabled_cache.add(object_id) if unprepared_statement_forced\n end",
"def prepared_statement_key_array(keys)\n if dataset.requires_placeholder_type_specifiers?\n sch = db_schema\n Array(keys).map do |k|\n if (s = sch[k]) && (t = s[:type])\n [k, :\"$#{k}__#{t}\"]\n else\n [k, :\"$#{k}\"]\n end\n end\n else\n Array(keys).map{|k| [k, :\"$#{k}\"]}\n end\n end",
"def values\n @values.values\n end",
"def get_variable\n result = Array.new\n if @node_type == :lval\n result << self\n else\n result += @sons.map { |s| s.get_variable }\n end\n\n return result.flatten\n end",
"def parameters\n parameter_row ? parameter_row.cells.map(&:value) : []\n end",
"def values\n @observables.map{|observable| @values[observable] }\n end",
"def bound_variable_array(a)\n case a\n when JSONObject, JSONBObject\n \"\\\"#{Sequel.object_to_json(a).gsub('\"', '\\\\\"')}\\\"\"\n else\n super\n end\n end",
"def values\n rows.map{|r| r.value}\n end",
"def available_values\n result = []\n for i in (0 .. @tag.length - 1)\n result << @tag[i].value\n end\n return result\n end",
"def available_values\n result = []\n for i in (0 .. @tag.length - 1)\n result << @tag[i].value\n end\n return result\n end",
"def bound?\n !variables.empty? && variables.values.all?(&:bound?)\n end",
"def all_bindings_in_clauses clauses\n clauses.map do |clause|\n clause.refs.map do |ref|\n raise \"Binding reference #{ref.inspect} is not bound to a binding\" unless ref.binding\n [ref.binding] + (ref.nested_clauses ? all_bindings_in_clauses(ref.nested_clauses) : [])\n end\n end.\n flatten.\n uniq\n end",
"def values\n @values.values\n end",
"def get_variables\n result = @assigns.each_value.reduce([]) do |ar,tree|\n ar.concat(tree.get_variables)\n end\n result.uniq!.sort!\n return result\n end",
"def addr_bound_params\n\t\t\tparams[:address][:addr_bounds_attributes][\"0\"][:addr_code].reject!{ |a| a.empty? }.sort\n\t\tend",
"def values\n @values.values\n end",
"def values\n self\n end",
"def fields\n [*lookup]\n end",
"def non_foreign_key_values\n vals = []\n non_foreign_key_fields.each do |field|\n vals << self.send(field)\n end\n vals\n end",
"def vars\n variable? ? [self] : []\n end",
"def to_lp_vars\n index_tuples.map{|t| \"v#{t.join('x')}\"}\n end",
"def values_at( *attributes )\n\t\treturn attributes.collect do |attribute|\n\t\t\tself[ attribute ]\n\t\tend\n\tend",
"def variables\n @table.keys\n end",
"def get_local_variables_from_binding_helper_func1(\n ar_variable_names, i_array_instance_object_id)\n ar=ObjectSpace._id2ref(i_array_instance_object_id)\n ar.concat(ar_variable_names)\n end",
"def collect_variables\n variables = []\n statements.collect { |s| variables += s.collect_variables }\n variables.uniq\n end",
"def bind_params( *bind_vars )\n index = 1\n bind_vars.flatten.each do |var|\n if Hash === var\n var.each { |key, val| bind_param key, val }\n else\n bind_param index, var\n index += 1\n end\n end\n end",
"def all(starting_with=nil)\n query = target_scoped\n query = query.where([\"var LIKE ?\", \"#{starting_with}%\"]) if starting_with\n\n result = defaults.dup\n \n query.all.each do |record|\n result[record.var.to_sym] = record.value\n end\n \n result.with_indifferent_access\n end",
"def var_list_fixing_neo4j_2_1_8_bug(variables)\n var_list(variables) { |var| \"#{var} AS #{var}\" }\n end",
"def values\n valid_criteria[attribute_name].nil? ? {} : valid_criteria[attribute_name][\"values\"]\n end",
"def values\n @values ||= MapscriptEnumerable.new(self, :numvalues, :getValue)\n end",
"def bt_value_attributes\n attributes.slice(*(self.class.bt_scope_columns + self.class.bt_versioned_columns))\n end",
"def var_list(variable_name)\n [\"${split(\\\",\\\",var.#{variable_name})}\"]\n end",
"def bind_arguments\n @opts[:bind_arguments]\n end",
"def to_a\n variables.keys\n end",
"def values() end",
"def attribute_values \n columns = self.class.columns\n columns.map { |col| self.send(col) } #=> ex. [:id, :name, :owner_id]\n end",
"def values\n vals = []\n each{|k,v| vals << v}\n vals\n end",
"def get_tags\n variables = @db.execute(\"SELECT key FROM variables ORDER BY key ASC;\")\n tags = []\n variables.each do |k|\n tags << k[\"key\"].to_s\n puts k[\"key\"].to_s\n end\n return tags\n end",
"def attribute_values\n @columns.map do |column|\n @attributes[column.to_sym]\n end\n end",
"def param_values_for(param_item_id)\r\n defined_param_values.\r\n joins(:param_item).\r\n where(param_items: {id: param_item_id}).\r\n pluck(\"param_values.value\")\r\n end",
"def params_array_from(raw_params)\n raw_params.map { |param| param.split %r/=(.+)?/ }\n end",
"def declared_variables\n @variables.select {|k, v| v == :var }.map {|pair| pair[0].to_s }.sort\n end",
"def self_values\n self_values = []\n database_field_names.each do |param| \n self_values << get_value_including_foreign_keys(self.send(param))\n end\n self_values\n end",
"def variables( *new_values )\n\t\tself.variables = new_values unless new_values.empty?\n\t\treturn @variables.dup\n\tend",
"def all_values(name)\n @values[name.to_sym] || []\n end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def values; end",
"def values; end"
] |
[
"0.7021773",
"0.6377845",
"0.6258958",
"0.62065595",
"0.6098467",
"0.6051704",
"0.59970284",
"0.5984563",
"0.59518844",
"0.5900561",
"0.58304477",
"0.58043385",
"0.579103",
"0.5732291",
"0.57134974",
"0.5661262",
"0.565011",
"0.5636184",
"0.56202203",
"0.5615815",
"0.5588527",
"0.5580837",
"0.5563704",
"0.5521003",
"0.55076677",
"0.55058616",
"0.5504723",
"0.5504723",
"0.55041814",
"0.54982567",
"0.5489922",
"0.5466938",
"0.5462981",
"0.54568464",
"0.54568464",
"0.5449667",
"0.54432625",
"0.5439953",
"0.5426628",
"0.5421766",
"0.5421766",
"0.54129297",
"0.5388107",
"0.5375882",
"0.53586423",
"0.53565",
"0.5352912",
"0.53379434",
"0.53357005",
"0.5335237",
"0.5334392",
"0.5332701",
"0.53289217",
"0.5326313",
"0.53158575",
"0.52967113",
"0.5294145",
"0.5277278",
"0.5277278",
"0.5265912",
"0.5263909",
"0.5255671",
"0.52510303",
"0.5247599",
"0.5237359",
"0.5225688",
"0.52212214",
"0.522007",
"0.5210023",
"0.5205987",
"0.5200023",
"0.5193065",
"0.5190545",
"0.51881975",
"0.51857114",
"0.5180116",
"0.5174444",
"0.5173993",
"0.5173286",
"0.5169379",
"0.51673126",
"0.5164929",
"0.51591164",
"0.5157966",
"0.51523983",
"0.5147818",
"0.51449215",
"0.5144262",
"0.51406646",
"0.51262736",
"0.5121484",
"0.5116592",
"0.51149106",
"0.5114387",
"0.5104178",
"0.5104178",
"0.5104178",
"0.5104178",
"0.5104178",
"0.5104178",
"0.5104178"
] |
0.0
|
-1
|
Always assume a prepared argument.
|
def prepared_arg?(k)
true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prepare(*)\n raise Error, \"cannot prepare an already prepared statement\" unless allow_preparing_prepared_statements?\n super\n end",
"def prepared_arg_placeholder\n PREPARED_ARG_PLACEHOLDER\n end",
"def call(*)\n raise Error, \"Cannot call prepared statement without a name\" if prepared_statement_name.nil?\n super\n end",
"def allow_preparing_prepared_statements?\n false\n end",
"def prepared_arg_placeholder\n PREPARED_ARG_PLACEHOLDER\n end",
"def prepared_arg?(k)\n true\n end",
"def prepared_arg?(k)\n true\n end",
"def prepared_args\n @opts[:prepared_args]\n end",
"def prepare!; end",
"def prepare!; end",
"def skip_sql_param_names=(_arg0); end",
"def prepare(*args)\n ps = super\n ps.extend(::Sequel::Postgres::DatasetMethods::PreparedStatementMethods)\n ps\n end",
"def prepared?\n !!@prepared\n end",
"def prepared?\n !!@prepared\n end",
"def _execute_prepared_statement(conn, ps_name, args, opts)\n conn.exec_prepared(ps_name, args)\n end",
"def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end",
"def prepared?\n @prepared\n end",
"def prepared_arg?(k)\n @opts[:bind_vars].has_key?(k)\n end",
"def prepared_arg(k)\n prepared_args << k\n prepared_arg_placeholder\n end",
"def prepared?\n @prepared\n end",
"def test_raw_insert_bind_param_with_q_mark_deprecated; end",
"def prepare; end",
"def prepare; end",
"def prepare; end",
"def without_prepared_statement?(binds)\n !@prepared_statements || binds.empty?\n end",
"def prepared_statements\n false\n end",
"def prepare record = nil, command\n record ? Statement.new(record, command) : db.prepare(command)\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare()\n end",
"def execute(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end",
"def prepare\n true\n end",
"def prepare\n true\n end",
"def prepared_sql\n if sql = @opts[:prepared_sql] || cache_get(:_prepared_sql)\n return sql\n end\n cache_set(:_prepared_sql, super)\n end",
"def prepare(&block)\n define_method(:prepare, &block)\n end",
"def prepare\n end",
"def prepare(options = {})\n raise \"prepare not implemented\"\n end",
"def prepare\n raise NotImplementedError\n end",
"def prepared_arg(k)\n @opts[:bind_vars][k]\n end",
"def execute_prepared_statement(ps_name, opts)\n args = opts[:arguments]\n ps = prepared_statement(ps_name)\n sql = ps.prepared_sql\n synchronize(opts[:server]) do |conn|\n unless conn.prepared_statements.fetch(ps_name, []).first == sql\n log_connection_yield(\"PREPARE #{ps_name}: #{sql}\", conn){conn.prepare(sql, ps_name)}\n end\n args = args.map{|v| v.nil? ? nil : prepared_statement_arg(v)}\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n begin\n stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free_result if stmt\n end\n end\n end",
"def skip_sql_param_names; end",
"def execute_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return perform_select(query_string).get_rows()\n end",
"def prepare_sql; raise \"Define #prepare_sql in your subclass\"; end",
"def prepare\n @prepare ||= default_prepare\n end",
"def prepare_invoke!\n @prepared = true\n end",
"def prepare( str )\n @db.prepare( str )\n end",
"def prepare!\n self.prepared_object = resolve_object\n end",
"def call(bind_vars={}, &block)\n sql = prepared_sql\n prepared_args.freeze\n ps = bind(bind_vars)\n ps.clone(:bind_arguments=>ps.map_to_prepared_args(ps.opts[:bind_vars]), :sql=>sql, :prepared_sql=>sql).run(&block)\n end",
"def use_prepared_statements_for_pk_lookup?\n !@fast_pk_lookup_sql && !dataset.joined_dataset?\n end",
"def prepare(name, sql)\n check_disconnect_errors{super}\n end",
"def prepare(&block)\n @prepare = block\n end",
"def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(JDBC::Dataset::PreparedStatementMethods)\n ps.extend(::Sequel::Fdbsql::DatasetMethods::PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end",
"def prepared_statement_arg(v)\n case v\n when Numeric\n v.to_s\n when Date, Time\n literal(v).gsub(\"'\", '')\n else\n v\n end\n end",
"def prepare\n end",
"def prepare\n end",
"def execute_prepared(ps_name, *values)\n stmt = @prepared_statements[ps_name].last\n res = stmt.execute(*values)\n unless res\n raise Error.new(\"Error executing statement #{ps_name}: #{error_msg}\", error_sqlstate)\n end\n stmt\n end",
"def _prepare(name, sql, datatypes = nil, tx = nil)\n run(:_send_parse, [name, sql, datatypes], tx)\n end",
"def bound_variable_arg(arg, conn)\n case arg\n when Sequel::SQL::Blob\n {:value=>arg, :type=>17, :format=>1}\n when Sequel::SQLTime\n literal(arg)\n when DateTime, Time\n literal(arg)\n else\n arg\n end\n end",
"def bound_variable_arg(arg, conn)\n case arg\n when JSONObject, JSONBObject\n Sequel.object_to_json(arg)\n else\n super\n end\n end",
"def prepare_explicit_statement(ds, type, vals=OPTS)\n f = ds.opts[:from]\n meth = type == :insert_select ? :returning : :select\n s = ds.opts[meth]\n if f && f.length == 1 && !ds.opts[:join] && (!s || s.empty?)\n ds = ds.send(meth, *columns.map{|c| Sequel.identifier(c)})\n end \n \n prepare_statement(ds, type, vals)\n end",
"def execute_dui(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end",
"def prepare; dup; end",
"def execute_prepared(sql,params_arr)\n prepared_statement = @database_handle.prepare(sql)\n params_arr.each_with_index do |param,index|\n prepared_statement.bind_param(index+1,param)\n end \n prepared_statement.execute\n end",
"def parameterized?\n options[:using] == :parameterized\n end",
"def execute(sql, opts=OPTS, &block)\n super(sql, {:arguments=>bind_arguments}.merge(opts), &block)\n end",
"def prepare_for_bind(string)\n string\n end",
"def select_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return select_cached(query_string)\n end",
"def bind_param( param, value )\n @statement.bind_param( param, value )\n end",
"def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end",
"def prepare\n super\n end",
"def set_param\n send \"#{param_column}=\", to_param if param_column?\n end",
"def set_param\n send \"#{param_column}=\", to_param if param_column?\n end",
"def affect_prepared_values!\n (upper(:@@preparers) || []).each do |preparer|\n @params[preparer[:key]] = preparer[:lambda].try(:call, @params[preparer[:key]])\n end\n end",
"def set_preparedinfo\n @preparedinfo = Preparedinfo.find(params[:id])\n end",
"def prepare(sql, datatypes = nil, tx = nil)\n Statement.prepare(self, sql, datatypes, tx)\n end",
"def prepared_lookup\n # SEQUEL5: Remove\n cached_prepared_statement(:fixed, :lookup){prepare_explicit_statement(filter(prepared_statement_key_array(primary_key)), :first)}\n end",
"def prepared_refresh\n # SEQUEL5: Remove\n cached_prepared_statement(:fixed, :refresh){prepare_explicit_statement(naked.clone(:server=>dataset.opts.fetch(:server, :default)).where(prepared_statement_key_array(primary_key)), :first)}\n end",
"def argument?; end",
"def execute_prepared_statement(conn, name, opts=OPTS, &block)\n ps = prepared_statement(name)\n sql = ps.prepared_sql\n ps_name = name.to_s\n\n if args = opts[:arguments]\n args = args.map{|arg| bound_variable_arg(arg, conn)}\n end\n\n unless conn.prepared_statements[ps_name] == sql\n conn.execute(\"DEALLOCATE #{ps_name}\") if conn.prepared_statements.include?(ps_name)\n conn.check_disconnect_errors{log_connection_yield(\"PREPARE #{ps_name} AS #{sql}\", conn){conn.prepare(ps_name, sql)}}\n conn.prepared_statements[ps_name] = sql\n end\n\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n\n q = conn.check_disconnect_errors{log_connection_yield(log_sql, conn, args){_execute_prepared_statement(conn, ps_name, args, opts)}}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def prepared_statement(name)\n Sequel.synchronize{prepared_statements[name]}\n end",
"def set_prepared_statement(name, ps)\n Sequel.synchronize{prepared_statements[name] = ps}\n end",
"def bound_variable_arg(arg, conn)\n case arg\n when ArrayRow\n \"(#{arg.map{|v| bound_variable_array(v) if v}.join(',')})\"\n when HashRow\n arg.check_columns!\n \"(#{arg.values_at(*arg.columns).map{|v| bound_variable_array(v) if v}.join(',')})\"\n else\n super\n end\n end",
"def prepare_data\n # This method is just a stub.\n end",
"def use_prepared_statements_for?(type)\n if (type == :update || type == :delete) && !instance_filters.empty?\n false\n else\n super if defined?(super)\n end\n end",
"def prepare; self; end",
"def to_prepare(&blk); end",
"def inspect\n \"<#{visible_class_name}/PreparedStatement #{prepared_sql.inspect}>\"\n end",
"def normalize_pending_arguments(arguments)\n if arguments.empty?\n self.where = \"dbagile\"\n else\n self.where = valid_argument_list!(arguments, String)\n end\n end",
"def prepare\n # Only do this once\n return if $has_prepared\n\n prepared_statements = {\n temperature_readings: :insert_temp,\n moisture_readings: :insert_moisture,\n light_readings: :insert_light,\n }\n\n prepared_statements.each do |table, name|\n DB[table].prepare(:insert, name, plant_id: :$plant_id, value: :$value)\n end\n\n $has_prepared = true\nend",
"def prepare\n []\n end",
"def prepared_sql\n case prepared_type\n when :select, :all, :each\n # Most common scenario, so listed first.\n select_sql\n when :first\n clone(:limit=>1).select_sql\n when :insert_select\n insert_select_sql(*prepared_modify_values)\n when :insert, :insert_pk\n insert_sql(*prepared_modify_values)\n when :update\n update_sql(*prepared_modify_values)\n when :delete\n delete_sql\n else\n select_sql\n end\n end",
"def prepared_type\n @opts[:prepared_type]\n end",
"def safe=(_arg0); end",
"def db=(_arg0); end",
"def db=(_arg0); end"
] |
[
"0.7035655",
"0.69638205",
"0.6953646",
"0.6940995",
"0.688927",
"0.68674064",
"0.6824744",
"0.6657382",
"0.6598382",
"0.6598382",
"0.6484042",
"0.64726216",
"0.64351463",
"0.64351463",
"0.64128995",
"0.64004356",
"0.6383804",
"0.63483405",
"0.63333327",
"0.6299877",
"0.6288564",
"0.6234491",
"0.6234491",
"0.6234491",
"0.61967",
"0.6189047",
"0.6093811",
"0.6089377",
"0.6089377",
"0.6089377",
"0.6089377",
"0.6089377",
"0.6089377",
"0.6089377",
"0.6085409",
"0.6085186",
"0.60675687",
"0.60675687",
"0.6064542",
"0.6053549",
"0.6047018",
"0.60407597",
"0.602248",
"0.6000706",
"0.5992927",
"0.5954074",
"0.5946942",
"0.5945905",
"0.59448004",
"0.59431",
"0.5942022",
"0.5902908",
"0.59001833",
"0.5862461",
"0.58596814",
"0.5840723",
"0.583159",
"0.5824229",
"0.5789384",
"0.5789384",
"0.5774624",
"0.5753736",
"0.5750365",
"0.5749582",
"0.5744997",
"0.5739963",
"0.57336503",
"0.5721703",
"0.5720008",
"0.571905",
"0.5708611",
"0.5698627",
"0.5695896",
"0.56906044",
"0.56694895",
"0.5666896",
"0.5666896",
"0.56480306",
"0.5612645",
"0.5605076",
"0.5602578",
"0.5593833",
"0.5579515",
"0.5573038",
"0.557185",
"0.5557513",
"0.5555019",
"0.55539227",
"0.55466115",
"0.5539184",
"0.553587",
"0.5524537",
"0.5499794",
"0.54859746",
"0.54852945",
"0.54823875",
"0.5471808",
"0.54139024",
"0.5401176",
"0.5401176"
] |
0.6848919
|
6
|
PostgreSQL uses $N for placeholders instead of ?, so use a $ as the placeholder.
|
def prepared_arg_placeholder
PREPARED_ARG_PLACEHOLDER
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def postgres_binds(query_with_binds)\n bind_index = 0\n query_with_binds.gsub('?') { |match|\n bind_index += 1\n \"$#{bind_index}\"\n }\nend",
"def prepare_statement_sub(sql)\n sql.gsub(/\\$\\d+/, '?')\n end",
"def prepared_statement_arg(v)\n case v\n when Numeric\n v.to_s\n when Date, Time\n literal(v).gsub(\"'\", '')\n else\n v\n end\n end",
"def prepared_arg_placeholder\n PREPARED_ARG_PLACEHOLDER\n end",
"def fields_for_sql(num_fields)\r\n '(' + \"?,\\s\" * (num_fields - 1) + '?' + ')'\r\nend",
"def replace_params(sql, *params)\n sql.gsub!(/\\?/) { |a| quote(params.shift) }\n end",
"def bound_variable_arg(arg, conn)\n case arg\n # TODO TDD it:\n when Sequel::SQL::Blob\n # the 1 means treat this as a binary blob\n {:value => arg, :format => 1}\n when Sequel::SQLTime\n # the literal methods put quotes around things, but this is a bound variable, so we can't use those\n arg.strftime(BOUND_VARIABLE_SQLTIME_FORMAT)\n when DateTime, Time\n # the literal methods put quotes around things, but this is a bound variable, so we can't use those\n from_application_timestamp(arg).strftime(BOUND_VARIABLE_TIMESTAMP_FORMAT)\n else\n arg\n end\n end",
"def bound_variable_arg(arg, conn)\n case arg\n when Sequel::SQL::Blob\n {:value=>arg, :type=>17, :format=>1}\n when Sequel::SQLTime\n literal(arg)\n when DateTime, Time\n literal(arg)\n else\n arg\n end\n end",
"def escape_sql(args)\n return @text if args.empty?\n sql = @text.dup\n vars = args.dup\n\n replacements = 0\n mismatch = false\n\n sql.gsub!(/'[^']*'|\"[^\"]*\"|`[^`]*`|\\?/) do |x|\n next x unless x == '?'\n replacements += 1\n if vars.empty?\n mismatch = true\n else\n var = vars.shift\n connection.quote_value(var)\n end\n end\n\n if !vars.empty? || mismatch\n raise ArgumentError, \"Binding mismatch: #{args.size} for #{replacements}\"\n else\n sql\n end\n end",
"def bind_named_parameters( params )\n check_parameter_count!( params.size )\n params.each_pair do | param, value |\n position = param_position_of( param )\n if position > 0 then\n bind_parameter_to( position, value )\n else\n raise Amalgalite::Error, \"Unable to find parameter '#{param}' in SQL statement [#{sql}]\"\n end\n end\n end",
"def sql(bindings, type = :find)\n statement, bind_values = build_statement(type)\n statement.gsub('?') { eval_bound_value(bind_values.shift, connection, bindings) }\n end",
"def prepared_arg(k)\n y, type = k.to_s.split(\"__\", 2)\n prepared_args << [y.to_sym, type]\n i = prepared_args.length\n LiteralString.new(\":#{i}\")\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def literal_symbol_append(sql, v)\n if @opts[:bind_vars] and match = /\\A\\$(.*)\\z/.match(v.to_s)\n s = match[1].to_sym\n if prepared_arg?(s)\n literal_append(sql, prepared_arg(s))\n else\n sql << v.to_s\n end\n else\n super\n end\n end",
"def raw_parameter(n)\n\t\t\t@node.parameter(n).contents.to_s rescue nil\n\t\tend",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def bind_parameter_to( position, value )\n bind_type = db.type_map.bind_type_of( value ) \n case bind_type\n when DataType::FLOAT\n @stmt_api.bind_double( position, value )\n when DataType::INTEGER\n @stmt_api.bind_int64( position, value )\n when DataType::NULL\n @stmt_api.bind_null( position )\n when DataType::TEXT\n @stmt_api.bind_text( position, value.to_s )\n when DataType::BLOB\n if value.incremental? then\n @stmt_api.bind_zeroblob( position, value.length )\n @blobs_to_write << value\n else\n @stmt_api.bind_blob( position, value.source )\n end\n else\n raise ::Amalgalite::Error, \"Unknown binding type of #{bind_type} from #{db.type_map.class.name}.bind_type_of\"\n end\n end",
"def add_limit_offset!(statement, limit, offset, bind_values)\n if limit && offset > 0\n statement.replace \"select * from (select raw_sql_.*, rownum raw_rnum_ from (#{statement}) raw_sql_ where rownum <= ?) where raw_rnum_ > ?\"\n bind_values << offset + limit << offset\n elsif limit\n statement.replace \"select raw_sql_.* from (#{statement}) raw_sql_ where rownum <= ?\"\n bind_values << limit\n elsif offset > 0\n statement.replace \"select * from (select raw_sql_.*, rownum raw_rnum_ from (#{statement}) raw_sql_) where raw_rnum_ > ?\"\n bind_values << offset\n end\n end",
"def substitute(s)\n # Kludge to handle escaped \"$\". Temporarily replace it with\n # something highly unlikely to be in the string. Then, put a single\n # \"$\" in its place, after the substitution. Must be sure to handle\n # even versus odd number of backslash characters.\n\n def pre_sub(s)\n\n def handle_match(m, s)\n if (m[1].length % 2) == 0\n # Odd number of backslashes before \"$\", including\n # the one with the dollar token (group 2). Valid escape.\n\n b = m.begin(0)\n start = (b == 0 ? \"\" : s[0..(b-1)])\n start + ESCAPED_DOLLAR_PLACEHOLDER + pre_sub(s[m.end(0)..-1])\n else\n # Even number of backslashes before \"$\", including the one\n # with the dollar token (group 2). Not an escape.\n s\n end\n end\n\n # Check for an escaped \"$\"\n m = ESCAPED_DOLLAR.match(s)\n if (m)\n handle_match(m, s)\n else\n s\n end\n end\n\n s2 = super(pre_sub(s))\n s2.gsub(ESCAPED_DOLLAR_PLACEHOLDER, '$')\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"count\"\n return \"%24count\"\n when \"expand\"\n return \"%24expand\"\n when \"filter\"\n return \"%24filter\"\n when \"orderby\"\n return \"%24orderby\"\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n when \"skip\"\n return \"%24skip\"\n when \"top\"\n return \"%24top\"\n else\n return original_name\n end\n end",
"def prepared_arg(k)\n @opts[:bind_vars][k]\n end",
"def max_sql_param_length=(_arg0); end",
"def escape_wildcards(unescaped)\n case ActiveRecord::Base.connection.adapter_name\n when \"Mysql2\".freeze\n # Necessary for MySQL\n unescaped.to_s.gsub(/([\\\\%_])/, '\\\\\\\\\\\\1')\n when \"PostgreSQL\".freeze\n # Necessary for PostgreSQL\n unescaped.to_s.gsub(/([\\\\%_.])/, '\\\\\\\\\\\\1')\n else\n unescaped\n end\n end",
"def query_param(raw_query_str)\n \"query:(query_string:(analyze_wildcard:\" \\\n \"!t,query:'#{escape(raw_query_str)}'))\"\n end",
"def test_raw_insert_bind_param_with_q_mark_deprecated; end",
"def escape(value)\n $db.escape_identifier(value)\nend",
"def escape_wildcards(unescaped)\n case ActiveRecord::Base.connection.adapter_name\n when \"Mysql2\", \"PostgreSQL\"\n # Necessary for PostgreSQL and MySQL\n unescaped.to_s.gsub(/([\\\\|\\%|.])/, '\\\\\\\\\\\\1')\n else\n unescaped\n end\n end",
"def bind_string(stmt, index, value)\n case value.encoding\n when Encoding.utf_8, Encoding.us_ascii\n API.sqlite3_bind_text(stmt, index, value, value.bytesize, TRANSIENT)\n when Encoding.utf_16le, Encoding.utf_16be\n value = add_byte_order_mask(value)\n API.sqlite3_bind_text16(stmt, index, value, value.bytesize, TRANSIENT)\n else\n API.sqlite3_bind_blob(stmt, index, value, value.bytesize, TRANSIENT)\n end\n end",
"def bind_params_length\n 999\n end",
"def interpolate_variables(raw_command)\n raw_command.scan(/[^\\\\]\\$[-_a-zA-Z]+\\$/).each do |match|\n match = match[0..0] == \"$\" ? match : match[1..(match.size - 1)]\n match.strip!\n raw_command.gsub!(match, matched_variable(match))\n end\n raw_command.gsub(\"\\\\$\", \"$\")\n end",
"def interpolate_sql(sql, record = nil)\n instance_eval(\"%(#{sql})\")\n end",
"def sql_string(value)\n \"'#{value.gsub(\"'\", \"''\")}'\" \nend",
"def prepared_arg(k)\n prepared_args << k\n prepared_arg_placeholder\n end",
"def query_literal(args)\n case (s = args[0])\n when LiteralString, SQL::Blob\n nil\n when String\n if args.length == 1\n LiteralString.new(s)\n else\n SQL::PlaceholderLiteralString.new(s, args[1..-1])\n end\n end\n end",
"def to_escaped_for_sql_like\n gsub(/[\\\\%_]/) { |x| '\\\\' + x }.gsub(\"*\", \"%\")\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"search\"\n return \"%24search\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def param_namer(param)\n \"$_#{param}\"\n end",
"def max_sql_param_length; end",
"def interpolate_variables(raw_command)\n raw_command.scan(/[^\\\\]\\$[-_a-zA-Z]+\\$/).each do |match|\n match.strip!\n raw_command.gsub!(match, matched_variable(match))\n end\n raw_command.gsub(\"\\\\$\", \"$\")\n end",
"def bind_params( *bind_vars )\n @statement.bind_params( *bind_vars )\n end",
"def bind_positional_parameters( params )\n check_parameter_count!( params.size )\n params.each_with_index do |value, index|\n position = index + 1\n bind_parameter_to( position, value )\n end\n end",
"def bind(i, value)\n case value\n when NilClass\n bind_null(i)\n when Float\n bind_double(i, value)\n when Integer\n case value\n when RANGE_INT64\n bind_int64(i, value)\n else\n bind_varchar(i, value.to_s)\n end\n when String\n blob?(value) ? bind_blob(i, value) : bind_varchar(i, value)\n when TrueClass, FalseClass\n bind_bool(i, value)\n when Time\n bind_varchar(i, value.strftime('%Y-%m-%d %H:%M:%S.%N'))\n when Date\n bind_varchar(i, value.strftime('%Y-%m-%d'))\n when BigDecimal\n bind_varchar(i, value.to_s('F'))\n else\n raise(DuckDB::Error, \"not supported type `#{value}` (#{value.class})\")\n end\n end",
"def escape_query_value(s)\n s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/u) {\n '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase\n }.tr(' ', '+')\n end",
"def generate_pg_insert_query(table_name, keys, rows)\n \"INSERT INTO #{table_name}(#{keys.map { |i| \"\\\"#{i}\\\"\" }.join(',')}) VALUES(#{keys.map { |i| rows[i] == nil ? 'NULL' : \"'\" + pg_conn.escape_string(rows[i]) + \"'\" }.join(',')});\\n\"\n end",
"def dbinsert(table, variables, variable_names)\n i = 1\n marks = \"?\"\n while i < variables.length\n marks += \",?\"\n i += 1\n end\n\n v = \"\"\n i = 0\n while i < variables.length\n v += variables[i].to_s \n i += 1\n if i < variables.length\n v += \", \"\n end\n end\n\n return db.execute(\"INSERT INTO #{table}(#{v}) VALUES (#{marks})\", variable_names)\nend",
"def literal_string_append(sql, s)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(s)} << \"'\"\n end",
"def save()\n #connect to database\n db = PG.connect({ dbname: 'bounty_hunters', host: 'localhost' })\n #write big long SQL string\n sql = \"INSERT INTO bounties\n (\n name,\n species,\n bounty_value,\n favourite_weapon\n )\n VALUES\n ($1, $2, $3, $4)\"\n\n #make array of values for prepared statement\n values = [@name, @species, @bounty_value, @favourite_weapon]\n #prepare statement\n db.prepare(\"save\", sql)\n #exec statement\n db.exec_prepared(\"save\", values)\n #close link to db\n db.close()\n end",
"def bound_variable_arg(arg, conn)\n case arg\n when ArrayRow\n \"(#{arg.map{|v| bound_variable_array(v) if v}.join(',')})\"\n when HashRow\n arg.check_columns!\n \"(#{arg.values_at(*arg.columns).map{|v| bound_variable_array(v) if v}.join(',')})\"\n else\n super\n end\n end",
"def to_param\n \"#{id} #{full_number}\".parameterize\n end",
"def update()\ndb = PG connect( {dbname: 'bounty_hunter',\n host: 'localhost'\n })\nsql = \"UPDATE bounty_hunters\nSET (name,\n species,\n homeworld,\n favourite_weapon\n )=(\n $1, $2, $3, $4\n )\n WHERE id = $5\n \"\n\nvalues = [@name, @species, @homeworld, @favourite_weapon]\ndb.prepare('update',sql)\n db.exec_prepared('update', values)\n db.close\nend",
"def bind_hugeint(i, value)\n case value\n when Integer\n bind_varchar(i, value.to_s)\n else\n raise(ArgumentError, \"2nd argument `#{value}` must be Integer.\")\n end\n end",
"def bind_param( param, value )\n @statement.bind_param( param, value )\n end",
"def prepare_for_bind(string)\n string\n end",
"def interpolate(replacement, match)\n group_idx = replacement.index('$')\n return replacement if group_idx.nil?\n\n group_nbr = replacement[group_idx + 1]\n replacement.sub(\"$#{group_nbr}\", match[group_nbr.to_i])\n end",
"def check_parameter_count!( num )\n expected = @stmt_api.parameter_count\n if num != expected then \n raise Amalgalite::Error, \"#{sql} has #{expected} parameters, but #{num} were passed to bind.\"\n end\n return expected\n end",
"def sql_with_postgres_pgp(event)\n filter = /(pgp_sym_(encrypt|decrypt))\\(((.|\\n)*?)\\)/i\n\n event.payload[:sql] = event.payload[:sql].gsub(filter) do |_|\n \"#{$1}([FILTERED])\"\n end\n\n sql_without_postgres_pgp(event)\n end",
"def literal_string_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(v)} << \"'\"\n end",
"def bind_params_length\n 2_098\n end",
"def prepared_query(str)\n str.gsub(/\\,/, ' ')\n end",
"def prepared_query(str)\n str.gsub(/\\,/, ' ')\n end",
"def literal_string_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape_string(v)} << \"'\"\n end",
"def bind_first_unbound_field(value)\n field = @unbound_fields.first.first\n PreparedInstruction.new(bound_fields: @bound_fields + [[field,value]], unbound_fields: @unbound_fields[1..-1], operands: @operands)\n end",
"def dbselect2(find, table)\n if find.kind_of?(Array) == false\n variables = find\n else\n variables = \"\"\n i = 0\n while i < find.length\n variables += find[i].to_s\n i += 1\n if i < find.length\n variables += \", \"\n end\n end\n end\n return db.execute(\"SELECT #{variables} FROM #{table}\")\nend",
"def execute_prepared(sql,params_arr)\n prepared_statement = @database_handle.prepare(sql)\n params_arr.each_with_index do |param,index|\n prepared_statement.bind_param(index+1,param)\n end \n prepared_statement.execute\n end",
"def add_price(asin, title, price_s, price_i, day, day_i)\r\n $db.execute(\"INSERT INTO prices (asin, title, price_s, price_i, day, day_i) VALUES (?,?,?,?,?,?)\", [asin, title, price_s, price_i, day, day_i])\r\nend",
"def to_sql_ends_with\n \"%#{to_sql_escaped_for_like}\"\n end",
"def update_quantity(database, quantity, item)\n $database.execute(\"UPDATE shopping SET quantity = (?) WHERE item = (?)\", [quantity, item])\nend",
"def literal_string_append(sql, v)\n sql << \"'\" << ::Mysql.quote(v) << \"'\"\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def i(s)\n connection.quote_column_name(s)\n end",
"def query(n)\n @query_num_to_byte[n]\n end",
"def lit(*args)\n args.empty? ? self : SQL::PlaceholderLiteralString.new(self, args)\n end",
"def save()\n db = PG.connect({\n dbname: 'houses',\n host: 'localhost'\n })\n\nsql = \"INSERT INTO houses\n(address, value, num_bedrooms, year) VALUES\n($1, $2, $3, $4) RETURNING *\"\nvalues = [@address, @value, @num_bedrooms, @year]\ndb.prepare(\"save\", sql)\nresult = db.exec_prepared(\"save\", values)\n@id = result[0]['id'].to_i()\n\ndb.close()\nend",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def sql_match_pattern(column, value, **opt)\n '(%s)' % sql_test(column, value, **opt)\n end",
"def execute_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return perform_select(query_string).get_rows()\n end",
"def query_limit(query, table, limit=nil)\n\tquery = \"select #{query} form #{table}\"\n\tif limit != nil\n\t\tquery += \" LIMIT #{limit}\"\n\tend\n\treturn query\nend",
"def select_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return select_cached(query_string)\n end",
"def literal_string_append(sql, v)\n sql << \"'\" << v.gsub(\"'\", \"''\") << \"'\"\n end",
"def quote_ident(*args)\n PG::Connection.quote_ident(*args.map(&:to_s))\n end",
"def bind_string(name, value)\n ActiveRecord::Relation::QueryAttribute.new(name, value, Type::OracleEnhanced::String.new)\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def escaped_sql\n sql % binds.reduce({}) { |a, (col, val)|\n a[col.to_sym] = if val.is_a? Array\n val.map { |x| @conn.quote x }.join(', ')\n else\n @conn.quote val\n end\n a\n }\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def preprocess_query(query, *binds)\n mutex.synchronize do\n self.last_query = query\n end\n\n ep = Epoxy.new(query)\n ep.quote { |x| %Q{'#{binds[x].to_s.gsub(/'/, \"''\")}'} }\n end",
"def binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end",
"def get_query_parameter(original_name)\n raise StandardError, 'original_name cannot be null' if original_name.nil?\n case original_name\n when \"expand\"\n return \"%24expand\"\n when \"select\"\n return \"%24select\"\n else\n return original_name\n end\n end"
] |
[
"0.6733609",
"0.657479",
"0.5401105",
"0.53487104",
"0.53409624",
"0.5333208",
"0.53086066",
"0.50910074",
"0.50256133",
"0.4971306",
"0.49156997",
"0.49103904",
"0.49088508",
"0.48526096",
"0.48482475",
"0.48445773",
"0.48445773",
"0.48402953",
"0.483787",
"0.48369294",
"0.483429",
"0.483429",
"0.483429",
"0.48337406",
"0.4829956",
"0.4798174",
"0.479648",
"0.47902387",
"0.47829324",
"0.4774379",
"0.47576943",
"0.47440255",
"0.4743671",
"0.4734008",
"0.47070813",
"0.47035354",
"0.46840438",
"0.46805218",
"0.4668732",
"0.46651474",
"0.46625587",
"0.4662193",
"0.46551633",
"0.4618339",
"0.46102038",
"0.46100467",
"0.45818433",
"0.4581193",
"0.45637032",
"0.4541114",
"0.45312524",
"0.45291072",
"0.45283464",
"0.4524954",
"0.45037833",
"0.45022362",
"0.45014182",
"0.44983238",
"0.44918907",
"0.44874546",
"0.44737494",
"0.44697165",
"0.44585165",
"0.44585165",
"0.4446828",
"0.44432476",
"0.4441259",
"0.4438571",
"0.44328943",
"0.44271067",
"0.43975976",
"0.43902174",
"0.43879342",
"0.43879342",
"0.43879342",
"0.4387064",
"0.43800744",
"0.43724415",
"0.43712932",
"0.43681985",
"0.43681985",
"0.43640313",
"0.43618733",
"0.43538463",
"0.43506914",
"0.4349038",
"0.43474767",
"0.43474102",
"0.43438303",
"0.43438303",
"0.43425637",
"0.43305823",
"0.43305823",
"0.43305823",
"0.43302646",
"0.43300518",
"0.43265232",
"0.43265232",
"0.43265232",
"0.43223587"
] |
0.52231836
|
7
|
Use a cursor to fetch groups of records at a time, yielding them to the block.
|
def cursor_fetch_rows(sql)
server_opts = {:server=>@opts[:server] || :read_only}
cursor = @opts[:cursor]
hold = cursor[:hold]
cursor_name = quote_identifier(cursor[:cursor_name] || 'sequel_cursor')
rows_per_fetch = cursor[:rows_per_fetch].to_i
db.send(*(hold ? [:synchronize, server_opts[:server]] : [:transaction, server_opts])) do
begin
execute_ddl("DECLARE #{cursor_name} NO SCROLL CURSOR WITH#{'OUT' unless hold} HOLD FOR #{sql}", server_opts)
rows_per_fetch = 1000 if rows_per_fetch <= 0
fetch_sql = "FETCH FORWARD #{rows_per_fetch} FROM #{cursor_name}"
cols = nil
# Load columns only in the first fetch, so subsequent fetches are faster
execute(fetch_sql) do |res|
cols = fetch_rows_set_cols(res)
yield_hash_rows(res, cols){|h| yield h}
return if res.ntuples < rows_per_fetch
end
loop do
execute(fetch_sql) do |res|
yield_hash_rows(res, cols){|h| yield h}
return if res.ntuples < rows_per_fetch
end
end
rescue Exception => e
raise
ensure
begin
execute_ddl("CLOSE #{cursor_name}", server_opts)
rescue
raise e if e
raise
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def each\n (0...record_count).each do |i|\n yield get_record(i)\n end\n end",
"def each\n # Need to close the connection, teh result_set, AND the result_set.getStatement when\n # we're done.\n connection = open_connection!\n\n # We're going to need to ask for item/copy info while in the\n # middle of streaming our results. JDBC is happier and more performant\n # if we use a seperate connection for this.\n extra_connection = open_connection! if include_some_holdings?\n\n # We're going to make our marc records in batches, and only yield\n # them to caller in batches, so we can fetch copy/item info in batches\n # for efficiency.\n batch_size = settings[\"horizon.batch_size\"].to_i\n record_batch = []\n\n exclude_tags = (settings[\"horizon.exclude_tags\"] || \"\").split(\",\")\n\n\n rs = self.fetch_result_set!(connection)\n\n current_bib_id = nil\n record = nil\n record_count = 0\n\n error_handler = org.marc4j.ErrorHandler.new\n\n while(rs.next)\n bib_id = rs.getInt(\"bib#\");\n\n if bib_id != current_bib_id\n record_count += 1\n\n if settings[\"debug_ascii_progress\"] && (record_count % settings[\"solrj_writer.batch_size\"] == 0)\n $stderr.write \",\"\n end\n\n # new record! Put old one on batch queue.\n record_batch << record if record\n\n # prepare and yield batch?\n if (record_count % batch_size == 0)\n enhance_batch!(extra_connection, record_batch)\n record_batch.each do |r|\n # set current_bib_id for error logging\n current_bib_id = r['001'].value\n yield r\n end\n record_batch.clear\n end\n\n # And start new record we've encountered.\n error_handler = org.marc4j.ErrorHandler.new\n current_bib_id = bib_id\n record = MARC::Record.new\n record.append MARC::ControlField.new(\"001\", bib_id.to_s)\n end\n\n tagord = rs.getInt(\"tagord\");\n tag = rs.getString(\"tag\")\n\n # just silently skip it, some weird row in the horizon db, it happens.\n # plus any of our exclude_tags.\n next if tag.nil? || tag == \"\" || exclude_tags.include?(tag)\n\n indicators = rs.getString(\"indicators\")\n\n # a packed byte array could be in various columns, in order of preference...\n # the xref stuff is joined in from the auth table\n # Have to get it as bytes and then convert it to String to avoid JDBC messing\n # up the encoding marc8 grr\n authtext = rs.getBytes(\"xref_longtext\") || rs.getBytes(\"xref_text\")\n text = rs.getBytes(\"longtext\") || rs.getBytes(\"text\")\n\n\n if tag == \"000\"\n # Horizon puts a \\x1E marc field terminator on the end of hte\n # leader in the db too, but that's not really part of it.\n record.leader = String.from_java_bytes(text).chomp(\"\\x1E\")\n\n fix_leader!(record.leader)\n elsif tag != \"001\"\n # we add an 001 ourselves with bib id in another part of code.\n field = build_marc_field!(error_handler, tag, indicators, text, authtext)\n record.append field unless field.nil?\n end\n end\n\n # last one\n record_batch << record if record\n\n # yield last batch\n enhance_batch!(extra_connection, record_batch)\n\n record_batch.each do |r|\n yield r\n end\n record_batch.clear\n\n rescue Exception => e\n logger.fatal \"HorizonReader, unexpected exception at bib id:#{current_bib_id}: #{e}\" \n raise e\n ensure\n logger.info(\"HorizonReader: Closing all JDBC objects...\")\n\n # have to cancel the statement to keep us from waiting on entire\n # result set when exception is raised in the middle of stream.\n statement = rs && rs.getStatement\n if statement\n statement.cancel\n statement.close\n end\n\n rs.close if rs\n\n # shouldn't actually need to close the resultset and statement if we cancel, I think.\n connection.close if connection\n\n extra_connection.close if extra_connection\n\n logger.info(\"HorizonReader: Closed JDBC objects\")\n end",
"def each( & block )\n \n return atomic_cursor.each( & block )\n\n end",
"def each\n @records.each { |record| \n yield record\n }\n end",
"def each(&block)\n if @rows\n # we've been memoized\n @rows.each(&block)\n \n elsif start_record\n # we represent a single page\n # do the fetching and iterate\n @rows = fetch_rows\n\n @rows.each(&block)\n else\n # we represent the whole set of possible records\n # fetch repeatedly, in pages\n page_number = 1\n records_per_page = 100\n \n loop {\n # create a scope for this page\n inner_scope = page(page_number, records_per_page)\n \n # fetch the records as an array\n records = inner_scope.to_a\n \n # pass them to the caller\n records.each(&block)\n \n # is this the last page?\n if records.size < records_per_page\n # was this the first page?\n if page_number == 1\n # this is the only page\n # memoize\n @rows = records\n end\n \n # regardless, we're done\n break\n end\n \n page_number += 1\n }\n \n end\n \n self\n end",
"def each\n return enum_for(:each) unless block_given?\n\n relation = @query.all(batch_order).all(:limit => @per_chunk)\n records = relation.all(primary_key.name.gte => 0)\n\n while records.any?\n yield records\n\n break if records.size < @per_chunk\n\n if primary_key_offset = records.last.key.first\n records = relation.all(primary_key.name.gt => primary_key_offset)\n else\n raise \"Primary key not included in the custom select clause\"\n end\n end\n\n return self\n end",
"def run_cursor_loop(connection, &block)\n Backfiller.log 'Start cursor loop'\n\n total_count = 0\n cursor = build_cursor(connection)\n\n loop do\n finished, count = cursor.transaction do\n run_fetch_loop(cursor, &block)\n end\n\n total_count += count\n\n Backfiller.log \"Total processed #{total_count}\"\n break if finished\n end\n end",
"def each(&block)\n @grouped_collection.each { |gc| block.call(gc) }\n end",
"def each\n while @cur_record_index < @num_records\n yield _read_next_record\n end if @opened\n end",
"def cursor_eachrow(sql, name='csr', transaction=true, buffer_size=10000)\n count = 0\n begin\n begin_db_transaction if transaction\n open_cursor(sql, name, buffer_size)\n while (row = fetch_cursor(name)) do\n count+= 1\n #puts \"EACH CSR #{row.inspect}\"\n yield row\n end\n close_cursor(name)\n ensure\n commit_db_transaction if transaction\n end\n count\n end",
"def each\n @cursor = nil\n session = client.send(:get_session, @options)\n server = cluster.next_primary(nil, session)\n result = send_initial_query(server, session, context: Operation::Context.new(client: client, session: session))\n result = send_fetch_query(server, session) unless inline?\n @cursor = Cursor.new(view, result, server, session: session)\n if block_given?\n @cursor.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def each(&block)\n @raw_page['records'].each { |record| yield Restforce::Mash.build(record, @client) }\n\n np = next_page\n while np\n np.current_page.each(&block)\n np = np.next_page\n end\n end",
"def each(&block)\n return enum_for(:each) unless block\n while rec = fetch\n block.call rec\n end\n self\n end",
"def each(&block)\n return enum_for(:each) unless block\n while rec = fetch\n block.call rec\n end\n self\n end",
"def each(&block)\n @result_records.each(&block)\n end",
"def each(&block)\n @records.each(&block)\n end",
"def each\n @pool.with do |conn|\n conn.send_query @sql\n conn.set_single_row_mode\n loop do\n res = conn.get_result\n break unless res\n res.check\n res.stream_each { |row| yield row }\n end\n end\n end",
"def each(&block)\n records.each(&block)\n end",
"def find_each(options = {})\n find_in_batches(options) do |records|\n records.each { |record| yield record }\n end\n end",
"def each\n # If the caching cursor is closed and was not fully iterated,\n # the documents we have in it are not the complete result set and\n # we have no way of completing that iteration.\n # Therefore, discard that cursor and start iteration again.\n # The case of the caching cursor not being closed and not having\n # been fully iterated isn't tested - see RUBY-2773.\n @cursor = if use_query_cache? && cached_cursor && (\n cached_cursor.fully_iterated? || !cached_cursor.closed?\n )\n cached_cursor\n else\n session = client.send(:get_session, @options)\n select_cursor(session).tap do |cursor|\n if use_query_cache?\n # No need to store the cursor in the query cache if there is\n # already a cached cursor stored at this key.\n QueryCache.set(cursor, **cache_options)\n end\n end\n end\n\n if use_query_cache?\n # If a query with a limit is performed, the query cache will\n # re-use results from an earlier query with the same or larger\n # limit, and then impose the lower limit during iteration.\n limit_for_cached_query = respond_to?(:limit) ? QueryCache.normalized_limit(limit) : nil\n end\n\n if block_given?\n # Ruby versions 2.5 and older do not support arr[0..nil] syntax, so\n # this must be a separate conditional.\n cursor_to_iterate = if limit_for_cached_query\n @cursor.to_a[0...limit_for_cached_query]\n else\n @cursor\n end\n\n cursor_to_iterate.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def each_group(transaction=false)\n @db.transaction(transaction) do\n groups = @db[\"players\"] || Hash.new\n groups.each do |group, players|\n yield group,players\n end\n end\n end",
"def batch\n yield if block_given?\n end",
"def each_record\n return to_enum(:each_record) unless block_given?\n\n @relation.to_enum(:in_batches, of: @of, start: @start, finish: @finish, load: true).each do |relation|\n relation.records.each { |record| yield record }\n end\n end",
"def each_record\n return enum_for(:each_record) unless block_given?\n\n while (rec = record)\n yield rec\n end\n end",
"def each(&block)\n @all.each_batch { |batch| batch.each { |s| yield s } }\n end",
"def each\n 0.upto(@record_count - 1) do |n|\n seek_to_record(n)\n yield ADT::Record.new(self)\n end\n end",
"def find_each(options = {})\n find_in_batches(options) do |batch|\n batch.each { |record| yield record }\n end\n end",
"def each\n loop do\n data = fetch\n\n if data\n yield data\n else\n break\n end\n end\n end",
"def find_each(&block)\n find_in_batches do |batch|\n batch.each(&block)\n end\n end",
"def each_record(&block)\n return to_enum(:each_record) unless block_given?\n\n @relation.to_enum(:in_batches, of: @of, start: @start, finish: @finish, load: true, order: @order).each do |relation|\n relation.records.each(&block)\n end\n end",
"def all_sequentially &block\n page, per_page = 1, 5\n begin\n results = paginate(page: page, per_page: per_page, order: '_id asc')\n results.each{|o| block.call o}\n page += 1\n end until results.blank? or results.size < per_page\n end",
"def fetch_sequential(collection, &block)\n results = []\n engine = @turn_on_engine ? @engine_klass.new(@config.domain, @config.cache_http) : nil\n collection&.each_slice(@config.download_batch_size) do |batch|\n batch.each do |item|\n batch_results = block.call(item, engine)&.flatten\n results += ( batch_results || [])\n end\n end\n results\n end",
"def paged_each(opts=OPTS, &block)\n use_cursor(opts).each(&block)\n end",
"def find_each\n return enum_for(:find_each) unless block_given?\n\n client = IronBank.client\n query_string = IronBank::QueryBuilder.zoql(object_name, query_fields)\n query_result = client.query(query_string) # up to 2k records from Zuora\n\n loop do\n query_result[:records].each { |data| yield new(data) }\n break if query_result[:done]\n\n query_result = client.query_more(query_result[:queryLocator])\n end\n end",
"def each\n return to_enum(:each) unless block_given?\n\n @dataset.entries.find_in_batches(batch_size: @batch_size) do |group|\n search_result = RLetters::Solr::Connection.search(search_query_for(group))\n\n # :nocov:\n unless search_result.num_hits == group.size\n fail \"Failed to get batch of results in DocumentEnumerator (wanted #{group.size} hits, got #{search_result.num_hits})\"\n end\n # :nocov:\n\n search_result.documents.each { |doc| yield(doc) }\n end\n end",
"def each(&block)\n group.each_value(&block)\n end",
"def each\n params = {}\n if range[:begin]\n begin_key = range[:begin_inclusive] ? :start : :after\n params[begin_key] = range[:begin]\n end\n if range[:end]\n end_key = range[:end_inclusive] ? :end : :before\n params[end_key] = range[:end]\n end\n params[:limit] = range[:limit]\n @response ||= collection.perform(:list, params)\n return enum_for(:each) unless block_given?\n raise ResultsNotReady.new if collection.app.inside_parallel?\n loop do\n @response.results.each do |doc|\n yield KeyValue.from_listing(collection, doc, @response)\n end\n break unless @response.next_link\n @response = @response.next_results\n end\n @response = nil\n end",
"def each_group\n @groups.each_value do | group |\n yield( group )\n end\n end",
"def each_row_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_row_batch(&block) if block_given?\n cursor.iterate_batched\n end",
"def each\n while row=self.next\n yield row\n end\n end",
"def each\n while row=self.next\n yield row\n end\n end",
"def each_row_for_next_chunk\n return nil if finished?\n raise \"#{self.class}: instance not prepared before running the iteration\" unless @prepared\n\n select_sql = @select_sql.present? ? @select_sql : '*'\n sql = \"SELECT #{select_sql} FROM #{data_table_name} WHERE #{data_where_scope} ORDER BY id ASC LIMIT #{Import::CHUNK_ROWS_COUNT} OFFSET #{@iteration_number * Import::CHUNK_ROWS_COUNT}\"\n pg_result = postgres.copy(\"COPY (#{sql}) TO STDOUT WITH CSV DELIMITER ','\") do |row|\n yield row\n end\n\n @iteration_number += 1\n check_if_finished\n end",
"def each_instance_batch_by_sql(sql, options={}, &block)\n options = {:connection => self.connection}.merge(options)\n cursor = PostgreSQLCursor::Cursor.new(sql, options)\n return cursor.each_instance_batch(self, &block) if block_given?\n cursor.iterate_type(self).iterate_batched\n end",
"def each(&block)\n @db.each_key{|key|yield key, @db[key]}\n end",
"def rows(opts={'group_id' => nil, 'return_data' => true, 'start' => nil, 'limit' => nil})\n update if running?\n if succeeded?\n if not opts['group_id'].nil?\n collection = link('groups') + '/' + opts['group_id'].to_s\n else\n collection = link('rows')\n end\n return Cursor.new({'collection' => collection,\n 'start' => opts['start'],\n 'limit' => opts['limit'],\n 'extra_args' => {:return_data => opts['return_data']}}.update(@opts))\n elsif running?\n raise VeritableError.new(\"Grouping on column #{column_id} is still running and not yet ready to return groups.\")\n elsif failed?\n raise VeritableError.new(\"Grouping on column #{column_id} has failed and cannot return groups.\")\n else\n raise VeritableError.new(\"Grouping -- Shouldn't be here -- please let us know at support@priorknowledge.com.\")\n end\n end",
"def each(&block)\n @queries.each &block\n end",
"def each_set(&block)\n loops = 0\n while records = self.records\n begin\n block.call(records)\n loops += 1\n if @max > 0 && loops >= @max\n raise MaxIterations, self\n end\n ensure\n @redis.set(key, @current_id) if @current_id\n end\n end\n end",
"def process(record)\n this_key = get_key(record)\n if this_key != self.key\n finalize { |record| yield record } unless self.key == :__first_group__\n self.key = this_key\n start record\n end\n accumulate(record)\n end",
"def each_record\n return enum_for(:each_record) unless block_given?\n\n c = record_cursor(:min)\n\n while (rec = c.record)\n yield rec\n end\n\n nil\n end",
"def each_garbage_record\n return enum_for(:each_garbage_record) unless block_given?\n return if garbage_offset.zero?\n\n c = record_cursor(garbage_offset)\n\n while (rec = c.record)\n yield rec\n end\n\n nil\n end",
"def each\n @job = block = (block_given? ? Proc.new : @job)\n each_set do |records|\n records.each do |record|\n block.call(record)\n @current_id = record.send(@id_field)\n end\n end\n cleanup\n end",
"def each(&block)\n results.each(&block)\n end",
"def each\n response = run\n\n entities = @collection.deserialize(response.entities)\n entities.each { |x| yield(x) }\n\n while continue?(response)\n response.entities = []\n\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n\n entities = @collection.deserialize(response.entities)\n entities.each { |x| yield(x) }\n end\n\n response.count\n end",
"def each(&block)\n @current_page += 1\n fetch_current_page if !@fetched_current_page\n @items.each { |i| block.call i } \n @fetched_current_page = false\n end",
"def fetch_rows(sql, &block)\n execute(sql) do |r|\n r.each(:symbolize_keys => true, &block)\n end\n self\n end",
"def eachGroup(&block)\n debug(\"Running 'eachGroup' in GroupNodeSet\")\n @nodeSets.each { |g|\n block.call(g)\n }\n end",
"def each\n @data.each do |row|\n yield row\n end\n end",
"def each_with_index\n @h.seek(0, IO::SEEK_SET)\n\n i = 0\n while(record = @h.read(@record_size))\n yield(record, i)\n i += 1\n end\n end",
"def each_with_details\n transaction do\n cursor = connection.select_value(\"select place.all_with_attributes('place_cursor')\")\n place = nil\n begin\n # We have to strip off the place information from the first record...\n results = many.next_with_attributes(cursor)\n unless results.empty?\n place = with_details(results)\n yield place\n else\n place = nil\n end\n end while !place.nil?\n end\n end",
"def each(&block)\n\t plan.query_each(result_set, &block)\n\t self\n\tend",
"def each_record#:yields: record\n return unless self.dataset\n self.dataset.each do |record|\n yield record\n end\n end",
"def each(&block)\n @collection.each do |collectable|\n if block_given?\n block.call collectable\n else \n yield collectable\n end\n end \n end",
"def process_group\n slice_size = 0.step(@ids.size - 1, @process_group_chunk).size\n\n @ids.each_slice(slice_size).lazy\n # => [[1, 2, 3, ...], [10, 11, 12, ...], ...]\n end",
"def each_slice(&block)\n @csv.each_slice(1000) do |slice|\n yield(slice) if block_given?\n end\n end",
"def each(query_options={}, start_page=0, limit=15) # :yields: rows, skip, page, max_page, max_rows\n pages(@default_query_options.merge(query_options), start_page, limit, true, false) do |rows, skip, page, max_page ,max_rows|\n yield [rows, skip, page, max_page ,max_rows]\n end\n end",
"def run_once(&processor)\n processor = Proc.new { |cursor, batch| process(cursor, batch) } unless block_given?\n\n logger.info(\"Starting loop\")\n cursor_group.with_next do |cursor|\n logger.info(\"Selecting cursor for #{cursor.name}\")\n cursor.load_from_db unless cursor.from_env?\n logger.info(\"Finding batch...\")\n batch = find_batch(cursor)\n\n logger.info(\"Attempting to process\")\n if batch.empty? || processor.call(cursor, batch) == :stop\n logger.info(\"No more work found, stopping.\")\n next false\n end\n\n cursor.save_to_db unless cursor.from_env?\n next true\n end\n end",
"def chunk_records(records, batch_size)\n Enumerator.new do |enum|\n chunked_records = []\n\n records.each do |record|\n if chunked_records.size == batch_size\n enum.yield(chunked_records)\n chunked_records = []\n end\n\n transformed_record = block_given? ? yield(record) : record\n chunked_records.push(transformed_record)\n end\n\n # Yield the remaining records if any\n enum.yield(chunked_records) unless chunked_records.empty?\n end\nend",
"def fetch_rows(sql)\n return cursor_fetch_rows(sql){|h| yield h} if @opts[:cursor]\n execute(sql){|res| yield_hash_rows(res, fetch_rows_set_cols(res)){|h| yield h}}\n end",
"def consume_each_batch\n kafka_consumer.each_batch(\n ConfigAdapter.consuming(consumer_group)\n ) do |batch|\n yield(batch.messages)\n end\n end",
"def groups(opts={'start' => nil, 'limit' => nil})\n update if running?\n if succeeded?\n return Cursor.new({'collection' => link('groups'),\n 'start' => opts['start'],\n 'limit' => opts['limit']}.update(@opts)) { |g| g['group_id'] }\n elsif running?\n raise VeritableError.new(\"Grouping on column #{column_id} is still running and not yet ready to return groups.\")\n elsif failed?\n raise VeritableError.new(\"Grouping on column #{column_id} has failed and cannot return groups.\")\n else\n raise VeritableError.new(\"Grouping -- Shouldn't be here -- please let us know at support@priorknowledge.com.\")\n end\n end",
"def each(&block)\n @collection.each(&block)\n end",
"def each\n while row = next_row\n yield row\n end\n return self\n end",
"def each(&block) \n reset\n \n while transaction = next_transaction\n yield transaction\n end\n end",
"def each\n group.each\n end",
"def each_with_iterator\n\n iterator = get_iterator_fast\n while (iterator.has_next?)\n yield iterator.get_next, iterator if block_given?\n end\n \n end",
"def records_for_rebuild(batch_size = 1000)\n transaction do\n if use_fast_batches?\n offset = 0\n while (rows = find :all, :conditions => [ \"#{table_name}.id > ?\", offset ], :limit => batch_size).any?\n offset = rows.last.id\n yield rows, offset\n end\n else\n order = \"#{primary_key} ASC\" # fixes #212\n 0.step(self.count, batch_size) do |offset|\n yield find( :all, :limit => batch_size, :offset => offset, :order => order ), offset\n end\n end\n end\n end",
"def each\n @collection.each { |c| yield c }\n end",
"def find_all(&block)\r\n copy_and_return(@records.select(&block))\r\n end",
"def each_record\n keys.sort.each {|key| yield @records[key]}\n end",
"def each(&block)\n @size.times { |position| yield self.get(position) }\n end",
"def process(cursor, batch) end",
"def fetch_loop\n settings = ApiAdapter.consumption(consumer_group)\n\n if consumer_group.batch_fetching\n kafka_consumer.each_batch(**settings) { |batch| yield(batch, :batch) }\n else\n kafka_consumer.each_message(**settings) { |message| yield(message, :message) }\n end\n # @note We catch only the processing errors as any other are considered critical (exceptions)\n # and should require a client restart with a backoff\n rescue Kafka::ProcessingError => e\n # If there was an error during consumption, we have to log it, pause current partition\n # and process other things\n Karafka.monitor.instrument(\n 'connection.client.fetch_loop.error',\n caller: self,\n error: e.cause\n )\n pause(e.topic, e.partition)\n retry\n end",
"def _each(&block)\n _next.each(&block) if _next\n end",
"def each(&block)\n current_page = self\n while current_page\n current_page.results.each(&block)\n current_page = current_page.next_page\n end\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 find_each\n if @model == Magento::Category\n raise NoMethodError, 'undefined method `find_each` for Magento::Category'\n end\n\n @current_page = 1\n\n loop do\n redords = all\n\n redords.each do |record|\n yield record\n end\n\n break if redords.last_page?\n\n @current_page = redords.next_page\n end\n end",
"def each\n store.read do |data|\n data[:columns][column].each do |id, contents| \n yield(Record.new(column, id, contents)) \n end\n end\n end",
"def find_each(options = {})\n return enum_for(:find_each, options) unless block_given?\n\n find_in_batches options do |batch|\n batch.each do |record|\n yield record\n end\n end\n end",
"def each(&block)\n @collection.each(&block)\n end",
"def get_records_with_filter (&block)\n ui2 = @records_unpacked\n records = []\n\n ui2_size = ui2.size\n offset = 0\n ptr = ui2\n\n while(offset < ui2_size) do\n curr_record_type = ptr[0]\n record_size = ptr[1]\n offset += (record_size/2)\n\n yield records, curr_record_type, offset, ptr\n\n ptr = ptr[(record_size/2)..-1]\n end\n\n records\n end",
"def each(&block)\n process_results unless @processed\n @results.each(&block)\n end",
"def script_do_in_batches(options = {}, &block)\n start = Time.now\n count_options = options.reject {|k,v| %w(order select batch_size sleep logger).include?(k.to_s)}\n item_count = count(count_options)\n iteration = 1\n do_in_batches(options) do |record|\n msg = \"#{iteration} of #{item_count} (#{(iteration.to_f / item_count * 100).round(2)}%)\"\n puts \"#{record.id.to_s.ljust(10)} #{msg.ljust(30)} time #{Time.now - start}\"\n yield(record)\n iteration += 1\n end\n puts \"Finished in #{Time.now - start} s\"\n end",
"def each(opts = {})\n current_start = opts[:start] || ''\n finish = opts[:finish] || ''\n batch_size = opts[:batch_size] || 100\n \n while list = slice(:start => current_start, :finish => finish, :count => batch_size)\n list.each do |it|\n yield(it)\n end\n \n # batch wasnt full, so we are done\n break if list.length < batch_size\n \n current_start = @config.compare_with.incr(list.last.name)\n end\n end",
"def eager_cursor rows_per_fetch=1000, *associations\n cursor = use_cursor(rows_per_fetch: rows_per_fetch)\n cursor.each_slice(rows_per_fetch) do |records|\n associations.each do |assoc|\n refl = model.association_reflection(assoc)\n case refl[:type]\n when :one_to_one\n EagerCursorOneToMany\n when :many_to_one\n EagerCursorManyToOne\n else\n raise \"Cannot handle: #{refl[:type]}\"\n end.new(records, refl).load\n end\n\n records.each do |r|\n yield(r)\n end\n end\n end",
"def each(&block)\n Fetcher.new(self).each(&block)\n end",
"def find_batch(cursor)\n expansion_number = 1\n cursor[:seen_ids] ||= []\n state = self.start_batch_state(cursor)\n last_scanned_positions = []\n last_updated_at = cursor.updated_at || Time.at(0)\n\n while true\n results = self.execute_batch_find(state, expansion_number)\n\n # The list of tuples identifying the records by both their id, and file hashes,\n # to compare when we see a stable set of results.\n scanned_positions = results\n .map { |r| self.result_scanned_position(r) }\n .sort\n\n # Partition our results into those that\n # have a changed hash and those who do not.\n changed_set, unchanged_set = results.partition do |result|\n file_hashes_changed?(cursor, result)\n end\n\n # After a previous scan, in which we did not yield a changed dataset, if the last_scanned_positions\n # is stable with the next one (despite a larger expansion number), we assume that we are not going to\n # find a changed set in the future, and thus commit to returning the changed_set, updating our seen_ids.\n if scanned_positions == last_scanned_positions\n update_seen_ids(cursor, changed_set)\n\n return changed_set\n end\n\n last_scanned_positions = scanned_positions\n\n if changed_set.empty?\n # Increase out paging size, see if we get new results and find a changed set.\n expansion_number += 1\n else\n # Persist all scanned records here with their last known\n # file hashes, so we can compare them against future changes.\n update_seen_ids(cursor, changed_set)\n cursor.updated_at = changed_set.map { |r| self.result_updated_at(r) }.max\n return changed_set\n end\n end\n end",
"def each\n return enum_for(:each) unless block_given?\n\n @data.collection.each { |item| yield item }\n end",
"def select_rows(table_name, &block)\n return self.connection.select_all(\"SELECT * FROM #{table_name}\") unless block_given?\n\n row_count = count(table_name);\n pages = (row_count.to_f/batch_size).ceil\n (1..pages).each do |page|\n rows = select_paged_rows(table_name, batch_size, page)\n yield rows, page, pages\n end\n\n end",
"def each\n raise ResultsAlreadyConsumedException unless @unread\n\n if block_given?\n @unread = false\n @source.each { |row| yield symbolize_row_keys(row) }\n else\n Enumerator.new(self)\n end\n end",
"def find_in_batches(batch_size: 1000, &block)\n if iterator\n iterator.call(&block)\n elsif query\n manager_uuids_set.each_slice(batch_size) do |batch|\n yield(query.where(inventory_collection.targeted_selection_for(batch)))\n end\n else\n manager_uuids_set.each_slice(batch_size) do |batch|\n yield(inventory_collection.db_collection_for_comparison_for(batch))\n end\n end\n end"
] |
[
"0.6799851",
"0.6772429",
"0.65938264",
"0.65904593",
"0.65655833",
"0.6564742",
"0.65478736",
"0.6546743",
"0.652328",
"0.6497984",
"0.64833355",
"0.6441489",
"0.642705",
"0.642705",
"0.6414251",
"0.63845885",
"0.62919897",
"0.6277137",
"0.6227007",
"0.6220967",
"0.61979157",
"0.6196815",
"0.61733997",
"0.6163897",
"0.6161397",
"0.6142486",
"0.61245996",
"0.6100486",
"0.6091787",
"0.60862106",
"0.6069723",
"0.606341",
"0.6039819",
"0.60066676",
"0.599416",
"0.59915",
"0.5989139",
"0.5989006",
"0.59803313",
"0.59568787",
"0.59568787",
"0.5925727",
"0.5915589",
"0.5878775",
"0.5877445",
"0.58456284",
"0.5840858",
"0.5836276",
"0.58360726",
"0.58258456",
"0.58241546",
"0.58129394",
"0.5809546",
"0.58067614",
"0.5802068",
"0.57865673",
"0.5778422",
"0.57714325",
"0.57655567",
"0.5763805",
"0.5745656",
"0.5734625",
"0.57142854",
"0.57039654",
"0.5690012",
"0.56889755",
"0.56872624",
"0.56859875",
"0.5680838",
"0.56727076",
"0.566583",
"0.5665546",
"0.5662912",
"0.5650824",
"0.56466115",
"0.5645752",
"0.56409293",
"0.5627872",
"0.5620745",
"0.56114537",
"0.5610866",
"0.5607011",
"0.5602807",
"0.55997473",
"0.5594229",
"0.55895567",
"0.55892295",
"0.5588141",
"0.5585909",
"0.55745655",
"0.55710846",
"0.5565333",
"0.5564747",
"0.555753",
"0.55436367",
"0.55387056",
"0.5538024",
"0.55316436",
"0.5525091",
"0.55234295"
] |
0.55665255
|
91
|
Set the columns based on the result set, and return the array of field numers, type conversion procs, and name symbol arrays.
|
def fetch_rows_set_cols(res)
cols = []
procs = db.conversion_procs
res.nfields.times do |fieldnum|
cols << [fieldnum, procs[res.ftype(fieldnum)], output_identifier(res.fname(fieldnum))]
end
self.columns = cols.map{|c| c[2]}
cols
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_column_descriptors\n #skip past header to get to column information\n @data.seek(HEADER_LENGTH)\n \n # column names are the first 128 bytes and column info takes up the last 72 bytes. \n # byte 130 contains a 16-bit column type\n # byte 136 contains a 16-bit length field\n @columns = []\n @column_count.times do\n name, type, length = @data.read(200).unpack('A128 x S x4 S')\n if length > 0\n @columns << Column.new(name.strip, type, length)\n end\n end\n # Reset the column count in case any were skipped\n @column_count = @columns.size\n \n @columns\n end",
"def columns()\n \t cols = {}\n cols['oml_sender_id'] = {:type => 'INTEGER'}\n cols['oml_seq'] = {:type => 'INTEGER'}\n cols['oml_ts_client'] = {:type => 'REAL'}\n cols['oml_ts_server'] = {:type => 'REAL'}\n \t if @filters.size > 0\n \t @filters.each do |f|\n cols.merge!(f.columns)\n \t end\n \t else\n #appDef = AppDefinition[@application.to_s]\n appDef = @application.appDefinition\n appDef.measurements[@mdef].metrics.each do |name, opts|\n #[name] = {:type => type, :description => description, :seqNo => @metrics.length}\n case (type = opts[:type])\n when 'xsd:string' then\n cols[name] = {:type => 'TEXT'}\n when 'xsd:long', 'xsd:float' then\n if @single_sample_mode\n cols[name] = {:type => Xsd2SqlType[type]}\n else\n cols[\"#{name}_avg\"] = cols[\"#{name}_min\"] = cols[\"#{name}_max\"] = {:type => 'REAL'}\n end\n else\n error \"Type '#{opts[:type]}' for '#{name}' not implemented\"\n end\n \t end\n \t end\n cols\n \tend",
"def result_meta\n unless @result_meta\n meta = []\n column_count.times do |idx|\n column_meta = ::OpenStruct.new\n column_meta.name = @stmt_api.column_name( idx )\n\n db_name = @stmt_api.column_database_name( idx ) \n tbl_name = @stmt_api.column_table_name( idx ) \n col_name = @stmt_api.column_origin_name( idx ) \n\n column_meta.schema = ::Amalgalite::Column.new( db_name, tbl_name, col_name, idx )\n column_meta.schema.declared_data_type = @stmt_api.column_declared_type( idx )\n\n # only check for rowid if we have a table name and it is not one of the\n # sqlite_master tables. We could get recursion in those cases.\n if not using_rowid_column? and tbl_name and\n not %w[ sqlite_master sqlite_temp_master ].include?( tbl_name ) and is_column_rowid?( tbl_name, col_name ) then\n @rowid_index = idx\n end\n\n meta << column_meta \n end\n\n @result_meta = meta\n end\n return @result_meta\n end",
"def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end",
"def columns\n ColumnCollection.new(@data)\n end",
"def fetch_fields\n fields = @result.fields\n field_types = @result.field_types\n tables = @result.respond_to?(:tables) ? @result.tables : [] # My addition to mysql2 results.c\n fields_arr = []\n (0...@result.fields.length).each do |i|\n fields_arr[i] = MySQL_FIELD.new(\n name: fields[i],\n table: tables[i],\n db: databases[i],\n type: field_types[i]\n )\n end\n return fields_arr\n end",
"def columns \n @c\n end",
"def columns\n @stmt.columns\n end",
"def columns; @columns; end",
"def columns\n @columns ||= 1.upto(@rowset.get_meta_data.get_column_count).map do |i|\n {\n :id => @rowset.get_meta_data.getColumnName(i),\n :name => @rowset.get_meta_data.getColumnLabel(i)\n }\n end\n end",
"def columns\n @columns ||= [];\n end",
"def columns; @columns_hash.values; end",
"def columns\n @stmt.columns\n end",
"def columns!\n ds = clone(opts.merge(:sql => \"SELECT TOP 1 [T1].* FROM (#{opts[:sql]}) \\\"T1\\\"\"))\n ds.each{break}\n\n if cols = ds.cache[:_columns]\n self.columns = cols\n else\n []\n end\n end",
"def all_columns(excluded_supertypes) #:nodoc:\n columns = []\n trace :columns, \"All Columns for #{name}\" do\n if is_table\n self_value_reference\n else\n columns << ActiveFacts::RMap::Column.new\n end\n references_from.each do |ref|\n trace :columns, \"Columns absorbed via #{ref}\" do\n columns += ref.columns({})\n end\n end\n end\n columns\n end",
"def calculate_column_names(method)\n column_names = AllTypesObject.column_names\n case method\n when 'calculate', 'count'\n column_names = [nil] + column_names\n when 'average', 'sum'\n column_names = column_names.reject { |a| ['binary_col', 'boolean_col', 'date_col', 'datetime_col', 'string_col', 'text_col', 'timestamp_col', 'created_at', 'updated_at'].include?(a) }\n when 'maximum', 'minimum'\n column_names = column_names.reject { |a| ['binary_col', 'boolean_col'].include?(a) }\n end\n column_names\n end",
"def columns\n collect = []\n recursive_columns(@base, collect)\n end",
"def columns\n @columns = @clazz.columns_hash.map do |name, column|\n [name, @columns[name] || Column.new(column, @dump)]\n end.to_h.with_indifferent_access\n end",
"def columns; end",
"def columns\n @columns ||= [].tap do |fields|\n @model.columns.reject { |a| a.name.match(/_id$/) }.each do |column|\n fields << resolve(column.type, column.name)\n end\n end\n end",
"def columns\n @columns ||= []\n end",
"def columns\n @pz.group_by.each_with_index { |val, n| column_id(n) }\n end",
"def column_names\n\t\t@validated_gets.map{|f| f[:external]} + [\"usd_2009\", \"usd_current\", \"count\", \"min_year\", \"max_year\"]\n\tend",
"def columns \n []\n end",
"def all\n __getobj__.column_names\n end",
"def create_column_data_array\n\ttable_id = create_table_id('../data/census_column_metadata.csv')\n\tcolumn_id = create_column_id('../data/census_column_metadata.csv')\n\t\n\t[title_processor,table_id,column_id].transpose\n\nend",
"def convert_columns(arr)\n if ccs = @column_converters\n arr.zip(ccs).map{|v, pr| (v && pr) ? pr.call(v) : v}\n else\n arr \n end\n end",
"def columns()\n cols = {}\n prefix = \"#{@opts[:pname]}_\"\n fspec = @opts[:fspec]\n\n fspec.params.each do |name, opts|\n cols[prefix + name] = opts\n end\n cols \n end",
"def get_columns_name\r\n columns = []\r\n if @columns != nil\r\n @columns.each do |column|\r\n columns.push column\r\n end\r\n end\r\n \r\n if @stats != nil and @stats.length > 0\r\n @stats.each do |stat|\r\n columns.push stat.to_column_name\r\n end\r\n end\r\n \r\n return columns\r\n end",
"def columns\n select.inject([]) do |columns, column|\n columns << {\n :type => all_columns[column][:type]\n }.merge({\n :id => column.to_s,\n :label => column_label(column)\n })\n end\n end",
"def columns\n @columns ||= @csv_data[0].zip(*@csv_data[1..])\n end",
"def columns(table_name, name = nil)#:nodoc:\n sql = \"SHOW FIELDS FROM #{quote_table_name(table_name)}\"\n columns = []\n result = execute(sql, name)\n result.each do |field|\n klass = field[1] =~ /geometry|point|linestring|polygon|multipoint|multilinestring|multipolygon|geometrycollection/i ? ActiveRecord::ConnectionAdapters::SpatialMysql2Column : ActiveRecord::ConnectionAdapters::Mysql2Column\n columns << klass.new(field[0], field[4], field[1], field[2] == \"YES\")\n end\n columns\n end",
"def columns(tables)\n columns = execute <<-SQL\n SELECT\n s.nspname || '.' || t.relname AS table_name,\n a.attname AS column_name,\n pg_catalog.format_type(a.atttypid, a.atttypmod) AS data_type\n FROM pg_attribute a\n JOIN pg_class t on a.attrelid = t.oid\n JOIN pg_namespace s on t.relnamespace = s.oid\n WHERE a.attnum > 0\n AND NOT a.attisdropped\n AND s.nspname || '.' || t.relname IN (#{tables.map {|t| quote(t)}.join(\", \")})\n ORDER BY\n 1, 2\n SQL\n\n columns.map {|v| {table: v[\"table_name\"], column: v[\"column_name\"], type: v[\"data_type\"]}}\n end",
"def columns\n @columns ||= begin\n column_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end",
"def columns\n self.class.const_get(:COLUMNS) rescue []\n end",
"def columns\n single_record unless @columns\n @columns || []\n end",
"def generateResultColumns\n resultColumns = {\n columns: {},\n maxRowIndex: 0 # We're going to count the rows, for future use\n }\n\n # Using a lambda to add the right columns into resultColumns, and keep track\n # of maxRowIndex\n setColumnValue = lambda do |column, rowIndex, value|\n unless self.columnIsFiltered?(column)\n resultColumns[:columns][column] ||= []\n resultColumns[:columns][column][rowIndex] = value\n end\n\n # Gotta keep track of how many rows we're working with.\n resultColumns[:maxRowIndex] = rowIndex if rowIndex > resultColumns[:maxRowIndex]\n end\n\n # Exit early if this is a simple math operation\n if @rawResponse.is_a? Numeric\n resultColumns[:columns]['result'] = [@rawResponse]\n resultColumns[:maxRowIndex] = 1\n return resultColumns\n end\n\n rowIndex = 0\n @rawResponse.each do |object|\n if object[\"value\"].is_a? Array\n # This result is grouped! We're gonna have to create alot more columns and rows\n object[\"value\"].each do |group|\n\n # iterate over each value grouping, and store the values\n self.flatten(group).each do |column, value|\n setColumnValue.call(column, rowIndex, value)\n end\n if object[\"timeframe\"]\n self.flatten({\"timeframe\" => object[\"timeframe\"]}).each do |column, value|\n setColumnValue.call(column, rowIndex, value)\n end\n end\n rowIndex += 1\n\n end\n else\n # Not grouped: This either an Extraction or a math operation on an interval.\n self.flatten(object).each do |column, value|\n setColumnValue.call(column, rowIndex, value)\n end\n rowIndex += 1\n\n end\n end\n\n resultColumns\n end",
"def columns\n @columns ||= @stats.values.flatten.map { |a| a.column_name }\n end",
"def columns\n @columns = columns_hash.values\n end",
"def columns\n @header.to_a\n end",
"def process_result_set(result, opts=OPTS)\n meta = result.getMetaData\n if fetch_size = opts[:fetch_size]\n result.setFetchSize(fetch_size)\n end\n\n converters = []\n self.columns = meta.getColumnCount.times.map do |i|\n col = i + 1\n converters << TypeConverter::MAP[meta.getColumnType(col)]\n meta.getColumnLabel(col)\n end\n\n fetch_as_array = opts[:as] == :array\n while result.next\n row = fetch_as_array ? [] : {}\n _columns.each_with_index do |column, i|\n k = fetch_as_array ? i : column\n col = i+1\n row[k] = converters[i].call(result, col, opts)\n end\n yield row\n end\n ensure\n result.close\n end",
"def columns\n end",
"def to_a()\n res = []\n r = @raw\n @schema.each do |col|\n res << @vprocs[col[:name]].call(r)\n end\n res\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def get_columns(class_name)\n \t\t\tcolumns = [] # the standard columns we will show depending on the type\n \t\t\tall_possible_columns = [] # every column available depending on type\n\t\t\t\tglobal_add = ['id'] # the standard columns that we'll always show\n \t\t\tglobal_remove = ['created_at', 'updated_at', 'datastore'] # stuff we never show\n\t\n\t\t\t\tif class_name == \"Host\"\n\t\t\t\t\tcolumns = [ 'address','name','state','os_name','os_flavor','os_sp']\n\t\t\t\telsif class_name == \"Service\"\n\t\t\t\t\tcolumns = ['port','proto','state','name']\n\t\t\t\telsif class_name == \"Session\"\n\t\t\t\t\tcolumns = [ 'host_id', 'local_id', 'stype', 'closed_at', 'port', 'desc' ]\n\t\t\t\tend\n\n\t\t\t\t## generate all possible columns\n\t\t\t\tif eval(\"Msf::DBManager::#{class_name}.respond_to?('columns')\")\n\t \t\t\t\teval(\"Msf::DBManager::#{class_name}.columns.each do |type_col|\n\t \t\t\t\t\t\tall_possible_columns << type_col.name\n\t \t\t\t\t\tend\")\n\t \t\t\tend\n\t \t\t\tif all_possible_columns.empty?\n\t \t\t\t\tprint_error(\"The database does not recognize #{class_name} objects\")\n\t \t\t\t\tprint_deb(\"DBManager didn't respond_to? #{class_name}.columns\")\n\t \t\t\t\treturn []\n\t \t\t\tend\t\t\n\n\t\t\t\t# if columns is still empty, just dup all_possible_columns\n\t\t\t\tcolumns = all_possible_columns.dup if columns.empty?\n\t\t\t\t\n\t\t\t\t# Globally remove these \t\t\t\n\t\t\t\tcolumns = columns - global_remove\n\n\t\t\t\t# Globally add these\n\t\t\t\tcolumns = global_add | columns\n\n \t\t\treturn [columns,all_possible_columns]\n \t\tend",
"def initialize\n @col_specs = []\n end",
"def columns\n @columns_hash.values\n end",
"def columns(table)\n dbh = DBI::DatabaseHandle.new(self)\n uniques = []\n dbh.execute(\"SHOW INDEX FROM #{table}\") do |sth|\n sth.each do |row|\n uniques << row[4] if row[1] == \"0\"\n end\n end \n\n ret = nil\n dbh.execute(\"SHOW FIELDS FROM #{table}\") do |sth|\n ret = sth.collect do |row|\n name, type, nullable, key, default, extra = row\n #type = row[1]\n #size = type[type.index('(')+1..type.index(')')-1]\n #size = 0\n #type = type[0..type.index('(')-1]\n\n sqltype, type, size, decimal = mysql_type_info(row[1])\n col = Hash.new\n col['name'] = name\n col['sql_type'] = sqltype\n col['type_name'] = type\n col['nullable'] = nullable == \"YES\"\n col['indexed'] = key != \"\"\n col['primary'] = key == \"PRI\"\n col['unique'] = uniques.index(name) != nil\n col['precision'] = size\n col['scale'] = decimal\n col['default'] = row[4]\n col\n end # collect\n end # execute\n \n ret\n end",
"def columns\n @columns\n end",
"def columns(table_name, _name = nil)\n return [] if table_name.blank?\n table_structure(table_name).each_with_object([]) do |col, cols|\n col_name = col[0] # SQLColumns: COLUMN_NAME\n col_default = col[1] # SQLColumns: COLUMN_DEF\n col_sql_type = col[2] # SQLColumns: DATA_TYPE\n col_nullable = col[3] # SQLColumns: IS_NULLABLE\n col_native_type = col[4] # SQLColumns: TYPE_NAME\n col_limit = col[5] # SQLColumns: COLUMN_SIZE\n col_scale = col[6] # SQLColumns: DECIMAL_DIGITS\n\n args = { sql_type: col_sql_type, type: col_sql_type, limit: col_limit }\n args[:sql_type] = 'boolean' if col_native_type == self.class::BOOLEAN_TYPE\n\n if [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(col_sql_type)\n args[:scale] = col_scale || 0\n args[:precision] = col_limit\n end\n sql_type_metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(**args)\n cols << new_column(format_case(col_name), col_default, sql_type_metadata, col_nullable, table_name, col_native_type)\n end\n end",
"def column_names\n keys = COLUMN_NAMES\n keys.map{|key| [Person.field_name(key), key]}\n end",
"def to_a\n columns.map { |column| @attributes[column.name.underscore] }\n end",
"def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n else\n \"\"\n end\n }.compact\n end",
"def info\n if @filtered_rset.empty?\n @columns = {}\n return\n end\n\n query = @filtered_rset.to_sql\n\n @columns = @filtered_rset.first.attributes.each_with_object({}) do |c, m|\n m[c[0].to_sym] = nil\n m\n end\n\n tables = ActiveRecord::Base.connection.tables.select do |t|\n Regexp.new('\\b' + t + '\\b') =~ query\n end\n\n tables.each do |t|\n ActiveRecord::Base.connection.columns(t).each do |c|\n @columns[c.name.to_sym] = c.type if @columns.key?(c.name.to_sym)\n end\n end\n\n unless (extra = @columns.values.reject(&:present?)).empty?\n msg = extra.join(', ') + 'have missing types, perhaps these are aliased?'\n raise KilterError, msg\n end\n end",
"def numeric_columns(table_name)\n columns = []\n @client.query(\"DESC `#{table_name}`;\").each do |column|\n if is_numeric(column[\"Type\"])\n columns.push(column[\"Field\"])\n end\n end\n\n columns\n end",
"def cols_array\n arr = Array.new\n @columns_hash.each{|k,v| arr << k}\n return arr\n end",
"def pack_cursor(cursor, options = {})\n \n recordset = []\n column_names = []\n var_cursor = cursor.get_col_names\n \n while current_row = cursor.fetch() \n case options[:return]\n when 'hash'\n current_record = {}\n current_row.each_index{ |index| \n current_record[var_cursor[index]] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n }\n when 'array'\n current_record = []\n current_row.each_index{ |index| \n current_record[index] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n } \n end\n \n recordset.push(current_record)\n end\n \n return recordset, column_names\n end",
"def add_column_types obj\n FbArray.new(obj)\n end",
"def columns\n CellCollection.new(@data, @row)\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def query_part_column_names\n remote_query_column_types.map{|name, type| name}.join(\"\\n , \")\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def cols\r\n if !@cols\r\n require \"#{File.dirname(__FILE__)}/drivers/#{@opts[:type]}/knjdb_#{@opts[:type]}_columns\" if (!@opts.key?(:require) or @opts[:require])\r\n @cols = Kernel.const_get(\"KnjDB_#{@opts[:type]}\".to_sym).const_get(:Columns).new(\r\n :db => self\r\n )\r\n end\r\n \r\n return @cols\r\n end",
"def generateColumnDef()\n res=@conn.exec(\"select tablename from pg_tables where schemaname='public'\")\n classObj = \"\"\n for i in res\n classObj = classObj + \"\\n\\n\\n== \"+ i[0].to_s + \"\\n\"\n classObj = classObj + genrateTabledesc(i[0].to_s)\n classObj = classObj + \"\\n\"\n classObj = classObj + \".Properties\\n\"\n classObj = classObj + \"[frame=\\\"none\\\",options=\\\"header\\\"]\\n\"\n classObj = classObj + \"|======================================================================================\\n\"\n classObj = classObj + \"| | Data Type | Description \\n\"\n classObj = classObj + self.singleTableColDef(i.to_s)\n classObj = classObj + \"|======================================================================================\\n\"\n classObj = classObj + \"=== Links\\n\"\n classObj = classObj + self.generateForeignKeyDef(i.to_s)\n classObj = classObj + \"=== Methods\\n\"\n classObj = classObj + self.generateStoredProcDef(i.to_s)\n end\n puts classObj\n return classObj\n end",
"def column_names\n self[0].keys\n end",
"def columns\n raise NotImplementedError\n end",
"def expected_columns; end",
"def to_a\n columns\n end",
"def columns\n return @columns if @columns\n return nil if frozen?\n set_columns(dataset.naked.columns)\n end",
"def columns\n return @columns if @columns\n return nil if frozen?\n set_columns(dataset.naked.columns)\n end",
"def get_columns\n return @columns\n end",
"def columns()\n (cr=@records.get(GRT_COLROW)) ? cr[0] : nil\n end",
"def columns(table_name)\n column_definitions(table_name.to_s).map do |column_name, type, default, notnull, oid, fmod|\n default_value = extract_value_from_default(default)\n type_metadata = fetch_type_metadata(column_name, type, oid, fmod)\n default_function = extract_default_function(default_value, default)\n new_column(column_name, default_value, type_metadata, notnull == 'f', table_name, default_function)\n end\n end",
"def to_a\n column_names = [@query.klass.primary_key] | connect_by_columns\n column_names.map { |name| @query.table[name] }\n end",
"def to_columns\n @columns = transpose_to_columns\n end",
"def column_names\n klass.new.attributes.keys\n end",
"def infer_types!\n types = Array.new(ncols)\n each do |row| merge_types(types, row[:*].infer_string_types) end\n types.each.with_index do |type, i|\n colname = @colnames[i]\n if type <= Integer then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Integer(@rows[rowid][colname]) end\n elsif type <= Float then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Float(@rows[rowid][colname]) end\n end\n end\n self\n end",
"def to_a(cols=[])\n col_info = column_info(cols)\n rows = []\n rows << col_info.keys\n while try { @result_set.next } do\n row = []\n col_info.each do |col, info|\n obj = try{ @result_set.object(info[:index]) }\n case info[:type]\n when :string\n row << obj.to_s\n when :boolean\n row << (obj.to_s =~ /true/i ? true : false)\n when :long\n row << obj.to_i\n when :double\n row << obj.to_f\n else\n log.warning \"Unkown type: #{info[:type]} for #{col}\"\n row << obj.to_s\n end\n end\n rows << row\n end\n rows\n end",
"def columns\n self.class.instance_variable_get(:@columns)\n end",
"def columns\n @columns ||= dataset.columns\n end",
"def columns\n @columns ||= dataset.columns\n end",
"def columns; self.class.columns; end",
"def column_names\n klass.properties.keys\n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def columns\n _columns || columns!\n end",
"def columns\n @model.columns.map{|c| c.name}\n end",
"def columns\n @columns\n end",
"def column_names\n klass.attributes\n end",
"def _field_assignments\n result = []\n @fields.each do |field|\n field_type = field.type.type_sym # Record, Union, Enum, Array or Map\n schema_base_type = _schema_base_class(field.type)\n field_base_type = _field_type(schema_base_type)\n method_argument = %i(array map).include?(field_type) ? 'values' : 'value'\n is_schema_class = %i(record enum).include?(schema_base_type.type_sym)\n\n field_initialization = method_argument\n\n if is_schema_class\n field_initialization = \"#{field_base_type}.initialize_from_value(value)\"\n end\n\n result << {\n field: field,\n field_type: field_type,\n is_schema_class: is_schema_class,\n method_argument: method_argument,\n deimos_type: deimos_field_type(field),\n field_initialization: field_initialization\n }\n end\n\n result\n end",
"def columns!\n @columns = nil\n columns\n end",
"def columns\n unless @columns\n @columns = collection_info[table_name].columns.collect { |col_def|\n col = ActiveRecord::ConnectionAdapters::Column.new(col_def.name, col_def.default, col_def.sql_type, col_def.null)\n col.primary = col.name == primary_key\n col\n }\n end\n @columns\n end",
"def column_names\n columns.map(&:name)\n end",
"def columns(table_name, name = nil) #:nodoc:\r\n table_structure(table_name).map do |field|\r\n AdvantageColumn.new(strip_or_self(field['COLUMN_NAME']), field['COLUMN_DEF'], strip_or_self(field['TYPE_NAME']), field['NULLABLE'])\r\n end\r\n end",
"def columns\n @columns || self.class.columns\n end",
"def table_columns\n klass.column_names\n end",
"def columns\n return @columns\n end",
"def columns(table_name, name = nil) end",
"def select_arr\n result = []\n result.push \"#{groups.first.parent_table}_0_fk.year\" # Manually add the year of the survey\n # for each group\n groups.each_with_index do |group, idx|\n group_alias = \"#{group.parent_table}_#{idx}\" # Calculate the group alias for this table\n # all questions for this group\n questions = questions_for_group(group).uniq{|question|question.attribute_name}\n questions.each do |question|\n col_name = \"#{group_alias}_fk.#{question.attribute_name}\" #\n result.push col_name\n end\n end\n return result\n end"
] |
[
"0.6341035",
"0.6265122",
"0.61390173",
"0.61286724",
"0.6065369",
"0.60560626",
"0.6054228",
"0.6051409",
"0.60335994",
"0.6031213",
"0.60208285",
"0.60194063",
"0.599764",
"0.5990914",
"0.5966242",
"0.59636736",
"0.5963157",
"0.59273154",
"0.59227055",
"0.59190816",
"0.5916492",
"0.59151226",
"0.5911951",
"0.5907253",
"0.5905813",
"0.59015197",
"0.58979255",
"0.5891876",
"0.5877034",
"0.5831298",
"0.5822882",
"0.58100003",
"0.5801798",
"0.57933706",
"0.57877266",
"0.5786901",
"0.5773673",
"0.5769042",
"0.5764552",
"0.57620895",
"0.5717951",
"0.57116616",
"0.5705185",
"0.56949246",
"0.5694132",
"0.56882113",
"0.56859547",
"0.56780344",
"0.5666365",
"0.56659293",
"0.5665493",
"0.56647074",
"0.5659662",
"0.56545544",
"0.5652408",
"0.56507987",
"0.5649102",
"0.5649101",
"0.5644797",
"0.5644117",
"0.5644117",
"0.5643691",
"0.56428903",
"0.56428903",
"0.563521",
"0.56348693",
"0.56323963",
"0.563012",
"0.56241894",
"0.5622756",
"0.5617761",
"0.5617761",
"0.5617278",
"0.561157",
"0.5610982",
"0.56034994",
"0.5591844",
"0.5588644",
"0.5587397",
"0.5580531",
"0.55799204",
"0.5577071",
"0.5577071",
"0.55733335",
"0.55714613",
"0.55684316",
"0.55623066",
"0.5558331",
"0.5553321",
"0.5549476",
"0.55399364",
"0.5535662",
"0.55325484",
"0.5531881",
"0.5530067",
"0.55102867",
"0.55094445",
"0.5473971",
"0.5473575",
"0.5466207"
] |
0.7526813
|
0
|
Use the driver's escape_bytea
|
def literal_blob_append(sql, v)
sql << "'" << db.synchronize(@opts[:server]){|c| c.escape_bytea(v)} << "'"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def escape_bytea(str)\n # each_byte used instead of [] for 1.9 compatibility\n str.gsub(/[\\000-\\037\\047\\134\\177-\\377]/n){|b| \"\\\\#{sprintf('%o', b.each_byte{|x| break x}).rjust(3, '0')}\"}\n end",
"def escape(string); end",
"def escape(str); end",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def escaped_char(escape)\n if escape =~ /^\\\\([0-9a-fA-F]{1,6})[ \\t\\r\\n\\f]?/\n $1.to_i(16).chr(Encoding::UTF_8)\n else\n escape[1]\n end\n end",
"def escape(value)\n end",
"def escape(value)\n _escape(value.to_s.to_str)\n rescue ArgumentError\n _escape(value.to_s.to_str.force_encoding(Encoding::UTF_8))\n end",
"def insert_bytea(column, value = :no_value)\n @columns << column\n @values << Translate.escape_bytea(value, @connection.pgconn) unless value == :no_value\n end",
"def convert_escape_characters(*args, &block)\n maatsf_convert_escape_characters(super(*args, &block))\n end",
"def escape(s)\n dummy_conn.escape(s)\n end",
"def shell_escape\n inspect.gsub(/\\\\(\\d{3})/) { $1.to_i(8).chr }\n end",
"def escape(str)\n str.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").force_encoding('US-ASCII')\n end",
"def escape_string(str)\n raw_connection.escape(str)\n end",
"def escape_string(str)\n if not defined? Encoding and @charset.unsafe\n raise ClientError, 'Mysql#escape_string is called for unsafe multibyte charset'\n end\n self.class.escape_string str\n end",
"def string_to_binary(value)\n # Escape data prior to insert into a bytea column\n if value\n res = ''\n value.each_byte { |b| res << sprintf('\\\\\\\\%03o', b) }\n res\n end\n end",
"def escape_value(connection, value)\n connection.quote(value)\n end",
"def escape(val)\n return val\n end",
"def escape(value)\n $db.escape_identifier(value)\nend",
"def escape(str)\n str.dump\n end",
"def escape_text(text)\n text\n end",
"def escape(input); input.to_s.gsub('\"', '\\\\\"'); end",
"def escape(string)\n @conn.escape(string.to_s)\n end",
"def escape(text)\n text.gsub('\"', '\\\"')\nend",
"def escape(str, unsafe = @regexp[:UNSAFE])\n unless unsafe.kind_of?(Regexp)\n # perhaps unsafe is String object\n unsafe = Regexp.new(\"[#{Regexp.quote(unsafe)}]\", false)\n end\n str.gsub(unsafe) do\n us = $&\n tmp = ''\n us.each_byte do |uc|\n tmp << sprintf('%%%02X', uc)\n end\n tmp\n end.force_encoding(Encoding::US_ASCII)\n end",
"def escape(str, unsafe = @regexp[:UNSAFE])\n unless unsafe.kind_of?(Regexp)\n # perhaps unsafe is String object\n unsafe = Regexp.new(\"[#{Regexp.quote(unsafe)}]\", false)\n end\n str.gsub(unsafe) do\n us = $&\n tmp = ''\n us.each_byte do |uc|\n tmp << sprintf('%%%02X', uc)\n end\n tmp\n end.force_encoding(Encoding::US_ASCII)\n end",
"def escape_literal(text)\n text\n end",
"def escape(str)\n return ActiveRecord::Base.connection.quote_string(str)\n end",
"def escape_string (string)\n string.gsub(/([\\x00-\\x1f\\x21-\\x2f\\x3a-\\x40\\x5b-\\x5e\\x60\\x7b-\\x7f])/, '\\\\\\\\\\\\1')\n end",
"def encode_quoted_printable!\n self.replace(self.encode_quoted_printable)\n end",
"def escape(string)\n # This code is taken directly from the documentation so we dont have to rely on the SQLite3::Database class. This way it can also be used with JRuby and IronRuby...\n # http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html\n string.to_s.gsub(\"'\", \"''\")\n end",
"def cgi_escape(input); end",
"def _raw(string)\n ::Hanami::Utils::Escape::SafeString.new(string)\n end",
"def escape(s)\n s.gsub('\"', '\\\"')\nend",
"def escape_string(str)\n return if str.nil?\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\nend",
"def gas_escape(str)\n str.gsub(/./) { |s| \"\\\\x#{s[0].ord.to_s(16)}\"}\n end",
"def escape(string)\n if backend.unsafe? || @unsafe\n Shellwords.escape(string)\n else\n string\n end\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def create_escape_value(value)\n if value.is_a?(String) || value.is_a?(Symbol)\n \"#{sanitize_escape_sequences(value.to_s)}\"\n else\n value\n end\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def escape(str)\n str.to_s.gsub(/[%\\s]/) { |m| format(\"%%%<code>02X\", code: m.ord) }\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(str)\n str.dump[1..-2]\nend",
"def escape(s)\n s.to_s.gsub('\"', '"').gsub(\"'\", ''')\n end",
"def escape(str)\n str.gsub(/\\t/, '\\t').gsub(/\\n/, '\\n').gsub(/\\\\/, \"\\\\\\\\\\\\\")\n end",
"def set_escaped(options={})\n self.split(//).map do |ch|\n res = ch.escaped\n res = \"\\\\x#{'%02X' % ch.ord}\" if options[:no_ctrl] && res=~/^\\\\\\w$/\n res.gsub(\"-\",'\\\\-')\n end.join\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def quote(value, column = nil)\n case value\n when String, ActiveSupport::Multibyte::Chars\n value_S = value.to_s\n if column && column.type == :binary && column.class.respond_to?(:string_to_binary)\n \"'#{column.class.string_to_binary(value_S)}'\"\n else\n super(value, column)\n end\n else\n super(value, column)\n end\n end",
"def quote_and_escape(value)\n case value\n when \"NULL\"\n value\n else\n value = value.gsub(/\\\\/, ARRAY_ESCAPE)\n value.gsub!(/\"/,\"\\\\\\\"\")\n \"\\\"#{value}\\\"\"\n end\n end",
"def escape(string)\n raise NotImplementedError, \"#{self.class}#escape\"\n end",
"def escape_value(value)\n value = value.to_s.dup\n value.gsub!(%r{\\\\([0nrt])}, '\\\\\\\\\\1')\n value.gsub!(%r{\\n}, '\\n')\n value.gsub!(%r{\\r}, '\\r')\n value.gsub!(%r{\\t}, '\\t')\n value.gsub!(%r{\\0}, '\\0')\n value\n end",
"def escape(value)\n value.nil? ? nil : value.shellescape\n end",
"def escape(text)\n return text.gsub(/[\\`*_{}\\[\\]()#+\\-.!]/, \"\\\\\\\\\\\\0\")\n end",
"def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend",
"def escape(x)\n x = x.to_s\n x.gsub! @delimiter, @edelim if @delimiter\n x.gsub! @internal_delimiter, @eidelim\n x\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] }\n end",
"def bytea(value)\n \"'\\\\x#{value.unpack1('H*')}'::bytea\"\n end",
"def consume_escaped; end",
"def parse_escaped_chars; end",
"def _escape(text)\n ensure_mutable = text.is_a?(BuilderMutableString) ? text : BuilderMutableString.new(text)\n ensure_mutable.to_xs\n end",
"def escape(stream = '')\n return stream if absent?(stream)\n\n stream.gsub(/\\e/, '\\\\e')\n end",
"def escape(string)\n encoding = string.encoding\n string.b.gsub(/([^ a-zA-Z0-9_.\\-~]+)/) do |m|\n '%' + m.unpack('H2' * m.bytesize).join('%').upcase\n end.tr(' ', '+').force_encoding(encoding)\n end",
"def to_escaped_for_sql_like\n gsub(/[\\\\%_]/) { |x| '\\\\' + x }.gsub(\"*\", \"%\")\n end",
"def escape(str)\n ERB::Util.h(str).gsub('"', '\"').gsub(''', \"'\")\n end"
] |
[
"0.7539368",
"0.6832843",
"0.6641921",
"0.6616155",
"0.6569809",
"0.6566083",
"0.6548586",
"0.65367967",
"0.6482915",
"0.64156884",
"0.6363001",
"0.63303304",
"0.6325926",
"0.6306962",
"0.6290523",
"0.62771755",
"0.6260701",
"0.6244157",
"0.6196593",
"0.61818475",
"0.61613554",
"0.6119606",
"0.6118438",
"0.611227",
"0.611227",
"0.6103488",
"0.60710955",
"0.6063605",
"0.6054324",
"0.605303",
"0.60193574",
"0.5965706",
"0.59606993",
"0.5955937",
"0.5949009",
"0.59431756",
"0.5930705",
"0.5918335",
"0.59121704",
"0.58971334",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.5875907",
"0.58713114",
"0.5864273",
"0.58603215",
"0.5836255",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.58332276",
"0.5825242",
"0.58198726",
"0.581967",
"0.5812203",
"0.5808025",
"0.57903445",
"0.5775991",
"0.5762943",
"0.5758434",
"0.5751397",
"0.5744429",
"0.5740748",
"0.5728673",
"0.57285845",
"0.57241446",
"0.5715144",
"0.57048887"
] |
0.0
|
-1
|
Use the driver's escape_string
|
def literal_string_append(sql, v)
sql << "'" << db.synchronize(@opts[:server]){|c| c.escape_string(v)} << "'"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def escape(s)\n dummy_conn.escape(s)\n end",
"def escape(string)\n @conn.escape(string.to_s)\n end",
"def escape_string(str)\n raw_connection.escape(str)\n end",
"def escape(string); end",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def escape(str)\n return ActiveRecord::Base.connection.quote_string(str)\n end",
"def escape(str); end",
"def escape(string)\n # This code is taken directly from the documentation so we dont have to rely on the SQLite3::Database class. This way it can also be used with JRuby and IronRuby...\n # http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html\n string.to_s.gsub(\"'\", \"''\")\n end",
"def escape(str)\n str.gsub(/\\t/, '\\t').gsub(/\\n/, '\\n').gsub(/\\\\/, \"\\\\\\\\\\\\\")\n end",
"def escape(input); input.to_s.gsub('\"', '\\\\\"'); end",
"def escape(str)\n str.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").force_encoding('US-ASCII')\n end",
"def escape(string)\n string.gsub('\\\\', '\\\\\\\\').\n gsub(\"\\b\", '\\\\b').\n gsub(\"\\f\", '\\\\f').\n gsub(\"\\t\", '\\\\t').\n gsub(\"\\n\", '\\\\n').\n gsub(\"\\r\", '\\\\r').\n gsub('\"', '\\\\\"')\n end",
"def escape(s)\n s.to_s.gsub('\"', '"').gsub(\"'\", ''')\n end",
"def escape_string(str)\n if not defined? Encoding and @charset.unsafe\n raise ClientError, 'Mysql#escape_string is called for unsafe multibyte charset'\n end\n self.class.escape_string str\n end",
"def escape_string (string)\n string.gsub(/([\\x00-\\x1f\\x21-\\x2f\\x3a-\\x40\\x5b-\\x5e\\x60\\x7b-\\x7f])/, '\\\\\\\\\\\\1')\n end",
"def escape(s)\n s.gsub('\"', '\\\"')\nend",
"def escape(string)\n if backend.unsafe? || @unsafe\n Shellwords.escape(string)\n else\n string\n end\n end",
"def escape(string)\n if string.present?\n string.gsub(/\\\"/, \"\\\\\\\"\").gsub(/\\'/, '\\\\\\\\\\'')\n else\n nil\n end\n end",
"def escape(text)\n text.gsub('\"', '\\\"')\nend",
"def escape(str)\n str.dump\n end",
"def extra_escape(string)\n string.gsub('\\\\', '\\\\\\\\\\\\').\n gsub(\"\\\\'\", '\\\\\\\\' + \"'\").\n gsub('\\\\\\\\\\\\', '\\\\\\\\\\\\')\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end",
"def escape_text(text)\n text\n end",
"def escape(str)\n ERB::Util.h(str).gsub('"', '\"').gsub(''', \"'\")\n end",
"def quote_string( s ) #:nodoc:\n @connection.escape( s )\n end",
"def quote_string(s) #:nodoc:\n @connection.escape(s)\n end",
"def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] }\n end",
"def escape(value)\n end",
"def escape(string)\n return '' if string.nil?\n return string unless string.to_s =~ /[\\\\\\$`\" \\(\\)\\{\\}\\[\\]]/\n '\"' + string.to_s.gsub(/[\\\\\\$`\"]/) { |match| '\\\\' + match } + '\"'\n end",
"def escape(value)\n _escape(value.to_s.to_str)\n rescue ArgumentError\n _escape(value.to_s.to_str.force_encoding(Encoding::UTF_8))\n end",
"def escape_string(str)\n str.gsub(\"'\", \"''\")\n end",
"def escape_string(string)\n string.to_s.gsub(/([\\\\()|\\-!@~\"&\\/\\^\\$=])/, '\\\\\\\\\\\\1')\n end",
"def shell_escape(string)\n return string.gsub(/\\\\/, \"\\\\\\\\\\\\\").gsub(/\\\"/, \"\\\\\\\"\").gsub(/\\$/, \"\\\\\\$\").gsub(/\\`/, \"\\\\\\\\\\`\")\n end",
"def escape_value(connection, value)\n connection.quote(value)\n end",
"def escape(string)\n raise NotImplementedError, \"#{self.class}#escape\"\n end",
"def quote_string(string)\n with_raw_connection(allow_retry: true, materialize_transactions: false) do |connection|\n connection.escape(string)\n end\n end",
"def escape_for_double_quotes(str)\n str.gsub(/[\\\\\"`$]/) { |c| \"\\\\#{c}\" }\nend",
"def escape(value)\n $db.escape_identifier(value)\nend",
"def escape(text)\n return text.gsub(/[\\`*_{}\\[\\]()#+\\-.!]/, \"\\\\\\\\\\\\0\")\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def quote_string(string)\n @logger.unknown(\"ODBCAdapter#quote_string>\") if @trace\n\n # MySQL requires backslashes to be escaped\t\t\t\t\n string.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")\n end",
"def escape_hack(string)\n string.gsub('\\\\', '\\\\\\\\\\\\')\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def shell_escape(s)\n s = s.to_s\n if s !~ /^[0-9A-Za-z+,.\\/:=@_-]+$/\n s = s.gsub(\"'\") { \"'\\\\''\" }\n s = \"'#{s}'\"\n end\n s\n end",
"def escape_string(str)\n return if str.nil?\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\nend",
"def escape(string)\n return \"\" if string.nil?\n string = ':' + string.to_s if string.kind_of? Symbol\n string.gsub(\"\\\\\", \"\\\\\\\\\").gsub(\"&\", \"\\&\").gsub(\":\", \"\\:\").gsub(\"/\", \"\\/\")\n end",
"def shell_escape\n inspect.gsub(/\\\\(\\d{3})/) { $1.to_i(8).chr }\n end",
"def escape_for_cql_double_quotes(str)\n str = str.gsub('\"', \" \")\n str = str.gsub(\"'\", \"''\")\n\n return str\n end",
"def escape_shell_string(str)\n str = str.gsub(/\\\\/, \"\\\\\\\\\\\\\")\n str = str.gsub(/\"/, \"\\\\\\\"\")\n str = str.gsub(/`/, \"\\\\`\")\n str = str.gsub(/;/, \"\\\\;\")\n str = str.gsub(/&/, \"\\\\&\")\n str = str.gsub(/\\|/, \"\\\\|\")\n str = str.gsub(/\\$/, \"\\\\$\")\n str = str.gsub(/ /, \"\\\\ \")\n str\n end",
"def escape_single_quotes(str)\n str.gsub(\"'\", '\\\\\\\\\\'')\nend",
"def escape_double_quotes(str_to_escape)\n # Hash containing the required conversion\n conversions = {\n %r{\"}=>'"'\n } \n escaped_str = str_to_escape\n conversions.each do |x,y|\n escaped_str = escaped_str.gsub(x,y)\n end \n return escaped_str\n end",
"def escape_str(str)\n str.gsub!(/[`\\\\]/, '\\\\\\\\\\&')\n str.gsub!(/\\r\\n/, \"\\\\r\\r\\n\") if @newline == \"\\r\\n\"\n return str\n end",
"def escape_literal(text)\n text\n end",
"def escape_str_field(str)\n str = str.to_s.sub(/\\`/,'')\n @mysql.escape(str)\n end",
"def to_escaped_for_sql_like\n gsub(/[\\\\%_]/) { |x| '\\\\' + x }.gsub(\"*\", \"%\")\n end",
"def escape(val)\n return val\n end",
"def character_escape(string)\n string.gsub(/^'/, '').gsub(/'$/, '').gsub(/\\\\'/, \"'\")\n end",
"def _raw(string)\n ::Hanami::Utils::Escape::SafeString.new(string)\n end",
"def escape(string)\n out = +\"\"\n string.chars.each do |char|\n escape = nil\n case char\n when \"\\0\"\n escape = '0'\n when \"\\n\"\t\t\t\t# Must be escaped for logs */\n escape= 'n'\n when \"\\r\"\n escape= 'r';\n when \"\\\\\"\n escape= '\\\\';\n when '\\''\n escape= '\\'';\n when '\"'\t\t\t\t# Better safe than sorry */\n escape= '\"';\n end\n\n if escape\n out << '\\\\'\n out << escape\n else\n out << char\n end\n end\n out\n end",
"def escape_single_quotes(str_to_escape)\n # Hash containing the required conversion\n conversions = {\n %r{'}=>'%26apos;'\n } \n escaped_str = str_to_escape\n conversions.each do |x,y|\n escaped_str = escaped_str.gsub(x,y)\n end \n return escaped_str\n end",
"def escape_str(str)\n str.gsub!(/[\\\\`\\#]/, '\\\\\\\\\\&')\n str.gsub!(/\\r\\n/, \"\\\\r\\r\\n\") if @newline == \"\\r\\n\"\n return str\n end",
"def escape(str)\n CGI.escape(str)\n end"
] |
[
"0.80086935",
"0.7992954",
"0.7980062",
"0.7904878",
"0.78952354",
"0.7802086",
"0.7706913",
"0.76025826",
"0.7555844",
"0.754671",
"0.7527131",
"0.7501458",
"0.7473396",
"0.7428927",
"0.74200714",
"0.73981184",
"0.73971426",
"0.73894775",
"0.7380862",
"0.73803616",
"0.7291247",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.728375",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7282503",
"0.7275102",
"0.72738355",
"0.7243735",
"0.72192305",
"0.7211085",
"0.7192377",
"0.71644264",
"0.7150076",
"0.7136025",
"0.7115719",
"0.71078736",
"0.7104861",
"0.7089896",
"0.70775837",
"0.70646495",
"0.70621425",
"0.7048443",
"0.70450324",
"0.70348465",
"0.7033775",
"0.7025567",
"0.7022998",
"0.70000213",
"0.69987833",
"0.6995661",
"0.69580233",
"0.694467",
"0.69265914",
"0.69075996",
"0.69057107",
"0.68834233",
"0.68804926",
"0.68620116",
"0.6844758",
"0.68428254",
"0.6839621",
"0.6835165",
"0.68283296",
"0.68223697",
"0.67991155"
] |
0.0
|
-1
|
For each row in the result set, yield a hash with column name symbol keys and typecasted values.
|
def yield_hash_rows(res, cols)
res.ntuples.times do |recnum|
converted_rec = {}
cols.each do |fieldnum, type_proc, fieldsym|
value = res.getvalue(recnum, fieldnum)
converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value
end
yield converted_rec
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_hash(cols=[])\n col_info = column_info(cols)\n rows = []\n while try { @result_set.next } do\n row = {}\n col_info.each do |col, info|\n obj = try{ @result_set.object(info[:index]) }\n case info[:type]\n when :string\n row[col] = obj.to_s\n when :boolean\n row[col] = (obj.to_s =~ /true/i ? true : false)\n when :long\n row[col] = obj.to_i\n when :double\n row[col] = obj.to_f\n else\n log.warning \"Unkown type: #{info[:type]} for #{col}\"\n row[col] = obj.to_s\n end\n end\n rows << row\n end\n rows\n end",
"def resultset_to_hash(resultset)\n meta = resultset.meta_data\n rows = []\n\n while resultset.next\n row = {}\n\n (1..meta.column_count).each do |i|\n name = meta.column_name i\n row[name] = case meta.column_type(i)\n when -6, -5, 5, 4\n # TINYINT, BIGINT, INTEGER\n resultset.get_int(i).to_i\n when 41\n # Date\n resultset.get_date(i)\n when 92\n # Time\n resultset.get_time(i).to_i\n when 93\n # Timestamp\n resultset.get_timestamp(i)\n when 2, 3, 6\n # NUMERIC, DECIMAL, FLOAT\n case meta.scale(i)\n when 0\n resultset.get_long(i).to_i\n else\n BigDecimal.new(resultset.get_string(i).to_s)\n end\n when 1, -15, -9, 12\n # CHAR, NCHAR, NVARCHAR, VARCHAR\n resultset.get_string(i).to_s\n else\n resultset.get_string(i).to_s\n end\n end\n\n rows << row\n end\n rows\nend",
"def result_to_rows(result)\n result.rows.map do |row|\n typed_row = result.columns.zip(row).map do |column_name, value|\n typed_value = result.column_types[column_name].send(:type_cast, value)\n [column_name.to_sym, typed_value]\n end\n Hash[typed_row]\n end\n end",
"def each\n return unless @result\n\n @result.each(as: :hash, symbolize_keys: true) do |row|\n next unless row # This sometimes happens when streaming results...\n row = Hash[row.map { |k, v| [k, v.to_s] }] if @type_translation == :string\n yield row\n end\n end",
"def map_data_types(hsh)\n hsh.each_with_object({}) { |(column_name, column_type), hash| hash[column_name] = map_value(column_type) }\n end",
"def symbolize_row_keys(row)\n out = {} # move to a real hash!\n row.each do |key, value|\n out[key.to_sym] = value.respond_to?(:wrapper) ? value.wrapper : value\n end\n out\n end",
"def fetch\n row = @results[@index += 1]\n return unless row\n\n if @types\n row.map!.with_index { |value, index| translate_type(value, @types[index]) } if @types\n elsif @type_translation == :string\n row.map!(&:to_s)\n end\n\n Hash[*@columns.zip(row).flatten]\n end",
"def table_to_hash_lookup table, key_column, symbol_key = false, value_column=\"id\"\n key_column = key_column.to_s #allows for accepting symbols or strings\n value_column = value_column.to_s\n\n o=table.find_as_hashes(:all, :select => \"#{key_column}, #{value_column}\")\n #returns array of form\n # [{\"id\"=>\"1\", \"column\"=>\"value\"},{\"id\" => \"2\", \"column\" => \"value2\"}....]\n\n #convert to form\n #{'value' => 1, 'value2' => 2,...}\n\n dictionary=o.inject({}) {|result, element|\n #only get values that have a key column\n \n unless element[key_column].nil?\n entry = element[key_column].to_s#.force_encoding(\"utf-8\")\n entry = entry.to_sym if symbol_key\n #insert into the hash\n result[entry] = element[value_column].to_i \n end\n result\n }\n\n return dictionary\n end",
"def to_hash schema = {}\n schema = parse_schema schema\n\n HASH_TEMPLATE.clone.tap { |ret|\n @result.getNoVersionMap.each do |cf, cqmap|\n cqmap.each do |cq, val|\n name = ColumnKey.new(cf, cq)\n type = schema[name]\n ret[name] = type ? Util.from_bytes(type, val) : val\n end\n end\n }\n end",
"def pack_cursor(cursor, options = {})\n \n recordset = []\n column_names = []\n var_cursor = cursor.get_col_names\n \n while current_row = cursor.fetch() \n case options[:return]\n when 'hash'\n current_record = {}\n current_row.each_index{ |index| \n current_record[var_cursor[index]] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n }\n when 'array'\n current_record = []\n current_row.each_index{ |index| \n current_record[index] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n } \n end\n \n recordset.push(current_record)\n end\n \n return recordset, column_names\n end",
"def hash\n rows.hash\n end",
"def to_a(cols=[])\n col_info = column_info(cols)\n rows = []\n rows << col_info.keys\n while try { @result_set.next } do\n row = []\n col_info.each do |col, info|\n obj = try{ @result_set.object(info[:index]) }\n case info[:type]\n when :string\n row << obj.to_s\n when :boolean\n row << (obj.to_s =~ /true/i ? true : false)\n when :long\n row << obj.to_i\n when :double\n row << obj.to_f\n else\n log.warning \"Unkown type: #{info[:type]} for #{col}\"\n row << obj.to_s\n end\n end\n rows << row\n end\n rows\n end",
"def to_hash_with_versions schema = {}\n schema = parse_schema schema\n\n HASH_TEMPLATE.clone.tap { |ret|\n @result.getMap.each do |cf, cqmap|\n cqmap.each do |cq, tsmap|\n name = ColumnKey.new(cf, cq)\n type = schema[name]\n\n ret[name] =\n Hash[\n tsmap.map { |ts, val|\n [ ts, type ? Util.from_bytes(type, val) : val ]\n }\n ]\n end\n end\n }\n end",
"def process_result_set(result, opts=OPTS)\n meta = result.getMetaData\n if fetch_size = opts[:fetch_size]\n result.setFetchSize(fetch_size)\n end\n\n converters = []\n self.columns = meta.getColumnCount.times.map do |i|\n col = i + 1\n converters << TypeConverter::MAP[meta.getColumnType(col)]\n meta.getColumnLabel(col)\n end\n\n fetch_as_array = opts[:as] == :array\n while result.next\n row = fetch_as_array ? [] : {}\n _columns.each_with_index do |column, i|\n k = fetch_as_array ? i : column\n col = i+1\n row[k] = converters[i].call(result, col, opts)\n end\n yield row\n end\n ensure\n result.close\n end",
"def type_cast(table, row)\n @table_columns ||= {}\n unless @table_columns.include?(table)\n column_array = session.left.columns(table)\n column_hash = {}\n column_array.each {|column| column_hash[column.name] = column}\n @table_columns[table] = column_hash\n end\n columns = @table_columns[table]\n type_casted_row = {}\n row.each_pair do |column_name, value|\n type_casted_row[column_name] = columns[column_name].type_cast(value)\n end\n type_casted_row\n end",
"def row_hash(row)\n Hash[raw_headers.zip(row)].with_indifferent_access\n end",
"def extract_data(row)\n row_map.each_with_object({}) do |(db_column, row_column), output|\n output[db_column] = row[row_column]\n end\n end",
"def to_hash(row)\n r = {}\n row.each_with_index { |v, i| r[@cols[i]] = v }\n r\n end",
"def column_hash\n @table.hashes.reduce({}) do |h, row|\n row.each do |k,v|\n (h[k.symbolize] ||= []) << parse_formula(v)\n end\n h\n end\n end",
"def to_hash\n @data.map do |row|\n hsh = {}\n @field_names.each_with_index.map{ |fld, i| hsh[fld] = row[i] }\n hsh\n end\n end",
"def normalize_row(row)\n Hash[row.map{|column_name, row_value| [column_name.parameterize.underscore.to_sym, row_value.to_s]}]\n end",
"def next_hash\n result = @stmt.step\n return nil if result.nil?\n unless result.kind_of?(Hash)\n result_ary = result\n result = {}\n result_ary.each_with_index do |el, i|\n result[@stmt.column_name(i)] = el\n end\n end\n result\n end",
"def to_hash\n Hash[([column_names, column_values]).transpose]\n end",
"def to_hash\n Hash[([column_names, column_values]).transpose]\n end",
"def column_hash\n data_subject.df.to_h.reduce({}) do |h, (k,v)|\n h[k.symbolize] = v.to_a\n h\n end\n end",
"def result\n Hash[\n metadata.map do |key, value|\n [key, PostgresValue.for(value).result]\n end\n ]\n end",
"def fetch_rows_set_cols(res)\n cols = []\n procs = db.conversion_procs\n res.nfields.times do |fieldnum|\n cols << [fieldnum, procs[res.ftype(fieldnum)], output_identifier(res.fname(fieldnum))]\n end\n self.columns = cols.map{|c| c[2]}\n cols\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n columns = []\n convert = convert_smallint_to_bool\n cps = db.conversion_procs\n stmt.num_fields.times do |i|\n k = stmt.field_name i\n key = output_identifier(k)\n type = stmt.field_type(i).downcase.to_sym\n # decide if it is a smallint from precision\n type = :boolean if type == :int && convert && stmt.field_precision(i) < 8\n type = :blob if type == :clob && db.use_clob_as_blob\n columns << [key, cps[type]]\n end\n cols = columns.map{|c| c[0]}\n self.columns = cols\n\n while res = stmt.fetch_array\n row = {}\n res.zip(columns).each do |v, (k, pr)|\n row[k] = ((pr ? pr.call(v) : v) if v)\n end\n yield row\n end\n end\n self\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n self.columns = cols = stmt.result_fields.map{|c| output_identifier(c)}\n col_count = cols.size\n stmt.each do |result|\n row = {}\n col_count.times{|i| row[cols[i]] = result[i]}\n yield row\n end\n end\n end",
"def fetch\n row = @result.fetch\n return row unless @bind_result\n row.zip(@bind_result).map do |col, type|\n if col.nil?\n nil\n elsif [Numeric, Integer, Fixnum].include? type\n col.to_i\n elsif type == String\n col.to_s\n elsif type == Float && !col.is_a?(Float)\n col.to_i.to_f\n elsif type == Mysql::Time && !col.is_a?(Mysql::Time)\n if col.to_s =~ /\\A\\d+\\z/\n i = col.to_s.to_i\n if i < 100000000\n y = i/10000\n m = i/100%100\n d = i%100\n h, mm, s = 0\n else\n y = i/10000000000\n m = i/100000000%100\n d = i/1000000%100\n h = i/10000%100\n mm= i/100%100\n s = i%100\n end\n if y < 70\n y += 2000\n elsif y < 100\n y += 1900\n end\n Mysql::Time.new(y, m, d, h, mm, s)\n else\n Mysql::Time.new\n end\n else\n col\n end\n end\n end",
"def result_meta\n unless @result_meta\n meta = []\n column_count.times do |idx|\n column_meta = ::OpenStruct.new\n column_meta.name = @stmt_api.column_name( idx )\n\n db_name = @stmt_api.column_database_name( idx ) \n tbl_name = @stmt_api.column_table_name( idx ) \n col_name = @stmt_api.column_origin_name( idx ) \n\n column_meta.schema = ::Amalgalite::Column.new( db_name, tbl_name, col_name, idx )\n column_meta.schema.declared_data_type = @stmt_api.column_declared_type( idx )\n\n # only check for rowid if we have a table name and it is not one of the\n # sqlite_master tables. We could get recursion in those cases.\n if not using_rowid_column? and tbl_name and\n not %w[ sqlite_master sqlite_temp_master ].include?( tbl_name ) and is_column_rowid?( tbl_name, col_name ) then\n @rowid_index = idx\n end\n\n meta << column_meta \n end\n\n @result_meta = meta\n end\n return @result_meta\n end",
"def create_query_hash(array)\n names = array.shift\n rval = []\n array.each do |r|\n row = {}\n names.each_with_index { |column, idx| row[column] = r[idx] }\n rval << row\n end\n rval\nend",
"def row_to_hash(row, columns, key_map)\n hash = {}\n (0..columns.length - 1).each do |i|\n # First, convert the column name using the translation table\n key = key_map[columns[i]]\n\n # Only process column if it's name is included in translation table\n if key\n value = row[i]\n # For string values, convert carriage returns to newlines, since\n # EasyChair form-entered newlines appear to be stored as CRs in\n # the exported data. This is primarily for the abstract field,\n # but this code performs the mapping on all string-valued columns\n if value && value.is_a?(String)\n value.gsub!(/\\r/, \"\\n\")\n end\n\n # Now store the value in the hash we're building\n hash[key] = value\n end\n end\n # Return the hash created from the array representing a CSV row\n hash\nend",
"def columns_hash\n @columns_hash ||= columns.inject({}){|r,c| r.merge(c[:name].to_sym => c)}\n end",
"def machine_hash(headers,rows)\n # This is just to give a nice data structure (a hash of )\n rows.each_with_index.map do |row, index|\n # todo - rearrange the hash so it is sorted - do we need the row index?\n Hash[headers.each_with_index.map { |header, pos| \n [header, row[pos] ]}\n ].merge('row' => index+2)\n end\n end",
"def rs_to_hash(rs, index_key_field, multi_val)\n # setting default hash value is necessary for appending to arrays\n hash=Hash.new{ |h, k| h[k] = [] }\n\n # get basic metadata for the recordset\n meta = rs.getMetaData\n cols = meta.getColumnCount.to_i\n\n # loop through the records to add them into hash\n while rs.next do\n # if multi_val is not true... create new hash value as an empty hash if it doesn't already exist\n hash[rs.getString(index_key_field)]={} if (!hash[rs.getString(index_key_field)] and !multi_val)\n\n # if multi_val is true... create new hash value as an empty array if it doesn't already exist\n hash[rs.getString(index_key_field)]=[] if (!hash[rs.getString(index_key_field)] and multi_val)\n\n # r is a temporary hash for the row being processed\n r=Hash.new\n\n # add each row to r\n (1..cols).each do |c|\n r[meta.get_column_name(c)] = rs.getObject(c)\n if convert_to_ruby_time_classes.include?(r[meta.get_column_name(c)].class)\n r[meta.get_column_name(c)] = Time.at(r[meta.get_column_name(c)].get_time / 1000).utc\n end\n end # each cols\n\n # set hash value to r if not multi_val\n hash[rs.getString(index_key_field)] = r if !multi_val\n\n # append hash to r if multi_val\n hash[rs.getString(index_key_field)] << r if multi_val\n end # while\n\n # completed hash is returned\n return hash\n end",
"def lookup(row,col) #input file, put out rows\n @data.each do |row|\n\n row.each do |col|\n @parsed[row][col] = row[0][col].to_sym => col\n end\n end\n return @parsed\n end",
"def as_map\n row_names, rows = as_array\n map = {}\n row_names.zip(rows) do |row_name, row|\n map[row_name] = row\n end\n map\n end",
"def convert_row(row)\n return nil if row.nil?\n row.collect do |col|\n if col.is_a? ::ODBC::Date\n DBI::Date.new(col.year, col.month, col.day)\n elsif col.is_a? ::ODBC::Time\n DBI::Time.new(col.hour, col.minute, col.second)\n elsif col.is_a? ::ODBC::TimeStamp\n DBI::Timestamp.new(col.year, col.month, col.day,\n col.hour, col.minute, col.second, col.fraction)\n else\n col\n end\n end\n end",
"def columns; @columns_hash.values; end",
"def initialize_values\n #skip the first 5 bytes, don't know what they are for and they don't contain the data.\n @data.read(5)\n \n @attributes = columns.inject({}) do |hash, column|\n \n #get the unpack flag to get this data.\n value = @data.read(column.length).unpack(\"#{column.flag(column.type, column.length)}\").first\n hash[column.name] = value\n hash[column.name.underscore] = value\n \n hash\n end\n end",
"def rows\n @rows ||= if ActiveRecord::Base.connection.adapter_name == \"PostgreSQL\"\n result.entries\n else\n [].tap do |row_hashes|\n result.entries.map do |row|\n hash = {}\n result.fields.each do |field|\n hash[field] = row[result.fields.index(field)]\n end\n row_hashes << hash\n end\n end\n end\n end",
"def rs_to_array(rs)\n # creates an array of hashes from a jdbc record set\n arr = []\n\n # get basic metadata for the recordset\n meta = rs.getMetaData\n cols = meta.getColumnCount.to_i\n\n # loop through the records to add them into hash\n while rs.next do\n # r is a temporary hash for the row being processed\n r = {}\n\n # add each row to r\n (1..cols).each do |c|\n r[meta.get_column_name(c)] = rs.getObject(c)\n if convert_to_ruby_time_classes.include?(r[meta.get_column_name(c)].class)\n r[meta.get_column_name(c)] = Time.at(r[meta.get_column_name(c)].get_time / 1000).utc\n end\n end # each cols\n\n # append hash to array\n arr << r\n end # while\n\n # completed hash is returned\n return arr\n end",
"def native_type_mapping(abstract, rows)\n # The appropriate SQL for :primary_key is hard to derive as\n # ODBC doesn't provide any info on a DBMS's native syntax for\n # autoincrement columns. So we use a lookup instead.\n return adapter.class::PRIMARY_KEY if abstract == :primary_key\n selected_row = rows[0]\n\n # If more than one native type corresponds to the SQL type we're\n # handling, the type in the first descriptor should be the\n # best match, because the ODBC specification states that\n # SQLGetTypeInfo returns the results ordered by SQL type and then by\n # how closely the native type maps to that SQL type.\n # But, for :text and :binary, select the native type with the\n # largest capacity. (Compare SQLGetTypeInfo:COLUMN_SIZE values)\n selected_row = rows.max_by { |row| row[2] } if %i[text binary].include?(abstract)\n result = { name: selected_row[0] } # SQLGetTypeInfo: TYPE_NAME\n\n create_params = selected_row[5]\n # Depending on the column type, the CREATE_PARAMS keywords can\n # include length, precision or scale.\n if create_params && !create_params.strip.empty? && abstract != :decimal\n result[:limit] = selected_row[2] # SQLGetTypeInfo: COL_SIZE\n end\n\n result\n end",
"def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end",
"def to_hash\n @table.inject(Hash.new) { |h, arr| k, v = arr; h[k.id2name] = v; h }\n end",
"def convert_row(row_hash)\n result = ''\n row_hash.each_value do|col|\n result << '<td>'\n case col\n # Handle simple columns here, pass off more complex ones\n when String, Fixnum then result << col.to_s\n when NilClass then result << ''\n when Array then result << convert_array(col)\n else\n result << 'Unknown data type!!!'\n end\n result << '</td>'\n end\n result\n end",
"def raw_hash\n Hash.new.tap do |out|\n @map.each { |col| out[col.to] = @table[col.from] }\n end\n end",
"def each_record(table, &block)\n columns = nil\n read_each(table) do |line|\n if columns\n yield Hash[columns.zip(line)]\n else\n columns = line.map(&:to_sym)\n end\n end\n end",
"def as_row(result, columns)\n columns.map { |column| column.format_value(result) }\n end",
"def infer_types!\n types = Array.new(ncols)\n each do |row| merge_types(types, row[:*].infer_string_types) end\n types.each.with_index do |type, i|\n colname = @colnames[i]\n if type <= Integer then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Integer(@rows[rowid][colname]) end\n elsif type <= Float then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Float(@rows[rowid][colname]) end\n end\n end\n self\n end",
"def row_to_hsh(row)\n h = Hash[@headers.zip(row)]\n h.symbolize_keys\n end",
"def to_h\n @table.reduce({}) do |hash, (key, value)|\n hash[key] = value.to_h\n hash\n end\n end",
"def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end",
"def each_row_as_native\n @rows.each { |row| yield(Array.new(row.size) { |i| @columns[i].type.translate(row[i]) }) }\n self\n end",
"def data\n datacolumns.reduce({}) do |t, col|\n t[col.name] = col.data; t\n end\n end",
"def datatable\n dt = {}\n dt[:cols] = cols\n dt[:rows] = []\n data.each do |datarow|\n row = []\n datarow.each_with_index do |datacell, colnum|\n row << { :v => convert_cell(datacell, cols[colnum][:type]) }\n end\n \n dt[:rows] << { :c => row }\n end\n return dt\n end",
"def to_a\n column_names = [@query.klass.primary_key] | connect_by_columns\n column_names.map { |name| @query.table[name] }\n end",
"def inspect_data_types(t)\n types = {}\n\n t.headers.each do |col|\n type = NilClass\n t[col].each do |v|\n next if v.nil?\n if v.class == String\n type = type_of(v)\n else\n type = v.class\n end\n break\n end\n types[col] = type\n end\n\n types\n end",
"def col_types\n result = {}\n columns.each do |c|\n result[c.header] = c.type\n end\n result\n end",
"def to_h\n ret = ActiveSupport::OrderedHash.new\n get_all_sorted_columns.each{|col| ret[col.id] = col.name }\n return ret\n end",
"def generateResultColumns\n resultColumns = {\n columns: {},\n maxRowIndex: 0 # We're going to count the rows, for future use\n }\n\n # Using a lambda to add the right columns into resultColumns, and keep track\n # of maxRowIndex\n setColumnValue = lambda do |column, rowIndex, value|\n unless self.columnIsFiltered?(column)\n resultColumns[:columns][column] ||= []\n resultColumns[:columns][column][rowIndex] = value\n end\n\n # Gotta keep track of how many rows we're working with.\n resultColumns[:maxRowIndex] = rowIndex if rowIndex > resultColumns[:maxRowIndex]\n end\n\n # Exit early if this is a simple math operation\n if @rawResponse.is_a? Numeric\n resultColumns[:columns]['result'] = [@rawResponse]\n resultColumns[:maxRowIndex] = 1\n return resultColumns\n end\n\n rowIndex = 0\n @rawResponse.each do |object|\n if object[\"value\"].is_a? Array\n # This result is grouped! We're gonna have to create alot more columns and rows\n object[\"value\"].each do |group|\n\n # iterate over each value grouping, and store the values\n self.flatten(group).each do |column, value|\n setColumnValue.call(column, rowIndex, value)\n end\n if object[\"timeframe\"]\n self.flatten({\"timeframe\" => object[\"timeframe\"]}).each do |column, value|\n setColumnValue.call(column, rowIndex, value)\n end\n end\n rowIndex += 1\n\n end\n else\n # Not grouped: This either an Extraction or a math operation on an interval.\n self.flatten(object).each do |column, value|\n setColumnValue.call(column, rowIndex, value)\n end\n rowIndex += 1\n\n end\n end\n\n resultColumns\n end",
"def to_h\n t = {}\n @table.each do |k,v|\n if v.respond_to?(:to_h)\n t[k] = v.to_h\n else\n t[k] = v\n end\n end\n t\n end",
"def mapArrayToHash(rowarr, field_names)\n\ta = [] # an array of hashes\n\trowarr.each do |row|\n\t\thash = Hash.new\n\t\t0.upto(field_names.length-1) do |index|\n\t\t\t#puts \"#{index} #{field_names[index]} VALUE= #{row[index]} }\"\n\t\t\thash[field_names[index].downcase.to_sym] = row[index]\n\t\tend\n\t\ta << hash\n\tend\n\ta\nend",
"def raw_table_to_hash tbl\n fixd_hsh = tbl.reject{|arr| arr.blank?}.inject({}) do |h,arr|\n title = arr.first.downcase.gsub(/[-\\s]/, '_').to_sym\n val = arr.last.gsub(\",\",\"\")\n h[title] = val\n h\n end\n fixd_hsh\n end",
"def convert ( aobj, aclass )\n hash = {}\n aobj.attributes.each { | key, value | \n hash[key] = value if aclass.column_names.include?(key)\n }\n hash\n end",
"def each_hash(the_query, with_table_names = false, &block)\n begin\n if with_table_names\n # We have to build the hash ourselves, if we want table names included\n query(the_query, { as: :array, cache_rows: false })\n if @result != nil\n fields = @result.fields\n tables = @result.respond_to?(:tables) ? @result.tables : [] # My addition to mysql2 results.c\n\n result = []\n @result.each do |row|\n hrow = {}\n (0...row.length).each do |i|\n field_name = tables[i].nil? ? fields[i] : \"#{tables[i]}.#{fields[i]}\"\n hrow[field_name] = row[i]\n end\n yield hrow\n result << hrow\n end\n return result\n end\n else\n query(the_query, { as: :hash, cache_rows: false })\n if @result != nil\n if block_given?\n @result.each(&block)\n else\n return @result.to_a\n end\n end\n end\n rescue Mysql2::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def keys_values\n ole_table.column_names.zip(values).to_h\n end",
"def keys_values\n ole_table.column_names.zip(values).to_h\n end",
"def symbol cols\n decode_values :symbol, cols\n end",
"def map_to_hash_by_primary_key(result) \n hash = {}\n\n result.each do |record|\n hash[record[@primary_key]] = record\n end\n\n hash\n end",
"def get_column_mappings(row)\r\n mappings = {}\r\n row.each_with_index do |heading, index|\r\n # Stop collecting headings, if heading is empty\r\n if not heading.blank?\r\n mappings[heading.downcase.gsub(/\\A\\s*/, '').chomp.gsub(/\\s/, '_').to_sym] = index\r\n else\r\n break\r\n end\r\n end\r\n mappings\r\n end",
"def convert_pt_query_to_series(pt_query)\n num_series=pt_query.count\n fingerprints=Set.new\n \n # Get list of fingerprints\n pt_query.each do |row|\n row.each {|k,v| fingerprints.add(k)}\n end\n\n fingerprints.delete(nil)\n\n series={}\n # cycle through list\n fingerprints.each do |f|\n series[f]=[]\n (0...num_series).each do |i|\n val = pt_query[i][f]\n series[f].push(val)\n end\n end\n series\nend",
"def make_key_hash_for_row(keys, row)\n key_hash = {}\n keys.each {|k|\n key_hash[k] = row[k]\n }\n \n key_hash\nend",
"def map_values(row, columns)\n values = columns.map do |v|\n # TODO - stw - which other cases do we need to handle?\n case v[1]\n when /int/: \n row[v[0]] || 'NULL'\n else \n (row[v[0]].nil? ? 'NULL' : \"'\" + @db1.escape_string(row[v[0]].to_s) + \"'\")\n end\n end\n values = values.join(',') \n end",
"def fetch_rows(sql)\n execute(sql) do |r|\n i = -1\n cps = db.conversion_procs\n cols = r.fetch_fields.map do |f| \n # Pretend tinyint is another integer type if its length is not 1, to\n # avoid casting to boolean if convert_tinyint_to_bool is set.\n type_proc = f.type == 1 && cast_tinyint_integer?(f) ? cps[2] : cps[f.type]\n [output_identifier(f.name), type_proc, i+=1]\n end\n self.columns = cols.map(&:first)\n if opts[:split_multiple_result_sets]\n s = []\n yield_rows(r, cols){|h| s << h}\n yield s\n else\n yield_rows(r, cols){|h| yield h}\n end\n end\n self\n end",
"def to_hsh\n {name => {:columns => columns, :unqiue => unique}}\n end",
"def convert_data(*args)\n data = {}\n\n Observation.column_names.each do |column_name|\n method_name = \"get_#{column_name}\"\n if self.respond_to? method_name\n value = self.send(method_name, *args)\n data[column_name.to_sym] = value\n end\n end\n\n return data\n end",
"def yale_nd_row_as_hash i\n yale_nd_row(i, :hash)\n end",
"def read_input_row(row)\n row_out = {}\n schema.columns.each do |name, col|\n # use nil if row doesn't exist in input\n row_out[name] = row.fetch(name, nil)\n end\n row_out \n end",
"def format_schema_helper(hsh)\n hsh = map_data_types(hsh)\n hsh.map { |column_name,column_type| [\"#{column_type}\".to_sym,\"#{column_name}\"] }\n end",
"def values(row_value, col_value)\n row = @values_map[row_value.to_s]\n return empty_hash_for_missing_row_or_column if row.nil?\n facts = row[col_value.to_s]\n return empty_hash_for_missing_row_or_column if facts.nil?\n facts\n end",
"def _column_hashes\n @_column_hashes ||= {}\n end",
"def each\n if block_given?\n vals = []\n @query_schema.inputs.each_with_index do |input, i|\n vals << input.type.convert_from_ruby(@values[i])\n end\n @table.csv.each do |row|\n if @query_schema.inputs.zip(vals).all? {|input, val| row[input.pos] == val} and\n @query_schema.values.all? {|value| row[value.pos] == value.type.convert_from_ruby(value.value)}\n outputs = []\n cond = @query_schema.outputs.each do |output|\n val = row[output.pos]\n if output.options[:empty] == :ignore and val == \"\"\n break :break\n else\n outputs << output.type.convert_to_ruby(val)\n end\n end\n yield *outputs unless cond == :break\n end\n end\n else\n return Enumerator.new(self)\n end\n end",
"def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end",
"def oracle_sql_results(sql, conn = VACOLS::Case.connection)\n result = conn.execute(sql)\n output = []\n while r = result.fetch_hash\n output << r\n end\n output\nend",
"def all_hash\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name};\")\n return array_list = make_object_array(results)\n end",
"def to_a\n @table.columns.map { |col| @attributes[col] }\n end",
"def to_record(row)\n rec = Hash[HEADERS.zip(row)]\n return {\n :lat => rec[:lat].to_f,\n :lon => rec[:lon].to_f,\n :num_poi => rec[:num_poi].to_i,\n :mean_version => rec[:mean_version].to_f,\n :mean_users => rec[:mean_users].to_f\n }\nend",
"def oci_rows_to_hash(response)\n response_hash = Hash.new\n table_array = Array.new\n table_name = \"\"\n parse_response = REXML::Document.new(response)\n\n response_hash = Hash.new\n parse_response.elements[\"//command/\"].each do |ele|\n name = ele.name\n value = parse_response.elements['//'+name].text\n if name =~ /\\w+Table/\n table_array = oci_table_to_array(response,name)\n table_name = name\n end\n response_hash[name.to_sym] = value\n\n #If response contained table elements add array of these elements into hash with key == <tableName>\n response_hash[table_name.to_sym] = table_array unless table_array.empty?\n end\n return response_hash\n\n end",
"def rowkey type = :string\n Util.from_bytes type, @result.getRow\n end",
"def each_object(with_table=false)\n self.each_hash(with_table){|row| yield(Row.convert(row, self.fetch_fields, with_table)) }\n end",
"def build_columns_and_rows_hash(db_columns, client, table_names)\n db_columns_and_rows = {}\n\n table_names.each do |table|\n db_columns_and_rows[table] = {}\n\n puts \"table #{table}\"\n\n query = \"select * from #{table}\"\n results = client.query(query)\n\n rows = []\n\n results.each do |row|\n els = []\n row.each do |el|\n els.push(el[1].to_s)\n end\n rows.push(els)\n end\n\n db_columns_and_rows[table]['rows'] = rows\n db_columns_and_rows[table]['columns'] = db_columns[table]\n end\n\n db_columns_and_rows\nend",
"def to_hash\n fields.inject({type: type}) do |table, name|\n table.tap do\n if val = send(name)\n val = val.iso8601(3) if name == :timestamp\n table[name] = val\n end\n end\n end\n end",
"def symbols cols\n decode_values :symbol, cols, true\n end",
"def exec_raw(sql, options = {})\n cursor = $connection.exec(sql)\n if(options[:return_hash])\n recordset, = pack_cursor(cursor, :return => \"hash\")\n return recordset\n else\n return_data = []\n while current_row = cursor.fetch()\n return_data.push(current_row)\n end\n return return_data\n end\n end",
"def columns(table)\n dbh = DBI::DatabaseHandle.new(self)\n uniques = []\n dbh.execute(\"SHOW INDEX FROM #{table}\") do |sth|\n sth.each do |row|\n uniques << row[4] if row[1] == \"0\"\n end\n end \n\n ret = nil\n dbh.execute(\"SHOW FIELDS FROM #{table}\") do |sth|\n ret = sth.collect do |row|\n name, type, nullable, key, default, extra = row\n #type = row[1]\n #size = type[type.index('(')+1..type.index(')')-1]\n #size = 0\n #type = type[0..type.index('(')-1]\n\n sqltype, type, size, decimal = mysql_type_info(row[1])\n col = Hash.new\n col['name'] = name\n col['sql_type'] = sqltype\n col['type_name'] = type\n col['nullable'] = nullable == \"YES\"\n col['indexed'] = key != \"\"\n col['primary'] = key == \"PRI\"\n col['unique'] = uniques.index(name) != nil\n col['precision'] = size\n col['scale'] = decimal\n col['default'] = row[4]\n col\n end # collect\n end # execute\n \n ret\n end",
"def attributes_to_row_values_hash(only_attr_names = [])\n values = Hash.new { |hash, key| hash[key] = Hash.new }\n\n record.attributes_schema.each do |attr_name, orm_field|\n next unless only_attr_names.empty? || only_attr_names.include?(attr_name)\n values[orm_field.column_family.name][orm_field.column] = orm_field.encode(record[attr_name])\n end\n\n record.relation_proxies_for_embedded.select { |p| p.proxy_targets_update_hash.any? }.each do |proxy_with_changes|\n values[proxy_with_changes.metadata.store_in].merge!(proxy_with_changes.proxy_targets_update_hash)\n end\n\n values\n end",
"def parse_columns(row_data)\n\t\tcolumns = {}\n\t\trow_data.split(\"\\t\").each_with_index do |column_name, index|\n\t\t\tcolumns[column_name] = index\n\t\tend\n\t\treturn columns\n\tend"
] |
[
"0.74332345",
"0.7401011",
"0.72184217",
"0.65725565",
"0.6389287",
"0.6387967",
"0.6277099",
"0.62388194",
"0.6235864",
"0.61686397",
"0.6135354",
"0.60972464",
"0.60664576",
"0.6020494",
"0.5997272",
"0.5982124",
"0.59654903",
"0.5965236",
"0.59519607",
"0.5950875",
"0.593833",
"0.5924537",
"0.58857465",
"0.58857465",
"0.58435756",
"0.58364004",
"0.5827556",
"0.5781485",
"0.572518",
"0.5716092",
"0.57123965",
"0.57106036",
"0.57023656",
"0.5684661",
"0.56718725",
"0.56611943",
"0.56576806",
"0.5654007",
"0.56396866",
"0.56302416",
"0.5630025",
"0.562824",
"0.562744",
"0.56247014",
"0.5614713",
"0.56132036",
"0.5609315",
"0.5605547",
"0.5595652",
"0.55881995",
"0.5571932",
"0.5558155",
"0.5554545",
"0.5551746",
"0.55435663",
"0.5526757",
"0.5514162",
"0.5510813",
"0.5505644",
"0.5505473",
"0.5500214",
"0.5482507",
"0.54802036",
"0.54685855",
"0.5450553",
"0.543244",
"0.54298306",
"0.54269063",
"0.54269063",
"0.5412703",
"0.54101175",
"0.54039663",
"0.5395371",
"0.53936744",
"0.5383459",
"0.5367277",
"0.5362366",
"0.5361155",
"0.5352053",
"0.5349906",
"0.534795",
"0.5347525",
"0.5335126",
"0.5333798",
"0.5325517",
"0.53245604",
"0.5322512",
"0.53215015",
"0.53006566",
"0.5293998",
"0.5289582",
"0.5280568",
"0.5271956",
"0.5268088",
"0.52676964",
"0.5267543",
"0.52644104",
"0.5252785",
"0.52386075"
] |
0.7073877
|
4
|
Create an instance for a particular Nelumba::Activity.
|
def initialize activity, signature = nil, plaintext = nil
@activity = activity
@signature = signature
@plaintext = plaintext
account = activity.actors.first.url
# XXX: Negotiate various weird uri schemes to find identity account
@account = account
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new_activity(activity)\n Models::Activity.new(:name => activity.name, :description => activity.description)\n end",
"def create_activity(activity)\n create_or_update(activity, nil,\n 'activity', 'activities')\n end",
"def create_activity!(type, owner)\n create_activity(\n type,\n owner: owner,\n parameters: { application: application }\n )\n end",
"def new\n @activity = Activity.new\n end",
"def new\n @activity = Activity.new\n end",
"def create\n @activity = PublicActivity::Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_activity\n @activity = @user.activities.create!(\n trackable: @idea,\n recipient: @idea,\n key: 'idea.create',\n verb: 'pitched',\n unread: true\n )\n cache(@activity)\n PublishIdeaJob.perform_later(@idea.id, @user.id, @activity.id)\n end",
"def create_valid_activity\n create_activity_with 'Some test activity'\n end",
"def create_activity(opts = {})\n data, _status_code, _headers = create_activity_with_http_info(opts)\n return data\n end",
"def initialize activity\n @activity = activity\n end",
"def create_activity(**args)\n params = parameters(args) do\n required_params :subject, :type\n optional_params :subject, :type, :done, :due_date, :due_time, :duration, :user_id, :deal_id, :person_id, :participants, :org_id, :note\n end\n request(:post, 'activities', params)\n end",
"def create_activity\n player = Player.find_or_create_by(email:req_params[:email])\n project = Project.find_by(name:req_params[:project])\n event = req_params[:event]\n count = req_params[:count]\n @activity = Activity.get_activity_type(player,event,project,count)\n\n end",
"def create\n @breadcrumb = 'create'\n @activity = Activity.new(params[:activity])\n @activity.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: crud_notice('created', @activity) }\n format.json { render json: @activity, status: :created, location: @activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # byebug\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to root_path, notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_activity(task)\n @event_signup.create_activity task, owner: @user, unit_id: @event_signup.unit.id, parameters: { event_id: @event.id, user_id: @event_signup.user.id, created_at: Time.now }\n end",
"def create\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def init_activity(obj)\n if obj.nil?\n logger.error(\"Activity #{self.id}; called init_activity with nil\")\n else\n self.activity_name = obj.class.name\n self.activity_id = obj.id\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render json: @activity, status: :created, location: @activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n\n respond_to do |format|\n if @activity.save\n flash[:success] = 'Activity was successfully created.'\n format.html { redirect_to activities_path }\n format.json { render json: @activity, status: :created, location: @activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user\n if params[:format] == \"json\"\n @activity = current_user.activities.new_from_json(params)\n if params[:activity][:auto_title] == true\n @activity.auto_title!\n end\n else\n @activity = current_user.activities.new(params[:activity])\n end\n else\n @activity = Activity.new(params[:activity])\n end\n respond_to do |format|\n if @activity.save\n format.html { redirect_to(@activity, :notice => 'Activity was successfully created.') }\n format.xml { render :xml => @activity, :status => :created, :location => @activity }\n format.json { render :json => @activity.to_json, :status => :created, :location => @activity }\n else\n logger.info @activity.errors.inspect\n format.html { render :action => \"new\" }\n format.xml { render :xml => @activity.errors, :status => :unprocessable_entity }\n format.json { render :json => @activity.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(activity_params)\n # TODO: Need to move this logic to Model ??\n # Get max activity number\n current_activity_number = Activity.maximum(:activity_id, :conditions => [\"issue_id = ?\", activity_params[:issue_id]])\n\n # Set next activity number\n if current_activity_number\n next_activity_number = current_activity_number + 1\n else\n next_activity_number = 1\n end\n @activity.activity_id = next_activity_number\n\n # Convert blank into zero\n @activity.hours = 0 if @activity.hours.blank?\n @activity.minutes = 0 if @activity.minutes.blank?\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render action: 'show', status: :created, location: @activity }\n else\n format.html { render action: 'new' }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tRails.logger.info params\n @activity = Activity.new(params[:activity])\n @activity.user = current_user\n\n if params.has_key?('hidden-activity') and params['hidden-activity'].has_key?('tag_list')\n \t@activity.tag_list = params['hidden-activity'][:tag_list]\n end\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render json: @activity, status: :created, location: @activity }\n else\n # Delete images post invalidation\n @activity.activity_images.map(&:destroy)\n @activity.activity_images = []\n ActivitiesController::MAX_IMAGES.times { @activity.activity_images.build }\n\n format.html { render action: \"new\" }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n @activity.user = current_user\n @activity.organization = current_user.organization\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to activity_path(@activity), notice: 'Activity was successfully created.' }\n format.json { render json: @activity, status: :created, location: @activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to(@activity, :notice => 'Activity was successfully created.') }\n format.xml { render :xml => @activity, :status => :created, :location => @activity }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @activity.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n @activity[:user_id] = current_user.id\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to activities_path, notice: 'Activity was successfully created.' }\n format.json { render json: @activity, status: :created, location: @activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n\t\tauthorize! :create, @activity\n\n respond_to do |format|\n if @activity.save\n flash[:notice] = 'Activity was successfully created.'\n format.html { redirect_to(activities_url) }\n format.xml { render :xml => @activity, :status => :created, :location => @activity }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @activity.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n\n respond_to do |format|\n if @activity.save\n flash[:notice] = I18n.t('activities.controller.Successfully_created')\n format.html { redirect_to(@activity) }\n format.xml { render :xml => @activity, :status => :created, :location => @activity }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @activity.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render action: 'show', status: :created, location: @activity }\n else\n format.html { render action: 'new' }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render action: 'show', status: :created, location: @activity }\n else\n format.html { render action: 'new' }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render action: 'show', status: :created, location: @activity }\n else\n format.html { render action: 'new' }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @activity = LightweightActivity.new()\n authorize! :create, @activity\n end",
"def create\n @activity = Activity.new(activity_params)\n @activity.user = current_user\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to activities_path, notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(activity_params)\n\n if @activity.save\n redirect_to activities_path\n else\n render 'new'\n end\n\n end",
"def add_activity(activity)\n self.activities << activity\n end",
"def create_ar_activity(options = {})\n _create_ar_activity(false, options)\n end",
"def create\n\t@activity = Activity.new\n\ttime = Time.now\n\t#set attributes\n\t@activity.description = params[:description]\n\t@activity.user_id = params[:user_id]\n\t@activity.parent_or_child = params[:user_type]\n\t@activity.type = params[:type]\n\t@activity.created_at = Date.new(2011,4,17)\n\t@activity.created_at_time = time\n\n\t#save activity\n\t@activity.save\nend",
"def new\n @activity_entry = ActivityEntry.new\n @data = ActivityDatum.all\n end",
"def build_post_activity\n Activity.new :channel => channel!,\n :relation_ids => Array(_relation_ids)\n end",
"def create!(attributes = {})\n object = klass.new(attributes)\n object.save!\n object\n end",
"def set_activity\n @activity = PublicActivity::Activity.find(params[:id])\n end",
"def create\n @activity = Activity.new(activity_params)\n respond_to do |format|\n if @activity.save\n flash[:success] = 'Activity was successfully created.'\n correct_execution format, :created\n else\n error_execution format, :new\n end\n end\n end",
"def create\n ap = activity_params\n if !ap[:points].nil?\n doc = Nokogiri::XML(ap[:points].read)\n parse_gpx(doc,ap)\n end\n @activity = Activity.new(ap)\n @activity.owner_id = current_user.id\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def record_activity(activity_type, details)\n UserActivity.create(user: current_user, activity_type: activity_type, details: details)\n end",
"def add_new_activity(attr={})\n return nil if attr.empty?\n\n activity_index = DocumentStore.increase_atomic_count(DOCS[:latest_activity_count])\n activity = {\n :uid => attr[:uid],\n :activity => attr[:activity],\n :radlib_id => attr[:radlib_id]\n }\n\n if attr.has_key? :radlib_fillin_id\n activity[:radlib_fillin_id] = attr[:radlib_fillin_id]\n end\n\n DocumentStore.create_document(DOCS[:latest_activity_stub] + activity_index.to_s, activity)\n self\n end",
"def activity(id)\n child('activity', id)\n end",
"def add_activity(activity)\n @activities << activity\n return self\n end",
"def create(attribs={})\n obj = new\n obj.send :create, attribs\n obj\n end",
"def activity_object_builder\n build_activity_object\n end",
"def create\n @activity = Activity.new(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to [@course, @learning_unit, @activity], notice: 'Activity was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def case_activity\n self.case_activities.create(case_id: self.case_id,user_id: self.user_id,owner_id:self.owner_id)\n end",
"def set_activity\n begin\n @activity = Activity.find(params[:id])\n rescue\n end\n end",
"def create\n @type_activity = TypeActivity.new(type_activity_params)\n\n respond_to do |format|\n if @type_activity.save\n format.html { redirect_to @type_activity, notice: 'Type activity was successfully created.' }\n format.json { render :show, status: :created, location: @type_activity }\n else\n format.html { render :new }\n format.json { render json: @type_activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(attributes = nil)\n object = new(attributes)\n object.save\n object\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def set_activity\n @activity = Activity.find(params[:id])\n end",
"def add_activity(activity)\n @activities.push activity\n end",
"def create\n @activity = @user.activities.create(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Exercise event was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_activity(activity_name)\n within_frame(\"authorfrm\") do\n click_on(\"Add Activity\")\n \n within('.ui-dialog') do\n page.should have_selector(\"#createSequenceInput\")\n fill_in(\"createSequenceInput\", :with => activity_name)\n click_on(\"Submit\")\n end\n \n page.should have_content(\"Select a new location for the selected activity\")\n \n find('.projectNode.master').click\n end\nend",
"def set_activity\n @activity = Activity.where(uuid: params[:id])\n end",
"def create\n if current_user\n @activity = Activity.new(activity_params)\n @activity.user_id = current_user.id\n\n respond_to do |format|\n if @activity.save\n\n # add owner to going to activity\n Goingtoactivity.create(user_id: @activity.user_id, activity_id: @activity.id)\n\n format.json { render :show, status: :created, location: @activity }\n else\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.json { render :json => {:success=>false, :message=>\"Something's wrong with the token. current_user is nil.\"} }\n end\n end\n end",
"def create(attributes = { })\n inst = self.new(attributes)\n inst.save\n\n inst\n end",
"def create\n @activity = Activity.create activity_params\n status = @activity.new_record? ? 400 : 201\n if @activity.recurrence\n render json: @activity.activity_factory.activities.as_json, status:status\n else\n respond_with @activity, status:status\n end\n end",
"def create\n @activity_type = ActivityType.new(params[:activity_type])\n\n respond_to do |format|\n if @activity_type.save\n format.html { redirect_to @activity_type, notice: 'Activity type was successfully created.' }\n format.json { render json: @activity_type, status: :created, location: @activity_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity_participant = Activity::Participant.new(activity_participant_params)\n @activity_participant.user = current_user\n @activity_participant.activity = Activity.find_by_id(params[:activity_id])\n\n respond_to do |format|\n if @activity_participant.save\n format.html { redirect_to activity_participants_url, notice: \"Participant was successfully created.\" }\n format.json { render :show, status: :created, location: @activity_participant }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @activity_participant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n activity_params = params.require(:activity).permit(:title, :body,\n tags_attributes:\n [:category_id])\n @activity = Activity.create(activity_params)\n current_user.activities << @activity\n respond_to do |format|\n format.html\n format.json { render json: @activity }\n end\n end",
"def create_activity(object, symbol, old_value, new_value, activity_params)\n object.create_activity \"change_#{symbol}\".to_sym,\n owner: current_user,\n recipient: object,\n parameters: activity_params.merge(old: old_value, new: new_value)\n end",
"def create\n @project_activity = ProjectActivity.new(project_activity_params)\n\n respond_to do |format|\n if @project_activity.save\n format.html { redirect_to @project_activity, notice: 'Project activity was successfully created.' }\n format.json { render :show, status: :created, location: @project_activity }\n else\n format.html { render :new }\n format.json { render json: @project_activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = current_user.activities.new(activity_params)\n @activity.supplier_id = current_user.id\n #@activity.status = Activity::SETTING if @activity.activity_type.is_show?\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to edit_activity_path(@activity), notice: 'Activity was successfully created.' }\n format.json { render action: 'edit', status: :created, location: @activity }\n else\n format.html { render action: 'new' }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:events].nil?\n else\n params[:events].each do |e|\n if Activity.exists?(uuid: params[:events][e][:id])\n @activity = Activity.find_by uuid: params[:events][e][:id]\n @activity.update({\n start_time: params[:events][e][:start].in_time_zone,\n end_time: params[:events][e][:end].in_time_zone,\n })\n next\n else\n @activity = Activity.new({\n start_time: params[:events][e][:start].in_time_zone,\n end_time: params[:events][e][:end].in_time_zone,\n uuid: params[:events][e][:id],\n name: params[:events][e][:name],\n place: params[:events][e][:google_id],\n schedule_id: params[:schedule_id]\n })\n\n @activity.save\n end\n end\n end\n end",
"def create\n @backend_conf_activity = Conf::Activity.new(backend_conf_activity_params)\n\n respond_to do |format|\n if @backend_conf_activity.save\n format.html { redirect_to backend_conf_activity_path(@backend_conf_activity), notice: 'Conf activity was successfully created.' }\n format.json { render :show, status: :created, location: backend_conf_activity_path(@backend_conf_activity) }\n else\n format.html { render :new }\n format.json { render json: @backend_conf_activity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @activity = Activity.new(params[:activity])\n\n respond_to do |format|\n if @activity.save\n flash[:notice] = 'Activity was successfully created.'\n if @activity.is_achievement\n format.html { redirect_to :action => 'index' }\n else\n format.html { redirect_to :action => 'plan_chart' }\n end\n format.html { redirect_to :action => :plan_chart }\n format.xml { render :xml => @activity, :status => :created, :location => @activity }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @activity.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7712424",
"0.72746414",
"0.69641286",
"0.6732346",
"0.6732346",
"0.66194093",
"0.6532729",
"0.6526759",
"0.648766",
"0.6457502",
"0.6449306",
"0.64436126",
"0.64188987",
"0.6103056",
"0.6073012",
"0.607111",
"0.60684216",
"0.606149",
"0.60382956",
"0.60358834",
"0.60339046",
"0.6028963",
"0.601862",
"0.6006101",
"0.5999391",
"0.5966206",
"0.5963453",
"0.5960296",
"0.59547454",
"0.59545463",
"0.59545463",
"0.59392685",
"0.59341913",
"0.5896658",
"0.58733827",
"0.5859954",
"0.58293116",
"0.582092",
"0.58101314",
"0.5799605",
"0.5792072",
"0.5791971",
"0.57867956",
"0.5783221",
"0.5765746",
"0.5750468",
"0.5746042",
"0.57399684",
"0.57136965",
"0.56948906",
"0.5693778",
"0.5678047",
"0.5637194",
"0.56370753",
"0.562867",
"0.562867",
"0.562867",
"0.562867",
"0.562867",
"0.562867",
"0.562867",
"0.562867",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5616864",
"0.5614411",
"0.5613757",
"0.56083155",
"0.5602128",
"0.55878675",
"0.558202",
"0.55717784",
"0.5559645",
"0.5553722",
"0.5550977",
"0.55500114",
"0.55451256",
"0.5545079",
"0.554497",
"0.5529078",
"0.55235666"
] |
0.0
|
-1
|
Generate the xml for this notice and sign with the given private key.
|
def to_xml private_key
# Generate magic envelope
magic_envelope = XML::Document.new
magic_envelope.root = XML::Node.new 'env'
me_ns = XML::Namespace.new(magic_envelope.root,
'me', 'http://salmon-protocol.org/ns/magic-env')
magic_envelope.root.namespaces.namespace = me_ns
# Armored Data <me:data>
data = @activity.to_atom
@plaintext = data
data_armored = Base64::urlsafe_encode64(data)
elem = XML::Node.new 'data', data_armored, me_ns
elem.attributes['type'] = 'application/atom+xml'
data_type_armored = 'YXBwbGljYXRpb24vYXRvbSt4bWw='
magic_envelope.root << elem
# Encoding <me:encoding>
magic_envelope.root << XML::Node.new('encoding', 'base64url', me_ns)
encoding_armored = 'YmFzZTY0dXJs'
# Signing Algorithm <me:alg>
magic_envelope.root << XML::Node.new('alg', 'RSA-SHA256', me_ns)
algorithm_armored = 'UlNBLVNIQTI1Ng=='
# Signature <me:sig>
plaintext =
"#{data_armored}.#{data_type_armored}.#{encoding_armored}.#{algorithm_armored}"
# Assign @signature to the signature generated from the plaintext
@signature = Nelumba::Crypto.emsa_sign(plaintext, private_key)
signature_armored = Base64::urlsafe_encode64(@signature)
magic_envelope.root << XML::Node.new('sig', signature_armored, me_ns)
magic_envelope.to_s :indent => true, :encoding => XML::Encoding::UTF_8
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end",
"def sign(message, private_key)\n msg_point = BLS.norm_p2h(message)\n msg_point * BLS.normalize_priv_key(private_key)\n end",
"def sign_legacy(private_key)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(27 + recovery_id)\n result.pack('c*')\n end",
"def to_signed_tx(private_key)\n sign_tx to_raw_tx, private_key\n end",
"def sign_legacy(private_key)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(27 + recovery_id)\n result.pack('c*')\n end",
"def save!(private_key)\n bitcoin.sendrawtransaction to_signed_tx(private_key)\n end",
"def sign!(options = {})\n binary_security_token_node if options[:security_token]\n x509_data_node if options[:issuer_serial]\n\n if options[:inclusive_namespaces]\n c14n_method_node = signed_info_node.at_xpath('ds:CanonicalizationMethod', ds: 'http://www.w3.org/2000/09/xmldsig#')\n inclusive_namespaces_node = Nokogiri::XML::Node.new('ec:InclusiveNamespaces', document)\n inclusive_namespaces_node.add_namespace_definition('ec', c14n_method_node['Algorithm'])\n inclusive_namespaces_node['PrefixList'] = options[:inclusive_namespaces].join(' ')\n c14n_method_node.add_child(inclusive_namespaces_node)\n end\n\n signed_info_canon = canonicalize(signed_info_node, options[:inclusive_namespaces])\n\n signature = private_key.sign(@sign_digester.digester, signed_info_canon)\n signature_value_digest = Base64.encode64(signature).delete(\"\\n\")\n\n signature_value_node = Nokogiri::XML::Node.new('SignatureValue', document)\n signature_value_node.content = signature_value_digest\n signed_info_node.add_next_sibling(signature_value_node)\n self\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n @log.info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def generate_notification\n service_msg_number =\n sigparams =\n requried_service_params =\n SacPS::Auth::Banklink.generate_signature(service_msg_number, sigparams, required_service_params)\n end",
"def generate(socket, distinguished_name)\n attributes = {\n :type => :client,\n :subject => distinguished_name\n }\n keypair, certificate = server.depot.generate_keypair_and_certificate(attributes)\n socket.write keypair.private_key.to_s\n socket.write certificate.certificate.to_s\n end",
"def sign_key; end",
"def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end",
"def to_xml\n Nokogiri::XML::Builder.new do |xml|\n xml['me'].env({ 'xmlns:me' => XMLNS }) do\n xml['me'].data({ type: type }, OStatus2::Salmon.encode_base64url(body))\n xml['me'].encoding(encoding)\n xml['me'].alg(alg)\n xml['me'].sig({ key_id: key_id }, OStatus2::Salmon.encode_base64url(sig))\n end\n end.to_xml\n end",
"def generate\n cert = OpenSSL::X509::Certificate.new\n configure(cert)\n add_extensions(cert)\n cert.sign(Billy.certificate_authority.key, OpenSSL::Digest::SHA256.new)\n end",
"def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end",
"def signing_key; end",
"def sign(private_key)\n # Our multiline hash for authorization will be encoded in multiple header\n # lines - X-Ops-Authorization-1, ... (starts at 1, not 0!)\n header_hash = {\n \"X-Ops-Sign\" => SIGNING_DESCRIPTION,\n \"X-Ops-Userid\" => user_id,\n \"X-Ops-Timestamp\" => canonical_time,\n \"X-Ops-Content-Hash\" => hashed_body,\n }\n\n string_to_sign = canonicalize_request\n signature = Base64.encode64(private_key.private_encrypt(string_to_sign)).chomp\n signature_lines = signature.split(/\\n/)\n signature_lines.each_index do |idx|\n key = \"X-Ops-Authorization-#{idx + 1}\"\n header_hash[key] = signature_lines[idx]\n end\n \n Mixlib::Authentication::Log.debug \"String to sign: '#{string_to_sign}'\\nHeader hash: #{header_hash.inspect}\"\n \n header_hash\n end",
"def sign(t_outputs)\n # binding.pry\n Base64.encode64(private_key.sign(OpenSSL::Digest::SHA256.new, t_outputs.to_json))\n end",
"def regen_key\n @user = current_user\n @user.regen_private_key\n send_data @user.private_key, :type => \"application/pem-keys\", :disposition => \"attachment\", :filename => \"#{@user.username}.pem\"\n end",
"def signed_string\n \"service=#{params['service']}&v=#{params['v']}&sec_id=#{params['sec_id']}¬ify_data=#{params['notify_data']}#{key}\"\n end",
"def generate_signature\n sha1x16 = Digest::SHA1.hexdigest(signed_string)\n .tap { |s| logger.debug \"sha1x16 #{s}\" }\n enc = case form_fields['signMethod']\n when '01' # 01 means RSA\n merchant_private_key.sign(OpenSSL::Digest::SHA1.new, sha1x16)\n .tap { |s| logger.debug \"enc #{s}\" }\n else # at current time (2015-05-25) no other signing method is mentioned in Unionpay's official docs\n raise \"sign method #{form_fields['signMethod']} is not implemented yet.\"\n end\n Base64.strict_encode64(enc) # has to be strict_encode64, not encode64, as the latter as an extra '\\n'\n .tap { |s| logger.debug \"final: #{s}\" }\n end",
"def sign_metadata(metadata_xml, keypair, xmlsectool_path = nil)\n puts(\"Signing metadata locally with cert #{keypair.cert.subject}\")\n in_tmp_dir('proxy_node_meta') do |dir|\n cert_file = create_file('metadata.crt', keypair.cert.to_pem)\n key_file = create_file('metadata.key', keypair.key.to_der)\n metadata_file = create_file('metadata.xml', metadata_xml)\n\n cmd = <<~EOS\n #{xmlsectool_path} \\\n --sign \\\n --inFile #{dir}/metadata.xml \\\n --outFile #{dir}/metadata_signed.xml \\\n --certificate #{dir}/metadata.crt \\\n --key #{dir}/metadata.key \\\n --digest SHA-256\n EOS\n\n cmd_out = `#{cmd}`\n puts (cmd_out)\n File.open('metadata_signed.xml').read\n end\nend",
"def to_xml\n\t\tmsg_xml = ''\n\t\t@hash.each do |info|\n\t\t\tmsg_xml += \"<#{info.key}>#{xml(info.value)}</#{info.key}>\\n\"\n\t\tend\n\t\tmsg_xml\n\tend",
"def sign_metadata_hsm(metadata_xml, signing_cert, xmlsectool_path = nil)\n puts(\"TODO: Signing metadata using HSM with cert #{signing_cert.subject}\")\n return metadata_xml\nend",
"def generate\n Puppet.info \"Creating a new SSL key for #{name}\"\n @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i)\n end",
"def sign\n write_attr('mid', SecureRandom.uuid)\n write_attr('ts', Time.now.utc.to_i)\n canonical_msg = self.canonicalize\n\n #priv_key = OmfCommon::Key.instance.private_key\n #digest = OpenSSL::Digest::SHA512.new(canonical_msg)\n\n #signature = Base64.encode64(priv_key.sign(digest, canonical_msg)).encode('utf-8') if priv_key\n #write_attr('digest', digest)\n #write_attr('signature', signature) if signature\n\n if OmfCommon::Measure.enabled?\n MPMessage.inject(Time.now.to_f, operation.to_s, mid, cid, self.to_s.gsub(\"\\n\",''))\n @@mid_list << mid\n end\n self\n end",
"def signature_key; end",
"def sign!\n @signed_date_time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n @signature = Cybersource::Security.generate_signature(signed_data)\n\n self\n end",
"def generate_keys\n key = OpenSSL::PKey::RSA.new 2048\n self.pubkey = key.public_key.to_s\n self.privkey = key.to_s\n self.save\n end",
"def generate_signature(bytes, private_key)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilSigner.new(native_algorithm)\n wrap_bytes(signer.sign(bytes, private_key.raw_key))\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def create(name, write_private)\n new_key = OpenSSL::PKey::RSA.generate(1024)\n new_public = new_key.public_key.to_pem\n new_private = new_key.to_pem\n File.open(File.join(@keystore, \"#{name}.pub\"), 'w') { |f| f.puts new_public }\n File.open(File.join(@keystore, \"#{name}.key\"), 'w') { |f| f.puts new_key } if write_private\n new_key\n end",
"def xml_final_output\n\n parametros = ActiveSupport::OrderedHash.new\n parametros[\"xmlns\"] = \"http://cancelacfd.sat.gob.mx\"\n parametros[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n parametros[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n parametros[\"Fecha\"] = @fecha\n parametros[\"RfcEmisor\"] = @rfcemisor\n \n @certificate = CFDI::Certificado.new @certificate\n \n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Cancelacion(parametros) do\n xml.Folios {\n xml.UUID(@uuid)\n }\n xml.Signature({'xmlns' => \"http://www.w3.org/2000/09/xmldsig#\" }) do\n xml.SignedInfo do \n xml.CanonicalizationMethod({'Algorithm' =>\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"})\n xml.SignatureMethod({'Algorithm' => \"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"})\n \n xml.Reference({'URI' => \"\"}) do\n \n xml.Transforms do\n xml.Transform({ 'Algorithm' => \"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" })\n end\n \n xml.DigestMethod({ 'Algorithm' => \"http://www.w3.org/2000/09/xmldsig#sha1\" })\n xml.DigestValue(self.digested_canonicalized_data)\n \n end\n \n end\n xml.SignatureValue(self.computed_signed_info)\n xml.KeyInfo do \n xml.X509Data do\n xml.X509IssuerSerial do\n xml.X509IssuerName(@certificate.issuername)\n xml.X509SerialNumber(@certificate.serial)\n end\n xml.X509Certificate(@certificate.data)\n end\n end\n end\n end\n end\n \n CGI::unescapeHTML(@builder.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML).strip.gsub(/\\n/, ''))\n \n end",
"def generate_doc_from_model\n # Get the config for the model to be signed\n elt = @e_sign_document.option_type_config\n\n # Use either the specified fields in the activity log e_sign configuration,\n # or the fields specified in the model to be signed\n sign_fields = @specified_fields || elt.fields\n\n # Limit the attributes to just the specified fields, and order them according the field config\n att_order = @e_sign_document.class.permitted_params\n all_atts = {}\n if att_order\n att_order.each do |a|\n a = a.to_s\n all_atts[a] = @e_sign_document.attributes[a]\n end\n else\n all_atts = @e_sign_document.attributes.dup\n end\n atts = all_atts.select { |k, _v| sign_fields.include? k }\n\n ApplicationController.render(template: 'e_signature/document', layout: 'e_signature', locals: {\n e_sign_document: @e_sign_document,\n prepared_document: self,\n attributes: atts,\n caption_before: elt.caption_before,\n labels: elt.caption_before,\n show_if: elt.show_if,\n current_user: current_user,\n document_title: @document_title,\n document_intro: @document_intro\n }).html_safe\n end",
"def generate_key!\n unless priv_key\n tmp = OpenSSL::PKey.generate_key(self)\n set_key(tmp.pub_key, tmp.priv_key)\n end\n self\n end",
"def publish!(wallet)\n tx = self.sign(wallet)\n tx.commit\n tx.attributes[:id]\n end",
"def generate(opts)\n check_opts(opts)\n \n identity_file = opts[:prefix] + \"_identity\"\n ssh_wrapper_script_file = opts[:prefix] + \"_ssh_wrapper\"\n\n File.open(identity_file, \"w\") do |io|\n io << opts[:private_key]\n end\n FileUtils.chmod(0600, identity_file)\n FileUtils.chown(opts[:user], opts[:group], identity_file)\n\n File.open(ssh_wrapper_script_file, \"w\") do |io|\n io << template.result(:identity=>identity_file)\n end\n FileUtils.chmod(0755, ssh_wrapper_script_file)\n FileUtils.chown(opts[:user], opts[:group], ssh_wrapper_script_file)\n end",
"def to_s\n \"#<#{self.class} subj=#{@subject} can-sign=#{@key != nil}>\"\n end",
"def new_key(key)\n property = Atom::XML::Node.new('apps:property')\n property['name'] = 'publicKey'\n property['value'] = Base64.encode64 key\n\n @doc.root << property\n end",
"def echo\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.notification_echo do\n xml.payment_unique_id @payment_unique_id\n end\n xml.target!\n end",
"def private_key; end",
"def private_key; end",
"def private_key=(private_key); end",
"def create\n\n @signature = Signature.new(params[:signature])\n\n respond_to do |format|\n if @signature.save\n format.html { redirect_to(@signature, :notice => 'Signature was successfully created.') }\n format.xml { render :xml => @signature, :status => :created, :location => @signature }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @signature.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def signer\n end",
"def sign(message, privkey)\n group = ECDSA::Group::Secp256k1\n digest = Digest::SHA256.digest(message)\n signature = nil\n while signature.nil?\n temp_key = 1 + SecureRandom.random_number(group.order - 1)\n signature = ECDSA.sign(group, privkey.to_i(16), digest, temp_key)\n return ECDSA::Format::SignatureDerString.encode(signature).unpack(\"H*\").first\n end\n end",
"def sign_block(key_private, timestamp)\r\n # RSA Encryption (Formula: C = M^d mod n)\r\n timestamp = timestamp.to_i % key_private[1].to_i\r\n signature = timestamp.to_bn.mod_exp(key_private[0],key_private[1])\r\n return signature\r\nend",
"def signing_request\n req = OpenSSL::X509::Request.new\n req.public_key = key.public_key\n req.subject = OpenSSL::X509::Name.new([['CN', domain]])\n req.sign(key, OpenSSL::Digest::SHA256.new)\n end",
"def to_xml()\n XmlSimple.xml_out( { :email => self.to_hash() },\n { :KeepRoot=>true, :NoAttr=>true } )\n end",
"def output_key(key)\n STDOUT.write \"# Private key (d, n): #{'%X' % key.d} #{'%X' % key.n}\\n\"\n STDOUT.write \"key #{'%X' % key.e} #{'%X' % key.n}\\n\"\nend",
"def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {}\n attributes['ForceAuthn'] = force_authn unless force_authn.nil?\n attributes['IsPassive'] = is_passive unless is_passive.nil?\n # TODO implement assertion consumer service index\n # TODO implement assertion consumer service URL\n attributes['ProtocolBinding'] = protocol_binding unless protocol_binding.nil?\n attributes['AttributeConsumingServiceURL'] = attribute_consuming_service_url unless attribute_consuming_service_url.nil?\n attributes['ProviderName'] = provider_name unless provider_name.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:AuthnRequest', attributes) {\n xml << subject.to_xml unless subject.nil?\n xml << name_id_policy.to_xml unless name_id_policy.nil?\n xml << conditions.to_xml unless conditions.nil?\n xml << requested_authn_context unless requested_authn_context.nil?\n xml << scoping.to_xml unless scoping.nil?\n }\n end",
"def signer_info( xml, sig )\n sig_info = Hash.new\n if ! sig.signature_node.empty?\n sig_info[ :signer_name ] = sig.signer_name\n sig_info[ :signer_issuer_name ] = sig.signer_issuer\n if ! sig.signer_node.empty?\n signer_ns_prefix = namespace_prefix( xml, MStr::Ns_Xmldsig )\n sig_info[ :x509serialnumber ] = sig.signer_node.first.xpath( \"//#{ signer_ns_prefix }:X509SerialNumber\", signer_ns_prefix => MStr::Ns_Xmldsig ).first.text.to_i\n sig_info[ :cert_serial ] = sig.crypto.context.first.serial.to_i unless sig.crypto.context.empty?\n end\n end\n return sig_info\nend",
"def signer_info( xml, sig )\n sig_info = Hash.new\n if ! sig.signature_node.empty?\n sig_info[ :signer_name ] = sig.signer_name\n sig_info[ :signer_issuer_name ] = sig.signer_issuer\n if ! sig.signer_node.empty?\n signer_ns_prefix = namespace_prefix( xml, MStr::Ns_Xmldsig )\n sig_info[ :x509serialnumber ] = sig.signer_node.first.xpath( \"//#{ signer_ns_prefix }:X509SerialNumber\", signer_ns_prefix => MStr::Ns_Xmldsig ).first.text.to_i\n sig_info[ :cert_serial ] = sig.crypto.context.first.serial.to_i unless sig.crypto.context.empty?\n end\n end\n return sig_info\nend",
"def generate_key( username, password, contract)\n response_xml = self.call( :generate_key, message: {\n arg0: username,\n arg1: password,\n arg2: contract\n })\n response = IssueCentre::Response.parse( response_xml,\n {contract_id: contract})\n end",
"def signing_information\n super\n end",
"def sign!(cert)\n openssl_cert = cert.cert # because model -> OpenSSL object\n openssl_cert.serial = self.next_serial\n cert.serial = self.next_serial\n openssl_cert.issuer = ca_cert.subject\n openssl_cert.sign private_key, OpenSSL::Digest::SHA1.new\n self.next_serial = self.next_serial + 1\n self.save\n nil\n end",
"def sign(params)\n string = params_to_string(params)\n\n case @sign_type\n when 'RSA'\n ::Alipay::Sign::RSA.sign(@app_private_key, string)\n when 'RSA2'\n ::Alipay::Sign::RSA2.sign(@app_private_key, string)\n else\n raise \"Unsupported sign_type: #{@sign_type}\"\n end\n end",
"def write_genkey_parameter_file\n now = Time.now.to_i.to_s\n expire_date = Date.today + 14\n passphrase = SecureRandom.base64(100)\n genkey_parameters = [\n '%echo Generating Development GPG Key',\n '%echo',\n \"%echo This key will expire on #{expire_date}\",\n '%echo',\n 'Key-Type: RSA',\n 'Key-Length: 4096',\n 'Key-Usage: sign',\n 'Name-Real: SIMP Development',\n \"Name-Comment: Development key #{now}\",\n \"Name-Email: #{@key_email}\",\n 'Expire-Date: 2w',\n \"Passphrase: #{passphrase}\",\n ]\n\n if gpg_version < Gem::Version.new('2.1')\n genkey_parameters << '%pubring pubring.gpg'\n genkey_parameters << '%secring secring.gpg'\n end\n\n genkey_parameters << '# The following creates the key, so we can print \"Done!\" afterwards'\n genkey_parameters << '%commit'\n genkey_parameters << '%echo New GPG Development Key Created'\n\n File.open(GPG_GENKEY_PARAMS_FILENAME, 'w') { |fh| fh.puts(genkey_parameters.join(\"\\n\")) }\n end",
"def sign!(key, sign_nonce = T.unsafe(nil)); end",
"def sign!\n params = {\n :if_updated_at => @contract.content_updated_at\n }\n\n response = @client.put self.url, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } }\n\n if response.status != 201\n raise Inkdit::Error.new(response)\n end\n\n Inkdit::Signature.new(@client, response.parsed)\n end",
"def index\n begin\n\n # Instantiate the PadesSignatureStarter class, responsible for receiving the signature elements and start\n # the signature process\n signature_starter = RestPki::PadesSignatureStarter.new(get_restpki_client)\n\n # Set the signature policy\n signature_starter.signature_policy_id = RestPki::StandardSignaturePolicies::PADES_BASIC\n\n # Set the security context to be used to determine trust in the certificate chain\n signature_starter.security_context_id = get_security_context_id\n\n # Set the visual representation for the signature\n signature_starter.visual_representation = {\n text: {\n\n # The tags {{name}} and {{national_id}} will be substituted according to the user's certificate\n #\n # name : full name of the signer\n # national_id : if the certificate is ICP-Brasil, contains the signer's CPF\n #\n # For a full list of the supported tags, see: https://github.com/LacunaSoftware/RestPkiSamples/blob/master/PadesTags.md\n text: 'Signed by {{signerName}} ({{signerNationalId}})',\n # Specify that the signing time should also be rendered\n horizontalAlign: 'Left',\n # Optionally set the horizontal alignment of the text ('Left' or 'Right'), if not set the default is\n # Left\n includeSigningTime: true,\n # Optionally set the container within the signature rectangle on which to place the text. By\n # default, the text can occupy the entire rectangle (how much of the rectangle the text will\n # actually fill depends on the length and font size). Below, we specify that the text should respect\n # a right margin of 1.5 cm.\n container: {\n left: 0,\n top: 0,\n right: 1.5,\n bottom: 0\n }\n\n },\n image: {\n\n # We'll use as background the image content/PdfStamp.png\n resource: {\n content: Base64.encode64(get_pdf_stamp_content),\n mimeType: 'image/png'\n },\n # Opacity is an integer from 0 to 100 (0 is completely transparent, 100 is completely opaque).\n opacity: 50,\n # Align the image to the right\n horizontalAlign: 'Right',\n # Align the image to the center\n verticalAlign: 'Center'\n\n },\n # Position of the visual representation. We have encapsulated this code in a function to include several\n # possibilities depending on the argument passed to the function. Experiment changing the argument to\n # see different examples of signature positioning. Once you decide which is best for your case, you can\n # place the code directly here. See file helpers/pades_helper.rb\n position: get_visual_representation_position(1)\n }\n\n # Below we'll either set the PDF file to be signed. Prefer passing a path or a stream instead of the file's\n # contents as a byte array to prevent memory allocation issues with large files.\n @userfile = params[:userfile]\n if @userfile.nil?\n\n # If the URL argument \"userfile\" is filled, it means the user was redirected by upload_controller\n # (signature with file upload by user). We'll set the path of the file to be signed, which was saved in\n # the temporary folder by upload_controller (such a file would normally come from your application's\n # database)\n signature_starter.set_pdf_tosign_from_path(get_sample_doc_path)\n\n else\n\n # If userfile is null, this is the \"signature with server file\" case. We'll set the file to be signed\n # by passing its path\n signature_starter.set_pdf_tosign_from_path(Rails.root.join('public', 'uploads', @userfile))\n\n end\n\n # Call the start_with_webpki method, which initiates the signature. This yields the token, a 43-character\n # case-sensitive URL-safe string, which identifies this signature process. We'll use this value to call the\n # sign_with_restpki method on the Web PKI component (see signature-form.js) and also to complete the\n # signature after the form is submitted (see method create below). This should not be mistaken with the\n # API access token.\n @token = signature_starter.start_with_webpki\n\n # The token acquired above can only be used for a single signature attempt. In order to retry the signature\n # it is necessary to get a new token. This can be a problem if the user uses the back button of the browser,\n # since the browser might show a cached page that we rendered previously, with a now stale token. To prevent\n # this from happening, we call the method set_expired_page_headers, located in application_helper.rb, which\n # sets HTTP headers to prevent caching of the page.\n set_expired_page_headers\n\n rescue => ex\n @error = ex\n render 'layouts/_error'\n end\n end",
"def initialize params\n @saml_doc = LibXML::XML::Parser.string( params[:saml_xml] ).parse\n @private_key = OpenSSL::PKey::RSA.new( params[:private_key] )\n end",
"def to_xml\n Builder.new(owner, grants).to_s\n end",
"def build_request\n b = builder\n xml = b.SignatureProofOfDeliveryRequest(:xmlns => \"http://fedex.com/ws/track/v#{VERSION[:major]}\") do\n build_authentication(b)\n build_version(b, \"trck\", VERSION[:major], VERSION[:intermediate], VERSION[:minor])\n \n b.Type image_type\n b.TrackingNumber tracking_number\n b.FaxDetail fax_number if fax_number\n b.LetterFormat image_file_type\n end\n end",
"def sign()\n # TODO\n end",
"def gen_ec_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::EC.new key_content, priv_key_password\n\n # Get curve type (prime256v1...)\n group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)\n # Get Generator point & public point (priv * generator)\n generator = group.generator\n pub_point = generator.mul(key.private_key)\n key.public_key = pub_point\n\n # Public Key in pem\n public_key = ::OpenSSL::PKey::EC.new\n public_key.group = group\n public_key.public_key = pub_point\n public_key.to_pem\n end",
"def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:AssertionIDRequest') {\n assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml }\n }\n end",
"def to_xml\n xml_builder = Nokogiri::XML::Builder.new do |xml|\n xml.Package('xmlns' => 'http://soap.sforce.com/2006/04/metadata') {\n self.each do |key, members|\n xml.types {\n members.each do |member|\n xml.members member\n end\n xml.name key.to_s.camelize\n }\n end\n xml.version Metaforce.configuration.api_version\n }\n end\n xml_builder.to_xml\n end",
"def create_key\n self.key = Digest::MD5.hexdigest(self.official_id.to_s + self.sent_to_email)\n end",
"def write_signature\n self.message = \"#{real_message.chomp}\\n\\n#{SIG_KEY}: #{signature}\\n\"\n IO.write(@message_file, message, 0, mode: 'w') unless @message_file.nil?\n end",
"def sign(message); end",
"def create\n @sign = Sign.new(sign_params)\n if @sign.save\n respond_with(@sign)\n else\n @error = \"签到 失败 !\"\n respond_with(@error)\n end\n end",
"def signature_key=(_arg0); end",
"def make_keypair\n\t gpg = OpenPGP::Engine::GnuPG.new(:homedir => '~/.gnupg')\n\t key_id = gpg.gen_key({\n\t\t :key_type => 'DSA',\n\t\t :key_length => 1024,\n\t\t :subkey_type => 'ELG-E',\n\t\t :subkey_length => 1024,\n\t\t :name => @dname,\n\t\t :comment => nil,\n\t\t #:email => '',\n\t\t #:passphrase => '',\n\t\t})\n\tend",
"def regenerate_key\n self.private_key = true\n self.save\n end",
"def generate(value, expires_at: nil, expires_in: nil, purpose: nil)\n data = encode(Messages::Metadata.wrap(@serializer.dump(value), expires_at: expires_at, expires_in: expires_in, purpose: purpose))\n \"#{data}--#{generate_digest(data)}\"\n end",
"def to_xml(xml=Builder::XmlMarkup.new)\n attributes = {'ID' => id, 'Version' => version, 'IssueInstant' => issue_instant.in_time_zone.xmlschema}\n attributes['InResponseTo'] = in_response_to unless in_response_to.nil?\n attributes['Destination'] = destination unless destination.nil?\n attributes['Consent'] = consent unless consent.nil?\n attributes = add_xmlns(attributes)\n xml.tag!('samlp:Response', attributes) {\n xml << issuer.to_xml unless issuer.nil?\n xml << signature.to_xml unless signature.nil?\n # TODO: add extensions support\n xml << status.to_xml unless status.nil?\n assertions.each { |assertion| xml << assertion.to_xml }\n encrypted_assertions.each { |encrypted_assertion| xml << encrypted_assertion.to_xml }\n }\n end",
"def create\n @signature = Signature.new(params[:signature])\n\n respond_to do |format|\n if @signature.save\n format.html { redirect_to(@signature, :notice => 'La asignatura se ha creado correctamente.') }\n format.xml { render :xml => @signature, :status => :created, :location => @signature }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @signature.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def signon_app_cert_rq()\n xml = Builder::XmlMarkup.new(:indent => 2)\n create_xml_header(xml, options)\n\n xml.tag!('QBMSXML') do\n xml.tag!('SignonMsgsRq') do\n xml.tag!('SignonAppCertRq') do\n xml.tag!('ClientDateTime', Time.now)\n xml.tag!('ApplicationLogin', @options[:applogin])\n xml.tag!('ConnectionTicket', @options[:conntkt])\n end\n end\n end\n xml.target!\n end",
"def signing_input; end",
"def signing_input; end",
"def private_key_string(privatekey)\n private_key_names=[\"primesinverses\",\"d_set\", \"primes\"]\n private_key_string=\"privatekey=[\"\n for i in 0..privatekey.length-1\n private_key_string << private_key_names[i]+\"=[\"\n for x in 0..privatekey[i].length-1\n private_key_string << privatekey[i][x].to_s+\",\"\n end\n private_key_string << \"],\\n\"\n end\n private_key_string << \"]\"\n private_key_string\n end",
"def signstuff(revision, data, pkeypath)\n pkey = OpenSSL::PKey::EC.new File.read pkeypath\n\n revm = revision.match(/([0-9]+)-.+/)\n oldrev = revm[1]\n newrev = oldrev.to_i + 1\n\n signature = Base64.encode64(pkey.dsa_sign_asn1(newrev.to_s+data))\nend",
"def create(pvt)\n key = Bitcoin::Key.new\n key.priv = pvt\n key.addr\n end",
"def get_visual_representation\n\n # Create a visual representation\n vr = PkiExpress::PadesVisualRepresentation.new\n\n # The tags {{name}} and {{national_id}} will be substituted according\n # to the user's certificate:\n #\n # name : full name of the signer;\n # national_id : if the certificate is ICP-Brasil, contains the\n # signer's CPF.\n # For a full list of the supported tags, see:\n # https://docs.lacunasoftware.com/articles/pki-express/pades-tags.html\n text = PkiExpress::PadesVisualText.new('Signed by {{name}} ({{national_id}})', true)\n text.font_size = 13.0\n # Create a text container and add PadesVisualText object.\n container = PkiExpress::PadesVisualRectangle.new\n container.set_vertical_stretch(0.2, 0.2)\n container.set_horizontal_stretch(0.2, 0.2)\n text.container = container\n # Add text to visual representation.\n vr.text = text\n\n # Create an instance of PadesVisualImage class.\n image = PkiExpress::PadesVisualImage.new\n # Set the content of the image\n image.content = get_pdf_stamp_content\n # Add image to visual representation.\n vr.image = image\n\n # Create an instance of PadesVisualAutoPositioning class. This class will\n # create a custom auto positioning for the visual representation.\n position = PkiExpress::PadesVisualAutoPositioning.new\n # Set the page number. Negative values represent pages counted form the end\n # of the document (-1 is the last page).\n position.page_number = -1\n # Set the row spacing between signatures. The signatures will be placed in\n # container side by side. If there's no room left, the signatures will\n # \"wrap\" to the next row. This value specifies the vertical distance between\n # rows.\n position.row_spacing = 0.0\n # Specify the size of each signature rectangle.\n size = PkiExpress::PadesSize.new(8.0, 4.94)\n position.signature_rectangle_size = size\n # Create the position container and add to PadesVisualPosition object.\n position_container = PkiExpress::PadesVisualRectangle.new\n position_container.set_height_bottom_anchored(4.94, 1.5)\n position_container.set_horizontal_stretch(1.5, 1.5)\n position.container = position_container\n # Add position to visual representation.\n vr.position = position\n\n # Return visual representation.\n vr\n end",
"def calculate_signature(doc, node)\n sha1 = OpenSSL::Digest::SHA1.new\n node = doc.at_css(node)\n canon_signed_info_node = canonicalize_exclusively(node)\n signature = @signing_private_key.sign(sha1, canon_signed_info_node)\n\n encode(signature).gsub(/\\s+/, \"\")\n end",
"def to_s\n signed = (signed_at || Time.now).to_i.to_s\n\texpires = expires_at.to_i.to_s\n\tsignature = \"#{public_key}#{expires}#{signed}#{action}\"\n\ttoken = OpenSSL::HMAC.hexdigest DIGEST, secret, signature\n\tencoded_token = Base64.encode64(token)\n\tencoded_token.gsub! /\\n/, ''\n\tparams = [ encoded_token, public_key, expires, signed ].join SEPARATOR\n\tBase64.encode64(params).gsub(/\\n/, '')\n end",
"def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end",
"def sign!(signing_profile={})\n raise \"Invalid certificate #{self.errors.full_messages}\" unless valid?\n merge_profile_with_extensions(signing_profile)\n\n openssl_cert = OpenSSL::X509::Certificate.new\n openssl_cert.version = 2\n openssl_cert.not_before = self.not_before\n openssl_cert.not_after = self.not_after\n openssl_cert.public_key = self.key_material.public_key\n\n openssl_cert.serial = self.serial_number.number\n\n openssl_cert.subject = self.distinguished_name.to_x509_name\n openssl_cert.issuer = parent.distinguished_name.to_x509_name\n\n factory = OpenSSL::X509::ExtensionFactory.new\n factory.subject_certificate = openssl_cert\n\n #NB: If the parent doesn't have an SSL body we're making this a self-signed cert\n if parent.openssl_body.nil?\n factory.issuer_certificate = openssl_cert\n else\n factory.issuer_certificate = parent.openssl_body\n end\n\n factory.config = build_openssl_config\n\n # Order matters: e.g. for self-signed, subjectKeyIdentifier must come before authorityKeyIdentifier\n self.extensions.keys.sort{|a,b| b<=>a}.each do |k|\n e = extensions[k]\n next if e.to_s.nil? or e.to_s == \"\" ## If the extension returns an empty string we won't include it\n ext = factory.create_ext(e.openssl_identifier, e.to_s, e.critical)\n openssl_cert.add_extension(ext)\n end\n\n if signing_profile[\"digest\"].nil?\n digest = OpenSSL::Digest.new(\"SHA512\")\n else\n digest = OpenSSL::Digest.new(signing_profile[\"digest\"])\n end\n\n self.openssl_body = openssl_cert.sign(parent.key_material.private_key, digest)\n end",
"def update_signature!; end",
"def update_signature!; end",
"def sign_tx(raw_tx, pkey_wif)\n # Seems like this is your quintessential reference: \n # http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html\n\n # I think this is the right way to do it...\n Bitcoin.network = (bitcoin.is_testing?) ? :testnet3 : :bitcoin\n\n # This parses the binary-encoded raw transaction:\n tx = Bitcoin::P::Tx.new [raw_tx].pack('H*')\n\n # This is the input transaction, which we'll need for signining:\n prev_hash = tx.in[0].prev_out.reverse_hth\n\n # let's parse the keys:\n key = Bitcoin::Key.from_base58 pkey_wif\n\n pubkey = [key.pub].pack('H*')\n\n # And parse the input transaction:\n prev_tx = Bitcoin::P::Tx.new [bitcoin.getrawtransaction(prev_hash)].pack('H*')\n\n # And, now we're ready to sign: \n subscript = tx.signature_hash_for_input 0, prev_tx\n sig = Bitcoin.sign_data Bitcoin.open_key(key.priv), subscript\n tx.in[0].script_sig = Bitcoin::Script.to_signature_pubkey_script sig, pubkey \n\n tx.to_payload.unpack('H*')[0]\n end",
"def gen_sig(mac, params)\n signed = params[\"signed\"].split(\",\").map {|k| [k, params[k]]}\n base64_encode(Signatures.sign(mac, kv_encode(signed)))\n rescue Signatures::NotFound\n nil\n end",
"def key_pem; end",
"def aws_get_signature_key(key, date_stamp, region_name, service_name)\n k_date = aws_sign(\"AWS4\" + key, date_stamp)\n k_region = aws_sign(k_date, region_name)\n k_service = aws_sign(k_region, service_name)\n aws_sign(k_service, \"aws4_request\")\n end",
"def to_xml\n if username_token? && timestamp?\n Gyoku.xml wsse_username_token.merge!(wsu_timestamp) {\n |key, v1, v2| v1.merge!(v2) {\n |key, v1, v2| v1.merge!(v2)\n }\n }\n elsif username_token?\n Gyoku.xml wsse_username_token.merge!(hash)\n elsif timestamp?\n Gyoku.xml wsu_timestamp.merge!(hash)\n else\n \"\"\n end\n end",
"def make_keypair\n\t gpg = OpenPGP::Engine::GnuPG.new(:homedir => '~/.gnupg')\n\t key_id = gpg.gen_key({\n\t\t :key_type => 'RSA',\n\t\t :key_length => 4096,\n\t\t :subkey_type => 'RSA',\n\t\t :subkey_length => 4096,\n\t\t :name => @dname,\n\t\t :comment => nil,\n\t\t #:email => '',\n\t\t #:passphrase => '',\n\t\t})\n\tend",
"def notification_signature(ns_merchant_id, \n ns_acquirer_bin,\n ns_terminal_id, \n ns_num_operacion, \n ns_importe, \n ns_tipo_moneda,\n ns_exponente,\n ns_referencia)\n\n charge = Charge.get(ns_num_operacion.to_i)\n configuration = configuration(charge.nil? ? nil : charge.sales_channel_code)\n\n signature = \"\"\n signature << configuration[:clave_encriptacion]\n signature << ns_merchant_id\n signature << ns_acquirer_bin\n signature << ns_terminal_id\n signature << ns_num_operacion\n signature << ns_importe\n signature << ns_tipo_moneda\n signature << ns_exponente\n signature << ns_referencia\n\n p \"calculating notification signature: #{signature}\"\n\n Digest::SHA256.hexdigest signature\n\n end",
"def to_xml\n Builder.new(permission, grantee).to_s\n end",
"def signing_key\n @signing_key\n end"
] |
[
"0.6189456",
"0.5949525",
"0.5949234",
"0.59353924",
"0.59199554",
"0.5917015",
"0.58884853",
"0.5887561",
"0.58661014",
"0.582439",
"0.5766398",
"0.57590437",
"0.56318474",
"0.5622876",
"0.56163824",
"0.5600364",
"0.55871844",
"0.55687976",
"0.55659765",
"0.5556279",
"0.55491626",
"0.55453837",
"0.5532034",
"0.55269724",
"0.5508351",
"0.54967433",
"0.54928017",
"0.54540485",
"0.54030967",
"0.5374931",
"0.53665453",
"0.5356048",
"0.53519225",
"0.5328747",
"0.5311417",
"0.5260216",
"0.5238281",
"0.52036905",
"0.5202762",
"0.5194149",
"0.5170819",
"0.5170819",
"0.5146906",
"0.5131063",
"0.5130889",
"0.51295346",
"0.5112525",
"0.51124966",
"0.5093512",
"0.5092323",
"0.50690067",
"0.506565",
"0.506565",
"0.5053985",
"0.5049388",
"0.5046337",
"0.50339794",
"0.5031966",
"0.5025682",
"0.5022368",
"0.50127494",
"0.5002105",
"0.49919757",
"0.498239",
"0.49813116",
"0.4980726",
"0.49781266",
"0.49744534",
"0.4973524",
"0.49715754",
"0.49576858",
"0.4953056",
"0.49526867",
"0.4950815",
"0.49463186",
"0.49392304",
"0.49329737",
"0.4930795",
"0.49300262",
"0.49288315",
"0.49288315",
"0.49262857",
"0.49194607",
"0.49166238",
"0.49136198",
"0.4910974",
"0.49037728",
"0.48945704",
"0.48934054",
"0.48932406",
"0.48932406",
"0.48927662",
"0.4884194",
"0.4879578",
"0.48789778",
"0.48706",
"0.48682284",
"0.48483306",
"0.48427373",
"0.48424128"
] |
0.6497375
|
0
|
Check the origin of this notification.
|
def verified? key
Nelumba::Crypto.emsa_verify(@plaintext, @signature, key)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_origin\n origin = @transport.get_data(\"meta\",\"origin\")\n # compare two arrays with intersection\n return (origin & [@name,@version,@action]).empty?\n end",
"def originated?\n self.state == 'originated'\n end",
"def origin\n origins && origins.length == 1 && origins[0] || nil\n end",
"def origin\n return @origin\n end",
"def originator\n @originator ||= original_message.sender\n end",
"def origin\n end",
"def originator\n @originator = self.original_message.sender if @originator.nil?\n return @originator\n end",
"def has_error_from?(origin)\n if @propagation_exceptions\n @propagation_exceptions.any? do |error|\n error.originates_from?(origin)\n end\n end\n end",
"def valid_request_origin?; end",
"def originating? other\n originating.include? other\n end",
"def origin=(value)\n @origin = value\n end",
"def origin; end",
"def origin; end",
"def origin; end",
"def originator\n self.user ? self.user.name : NOT_SET\n end",
"def originates_from?(object)\n [generator, origin].include?(object)\n end",
"def originating\n self.class.originating(2, id)\n end",
"def from_client?\n @origin == :client\n end",
"def origin\n Position.new(0,0)\n end",
"def text_origin\n\t\t# puts \"Is this working *******************************\"\n\t\tif self.origin != nil\n\t\t\tBoat::LOCATIONS[self.origin]\n\t\telse\n\t\t\t\"ORIGIN NOT SET\"\n\t\tend\n\tend",
"def get_origin\n\t\treturn @transport.get_path(\"meta\",\"origin\")\n\tend",
"def verify_same_origin_request; end",
"def before_origin(point, axis)\n point.dot(axis) <= 0\n end",
"def validation_origin_destination\n errors.add(:base,\"Origin and Destination must be different\") if locale_origin_id == locale_destination_id # Rails3 slightly different?\n end",
"def marked_for_same_origin_verification?; end",
"def object_origin(obj)\n return obj.oy\n end",
"def object_origin(obj)\n return obj.oy\n end",
"def check_parent_info\n if self.mparent_id\n p = parent_message\n # force correct root id\n self.mroot_id = p.mroot_id || p.id\n #byebug\n # force correct dest (?)\n self.dest_id = p.user_id\n # force coherent visibility !\n self.is_public = p.is_public?\n end\n end",
"def from_server?\n @origin == :server\n end",
"def validate_from\n @from = validate_address(FROM)\n end",
"def origin=(v)\n @origin = v ? URI.parse(v) : nil\n end",
"def from_admin?\n if self.sender == self.receiver\n true\n else\n false\n end\n end",
"def compute_origin\n return nil if move.castle\n\n possibilities = case move.piece\n when /[brq]/i then direction_origins\n when /[kn]/i then move_origins\n when /p/i then pawn_origins\n else # don't care move, used in variations\n return nil\n end\n\n possibilities = disambiguate(possibilities) if possibilities.length > 1\n\n board.position_for(possibilities.first)\n end",
"def get_origin()\n origin = get_parent_surface().get_sub_surface_origin()\n return origin\n end",
"def from( origin )\n select { |e| e.respond_to?(:from?) && e.from?( origin ) }\n end",
"def safe_mail_from\n name = self.mail.from_name_if_present\n if name.nil?\n return nil\n end\n name = name.dup\n self.info_request.apply_censor_rules_to_text!(name)\n return name\n end",
"def origin_remote\n origin = git(\"remote\", \"-v\").lines.grep(/^origin\\s/).first\n origin && origin.split[1]\n end",
"def owned?\n @owner == caller\n end",
"def set_originator(message)\n # no originator. For jobs that are only called from within other\n # jobs, there is no need to override this method.\n end",
"def notify_original_creators\n origins.each do |o|\n unless o.parent.user_id == o.jingle.user_id\n Notification.create(\n target_id: o.parent_id,\n target_type: \"Jingle\",\n notice_id: o.jingle_id,\n notice_type: \"JingleOrigin\",\n user_id: o.jingle.user_id,\n notifier_id: user_id\n )\n end\n end\n end",
"def add_origin msg\n return if msg.connection != @connection\n\n msg.origin =~ /(.+)!(.+)@(.+)/\n\n add_user msg.connection.canonize($1), $2, $3\n end",
"def not_current_person(message)\n message.sender == current_person ? message.recipient : message.sender\n end",
"def state_author\n if self.originator\n return User.find_by_id(self.originator).email || 'Unknown'\n end\n return 'None'\n end",
"def ListView_GetOrigin(hwndLV, ppt) send_listview_message(hwndLV, :GETORIGIN, lparam: ppt) end",
"def request_origin\n @request_origin ||= \"#{request.remote_ip} at #{Time.now.to_s(:db)}\"\n end",
"def object_origin(obj)\n return obj.ox\n end",
"def object_origin(obj)\n return obj.ox\n end",
"def sender?\n !!self.sender\n end",
"def from\n @_from || payload && payload['from']\n end",
"def replied_to?\n !replied_at.nil?\n end",
"def original?\n self.parent == self\n end",
"def mark_for_same_origin_verification!; end",
"def check_ownership_requestor_user(requestor,user)\n if requestor.nickname != user.nickname\n raise Error, \"Requestor #{requestor.nickname} and user requested #{user.nickname} do not match\"\n end\n end",
"def origin\n unless params[:origin].blank?\n params[:origin].slice!(0) if params[:origin][0].upcase == \"R\" # Remove proceeding R if present\n origin = params[:origin].to_s.rjust(4, '0').prepend(\"R\") # Add zero padding and Prepend R\n cookies.permanent[:origin] = origin.upcase\n\n cookies.delete :start_location\n\n notice = \"Origin successfully updated to: #{cookies[:origin]}\"\n else\n cookies.delete :origin\n notice = \"Origin successfully cleared\"\n end\n\n respond_to do |format|\n format.json {\n render :json => {\n origin: cookies[:origin],\n notice: notice\n }\n }\n end\n end",
"def set_origin\n @origin = Origin.find(params[:id])\n end",
"def setOrigin(origin)\n @origin = origin\n end",
"def eligible_for_originator?\n return true if originator.nil?\n !originator.respond_to?(:eligible?) || originator.eligible?(source)\n end",
"def paper_trail_originator\n @paper_trail_originator ||= previous.try(:whodunnit)\n end",
"def current_request_child\n (status == :accept_recip_child || status == :accepted_full ) ? recipient : requester\n end",
"def validate_to_address\n to = validate_to\n unless to.nil? || to.bare == stream.user.jid.bare\n raise StanzaErrors::Forbidden.new(self, 'auth')\n end\n end",
"def valid?\n self.receiver.valid? && self.sender.valid?\n end",
"def origin\n \"#{scheme}://#{authority}\"\n end",
"def set_origin\n @origin = Origin.find(params[:id])\n end",
"def same_origin_as_host?(env)\n proto = Rack::Request.new(env).ssl? ? 'https' : 'http'\n host = env['HTTP_X_FORWARDED_HOST'] ? env['HTTP_X_FORWARDED_HOST'].split(/,\\s*/).first : env['HTTP_HOST']\n Rails.env.development? || env['HTTP_ORIGIN'] == \"#{proto}://#{host}\"\n end",
"def eligible_for_originator?\n return true if originator.nil?\n !originator.respond_to?(:eligible?) || originator.eligible?(adjustable)\n end",
"def smart_origin_url\n if params[:origin_url].blank?\n request.original_url\n else\n params[:origin_url]\n end\n end",
"def origin\n unless params[:origin].blank?\n params[:origin].slice!(0) if params[:origin][0].upcase == \"R\" # Remove proceeding R if present\n origin = params[:origin].to_s.rjust(4, '0').prepend(\"R\") # Add zero padding and Prepend R\n session[:start] = origin\n cookies.permanent[:origin] = origin.upcase\n\n cookies.delete :start_location\n\n notice = \"Origin successfully updated to: #{cookies[:origin]}\"\n else\n cookies.delete :origin\n notice = \"Origin successfully cleared\"\n end\n\n respond_to do |format|\n format.json {\n render :json => {\n origin: cookies[:origin],\n notice: notice\n }\n }\n end\n end",
"def not_current_user(message)\n\t\tmessage.sender == current_user ? message.recipient : message.sender\n\tend",
"def origin_names\n origins ? origins.map(&:to_sym) : nil\n end",
"def src_ip\n self[:sender_ip]\n end",
"def current_recipient_child\n (status == :accept_recip_child || status == :accepted_full ) ? requester : recipient\n end",
"def staff_initiated?\n self.from_phone == self.ride_zone.phone_number_normalized\n end",
"def origin\n config[:url]\n end",
"def isSelfMessage?\n if(@fromNick==@selfNick)\n return true\n else\n return false\n end\n end",
"def source_dest_check\n data[:source_dest_check]\n end",
"def check_mail_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Email.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id\n Log.add_check(request, '[check_mail_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def work_proxy_or_depositor\n work.on_behalf_of.blank? ? work.depositor : work.on_behalf_of\n end",
"def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end",
"def from\n @property[:from]\n end",
"def sender? usr\n usr.id == user_id\n end",
"def origin\n legs.first.start_address\n end",
"def in_reply_to\n return @in_reply_to\n end",
"def perspective_must_validate\n if sender.present? && recipient.present? && !self_contact.self?\n errors.add_to_base('Not set up from perspective of self')\n end\n end",
"def from?( state )\n origin_names.include?( state.to_sym ) || target_for_origin(state)\n end",
"def originator\n unless @originator\n uri = URI @request.url\n uri.query = nil if (uri.query = @meaningful_params.to_param).blank?\n uri.path = uri.path.sub(/\\..*/,'') # Remove any format indicator\n @originator = uri.to_s\n end\n @originator\n end",
"def in_reply_to\n headers['In-Reply-To']\n end",
"def valid?\n self.sender.valid? && self.receiver.valid?\n end",
"def sender?\n !!self.sender\n end",
"def set_originator\n @originator = Originator.find(params[:id])\n end",
"def valid_from\n utc_timestamp_from('valid_from')\n end",
"def valid?\n sender.valid?\n receiver.valid?\n end",
"def receive_recipient rcpt\n true\n end",
"def receive_recipient rcpt\n true\n end",
"def receive_recipient rcpt\n true\n end",
"def access_control_allow_origin\n headers 'Access-Control-Allow-Origin' => request.env['HTTP_ORIGIN'] if request_from_zendesk?\n end",
"def email_changed?\n (self.channel_referent_id==0) && super\n end",
"def check_user_ownership_and_set_message\n if @source_account && @source_account.user == current_user\n if @destination_account.present?\n @transaction.message = 'Transfer'\n return true\n end\n @transaction.message = 'Withdrawal'\n return true\n end\n\n if @destination_account.user == current_user\n @transaction.message = 'Deposit'\n return true\n end\n\n false\n rescue StandardError\n false\n end",
"def owned?\n user.present?\n end",
"def origin_dynamic=(v)\n @origin = !!v\n end",
"def check_resolved_at\n self.errors.add('Resolved at', 'can\\'t be blank') if (self.resolved && self.resolved_at.blank?)\n end",
"def set_Origin(value)\n set_input(\"Origin\", value)\n end"
] |
[
"0.65892726",
"0.64467144",
"0.6444163",
"0.6413615",
"0.61449504",
"0.5988132",
"0.59232336",
"0.58633226",
"0.5770973",
"0.57301587",
"0.5661349",
"0.56603426",
"0.56603426",
"0.56603426",
"0.5632777",
"0.562097",
"0.5600231",
"0.5464617",
"0.54541916",
"0.54413813",
"0.54086727",
"0.54084355",
"0.53860843",
"0.537961",
"0.5365847",
"0.5348111",
"0.53476113",
"0.5338191",
"0.53144526",
"0.53028315",
"0.5248687",
"0.5232017",
"0.52265203",
"0.52030975",
"0.5193087",
"0.51841414",
"0.5175886",
"0.5165456",
"0.51611257",
"0.5159896",
"0.5128723",
"0.51287127",
"0.50920576",
"0.50767374",
"0.5052076",
"0.502472",
"0.502472",
"0.50121695",
"0.4978719",
"0.4971129",
"0.49682537",
"0.496571",
"0.4952745",
"0.4947903",
"0.4947417",
"0.49434572",
"0.49215686",
"0.49166673",
"0.49077374",
"0.48616177",
"0.4857852",
"0.48550314",
"0.48521775",
"0.48519328",
"0.4849971",
"0.4841611",
"0.48270842",
"0.4812673",
"0.48077592",
"0.4797518",
"0.4789797",
"0.47855908",
"0.4785463",
"0.47811282",
"0.47755465",
"0.4773615",
"0.4772938",
"0.47669056",
"0.47653872",
"0.47637483",
"0.4753977",
"0.47525057",
"0.47508606",
"0.47481352",
"0.4737152",
"0.47350526",
"0.4734172",
"0.47310734",
"0.4726864",
"0.471775",
"0.47144297",
"0.4712326",
"0.4712326",
"0.4712326",
"0.4710844",
"0.47096974",
"0.4709615",
"0.47073212",
"0.46996158",
"0.4698131",
"0.46924973"
] |
0.0
|
-1
|
Retrieve the tag from the "tag" object data and apply it to the selection.
|
def format(b, txtvu)
s, e = txtvu.buffer.selection_bounds
# Our buttons contain Gtk::Stock#Items. Their label values
# begin with "gtk-", ie: gtk-bold, gtk-italic, ... We need
# the word after "gtk-" ie.: bold, italic ... which are used
# as tag property names; Hence Ruby's gsub (sub-string)
# extracts the 2nd string
tag_property_name = b.label.gsub(/(gtk-)([a-z]+)/, '\2')
txtvu.buffer.apply_tag(tag_property_name, s, e)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def selected_tags=(data)\n self.tags.clear\n data.split('tag').each { |id| self.tags << Tag.find(id) if id.length > 0 }\n end",
"def tag(tag); end",
"def tag(tag); end",
"def tag_text text_view, tag_type\n s, e = text_view.buffer.selection_bounds\n text_view.buffer.apply_tag(tag_type.tag, s, e)\n end",
"def tag tag = nil\n @tag = tag if tag\n @tag\n end",
"def set_tag\n @tag = Tag.where(id: params[:tag]).first\n end",
"def set_tag\n @tag = Tag.where('safe_name = ?', params[:id]).first\n end",
"def tag_text=(value)\n self.tag=(value)\n end",
"def set_tag_for_search(tag)\n @page.all(input_elements[:entries])\n @page.find(input_elements[:tag_filter_field]).set(tag)\n @page.find(input_elements[:tag_selected]).click\n @used_tag = tag\n end",
"def set_tag\n @tag = ActsAsTaggableOn::Tag.find(params[:id])\n end",
"def set_tag\n @tag = ActsAsTaggableOn::Tag.find(params[:id])\n end",
"def consider_tag\n\n tag = attribute(:tag)\n\n return unless tag && tag.strip.size > 0\n\n h.tagname = tag\n h.full_tagname = applied_workitem.tags.join('/')\n\n return if h.trigger\n #\n # do not consider tags when the tree is applied for an\n # on_x trigger\n\n h.full_tagname = (applied_workitem.tags + [ tag ]).join('/')\n\n set_variable(h.tagname, h.fei)\n set_variable('/' + h.full_tagname, h.fei)\n\n applied_workitem.send(:add_tag, h.tagname)\n\n @context.storage.put_msg(\n 'entered_tag',\n 'tag' => h.tagname,\n 'full_tag' => h.full_tagname,\n 'fei' => h.fei,\n 'workitem' => h.applied_workitem)\n end",
"def tag\n if @tag.is_a? String\n @tag\n end\n end",
"def tag(arg)\n @tag = arg.to_s\n self\n end",
"def get(tag)\n @orig[tag]\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def tag\n @tag\n end",
"def [](tag)\n unified_tag = Values.unify_tag(tag)\n convert(unified_tag, @values[unified_tag])\n end",
"def tag(tag)\n @tagname = tag\n end",
"def tag\n try_opt(:tag)\n end",
"def tag(new_tag); end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def tag= tag\n @tag = tag\n update!\n end",
"def tag\n return @tag\n end",
"def tag\n Tag.find(tag_id)\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def value_for_tag(tag)\n self.__send__(fields[tag].name)\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = Tag.find(params[:id])\n end",
"def handle_tag_as_text\n self[:is_tag] = false\n self[:closing_tag] = false\n self[:text] = self[:complete_match]\n end",
"def get_tag(tag_class); end",
"def tag=(value)\n @tag = value\n self.status = TAG_STATUS.fetch(value)\n @tag\n end",
"def add_tags(tag)\n remove_previous_tags\n if @page.find(input_elements[:tag_input_field]).present?\n @page.find(input_elements[:tag_input_field]).set(tag)\n else\n @page.find(input_elements[:tag_input_field2]).set(tag)\n end\n @page.find(input_elements[:tag_selected]).click\n @used_tag = tag\n end",
"def set_tag\n # TODO performant?\n @tag = parent.tags.find_by name: params[:name]\n end",
"def set_tag\n begin\n @tag = Tag.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n @tag = Tag.find_by(tag_id: params[:id]) || raise(ActiveRecord::RecordNotFound.new)\n end\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def setTag(tag)\n @fields['tag'] = tag\n self\n end",
"def parse_tag_with_name(tag_name, text); end",
"def select_tag(name, option_tags = T.unsafe(nil), options = T.unsafe(nil)); end",
"def tag_with tag_or_string, tagger_id, options={}\n if tag_or_string.is_a? String\n tags = Tag.strmatch tag_or_string, matchall: true, tagtype: options[:type], assert: true, userid: tagger_id\n tag = tags.first\n else\n tag = tag_or_string\n end\n @taggable_entity.tag_with tag, tagger_id\n end",
"def set_tag\n @tag = current_user.tags.find(params[:id])\n end",
"def tag\n old_word.tag\n end",
"def set_tag\n @tag = @affiliate.tags.find(params[:id])\n end",
"def getTag\n\t\treturn @tag\n\tend",
"def tag_name=(tag_name)\n self.tag = Tag.find_by_name!(tag_name)\n end",
"def set_field\n @tag = Tag.find(params[:id])\n end",
"def set_tag\n @tag = current_user.tags.find(params[:id])\n end",
"def selected_tags=(value)\n @selected_tags = value\n end",
"def set_tag\n\t\t\t@tag = current_user.tags.find(params[:id])\n end",
"def my_node_tagged(tag, options={})\n my_nodes_tagged(tag, options)[0]\n end",
"def my_node_tagged(tag, options={})\n my_nodes_tagged(tag, options)[0]\n end",
"def tag\n @model.tag.name if @model.tag\n end",
"def tag!(tag)\n H[tag, attr, convert_children]\n end",
"def node_tagged(tag, options={})\n nodes_tagged(tag, options)[0]\n end",
"def node_tagged(tag, options={})\n nodes_tagged(tag, options)[0]\n end",
"def set_tagging_select_to\n @tagging_select_to = TaggingSelectTo.find(params[:id])\n end",
"def get_tags_for_select() tag_ids.inject([]) { |l, tag_id| l << [get_tag_from_id(tag_id).label, tag_id] } end",
"def tag\n\t\t@tag = @relator = Relator.find(params[:id]).decorate\n\tend",
"def tag(value)\n merge(rvtag: value.to_s)\n end",
"def tag\n end",
"def tag\n end",
"def tagpane=(str)\n ou = Nokogiri::HTML str\n newtags = []\n oldtags = self.tag_ids\n ou.css(\".name\").each { |child|\n str = child.content.to_s\n # Look up the tag and/or create it\n tag = Tag.strmatch(str, self.current_user || User.guest_id, :Food, true)\n newtags << tag.id unless oldtags.include? tag.id\n x=2\n }\n if newtags.length\n self.tag_ids= oldtags + newtags\n self.save\n end\n super\n end",
"def set_thetag\n @thetag = Thetag.find(params[:id])\n end",
"def tag\n\t\t@tag = @identity = Identity.find(params[:id]).decorate\n\tend",
"def tag; end",
"def tag; end",
"def set_tag\n @tag = if current_manager\n Tag.find_by!(id: params[:id], organization_id: current_manager.organization_id)\n else\n Tag.find(params[:id])\n end\n end",
"def set_tag(tag, value, span=nil)\n raise NotImplementedError\n end",
"def search_tag(tag)\n search_text(tag.name)\n end",
"def tag_text()\n return self.tag(true)\n end",
"def parse_tag_with_types_and_title(tag_name, text); end",
"def update_tag_attribute(content, tag_name, attr_name, init_val); end",
"def set_tag_item\n @tag_item = TagItem.find(params[:id])\n end"
] |
[
"0.6610658",
"0.63108474",
"0.63108474",
"0.6192134",
"0.6185128",
"0.61658216",
"0.60441244",
"0.60328954",
"0.6016391",
"0.60049677",
"0.60049677",
"0.5936232",
"0.5919229",
"0.59021664",
"0.5899758",
"0.58446854",
"0.58446854",
"0.58407354",
"0.5828809",
"0.58242565",
"0.57825834",
"0.57732797",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.57726103",
"0.5772139",
"0.5742539",
"0.5737766",
"0.5735396",
"0.57162786",
"0.56996506",
"0.56908226",
"0.56908226",
"0.56908226",
"0.56908226",
"0.56908226",
"0.5688028",
"0.5669663",
"0.5664819",
"0.56496084",
"0.56462497",
"0.5643657",
"0.56353503",
"0.56114024",
"0.56114024",
"0.56114024",
"0.56114024",
"0.56114024",
"0.56114024",
"0.56114024",
"0.560518",
"0.5597392",
"0.5591066",
"0.5575407",
"0.5556602",
"0.55516875",
"0.5525522",
"0.55169934",
"0.551183",
"0.548517",
"0.54573596",
"0.5456635",
"0.5450725",
"0.5450725",
"0.54272383",
"0.54048866",
"0.5374885",
"0.5374885",
"0.53667206",
"0.5357563",
"0.53409463",
"0.53365386",
"0.531074",
"0.531074",
"0.53107136",
"0.5307481",
"0.53051275",
"0.52966887",
"0.52966887",
"0.52842236",
"0.5272362",
"0.52656853",
"0.52509767",
"0.5249552",
"0.52392733",
"0.52342474"
] |
0.0
|
-1
|
Apply the selected text size property as the tag.
|
def scale_changed(combo, txtvu)
return if combo.active == -1
s, e = txtvu.buffer.selection_bounds
txtvu.buffer.apply_tag(combo.active_text, s, e)
combo.active = -1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def font_size\r\n @style.font_size || @default_font_size\r\n end",
"def change_font_size\n @font_size = 20*(@size_slider.value*2)+20\n #Use change_font_decor to maintain if font is bold or not\n change_font_decor\n end",
"def text_size s, f = font\n f.text_size s\n end",
"def text_size s, f = font\n f.text_size s\n end",
"def font_size(size=nil)\n cur_page.font_size(size)\n end",
"def SetFontSize(size)\n\t\t#Set font size in points\n\t\tif (@font_size_pt== size)\n\t\t\treturn;\n\t\tend\n\t\t@font_size_pt = size;\n\t\t@font_size = size.to_f / @k;\n\t\tif (@page > 0)\n\t\t\tout(sprintf('BT /F%d %.2f Tf ET', @current_font['i'], @font_size_pt));\n\t\tend\n\tend",
"def fontsize=(fontSize)\n @elementHash[:fontsize] = fontSize.to_f\n end",
"def marker_font_size=(value)\n @marker_font.size = value\n end",
"def font_size\n size_tag = @styles.xpath('//w:docDefaults//w:rPrDefault//w:rPr//w:sz').first\n size_tag ? size_tag.attributes['val'].value.to_i / 2 : nil\n end",
"def font_descender(size = nil)\n size = @font_size if size.nil? or size <= 0\n\n select_font(\"Helvetica\") if @fonts.empty?\n hi = @fonts[@current_font].fontbbox[1].to_f\n (size * hi / 1000.0)\n end",
"def set_font_size size\n @font = @font_cache[size]\n return if (@font)\n @font = Gosu::Font.new(\n size,\n name: @settings.get(:font_name)\n )\n @font_cache[size] = @font\n end",
"def font_size\n return nil unless @styles\n\n size_tag = @styles.xpath('//w:docDefaults//w:rPrDefault//w:rPr//w:sz').first\n size_tag ? size_tag.attributes['val'].value.to_i / 2 : nil\n end",
"def font_size\n styles['font-size'] ? styles['font-size'].to_f : DEFAULT_FONT_SIZE\n end",
"def title_font_size=(value)\n @title_font.size = value\n end",
"def set_text(font, size)\n\t \t@pdf.setfont(font, size)\n\t end",
"def font_size\n @font_size ||= [cell_height, cell_width].sort.shift * 0.8\n end",
"def change_font_size(font_size=10)\n validate_worksheet\n if font_size.is_a?(Integer) || font_size.is_a?(Float)\n # Get copy of font object with modified size\n font = deep_copy(workbook.fonts[font_id().to_s][:font])\n font[:sz][:attributes][:val] = font_size\n # Update font and xf array\n change_font(font)\n else\n raise 'Argument must be a number'\n end\n end",
"def coordinate_labels_font_size\n if self.options[:font_size].blank?\n 10\n else\n self.options[:font_size]\n end\n end",
"def add_size!\n input_html_options[:size] ||= nil\n end",
"def title_size=(v)\n @title.text_size = v unless v.to_s.empty?\n end",
"def change_font_size(font_size = 10)\n validate_worksheet\n raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)\n\n font = get_cell_font.dup\n font.set_size(font_size)\n update_font_references(font)\n end",
"def change_font_size(font_size = 10)\n validate_worksheet\n raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)\n\n font = get_cell_font.dup\n font.set_size(font_size)\n update_font_references(font)\n end",
"def scale_fontsize(value)\n value * @scale\n end",
"def size= (x)\n change_options({\"size\" => x})\n end",
"def font_size\n return sz if sz\n\n font = styles.fonts[styles.cellXfs[style].fontId] || styles.fonts[0]\n font.b || (defined?(@b) && @b) ? (font.sz * 1.5) : font.sz\n end",
"def font_size=(font_size)\n if !font_size.nil? && font_size < 0\n fail ArgumentError, 'invalid value for \"font_size\", must be greater than or equal to 0.'\n end\n\n @font_size = font_size\n end",
"def size\n \"btn-#{ @options[:size] }\" if @options[:size]\n end",
"def size\n prompt_size + text_size\n end",
"def render_text_size(text = @text)\n lines = render_text_lines(text)\n width = lines.map(&:length).max\n height = lines.length\n { width: width, height: height }\n end",
"def default_font_size\n (options[:default] and options[:default][:size]) ? options[:default][:size] : 40\n end",
"def size\n label.to_s.downcase.sub(/\\s+/,'_')\n end",
"def text_line_width(text, size = nil)\n if text.kind_of?(Numeric) and size.kind_of?(String)\n text, size = size, text\n warn PDF::Writer::Lang[:text_width_parameters_reversed] % caller[0]\n end\n\n if size.nil? or size <= 0\n size = @font_size\n end\n\n # This function should not change any of the settings, though it will\n # need to track any tag which change during calculation, so copy them\n # at the start and put them back at the end.\n t_CTS = @current_text_state.dup\n\n select_font(\"Helvetica\") if @fonts.empty?\n # converts a number or a float to a string so it can get the width\n tt = text.to_s\n # hmm, this is where it all starts to get tricky - use the font\n # information to calculate the width of each character, add them up\n # and convert to user units\n width = 0\n font = @current_font\n\n pos = -1\n loop do\n pos += 1\n break if pos == tt.size\n font_change = true\n tag_size, text, font_change = quick_text_tags(text, pos, font_change)\n if tag_size != 0\n if font_change\n current_font!\n font = @current_font\n end\n pos += tag_size - 1\n else\n if \"<\" == tt[pos, 4]\n width += char_width(font, '<')\n pos += 3\n elsif \">\" == tt[pos, 4]\n width += char_width(font, '>')\n pos += 3\n elsif \"&\" == tt[pos, 5]\n width += char_width(font, '&')\n pos += 4\n else\n width += char_width(font, tt[pos, 1])\n end\n end\n end\n\n @current_text_state = t_CTS.dup\n current_font!\n\n (width * size / 1000.0)\n end",
"def size=(size)\n check_is_a!(size, Integer)\n check_gt!(size, 0)\n @attributes[:Size] = size\n end",
"def tag_text text_view, tag_type\n s, e = text_view.buffer.selection_bounds\n text_view.buffer.apply_tag(tag_type.tag, s, e)\n end",
"def set_font(face, size)\n @curr_font = Gauges::FontRef.get(face, size)\n end",
"def size(size)\n @value[:size] = size\n self\n end",
"def size=(size)\n instance_set(:size, size)\n end",
"def edit_size\n\t\tif (self.type == SECT_TYPE::OUTPUT || self.type == SECT_TYPE::CODE || self.type == SECT_TYPE::NOTES)\n\t\t\treturn \"large\"\n\t\telse\n\t\t\treturn \"small\"\n\t\tend\n\tend",
"def set_Size(value)\n set_input(\"Size\", value)\n end",
"def text_width(font_handle, text)\n end",
"def font_size\n return sz if sz\n\n font = styles.fonts[styles.cellXfs[style].fontId] || styles.fonts[0]\n font.b || (defined?(@b) && @b) ? (font.sz * row.worksheet.workbook.bold_font_multiplier) : font.sz\n end",
"def size=(size)\n end",
"def size=(size)\n validator = EnumAttributeValidator.new('String', [\"8.75x3.75\"])\n unless validator.valid?(size)\n fail ArgumentError, \"invalid value for \\\"size\\\", must be one of #{validator.allowable_values}.\"\n end\n @size = size\n end",
"def size=(value)\n @size = value\n end",
"def size=(value)\n @size = value\n end",
"def size=(size)\n self.width = self.height = @size = size\n end",
"def calc_size\n return size unless translatable?\n translated_text.size + 8\n end",
"def size=(size)\n @size = size\n resize\n end",
"def legend_font_size=(value)\n @legend_font.size = value\n end",
"def process_text_options(options)\n if options[:style]\n raise 'Bad font family' unless font.family\n font(font.family, style: options[:style])\n end\n\n # must compare against false to keep kerning on as default\n unless options[:kerning] == false\n options[:kerning] = font.has_kerning_data?\n end\n\n options[:size] ||= font_size\n end",
"def adjusts_font_size_to_fit_width ; view.adjustsFontSizeToFitWidth ; end",
"def width\n @font.text_width(self.text)\n end",
"def set_size!(size) \n @transforms << SIZES[size]\n self \n end",
"def font_size()\n validate_worksheet\n return @workbook.fonts[font_id()][:font][:sz][:attributes][:val]\n end",
"def text_width(text, size = nil)\n if text.kind_of?(Numeric) and size.kind_of?(String)\n text, size = size, text\n warn PDF::Writer::Lang[:text_width_parameters_reversed] % caller[0]\n end\n\n if size.nil? or size <= 0\n size = @font_size\n end\n\n max = 0\n\n text.to_s.each do |line|\n width = text_line_width(line, size)\n max = width if width > max\n end\n max\n end",
"def measure_size( window )\n @text_size = window.font[:button].measure( @text )\n ave_width = @text_size.width / @text.size\n\n @size = Size.new( @text_size.width + 4 * ave_width, @text_size.height * 2 )\n end",
"def vm_size(size)\n if parent.properties.nil? or parent.properties.hardware_profile.nil?\n hardware_profile vm_size: size\n else\n parent.properties.hardware_profile.vm_size = size\n end\n end",
"def interpret_size(size); end",
"def vms_text_box(text, x, y, width, height, size = 10, style = :normal, align = :center, valign = :center, font_family = nil, font_color = nil)\n font_family = @standard_font if font_family.nil?\n font_color = @standard_color if font_color.nil?\n font(font_family,\n style: style)\n font_size(size)\n fill_color(font_color)\n text_box(text,\n at: [x.in, y.in],\n width: width.in,\n height: height.in,\n align: align,\n valign: valign,\n inline_format: true,\n overflow: :shrink_to_fit)\n end",
"def change_row_font_size(row=0, font_size=10)\n # Get style object\n xf_id = xf_id(get_row_style(row))\n # Get copy of font object with modified size\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font[:sz][:attributes][:val] = font_size\n # Update font and xf array\n change_row_font(row, Worksheet::SIZE, font_size, font, xf_id)\n end",
"def width\n #@font.text_width(self.text)\n return 200\n end",
"def update_selection_rect\n pos = @text.selection_start\n if pos == 0\n @selection_rect.x = 1\n else\n @selection_rect.x = @sprite.bitmap.text_size(value[0...pos]).width\n end\n delta = @cursor.x - @selection_rect.x\n @selection_rect.zoom_x = delta.abs\n @selection_rect.x += delta if delta < 0\n end",
"def font_height(size = nil)\n size = @font_size if size.nil? or size <= 0\n\n select_font(\"Helvetica\") if @fonts.empty?\n hh = @fonts[@current_font].fontbbox[3].to_f - @fonts[@current_font].fontbbox[1].to_f\n (size * hh / 1000.0)\n end",
"def tabsize=(value)\n\t\t\teditor.tabsize= value\n\t\tend",
"def setMarginBottom(size)\n @textBox.set_margin_bottom(size)\n self\n end",
"def fontsize(points=20)\n @fsize = points\n font unless @fname\n #CGContextSetFontSize(@ctx,points)\n CGContextSelectFont(@ctx, @fname, @fsize, KCGEncodingMacRoman)\n end",
"def string_width(string, font_size)\n font_scale = font_size / 10.0\n string.size * font_scale\n end",
"def default_size_multiplier(font)\n\n # Define font hash.\n factors = {\n across_the_road: 0.7,\n alabama: 0.8,\n arty_signature: 2.5,\n asem_kandis: 0.9,\n autograf: 0.5,\n born_ready: 0.5,\n brittany_signature: 0.5,\n bulgatti: 0.5,\n estelly: 0.5,\n friday_vibes: 0.8,\n from_skyler: 0.6,\n gallatone: 0.75,\n halimun: 0.4,\n hello_santtiny: 0.5,\n just_realize: 0.7,\n just_signature: 0.35,\n mayestica: 0.9,\n notera: 0.6,\n prestige_signature: 0.8,\n reinata: 1,\n santos_dumont: 1,\n shopping_list: 1,\n signatures: 0.75,\n signerica: 0.4,\n silver_pen: 0.8,\n sophistica: 0.75,\n southampton: 0.75,\n thankfully: 0.5,\n the_jacklyn: 0.8,\n tomatoes: 0.35,\n wanted_signature: 0.7,\n white_angelica: 0.4,\n xtreem: 0.7\n }\n\n # Return factor.\n return factors.fetch(font.parameterize.underscore.to_sym, 0.5)\n\n end",
"def paper_size=(size)\n RestrictionValidator.validate 'paper_size', (1..118), size\n @paper_size = size\n end",
"def custom_styles(emote)\n if (1..38).include? emote.id\n 'style=\"font-size: 40px;\"'\n end\n end",
"def pointsize(points)\n primitive 'font-size ' + sprintf('%g', points)\n end",
"def calculate_width(font_size, text)\n @d.pointsize = font_size\n @d.get_type_metrics(@base_image, text.to_s).width\n end",
"def width\n @font.text_width(self.text)\n end",
"def apply\n @textBox.set_markup(\"<span style='\"+@style.to_s+\"' weight='\"+@weight.to_s+\"' foreground='\"+@color.to_s+\"' font_desc='\"+@font.to_s+\" \"+@size.to_s+\"'>\"+@label+\"</span>\")\n end",
"def set_size\n self.size = attachment.size if attachment.size\n end",
"def font_setup\n %Q(font \"#{@font},#{@fontsize}\")\n end",
"def change_column_font_size(col=0, font_size=10)\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified size\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font[:sz][:attributes][:val] = font_size\n # Update font and xf array\n change_column_font(col, Worksheet::SIZE, font_size, font, xf_id)\n end",
"def size=(size)\n validator = EnumAttributeValidator.new('String', ['Full', 'Half', 'Quarter'])\n unless validator.valid?(size)\n fail ArgumentError, 'invalid value for \"size\", must be one of #{validator.allowable_values}.'\n end\n @size = size\n end",
"def settextfontprec(*)\n super\n end",
"def resize_geometry_string\n params[:upsample] == 'true' ? @size : \"#{@size}>\"\n end",
"def size\n @sizes ||= strip(:size)\n end",
"def shrink_to_fit(text)\n wrap(text)\n until @everything_printed || @font_size <= @min_font_size\n @font_size = [@font_size - 0.3, @min_font_size].max\n @document.font_size = @font_size\n wrap(text)\n end\n end",
"def size(new_size = nil)\n new_size.nil? ? @size : @size = new_size\n end",
"def as_css_size\n size = self\n size += 'px' unless size.blank? || size.end_with?('px', '%', 'em') || size == 'auto' || size == 'inherit'\n return size\n end",
"def size=(width, height)\n end",
"def size=(size)\n if !size.nil? && size.to_s.length > 20\n fail ArgumentError, 'invalid value for \"size\", the character length must be smaller than or equal to 20.'\n end\n\n @size = size\n end",
"def edit_picture_dialog_size(content)\n if content.settings[:caption_as_textarea]\n content.settings[:sizes] ? \"380x320\" : \"380x300\"\n else\n content.settings[:sizes] ? \"380x290\" : \"380x255\"\n end\n end",
"def size\n super\n end",
"def size\n super\n end",
"def string_width(string, font_size)\n font_scale = font_size / row.worksheet.workbook.font_scale_divisor\n (string.to_s.size + 3) * font_scale\n end",
"def initialize(text:, size:, color:)\n @text = text\n @size = size\n @color = color\n end",
"def size=(size='300x200')\n @width, @height = size.split(\"x\").map { |dimension| dimension.to_i }\n end",
"def select_size(integer)\n scroll_to_top\n wait_for_options_and_select(footer_select_size_input_locator, select_size_input_options, integer.to_s)\n rescue\n wait_for_options_and_select(header_select_size_input_locator, select_size_input_options, integer.to_s)\n end",
"def size(w,h)\n @size = \"#{w}x#{h}\"\n end",
"def small\n filter << 'Size:Small'\n self\n end",
"def stringwidth(text, fontsize)\n @p.stringwidth(text, self, fontsize)\n end",
"def set_default_size_unit\n self.size_unit = \"m\" if self.size_unit.blank?\n end",
"def height\n @font.height\n end",
"def setSize _obj, _args\n \"_obj setSize _args;\" \n end",
"def visual_size(value)\n @ole.VisualSize = value\n nil\n end"
] |
[
"0.666083",
"0.6603351",
"0.6588039",
"0.6588039",
"0.6522651",
"0.6405367",
"0.62887317",
"0.60858434",
"0.60653156",
"0.6023379",
"0.5989415",
"0.5957307",
"0.59424853",
"0.5937337",
"0.5932861",
"0.59297097",
"0.5892705",
"0.5876129",
"0.5867842",
"0.58360225",
"0.5835716",
"0.5835716",
"0.5807395",
"0.5774674",
"0.5673341",
"0.5663947",
"0.56479937",
"0.56414646",
"0.5637516",
"0.56331116",
"0.5627518",
"0.56265676",
"0.5625661",
"0.5605422",
"0.5561522",
"0.5537957",
"0.5535562",
"0.55351233",
"0.5511744",
"0.54843354",
"0.54579514",
"0.5447703",
"0.5438431",
"0.5417443",
"0.5417443",
"0.5409881",
"0.5409112",
"0.5407792",
"0.54072803",
"0.53814095",
"0.53773",
"0.5369042",
"0.5354343",
"0.5335592",
"0.53073305",
"0.5284002",
"0.52715266",
"0.5253513",
"0.5248237",
"0.52203566",
"0.52156794",
"0.5209483",
"0.5202177",
"0.51885134",
"0.518767",
"0.5162223",
"0.5154414",
"0.5129181",
"0.5101845",
"0.5100872",
"0.50927895",
"0.5082485",
"0.50740767",
"0.506346",
"0.5059777",
"0.50560474",
"0.5046766",
"0.5037968",
"0.5034215",
"0.502155",
"0.5006077",
"0.500303",
"0.5001941",
"0.5000621",
"0.49847707",
"0.49834016",
"0.4980905",
"0.49804342",
"0.49804342",
"0.49781975",
"0.4960078",
"0.49596775",
"0.49512005",
"0.49393642",
"0.49335468",
"0.4929849",
"0.49292588",
"0.49241906",
"0.4923464",
"0.4913243"
] |
0.5288347
|
55
|
Remove all of the tags from the selected text.
|
def clear_clicked(txtvu)
s, e = txtvu.buffer.selection_bounds
txtvu.buffer.remove_all_tags(s, e)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy_tag(*tags)\n tags.each do |tag|\n gsub! Regexp.new(\"<\\s*#{tag}[^>]*>.*?<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n end\n end",
"def delete_all_tags\n delete_tags(self.tags)\n nil\n end",
"def remove\n from = Suspender.new(doc_with_tokens, tokens_to_remove).suspend\n from.filtered_text\n end",
"def sanitize_text(text)\n doc = Nokogiri::HTML.fragment(text)\n UNSUPPORTED_HTML_TAGS.each do |tag|\n doc.search(tag).each(&:remove)\n end\n doc.inner_html\n end",
"def strip_html_tags(text)\n return text.gsub!(/(<[^>]*>)|\\n|\\t/s) {\" \"}\n end",
"def strip_tags_delicately\n self.gsub(/<.[^<]*>/, ' ')\n end",
"def text\n html.gsub(REGEX_TAGS, \"\")\n end",
"def remove\n left\n @text.slice!(@cursor, 1)\n end",
"def remove_html_tag(tag_name); end",
"def untag(txt)\n Sanitize.clean(txt).strip.gsub(/\\s+/, \" \")\n end",
"def clean text\n text.gsub(/(\\n|\\t|\\r)/, ' ').gsub(/>\\s*</, '><').squeeze(' ')\n end",
"def remove_paragraph_tags mytext\n mytext.sub!(/^<p>\\s*<\\/p>/,\"\")\n mytext.sub!(/(<br>)*<p>\\s*<\\/p>$/,\"\")\n mytext.sub!(/^<p>/,'')\n mytext.sub!(/<\\/p>?/,'')\n return mytext\n end",
"def clean_up_text\n text.gsub!(/<br/, \"\\n<br\")\n text.gsub!(/<p/, \"\\n<p\")\n text.gsub!(/<\\/?span(.*?)?>/, '')\n text.gsub!(/<\\/?div(.*?)?>/, '')\n end",
"def delete_tags(name); end",
"def delete_tags\n @tags.delete_tags(@filename) unless @tags.nil?\n end",
"def reset\n @tags.clear\n end",
"def handle_tag_as_text\n self[:is_tag] = false\n self[:closing_tag] = false\n self[:text] = self[:complete_match]\n end",
"def removeTag(text,tag)\n return 0 unless text\n text=text.to_s\n text=text.gsub(\"<\"+tag+\">\", \"\")\n text=text.gsub(\"</\"+tag+\">\", \"\")\n \n return text.to_s\nend",
"def remove_all_selections locator\r\n command 'removeAllSelections', locator\r\n end",
"def removeTags(document,tagList)\n tagList.each do |tag|\n document.search(tag).remove\n end \n end",
"def clear_selection()\n @last_pos = nil\n @selection = nil\n end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def strip_tags(html); end",
"def delete\n @text.slice!(@cursor, 1)\n end",
"def strip_tags(html)\n return html if html.blank?\n if html.index(\"<\")\n text = \"\"\n tokenizer = ::HTML::Tokenizer.new(html)\n while token = tokenizer.next\n node = ::HTML::Node.parse(nil, 0, 0, token, false)\n # result is only the content of any Text nodes\n text << node.to_s if node.class == ::HTML::Text\n end\n # strip any comments, and if they have a newline at the end (ie. line with\n # only a comment) strip that too\n text.gsub(/<!--(.*?)-->[\\n]?/m, \"\")\n else\n html # already plain text\n end\n end",
"def clear_all_tags()\n puts \"Deleting Tags...\"\n Tag.delete_all()\n puts \"Finished deleting all tags.\"\nend",
"def tags_to_remove\n return @tags_to_remove\n end",
"def tags_to_remove=(value)\n @tags_to_remove = value\n end",
"def keep_only_tags(passage, tags = %w(NNP NN VB))\n raise \"invalid tag/s supplied\" unless (tags.map(&:downcase) - EngTagger::TAGS.keys).empty?\n @tagger.get_hashed(passage).delete_if{|tag,tokens| !tags.include?(tag)}.values.join(' ')\n end",
"def untag(*tags)\n tags.each do |tag|\n run_context.node.tags.delete(tag)\n end\n end",
"def untag(*tags)\n tags.each do |tag|\n run_context.node.tags.delete(tag)\n end\n end",
"def tags_text\n\t\tself.tags.join(', ') #convertir el arreglo en una cadena de texto separado por ,\n\tend",
"def tags_to_remove\n linked_tags - current_tags\n end",
"def strip_tags(html)\n strip(Sanitize.clean(html, :elements => [], :attributes => []))\n end",
"def strip_html_tags!\n @raw.gsub!(/<[^>]+?>/, ' ')\n end",
"def html_remove\n gsub(/<\\/?[^>]+>/, '')\n end",
"def remove_paragraphs_from_list_items!\n @document.tree.search('li p').each { |node| node.node_name = 'span' }\n end",
"def remove_text_within_quotes(review)\n # the read text is tagged with two sets of quotes!\n review.gsub!(/\"([^\"]*)\"/, \"\")\n review\n end",
"def cleanup_image_tags\n self.tags = self.tags.strip\n unless self.tags.empty?\n tags = self.tags.split(\",\")\n tags_new = []\n tags.each do |item|\n tags_new.push(item.strip)\n end\n self.tags = tags_new.join(\",\")\n end\n end",
"def clean_text(text)\n text = strip_html_quote_entities(text)\n text = Helper::Text.strip_html_tags(text)\n text = strip_copyright_text(text)\n text.strip!\n text = Helper::Text.clean_verse_start(text)\n text = Helper::Text.clean_verse_end(text)\n end",
"def cleaned_tags\n @product.tags.split(',').reject{ |c| c.empty? or c == \" \" }.uniq.join(',')\n end",
"def delete_tags(post_num_input, tags_input)\n tags_to_delete = tags_input.split(\" \")\n tags_to_delete.each do |y|\n BLOG[post_num_input].tags.delete_if {|x| x == y}\n end\n puts ''\n puts 'Your tags have been deleted'\n puts BLOG[post_num_input].tags\n puts ''\n end",
"def selected_tags=(data)\n self.tags.clear\n data.split('tag').each { |id| self.tags << Tag.find(id) if id.length > 0 }\n end",
"def strip_tags(html)\n html.gsub(/<\\/?[^>]*>/, \"\") if html\n end",
"def rm_tag(tag, *values)\n tag.upcase!\n @selected_files.each { |file| file.rm_values(tag, *values) }\n self\n end",
"def clean_all_tags\n self.tags.destroy_all\n self.countries.destroy_all\n self.requirements.destroy_all\n self.places.destroy_all\n end",
"def parse_unpaired_tags(wiki_text)\n wiki_text.gsub!(%r{<[a-zA-Z]*/>}im, \"\")\n wiki_text\n end",
"def unselect; end",
"def clean_up_tags\n self.tags.each do |tag|\n if tag.todos.count == 1\n tag.destroy\n end\n end\n end",
"def unhighlight\n perform_action(:delete, 'highlight')\n end",
"def remove_text(widget)\n # File chooser dialog\n chooser = create_chooser @filter, Gtk::Stock::REMOVE, \"Select the text to remove\"\n\n # Check the user input\n chooser.run do |r|\n if r == Gtk::Dialog::RESPONSE_ACCEPT\n if @project.delete_text chooser.filename\n @treeView.create_tree @project\n end\n end\n chooser.destroy\n end\n end",
"def remove_selection\n buffer_current.remove_selection\n update_status_line\n end",
"def remove_alt_text(value)\n @children['alt-text'][:value].delete(value)\n end",
"def undo\n if done\n @text = text.sub(DONE_REGEX, '').strip\n @done = false\n end\n end",
"def replace_selected_content(html, config)\n if config['tag_selector']\n doc = Nokogiri::HTML(html, nil, ENCODING_HTML_DOCUMENT)\n elements = doc.css(config['tag_selector'])\n elements.each do |node|\n pipeline = filter_pipeline.call(node.inner_html)\n node.inner_html = pipeline[:output].to_s\n end\n doc.to_html\n else\n pipeline = filter_pipeline.call(html)\n pipeline[:output].to_s\n end\n end",
"def selected_tags\n if @params[:tag] && @params[:tag].strip.length > 0\n @selected_tags ||= @params[:tag].downcase.split(',').collect{ |t| t.strip }\n end\n\n return @selected_tags\n end",
"def selected_tags\n if @params[:tag] && @params[:tag].strip.length > 0\n @selected_tags ||= @params[:tag].downcase.split(',').collect{ |t| t.strip }\n end\n\n return @selected_tags\n end",
"def selection_clear\n execute_only(:selection, :clear)\n end",
"def close_tags(text)\n open_tags = []\n text.scan(/\\<([^\\>\\s\\/]+)[^\\>\\/]*?\\>/).each { |t| open_tags.unshift(t) }\n text.scan(/\\<\\/([^\\>\\s\\/]+)[^\\>]*?\\>/).each { |t| open_tags.slice!(open_tags.index(t)) }\n open_tags.each {|t| text += \"</#{t}>\" }\n text\n end",
"def strip_html(text)\n unless text.nil?\n strip_tags(text)\n end\n end",
"def destroy\n tag_ids.clone.each { |tag_id| destroy_tag(tag_id) }\n super\n end",
"def tags_to_remove\n aws_tags.reject { |t, v| local_tags.include?(t) and local_tags[t] == v }\n end",
"def cleanText(txt)\r\n clean = txt.gsub(\"<\", \"<\")\r\n clean.gsub!(\">\", \">\")\r\n\r\n puts \"cleaned text: #{txt} -> #{clean}\" if $DEBUG\r\n clean\r\n\r\n end",
"def remove_tags_container(t, c)\n l, r = container_array(c)\n t.gsub!(l, '')\n t.gsub!(r, '')\n t\n end",
"def strip_html\n gsub(HTML_TAG_PATTERN, \"\")\n end",
"def unkeyword!(keyword_ids:)\n taggings.where(tag_id: keyword_ids).each(&:destroy)\n end",
"def remove_assignment_text\n frm.frame(:id, \"Assignment.view_submission_text___Frame\").div(:title=>\"Select All\").fire_event(\"onclick\")\n frm.frame(:id, \"Assignment.view_submission_text___Frame\").td(:id, \"xEditingArea\").frame(:index=>0).send_keys :backspace\n end",
"def remove_assignment_text\n frm.frame(:id, \"Assignment.view_submission_text___Frame\").div(:title=>\"Select All\").fire_event(\"onclick\")\n frm.frame(:id, \"Assignment.view_submission_text___Frame\").td(:id, \"xEditingArea\").frame(:index=>0).send_keys :backspace\n end",
"def delete_tags(filename=@filename)\n Mutagen::AIFF::delete_chunk filename\n clear\n end",
"def strip_tag(*tags, &block)\n tags.each do |tag|\n gsub! Regexp.new(\"<\\s*#{tag}(?:\\s+[^>]*)*>(.*?)<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE) do\n if block\n \"#{$1}#{yield}\"\n else\n $1\n end\n end\n # check we don't have any malformed or nested instances left\n gsub! Regexp.new(\"<\\s*#{tag}(?:\\s+[^>]*)*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n gsub! Regexp.new(\"<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n end\n end",
"def clear\n @hash_tags.clear\n end",
"def quick_text_tags(text, ii, font_change)\n ret = text_tags(text, ii, font_change)\n [ret[0], ret[1], ret[2]]\n end",
"def filter_all(text)\n state = :copying\n result = []\n tagged_lines = []\n tag = args = nil\n text.split(/\\n/).each do |line|\n case state\n when :copying\n if line =~ inline_tag\n tag = $1\n args = $2.strip\n state = :inside_tag\n elsif line =~ single_tag\n tag = $1\n args = $2.strip\n result << @filters[tag.to_sym].filter_single(args)\n else\n result << line\n end\n when :inside_tag\n # :endinlinewhatever, :endwhatever or just plain :end\n if line =~ /^:end(inline#{tag}|#{tag})?(\\s.*)?$/\n result << @filters[tag.to_sym].filter_inline(tagged_lines.join(\"\\n\"),args)\n tagged_lines = []\n state = :copying\n else\n tagged_lines << line\n end\n end\n end\n\n result.join(\"\\n\")\n end",
"def purge_custom_tags(options)\n options.reject{ |key,value| [:label, :html, :field, :field_type, :separator].include?(key.to_sym) }\n end",
"def delete_enders(text_arr)\n\t\tEnder.each {|ending| text_arr.delete(ending)}\n\t\treturn text_arr\n\tend",
"def rm_script_tags(text)\n puts text.length\n text.gsub!(/<script.*>.*<\\/script>/, \"\")\n puts text.length\n text.gsub!(/<script.*\\/>/, \"\")\n puts text.length\n text.gsub!(/<object.*>.*<\\/object>/, \"\")\n puts text.length\n text.gsub!(/<embed.*>.*<\\/embed>/, \"\")\n puts text.length\n return text\n end",
"def strip_tags\n %w(name description allowed_values).each do |a|\n next if send(a).blank?\n self.send \"#{a}=\", send(a).gsub(/\\<.*?\\>/, '')\n end\n true\n end",
"def strip_tags\n %w(name description allowed_values).each do |a|\n next if send(a).blank?\n self.send \"#{a}=\", send(a).gsub(/\\<.*?\\>/, '')\n end\n true\n end",
"def strip_tags\n %w(name description allowed_values).each do |a|\n next if send(a).blank?\n self.send \"#{a}=\", send(a).gsub(/\\<.*?\\>/, '')\n end\n true\n end",
"def hide_custom_tags!\n hide_custom_tags.each do |full_pattern, value|\n paragraphs = document.css('w|p')\n while paragraph = paragraphs.shift do\n next unless paragraph.text =~ full_pattern\n run_nodes = paragraph.css('w|r')\n while run_node = run_nodes.shift\n next unless run_node.at_css('w|t')\n next unless run_node.text =~ full_pattern\n tag_contents = split_tag_content(run_node.text, full_pattern)\n replacement_nodes = []\n tag_contents[:content_list].each_with_index do |content, idx|\n remainder_run_node = run_node.clone\n replace_content(remainder_run_node, content)\n matched_tag = tag_contents[:matched_tags][idx]\n replacement_nodes << remainder_run_node\n if matched_tag\n run_node_with_match = run_node.clone\n replace_style(run_node_with_match)\n matched_content = matched_tag\n if value\n matched_content = value.is_a?(Proc) ?\n value.call(matched_tag) :\n value.to_s\n end\n replace_content(run_node_with_match, matched_content)\n replacement_nodes << run_node_with_match\n end\n end\n run_node.add_next_sibling(Nokogiri::XML::NodeSet.new(document, replacement_nodes))\n run_node.unlink\n end\n end\n end\n end",
"def untag(tag_class); end",
"def clean_article_body\n get_source_selectors.each do |selector|\n if @page.search(selector).present?\n @page = page.search(selector)\n break\n end\n end\n # Strip unwanted spaces and newlines.\n @page.collect {|elt| elt.content.strip.gsub(/\\n|\\r/, '').gsub(/\\ +/, ' ')}.join(' ')\n end",
"def remove_paragraphs_from_tables!\n @document.tree.search('td p').each { |node| node.node_name = 'span' }\n end",
"def remove_text_label\n\t\t$tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.p.className(create_ats_regex_string(\"ats-removetxtlbl\")), format_method(__method__))\n\tend",
"def remove_assignment_text\n frm.frame(:id, \"grade_submission_feedback_text___Frame\").div(:title=>\"Select All\").fire_event(\"onclick\")\n frm.frame(:id, \"grade_submission_feedback_text___Frame\").td(:id, \"xEditingArea\").frame(:index=>0).send_keys :backspace\n end",
"def remove_assignment_text\n frm.frame(:id, \"grade_submission_feedback_text___Frame\").div(:title=>\"Select All\").fire_event(\"onclick\")\n frm.frame(:id, \"grade_submission_feedback_text___Frame\").td(:id, \"xEditingArea\").frame(:index=>0).send_keys :backspace\n end",
"def text_only(html)\n Nokogiri::HTML.parse(html).text.gsub(/\\A\\p{Space}+|\\p{Space}+\\z/, '')\n .strip\n end",
"def remove_selected\n case @selected\n when Stroke\n remove_stroke(@selected)\n when ToyInScene\n remove_toy(@selected)\n end\n end",
"def rm_single_tags(str)\n str.gsub(/<[^<>]*\\/>/, \"\")\n end",
"def purge_unused_tags!\n unused_tags.each do |tag|\n logger.info(\"Purging tag '#{tag}'\")\n entries_with(label: tag).each do |entry|\n payload = Protocol::Device::SetTagLabels.new(tags: id_to_tags_field(entry.tag_id), label: '')\n context.send_message(target: Target.new(site_id: entry.site_id),\n payload: payload,\n acknowledge: true)\n end\n end\n Timeout.timeout(5) do\n while !unused_tags.empty?\n sleep 0.1\n end\n end\n end",
"def destroy_taggings\n Tagging.where(:tag_id => self.id).each do |tagging|\n tagging.not_orphans = true\n tagging.destroy\n end\n end",
"def delete_unused_tags\n ActiveRecord::Base.connection.execute(\n \"delete from tags where id in(\n select t.id from tags as t left join posts_tags as pt on pt.tag_id = t.id where pt.tag_id is null\n )\"\n )\n end",
"def html_text( text_node )\n self.remove_leading_and_trailing_whitespace( text_node )\n end",
"def filter_tags(document)\n # Filter down and get the tags.\n @tags = document.css(TAG_CSS).map(&:children).map(&:text)\n end",
"def tag_text text_view, tag_type\n s, e = text_view.buffer.selection_bounds\n text_view.buffer.apply_tag(tag_type.tag, s, e)\n end",
"def delete_tag(model, text)\n model_tag = model.model_tags.find_by(name: text, user_ids: self.id)\n if model_tag\n model_tag.user_ids.delete(self.id)\n model_tag.inc(:taggings_count, -1)\n\n model_tag.save\n model.reload\n end\n model.model_tags.destroy_all(taggings_count: 0)\n\n tag = Tag.find_by(name: text)\n if tag.taggings.destroy_all(tagger: self, taggable: model)\n tag.inc(:taggings_count, -1)\n end\n\n Tag.destroy_all(taggings_count: 0)\n end",
"def remove(n = 1)\n left(n)\n @text.slice!(@cursor, n)\n end",
"def tags!\n @tags = nil\n tags\n end",
"def deactivate(*tags)\n tags.each { |t| TagList.delete(t) }\n end"
] |
[
"0.643675",
"0.6429013",
"0.63510513",
"0.6189877",
"0.60902566",
"0.6028987",
"0.6027333",
"0.60212183",
"0.6015184",
"0.60080105",
"0.5966635",
"0.59562767",
"0.5924286",
"0.5919715",
"0.5914191",
"0.5892503",
"0.58860105",
"0.5863277",
"0.5861183",
"0.58451355",
"0.5801099",
"0.5786783",
"0.5786783",
"0.5786783",
"0.5772459",
"0.5732015",
"0.5719946",
"0.57157284",
"0.5689118",
"0.5675986",
"0.5672393",
"0.5672393",
"0.5626586",
"0.5610831",
"0.56103677",
"0.56081915",
"0.55985016",
"0.55957645",
"0.55930835",
"0.55626",
"0.55613446",
"0.5561131",
"0.5550734",
"0.55498374",
"0.55491126",
"0.5548631",
"0.554184",
"0.5530568",
"0.5528033",
"0.552585",
"0.55128103",
"0.55064416",
"0.55058783",
"0.55052996",
"0.5501249",
"0.54875773",
"0.54857963",
"0.54857963",
"0.547261",
"0.54691476",
"0.54661155",
"0.5443977",
"0.54399616",
"0.54377246",
"0.54345596",
"0.5432623",
"0.5422741",
"0.5419003",
"0.5419003",
"0.5417778",
"0.54011226",
"0.5384192",
"0.5363912",
"0.53226334",
"0.5321898",
"0.53166425",
"0.5312234",
"0.5306171",
"0.5306171",
"0.5306171",
"0.52997553",
"0.52936834",
"0.5287771",
"0.5284447",
"0.5283883",
"0.5278218",
"0.5278218",
"0.5275685",
"0.52649677",
"0.5263548",
"0.5263523",
"0.52461225",
"0.52447325",
"0.5242314",
"0.5240879",
"0.52298695",
"0.5226288",
"0.521999",
"0.52196556",
"0.52143615"
] |
0.6968981
|
0
|
GET /units/1 GET /units/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def foods_units\n get('/foods/units.json')\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units = @units.uniq\n respond_to do |format|\n format.json { render json: @units }\n end\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def show\n query = {\n 'id' => unit_params[:id]\n }\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units/?id\", :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n @unit = JSON.parse(response.body)\n else\n redirect_to unit_path(params[:id]), notice: 'Hmm...thats strange...try that again.'\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @item_unit = ItemUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def unit_of_measurement_find_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_find ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\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', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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<UnitOfMeasurement>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_find\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def unit(unit_id=nil, opts = {})\n units = connection.get(connection.build_url(\"units\", opts.merge(:unitids => unit_id))).body\n units.map!{|hash| hash.values.first}\n units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}\n units.first\n end",
"def unit_of_measurement_find_one_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_find_one ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement/findOne\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\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', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'UnitOfMeasurement')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_find_one\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @extent_unit = ExtentUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @extent_unit }\n end\n end",
"def index\n @units = if params[:order] == 'updated'\n Unit.order('updated_at ' + params[:updated_direction])\n elsif params[:order] == 'created'\n Unit.order('created_at ' + params[:created_direction])\n elsif params[:order] == 'note_updated'\n Unit.order('note_updated_at ' + params[:note_updated_direction])\n elsif params[:order] == 'first_name'\n Unit.joins(:resident).order('residents.first_name ' + params[:first_name_direction])\n elsif params[:order] == 'last_name'\n Unit.joins(:resident).order('residents.last_name ' + params[:last_name_direction])\n elsif params[:order] == 'name'\n Unit.order('name ' + params[:name_direction])\n elsif params[:order] == 'address'\n Kaminari.paginate_array(Address.joins(:street, :units).order(\"streets.name #{params[:address_direction]}\").order(\"addresses.street_number #{params[:address_direction]}\").map(&:units).flatten)\n else\n Unit.order('created_at desc')\n end.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @units }\n end\n end",
"def show\n @unit_type = UnitType.find(params[:id])\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def transfer_unit\n if !params[:ic_number].nil?\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def show\n @retail_unit = RetailUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retail_unit }\n end\n end",
"def show\n @electoral_unit = ElectoralUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @electoral_unit }\n end\n end",
"def units\n @formulation = (params[:formulation] || '').upcase\n drug = Drug.find_by_name(@formulation) rescue nil\n render plain: \"per dose\" and return unless drug && !drug.units.blank?\n render plain: drug.units\n end",
"def find_single(scope) \n JSON[RestClient.get \"#{@site}/unit/#{scope}\", :accept=>'json'][0]\n end",
"def index\n @unit_type = UnitType.all\n\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def unit\n return @units[@index]\n end",
"def unit\n return @units[@index]\n end",
"def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end",
"def show\n @log_unit = LogUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @log_unit }\n end\n end",
"def index\n authorize Unit\n @units_version = Unit.version\n @units = Unit.all\n render\n end",
"def getuom\n @deliverable_type = DeliverableType.find(params[:id])\n respond_to do |format|\n format.json { render :json => @deliverable_type.uom}\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit}\n end\n end",
"def index\n @base_units = BaseUnit.all\n end",
"def units\n self.ListUnits.first.map { |u| map_unit(u) }\n end",
"def single_usage\r\n meter = get_meters[3]\r\n date_ranges = get_date_ranges\r\n dtps = Meter.get_daily_time_periods [meter]\r\n\r\n# usage = meter.usage_by_meter(date_ranges, dtps)\r\n# usage = meter.usage_by_time(date_ranges, dtps)\r\n usage = meter.detailed_usage_by_meter(date_ranges, dtps)\r\n# usage = meter.detailed_usage_by_time(date_ranges, dtps)\r\n\r\n render :json => usage\r\n\r\n# redirect_to action: 'index'\r\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unit }\n end\n end",
"def units(units=nil)\n cur_page.units(units)\n end",
"def index\n @standard_units = StandardUnit.all\n end",
"def units\n attribute('yweather:units')\n end",
"def index\n @units = @gang.units.order( :id )\n @can_add_units = can_add_units\n end",
"def index\n @study_units = StudyUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_units }\n end\n end",
"def get_units\n @agency, @depts = params[:agency], params[:dept]\n render :layout => false\n end",
"def get_adapter_unit_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AdapterApi.get_adapter_unit_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling AdapterApi.get_adapter_unit_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/adapter/Units/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'AdapterUnit'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"AdapterApi.get_adapter_unit_by_moid\",\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: AdapterApi#get_adapter_unit_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def select_unit_by_id(unit_id)\n @units[unit_id]\n end",
"def select_unit_by_id(unit_id)\n @units[unit_id]\n end",
"def show\n @title = \"Prima Lingua: #{@section.name}\"\n if params[:unit_id]\n @overview_unit = Unit.find(params[:unit_id])\n else\n @overview_unit = @section.lesson.unit\n end\n respond_to do |format|\n format.html { render_flex_layout }\n format.json { render :json => @section }\n end\n end",
"def get_usage_rum_units_with_http_info(start_hr, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_rum_units ...'\n end\n # verify the required parameter 'start_hr' is set\n if @api_client.config.client_side_validation && start_hr.nil?\n fail ArgumentError, \"Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_rum_units\"\n end\n # resource path\n local_var_path = '/api/v1/usage/rum'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'start_hr'] = start_hr\n query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;datetime-format=rfc3339'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'UsageRumUnitsResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :get_usage_rum_units,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type,\n :api_version => \"V1\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsageMeteringAPI#get_usage_rum_units\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def all_units\n services.map{|el| el[:units]} \n end",
"def show\n @study_unit = StudyUnit.find(params[:id])\n @logical_products = @study_unit.logical_products\n @data_collections = @study_unit.data_collections\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study_unit }\n end\n end",
"def show\n @resource = Resource.find(params[:resource_id])\n @incident = Incident.find(@resource.incident_id)\n @demob = Demob.find(params[:id])\n @logistics_units = @demob.units[0..5]\n @finance_units = @demob.units[6..8]\n @other_units = @demob.units[9..10]\n @plans_units = @demob.units[11..13]\n end",
"def show\n @unit = Unit.find(params[:id])\n @logs = @unit.logs.limit(15).order(:created_at)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @item_unit = ItemUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_units }\n end\n end",
"def index\n @german_units = GermanUnit.all\n end",
"def index\n @units = Unit.search.\n institution(current_institution).\n include_children(false).\n order(\"#{Unit::IndexFields::TITLE}.sort\").\n limit(9999)\n end",
"def index\n @police_units = PoliceUnit.all\n end",
"def index\n @display_units = DisplayUnit.all\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :ok }\n end\n end",
"def for_unit(unit); find(:all, :conditions => {:unit_id => (unit.nil? ? nil : unit.class == Fixnum ? unit : unit.id)}); end",
"def set_unit\n @unit = Unit.friendly.find(params[:id])\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def show\n @quantity_unit = QuantityUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quantity_unit }\n end\n end",
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def units=(value)\n @units = value\n end",
"def unit_of_measurement_count_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_count ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement/count\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'where'] = opts[:'where'] if !opts[:'where'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\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', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_count\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_metrica }\n end\n end",
"def index\n @handbook_structual_units = HandbookStructualUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @handbook_structual_units }\n end\n end",
"def index\n @breadcrumbs = [[t(:units)]]\n @units = @units.order(:name).page(params[:page])\n end",
"def show\n @handbook_structual_unit = HandbookStructualUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @handbook_structual_unit }\n end\n end",
"def new\n @unit_of_measure = UnitOfMeasure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def unit_params\n params.fetch(:unit, {})\n end",
"def base_unit\n units[0]\n end",
"def show\n @ad_unit = AdUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_unit }\n end\n end",
"def index\n # @units = Unit.all\n\n # dla formularza new\n @unit = current_user.units.build if signed_in?\n\n # dla tabeli index\n @units = Unit.find(:all, :conditions => [\"\\\"isDefault\\\" = ? or user_id = ?\", true, current_user.id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @units }\n end\n end",
"def index\n @army_units = ArmyUnit.all\n end",
"def show\n @metric = Metric.find(params[:id])\n\n render json: @metric\n end",
"def index\n @order_units = OrderUnit.all\n end",
"def show\n @usage = Usage.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usage }\n end\n end",
"def index\n @unit_measures = UnitMeasure.all\n end",
"def get_measurements\n render json: @data_source.measurements\n end",
"def index\n @unit_names = UnitName.all\n end",
"def units\n @units = SQF.units @this\n @units\n end",
"def show\n @unit_subtitle = UnitSubtitle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit_subtitle }\n end\n end",
"def index\n @org_units = OrgUnit.all\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def destroy\n if @unit.blank?\n render json: {error: \"Can't delete unit\"}, status: :unprocessable_entity\n else\n @unit.destroy\n render json: {notice: \"Deleted!\"}, :status => 204\n end\n\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end"
] |
[
"0.8020499",
"0.73782337",
"0.72968423",
"0.72761893",
"0.72446454",
"0.72446454",
"0.72446454",
"0.71800053",
"0.6931266",
"0.68731314",
"0.68319625",
"0.6751599",
"0.6751599",
"0.6751599",
"0.6751599",
"0.6751599",
"0.6751599",
"0.6694411",
"0.66735995",
"0.6655276",
"0.6631972",
"0.6622368",
"0.6561722",
"0.65173095",
"0.6498106",
"0.6450326",
"0.64292175",
"0.6412073",
"0.6371833",
"0.6353606",
"0.6353606",
"0.6346351",
"0.63216555",
"0.63014585",
"0.6297679",
"0.6287047",
"0.6287047",
"0.6287047",
"0.6265825",
"0.62475264",
"0.6224728",
"0.62189597",
"0.62031543",
"0.6170657",
"0.6145822",
"0.6129828",
"0.6117006",
"0.61132663",
"0.6102338",
"0.6070175",
"0.6054319",
"0.6054319",
"0.60409874",
"0.60264224",
"0.60248965",
"0.6008929",
"0.6008609",
"0.60035914",
"0.60008097",
"0.59960127",
"0.59865487",
"0.5973617",
"0.59687483",
"0.5955227",
"0.5949739",
"0.59495085",
"0.5948842",
"0.59429127",
"0.59429127",
"0.59429127",
"0.59429127",
"0.594093",
"0.5932105",
"0.59294766",
"0.59270376",
"0.59268725",
"0.59226334",
"0.59171367",
"0.5910503",
"0.59042114",
"0.5879901",
"0.587593",
"0.5875349",
"0.58624166",
"0.5853953",
"0.5852386",
"0.5851748",
"0.5849704",
"0.5846144",
"0.5834694",
"0.58307576",
"0.58301306",
"0.5828447",
"0.581727",
"0.58129096",
"0.58042246",
"0.58008003",
"0.58008003",
"0.58008003",
"0.58008003",
"0.58008003"
] |
0.0
|
-1
|
POST /units POST /units.json
|
def create
@unit = Unit.new(unit_params)
@unit.Creator=session[:name]
@unit.CreateDate=Time.now.strftime("%Y-%m-%d %H:%M:%S")
respond_to do |format|
if @unit.save
format.html { redirect_to @unit, notice: '创建成功!.' }
format.json { render :show, status: :created, location: @unit }
else
format.html { render :new }
format.json { render json: @unit.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @unit = Unit.new(params[:unit])\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit = Unit.new(params[:unit])\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def foods_units\n get('/foods/units.json')\n end",
"def unit_params\n params.require(:unit).permit(:date, :value)\n end",
"def unit_params\n params.require(:unit).permit(:name)\n end",
"def create\n @item = Item.find(params[:item_id])\n @unit = @item.units.create(params[:unit])\n \n redirect_to item_path(@item)\n end",
"def create\n post_params = {\n name: params[:name].downcase,\n units: params[:units] || 0\n }\n render json: Ingredient.create!(post_params), status: :created\n end",
"def unit_params\n params.require(:unit).permit(:name, :weight, :package_dimensions)\n end",
"def unit_params\n params.require(:unit).permit(:user_id, :building_id, :floor_number, :side, :unit_number, :area, :resident_count)\n end",
"def create\n authorize Unit\n @unit = Unit.new(unit_params)\n\n if @unit.save\n render status: :created\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def unit_params\n params.require(:unit).permit(:short_label, :long_label, :universe)\n end",
"def create\n @item_unit = ItemUnit.new(params[:item_unit])\n\n respond_to do |format|\n if @item_unit.save\n format.html { redirect_to @item_unit, notice: 'Item unit was successfully created.' }\n format.json { render json: @item_unit, status: :created, location: @item_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @extent_unit = ExtentUnit.new(params[:extent_unit])\n\n respond_to do |format|\n if @extent_unit.save\n format.html { redirect_to @extent_unit, notice: 'Extent unit was successfully created.' }\n format.json { render json: @extent_unit, status: :created, location: @extent_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @extent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:libe, :amount, :points, :weapon)\n end",
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units = @units.uniq\n respond_to do |format|\n format.json { render json: @units }\n end\n end",
"def create\n # @unit = Unit.new(params[:unit])\n @unit = current_user.units.build(params[:unit])\n\n respond_to do |format|\n if @unit.save\n # format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.html { redirect_to units_path, notice: 'Pomyślnie utworzono jednostkę.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n # format.html { render action: \"new\" }\n format.html { redirect_to units_path, :flash => { :error => 'Nie udało się utworzyć jednostki' } }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit_of_measure = UnitOfMeasure.create(params[:unit_of_measure])\n get_data\n end",
"def unit_params\n params.fetch(:unit, {}).permit(:name)\n end",
"def unit_params\n params.require(:unit).permit(:featured, :number, :avail_date, :category_id, :building_id, :title, :description, :bedrooms, :bathrooms, :price, :link, :image, :phoneNum)\n end",
"def unit_params\n params.fetch(:unit, {})\n end",
"def create\n @unit_measure = UnitMeasure.new(unit_measure_params)\n\n respond_to do |format|\n if @unit_measure.save\n format.html { redirect_to @unit_measure, notice: 'Unit measure was successfully created.' }\n format.json { render :show, status: :created, location: @unit_measure }\n else\n format.html { render :new }\n format.json { render json: @unit_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def units=(value)\n @units = value\n end",
"def unit_of_measure_params\n params.require(:unit_of_measure).permit(:unit_id, :unit_description, :unit_status, :created_by, :updated_by)\n end",
"def create\n @unit_of_measure = UnitOfMeasure.new(params[:unit_of_measure])\n\n respond_to do |format|\n if @unit_of_measure.save\n format.html { redirect_to @unit_of_measure, notice: t(:unit_of_measure_created) }\n format.json { render json: @unit_of_measure, status: :created, location: @unit_of_measure }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit_of_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_of_measure_params\n params.require(:unit_of_measure).permit(:name, :description, :code, :uom_type, :ratio, :uom_category_id)\n end",
"def unit_params\n params.require(:unit).permit(:Unitcode, :name, :Unitaccuracy, :Roundingtype,:fbillstatus,:Creator,:CreateDate,:Approver,:ApproverDate)\n end",
"def unit_params\n params.require(:unit).permit(:name, :circle_id)\n end",
"def create\n # I was not able to get this working. I suspected a change may have occurred in the API that hasn't been published to docs.\n # Used https://www.hurl.it/ to test requests to the API. Was getting a success response, but\n # never saw the newly created unit in either my SDK or in the stage environment. Could be in the DB but missing an attribute/flag that allows\n # association to the property and/or allows for display.\n puts 'test1'\n #@unit = Unit.new(params)\n puts 'XYZ'\n puts params[:name]\n puts 'ABC'\n end",
"def create\n @base_unit = BaseUnit.new(base_unit_params)\n\n respond_to do |format|\n if @base_unit.save\n format.html { redirect_to @base_unit, notice: 'Tray type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @base_unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @base_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.\n require(:unit).\n permit(:user_building_id, :unit_number, :sqfootage, :number_bedrooms,\n :number_bathrooms, :number_rooms, :number_occupants)\n end",
"def create\n @unit = Unit.new(unit_params)\n @unit.name = @unit.name.downcase\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to new_food_path, notice: 'Unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit }\n else\n flash[:error] = \"Unit can't be an empty string.\"\n format.html { redirect_to new_food_path }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retail_unit = RetailUnit.new(params[:retail_unit])\n\n respond_to do |format|\n if @retail_unit.save\n format.html { redirect_to @retail_unit, notice: 'Retail unit was successfully created.' }\n format.json { render json: @retail_unit, status: :created, location: @retail_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retail_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:title, :description, :use, :typology, :component_id, :ancestry, :parent_id)\n end",
"def unit_params\n params.require(:unit).permit(:name, :type, :attack, :defence)\n end",
"def transfer_unit\n if !params[:ic_number].nil?\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def create\n @property = @user.properties.new(params[:property])\n @number_of_units = params[:number_of_units].to_i\n \n respond_to do |format|\n if @property.save\n @number_of_units.times do |unit|\n @property.units.build(:name => unit.to_s, :bedrooms=>1, :bathrooms=>1, :square_feet => 1000, :base_rent=>1000)\n end\n if (@property.save)\n flash[:notice] = 'Property and units created!'\n else\n flash[:notice] = 'Property creted, but errors creating units.'\n end\n format.html { redirect_to(@property) }\n format.xml { render :xml => @property, :status => :created, :location => @property }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @property.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def unit_params \n params.require(:unit).permit(:name, :unit, :create_user, :edit_user, :comment)\n end",
"def create\n @storage_unit = StorageUnit.new(storage_unit_params)\n\n respond_to do |format|\n if @storage_unit.save\n format.html { redirect_to @storage_unit, notice: 'Storage unit was successfully created.' }\n format.json { render :show, status: :created, location: @storage_unit }\n else\n format.html { render :new }\n format.json { render json: @storage_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rented_unit_params\n params.require(:rented_unit).permit(:unit_no, :unit_model, :price, :bedrooms, :bathrooms, :half_baths, :square_footage, :leased, :appointment_id, :notes, :spanstart, :spanend)\n end",
"def unit_measure_params\n params.require(:unit_measure).permit(:nominal_reference, :unit_measure_id, :conversion_id, :metric_id)\n end",
"def create\n @unit = Unit.new(unit_params)\n respond_to do |format|\n if @unit.save\n Unit.transaction do\n auth = Signet::Rails::Factory.create_from_env :google, request.env\n client = Google::APIClient.new\n client.authorization = auth\n plusDomain = client.discovered_api('plusDomains')\n @result = client.execute(:api_method => plusDomain.circles.insert,\n :parameters => {'userId' => 'me'},\n :body =>MultiJson.dump('displayName' => @unit.name),\n :headers => {'Content-Type' => 'application/json'}\n )\n @unit.update_column(:circle_id, @result.data.id)\n end\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article = Article.new(article_params)\n respond_to do |format|\n if @article.save\n @article_unit = ArticlesUnit.create(article: @article,\n unit_id: params[:articles_units][:unit_id],\n value: params[:articles_units][:value])\n format.html { redirect_to @article, notice: \"L'Article a été créé avec succès.\" }\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 unit_params\n params.require(:unit).permit(:name, :role, :power, :movement, :shooting_skill, :strength, :combat_skill, :attacks, :wounds, :leadership, :armor_save, :invul_shooting, :invul_combat, :single_model_point_cost, :model_count_increment, :power_for_each_increment, :min_model_count, :max_model_count, :detachment_id)\n end",
"def measurements_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_post ...\"\n end\n \n # resource path\n path = \"/measurements\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\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 = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:POST, 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 => 'inline_response_200_13')\n if Configuration.debugging\n Configuration.logger.debug \"API called: MeasurementApi#measurements_post. Result: #{result.inspect}\"\n end\n return result\n end",
"def units\n @formulation = (params[:formulation] || '').upcase\n drug = Drug.find_by_name(@formulation) rescue nil\n render plain: \"per dose\" and return unless drug && !drug.units.blank?\n render plain: drug.units\n end",
"def standard_unit_params\n params.require(:standard_unit).permit(:name)\n end",
"def create\n @standard_unit = StandardUnit.new(standard_unit_params)\n\n if @standard_unit.save\n render :show, status: :created, location: @standard_unit\n else\n render json: @standard_unit.errors, status: :unprocessable_entity\n end\n end",
"def create\n @electoral_unit = ElectoralUnit.new(params[:electoral_unit])\n\n respond_to do |format|\n if @electoral_unit.save\n format.html { redirect_to @electoral_unit, notice: 'Electoral unit was successfully created.' }\n format.json { render json: @electoral_unit, status: :created, location: @electoral_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @electoral_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit_name = UnitName.new(unit_name_params)\n\n respond_to do |format|\n if @unit_name.save\n format.html { redirect_to @unit_name, notice: 'Unit name was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit_name }\n else\n format.html { render action: 'new' }\n format.json { render json: @unit_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:name, :subsystem_id)\n end",
"def units=(list)\n @units = makelist(list)\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def medical_unit_params\n params.permit(:name, :location, :speciality, :image)\n end",
"def create\n @unit = Unit.new(unit_params)\n authorize @unit\n begin\n ActiveRecord::Base.transaction do\n @unit.save!\n end\n rescue => e\n render partial: \"shared/validation_messages\",\n locals: { object: @unit.errors.any? ? @unit : e },\n status: :bad_request\n else\n RefreshOpensearchJob.perform_later\n toast!(title: \"Unit created\",\n message: \"The unit \\\"#{@unit.title}\\\" has been created.\")\n render \"shared/reload\"\n end\n end",
"def create\n @quotation_unit = QuotationUnit.new(quotation_unit_params)\n\n respond_to do |format|\n if @quotation_unit.save\n format.html { redirect_to @quotation_unit, notice: 'Quotation unit was successfully created.' }\n format.json { render :show, status: :created, location: @quotation_unit }\n else\n format.html { render :new }\n format.json { render json: @quotation_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit}\n end\n end",
"def create\n @german_unit = GermanUnit.new(german_unit_params)\n\n respond_to do |format|\n if @german_unit.save\n format.html { redirect_to @german_unit, notice: 'German unit was successfully created.' }\n format.json { render :show, status: :created, location: @german_unit }\n else\n format.html { render :new }\n format.json { render json: @german_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def storage_unit_params\n params.require(:storage_unit).permit(:name, :description, :length, :width, :height, :renter_id, :annual_rate, :monthly_rate)\n end",
"def create\n @quantity_unit = QuantityUnit.new(params[:quantity_unit])\n\n respond_to do |format|\n if @quantity_unit.save\n flash[:notice] = 'QuantityUnit was successfully created.'\n format.html { redirect_to(@quantity_unit) }\n format.xml { render :xml => @quantity_unit, :status => :created, :location => @quantity_unit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quantity_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def unit_params\n #params.require(:unit).permit(:name, :email, :cname)\n params.permit(:id, :name, :email, :cname)\n end",
"def set_Units(value)\n set_input(\"Units\", value)\n end",
"def set_Units(value)\n set_input(\"Units\", value)\n end",
"def assign_unit \n if !params[:ic_number].nil?\n @val = params[:transfer_from][:agency]\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def measurement_type_params\n params.require(:measurement_type).permit(:name, :units, :description)\n end",
"def create\n @police_unit = PoliceUnit.new(police_unit_params)\n\n respond_to do |format|\n if @police_unit.save\n format.html { redirect_to @police_unit, notice: 'Police unit was successfully created.' }\n format.json { render :show, status: :created, location: @police_unit }\n else\n format.html { render :new }\n format.json { render json: @police_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def police_unit_params\n params.require(:police_unit).permit(:name)\n end",
"def cat_uni_measure_unit_params\n params.require(:cat_uni_measure_unit).permit(:key, :description)\n end",
"def update\n @unit = Unit.find(params[:id])\n\n if @unit.update(unit_params)\n render :create, status: :ok\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def measurement_unit_params\n params.require(:measurement_unit).permit(:name, :lock)\n end",
"def unit_name_params\n params.require(:unit_name).permit(:title, :description)\n end",
"def create\n @recipe_ingredients_unit = RecipeIngredientsUnit.new(recipe_ingredients_unit_params)\n\n respond_to do |format|\n if @recipe_ingredients_unit.save\n format.html { redirect_to recipe_ingredients_units_path, notice: 'Recipe ingredients unit was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_ingredients_unit }\n else\n format.html { render :new }\n format.json { render json: @recipe_ingredients_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rent_unit = RentUnit.new(rent_unit_params)\n\n respond_to do |format|\n if @rent_unit.save\n format.html { redirect_to @rent_unit, notice: 'Rent unit was successfully created.' }\n format.json { render :show, status: :created, location: @rent_unit }\n else\n format.html { render :new }\n format.json { render json: @rent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{raw_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create POST request\n post_params = {\n :verbose => DEBUG,\n :method => \"post\",\n :body => form_encode(data)\n }\n post_params[:params] = query_params unless query_params.empty?\n post = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", post_params)\n # Send request\n do_request(post, format) \n end",
"def quotation_unit_params\n params.require(:quotation_unit).permit(:quotation_unit_name)\n end",
"def create\n @study_unit = StudyUnit.new(params[:study_unit])\n\n respond_to do |format|\n if @study_unit.save\n format.html { redirect_to @study_unit, notice: 'Study unit was successfully created.' }\n format.json { render json: @study_unit, status: :created, location: @study_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @study_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dataunit_params\n params.require(:dataunit).permit(:geoValue, :dataValue, :dataset_id, :user_id)\n end",
"def unit_params\n params.require(:unit).permit(\n :address1, :address2, :city, :state, :zip_code, :time_zone, :attach_consent_form,\n :use_consent_form, :consent_form, :url_consent_form, :home_address1, :home_address2, :home_zip_code,\n :home_state, :home_city, :home_map_url, :home_name, { health_form_coordinator_ids: [] }\n )\n end",
"def unit_group_params\n params.require(:unit_group).permit(:guid, :price, :group_key, :name, :available_units_count, :total_units_count, :total_non_excluded_units_count, :size, :standard_rate, :floor, :reduced_price, :occupancy_percent, :area, :length, :width, :height, :due_at_move_in, :due_at_move_in_without_fees, :due_monthly, :attribute_description, :description, :average_rent, :active_rate_type, :channel_rate_id, :unit_type_id)\n end",
"def create\n @unit_product = UnitProduct.new(unit_product_params)\n\n respond_to do |format|\n if @unit_product.save\n format.html { redirect_to @unit_product, notice: \"Unit product was successfully created.\" }\n format.json { render :show, status: :created, location: @unit_product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @unit_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def total_units=(value)\n @total_units = value\n end",
"def unit_params\n\t params.require(:unit).permit(:name, :semester_id)\n\t end",
"def create\n @currentunit = Currentunit.new(currentunit_params)\n\n respond_to do |format|\n if @currentunit.save\n format.html { redirect_to @currentunit, notice: 'Currentunit was successfully created.' }\n format.json { render :show, status: :created, location: @currentunit }\n else\n format.html { render :new }\n format.json { render json: @currentunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @army_unit = ArmyUnit.new(army_unit_params)\n\n respond_to do |format|\n if @army_unit.save\n format.html { redirect_to @army_unit, notice: 'Army unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @army_unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @army_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def create\n @ad_unit = AdUnit.new(params[:ad_unit])\n\n respond_to do |format|\n if @ad_unit.save\n format.html { redirect_to @ad_unit, notice: 'Ad unit was successfully created.' }\n format.json { render json: @ad_unit, status: :created, location: @ad_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ad_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @timeunit = Timeunit.new(params[:timeunit])\n\n respond_to do |format|\n if @timeunit.save\n format.html { redirect_to(@timeunit, :notice => 'Timeunit was successfully created.') }\n format.xml { render :xml => @timeunit, :status => :created, :location => @timeunit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @timeunit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @storage_unit = StorageUnit.new(params[:storage_unit])\n\n respond_to do |format|\n if @storage_unit.save\n flash[:notice] = 'StorageUnit was successfully created.'\n format.html { redirect_to(@storage_unit) }\n format.xml { render :xml => @storage_unit, :status => :created, :location => @storage_unit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @storage_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @unit_type = UnitType.new\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def create\n @unit = Unit.new(unit_params)\n @unit.organization = current_organization\n respond_to do |format|\n if @unit.save\n format.html { redirect_to units_url, notice: \"#{t(:unit)} #{t(:was_succfully_created)}\" }\n else\n flash.now[:danger] = \"#{t(:failed_to_create)} #{t(:unit)}\"\n format.html { render action: 'new' }\n end\n end\n end",
"def new\n @item_unit = ItemUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def new\n @extent_unit = ExtentUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @extent_unit }\n end\n end",
"def create\n @unit = Unit.new(params[:unit])\n if session[:resident_id]\n @unit.resident_id = session[:resident_id]\n session[:resident_id] = nil\n end\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit_category = UnitCategory.new(unit_category_params)\n\n respond_to do |format|\n if @unit_category.save\n format.html { redirect_to @unit_category, notice: 'Unit category was successfully created.' }\n format.json { render :show, status: :created, location: @unit_category }\n else\n format.html { render :new }\n format.json { render json: @unit_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @unit_of_measure = UnitOfMeasure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def part_measurement_params\n params.require(:part_measurement).permit(:name, :unit, :value)\n end",
"def create\n @unit_group = UnitGroup.new(unit_group_params)\n\n respond_to do |format|\n if @unit_group.save\n format.html { redirect_to @unit_group, notice: 'Unit group was successfully created.' }\n format.json { render :show, status: :created, location: @unit_group }\n else\n format.html { render :new }\n format.json { render json: @unit_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rent_unit_params\n params.require(:rent_unit).permit(:name)\n end",
"def army_unit_params\n params.require(:army_unit).permit(:unit_id, :army_id)\n end"
] |
[
"0.67017543",
"0.67017543",
"0.665163",
"0.66260743",
"0.65848905",
"0.6571388",
"0.6559905",
"0.6513941",
"0.64358485",
"0.643058",
"0.64260685",
"0.64147675",
"0.6377638",
"0.6371824",
"0.63462377",
"0.6335834",
"0.6332594",
"0.6331857",
"0.6330569",
"0.631212",
"0.6300642",
"0.62811875",
"0.6269009",
"0.6246745",
"0.6244873",
"0.6228291",
"0.62127006",
"0.6211468",
"0.61635095",
"0.6163071",
"0.6152031",
"0.6135335",
"0.6130623",
"0.6124361",
"0.6119586",
"0.61107767",
"0.6107671",
"0.60988545",
"0.60867715",
"0.608018",
"0.6051808",
"0.60513157",
"0.6045942",
"0.603699",
"0.6034467",
"0.60037124",
"0.5984483",
"0.5983168",
"0.59728163",
"0.59623504",
"0.5960372",
"0.59473234",
"0.5915013",
"0.5915013",
"0.5915013",
"0.5907898",
"0.59062356",
"0.5892365",
"0.589184",
"0.58906966",
"0.5886729",
"0.5873534",
"0.5868814",
"0.5854132",
"0.5854132",
"0.5846144",
"0.5843877",
"0.58182055",
"0.5817253",
"0.58150977",
"0.5783083",
"0.578286",
"0.5781806",
"0.5764004",
"0.5761108",
"0.57469064",
"0.57242024",
"0.572156",
"0.5709442",
"0.5707375",
"0.569352",
"0.5687306",
"0.56835973",
"0.56828755",
"0.5670335",
"0.5655355",
"0.56444335",
"0.56358874",
"0.56356585",
"0.5631565",
"0.5630403",
"0.56187975",
"0.56153435",
"0.5605503",
"0.5603294",
"0.5602921",
"0.56007236",
"0.56001174",
"0.5596223",
"0.5593767",
"0.55886316"
] |
0.0
|
-1
|
PATCH/PUT /units/1 PATCH/PUT /units/1.json
|
def update
respond_to do |format|
if @unit.update(unit_params)
format.html { redirect_to @unit, notice: '修改成功!.' }
format.json { render :show, status: :ok, location: @unit }
else
format.html { render :edit }
format.json { render json: @unit.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\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 update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit }\n else\n format.html { render :edit }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jobtype = Jobtype.find(params[:id])\n\n if @jobtype.update_attributes(params[:unit])\n render_json \"success\"\n else\n render_error \"failure\"\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n\n if @unit.update(unit_params)\n render :create, status: :ok\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def update_units(id, units, options = {})\n required = required_params(binding.send(:local_variables), binding, ['id'])\n call(:post, path(\"#{id}/actions/content/update/\"), :payload => { :required => required })\n end",
"def update\n @unit = Unit.find(params[:id])\n \n if params[:unit].andand[:note].present? && (@unit.note.blank? || (@unit.note != params[:unit][:note]))\n @unit.note_updated_by = current_person\n @unit.note_updated_at = Time.now\n end\n\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item_unit = ItemUnit.find(params[:id])\n\n respond_to do |format|\n if @item_unit.update_attributes(params[:item_unit])\n format.html { redirect_to @item_unit, notice: 'Item unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to new_food_path, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = \"Unit can't be an empty string.\"\n format.html { redirect_to new_food_path }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @base_unit.update(base_unit_params)\n format.html { redirect_to @base_unit, notice: 'Tray type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @base_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_name.update(unit_name_params)\n format.html { redirect_to @unit_name, notice: 'Unit name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @extent_unit = ExtentUnit.find(params[:id])\n\n respond_to do |format|\n if @extent_unit.update_attributes(params[:extent_unit])\n format.html { redirect_to @extent_unit, notice: 'Extent unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @extent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n format.html { redirect_to @item, notice: 'Unit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully update@datasheet.' }\n format.json { render :show, status: :ok, location: @unit }\n else\n format.html { render :edit }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n # format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.html { redirect_to units_path, notice: 'Pomyślnie zaktualizowano jednostkę.' }\n format.json { head :no_content }\n else\n # format.html { render action: \"edit\" }\n format.html { redirect_to units_path, :flash => { :error => 'Nie udało się zaktualizować jednostki' } }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n if params[:commit] == \"Save\"\n format.html { redirect_to @unit, notice: '<div class=\"alert alert-success\">Unit was successfully updated.</div>' }\n else\n @unit.toggle(current_user)\n format.html {\n redirect_to @unit, notice: \"<div class='alert alert-success'>Unit was successfully #{@unit.status_label}</div>\"\n }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @currentunit.update(currentunit_params)\n format.html { redirect_to @currentunit, notice: 'Currentunit was successfully updated.' }\n format.json { render :show, status: :ok, location: @currentunit }\n else\n format.html { render :edit }\n format.json { render json: @currentunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_ingredients_unit.update(recipe_ingredients_unit_params)\n format.html { redirect_to recipe_ingredients_units_path, notice: 'Recipe ingredients unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_ingredients_unit }\n else\n format.html { render :edit }\n format.json { render json: @recipe_ingredients_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n\n respond_to do |format|\n if @unit_of_measure.update_attributes(params[:unit_of_measure])\n format.html { redirect_to @unit_of_measure, notice: t(:unit_of_measure_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit_of_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @police_unit.update(police_unit_params)\n format.html { redirect_to @police_unit, notice: 'Police unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @police_unit }\n else\n format.html { render :edit }\n format.json { render json: @police_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @retail_unit = RetailUnit.find(params[:id])\n\n respond_to do |format|\n if @retail_unit.update_attributes(params[:retail_unit])\n format.html { redirect_to @retail_unit, notice: 'Retail unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retail_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @army_unit.update(army_unit_params)\n format.html { redirect_to @army_unit, notice: 'Army unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @army_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity_unit = QuantityUnit.find(params[:id])\n\n respond_to do |format|\n if @quantity_unit.update_attributes(params[:quantity_unit])\n flash[:notice] = 'QuantityUnit was successfully updated.'\n format.html { redirect_to(@quantity_unit) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quantity_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_measure.update(unit_measure_params)\n format.html { redirect_to @unit_measure, notice: 'Unit measure was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_measure }\n else\n format.html { render :edit }\n format.json { render json: @unit_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update\n respond_to do |format|\n if @storage_unit.update(storage_unit_params)\n format.html { redirect_to @storage_unit, notice: 'Storage unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @storage_unit }\n else\n format.html { render :edit }\n format.json { render json: @storage_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @first_level_unit.update(first_level_unit_params)\n format.html { redirect_to admin_first_level_units_path, notice: 'First level unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @first_level_unit }\n else\n format.html { render :edit }\n format.json { render json: @first_level_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @standard_unit.update(standard_unit_params)\n render :show, status: :ok, location: @standard_unit\n else\n render json: @standard_unit.errors, status: :unprocessable_entity\n end\n end",
"def update\n @contract = Contract.find(params[:id])\n @units = Unit.unsold(params[:tower_id])\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to tower_contract_path(@contract.unit.tower, @contract), notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @dataunit.update(dataunit_params)\n format.html { redirect_to @dataunit, notice: 'Dataunit was successfully updated.' }\n format.json { render :show, status: :ok, location: @dataunit }\n else\n format.html { render :edit }\n format.json { render json: @dataunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_fuel.update(unit_fuel_params)\n format.html { redirect_to @unit_fuel, notice: (t 'unit_fuels.title')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit_fuel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @article.update(article_params)\n @article.articles_units.last.update(unit_id: params[:articles_units][:unit_id],\n value: params[:articles_units][:value])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { render :show, status: :ok, location: @article }\n else\n format.html { render :edit }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n if @quantity.update_attributes(params[:quantity])\n format.html { redirect_to @quantity, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n if @quantity.update_attributes(params[:quantity])\n format.html { redirect_to @quantity, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @quotation_unit.update(quotation_unit_params)\n format.html { redirect_to @quotation_unit, notice: 'Quotation unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @quotation_unit }\n else\n format.html { render :edit }\n format.json { render json: @quotation_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @study_unit = StudyUnit.find(params[:id])\n\n respond_to do |format|\n if @study_unit.update_attributes(params[:study_unit])\n format.html { redirect_to @study_unit, notice: 'Study unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @study_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to units_url, notice: \"#{t(:unit)} #{t(:was_successfully_updated)}\" }\n else\n flash.now[:danger] = \"#{t(:failed_to_update)} #{t(:unit)}\"\n format.html { render action: 'show' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @workout_unit.update(workout_unit_params)\n format.html { redirect_to @workout_unit, notice: 'Workout unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @workout_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n \n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n flash[:notice] = 'Unit was successfully updated.'\n format.html { redirect_to(admin_army_unit_path(@unit.army,@unit)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @electoral_unit = ElectoralUnit.find(params[:id])\n\n respond_to do |format|\n if @electoral_unit.update_attributes(params[:electoral_unit])\n format.html { redirect_to @electoral_unit, notice: 'Electoral unit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @electoral_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @org_unit.update(org_unit_params)\n format.html { redirect_to @org_unit, notice: 'Org unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @org_unit }\n else\n format.html { render :edit }\n format.json { render json: @org_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @storage_unit = StorageUnit.find(params[:id])\n\n respond_to do |format|\n if @storage_unit.update_attributes(params[:storage_unit])\n flash[:notice] = 'StorageUnit was successfully updated.'\n format.html { redirect_to(@storage_unit) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @storage_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_action.update(unit_action_params)\n format.html { redirect_to @unit_action, notice: 'Unit action was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_action }\n else\n format.html { render :edit }\n format.json { render json: @unit_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @account_unit.update_attributes(params[:account_unit])\n format.html { redirect_to @account_unit, notice: 'Account unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @base_unit = args[:base_unit] if args.key?(:base_unit)\n @base_unit_conversion_factor = args[:base_unit_conversion_factor] if args.key?(:base_unit_conversion_factor)\n @base_unit_description = args[:base_unit_description] if args.key?(:base_unit_description)\n @display_quantity = args[:display_quantity] if args.key?(:display_quantity)\n @tiered_rates = args[:tiered_rates] if args.key?(:tiered_rates)\n @usage_unit = args[:usage_unit] if args.key?(:usage_unit)\n @usage_unit_description = args[:usage_unit_description] if args.key?(:usage_unit_description)\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @clase_unit.update(clase_unit_params)\n format.html { redirect_to @clase_unit, notice: 'Clase unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clase_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order_unit.update(order_unit_params)\n format.html { redirect_to @order_unit, notice: '部件信息更新成功!' }\n format.json { render :show, status: :ok, location: @order_unit }\n else\n format.html { render :edit }\n format.json { render json: @order_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n respond_to do |format|\n if @german_unit.update(german_unit_params)\n format.html { redirect_to @german_unit, notice: 'German unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @german_unit }\n else\n format.html { render :edit }\n format.json { render json: @german_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @timeunit = Timeunit.find(params[:id])\n\n respond_to do |format|\n if @timeunit.update_attributes(params[:timeunit])\n format.html { redirect_to(@timeunit, :notice => 'Timeunit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timeunit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n @unit_of_measure.update_attributes(params[:unit_of_measure])\n get_data\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rent_unit.update(rent_unit_params)\n format.html { redirect_to @rent_unit, notice: 'Rent unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @rent_unit }\n else\n format.html { render :edit }\n format.json { render json: @rent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_metum.update(test_metum_params)\n format.html { redirect_to @test_metum, notice: 'Test metum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_metum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @functional_unit = FunctionalUnit.find(params[:id])\n\n respond_to do |format|\n if @functional_unit.update_attributes(params[:functional_unit])\n format.html { redirect_to(@functional_unit, :notice => 'Functional unit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @functional_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @unit_of_measure.modified_by = current_user.id\n respond_to do |format|\n if @unit_of_measure.update(unit_of_measure_params)\n format.html { redirect_to unit_of_measures_path, notice: 'Unit of measure was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_of_measure }\n else\n format.html { render :edit }\n format.json { render json: @unit_of_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @commecial_unit.update(commecial_unit_params)\n format.html { redirect_to @commecial_unit, notice: 'Commecial unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @commecial_unit }\n else\n format.html { render :edit }\n format.json { render json: @commecial_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usage.update(usage_params)\n format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_product.update(unit_product_params)\n format.html { redirect_to @unit_product, notice: \"Unit product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @unit_product }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @unit_product.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 respond_to do |format|\n if @unit_category.update(unit_category_params)\n format.html { redirect_to @unit_category, notice: 'Unit category was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_category }\n else\n format.html { render :edit }\n format.json { render json: @unit_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @amount = args[:amount] if args.key?(:amount)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @programme_unit.update(programme_unit_params)\n format.html { redirect_to @programme_unit, notice: 'Programme unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @programme_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update!(**args)\n @unit = args[:unit] if args.key?(:unit)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @unit = args[:unit] if args.key?(:unit)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @unit = args[:unit] if args.key?(:unit)\n @value = args[:value] if args.key?(:value)\n end",
"def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend",
"def update\n @log_unit = LogUnit.find(params[:id])\n\n respond_to do |format|\n if @log_unit.update_attributes(params[:log_unit])\n format.html { redirect_to @log_unit, :notice => 'Log unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @log_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @instrument_patch.update(instrument_patch_params)\n format.html { redirect_to @instrument_patch, notice: 'Instrument patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instrument_patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ad_unit = AdUnit.find(params[:id])\n\n respond_to do |format|\n if @ad_unit.update_attributes(params[:ad_unit])\n format.html { redirect_to @ad_unit, notice: 'Ad unit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ad_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @commercial_unit.update(commercial_unit_params)\n format.html { redirect_to @commercial_unit, notice: 'Commercial unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @commercial_unit }\n else\n format.html { render :edit }\n format.json { render json: @commercial_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subset.update(subset_params)\n format.html { redirect_to @subset, notice: 'Subset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @subset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @u = U.find(params[:id])\n\n respond_to do |format|\n if @u.update_attributes(params[:u])\n format.html { render action: \"edit\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @u.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usage = Usage.find(params[:id])\n\n respond_to do |format|\n if @usage.update_attributes(params[:usage])\n format.html { redirect_to @usage, notice: 'usage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update\n @uset = Uset.find(params[:id])\n\n respond_to do |format|\n if @uset.update_attributes(params[:uset])\n format.html { redirect_to @uset, notice: 'Uset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_group.update(unit_group_params)\n format.html { redirect_to @unit_group, notice: 'Unit group was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_group }\n else\n format.html { render :edit }\n format.json { render json: @unit_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meter = Meter.find(params[:id])\n\n respond_to do |format|\n if @meter.update_attributes(params[:meter])\n format.html { redirect_to @meter, notice: 'Meter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create PUT request\n put_params = {\n :verbose => DEBUG,\n :method => \"put\",\n :body => form_encode(data)\n }\n put_params[:params] = query_params unless query_params.empty?\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", put_params)\n # Send request\n do_request(put, format)\n end",
"def update\n @unit = Unit.find(params[:id])\n if @unit.update(unit_params)\n redirect_to project_subsystem_path(:project_id => @unit.subsystem.project.id,\n :id => @unit.subsystem.id),\n :notice => 'Unit erfolgreich aktualisiert.'\n else\n render 'edit'\n end\n end",
"def update\n @shipping_unit = ShippingUnit.find(params[:id])\n\n respond_to do |format|\n if @shipping_unit.update_attributes(params[:shipping_unit])\n format.html { redirect_to(@shipping_unit, :notice => 'Shipping unit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shipping_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @operation.update(operation_params)\n format.html { redirect_to @operation, notice: 'Operation was successfully updated.' }\n format.json { render :json => @operation.to_json(:include => :task) }\n else\n format.html { render json: @operation.errors, status: :unprocessable_entity }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @usertable = Usertable.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @usertable.update_attributes(params[:usertable])\r\n format.html { redirect_to @usertable, notice: 'Your mood 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: @usertable.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @family_unit = FamilyUnit.find(params[:id])\n\n respond_to do |format|\n if @family_unit.update_attributes(params[:family_unit])\n format.html { redirect_to @family_unit, notice: 'Family unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @family_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @non_specific_value = args[:non_specific_value] if args.key?(:non_specific_value)\n @units = args[:units] if args.key?(:units)\n @units_string = args[:units_string] if args.key?(:units_string)\n @value = args[:value] if args.key?(:value)\n @value_string = args[:value_string] if args.key?(:value_string)\n end"
] |
[
"0.78404903",
"0.7101422",
"0.69241214",
"0.68288046",
"0.67853415",
"0.67808515",
"0.6655101",
"0.66174465",
"0.6590445",
"0.6557427",
"0.6543846",
"0.6528425",
"0.65177476",
"0.65111494",
"0.64887244",
"0.64756674",
"0.64402443",
"0.6405222",
"0.6357104",
"0.63470876",
"0.6311093",
"0.6300613",
"0.6289404",
"0.6285272",
"0.62737936",
"0.627223",
"0.627223",
"0.627223",
"0.627223",
"0.6248562",
"0.62417406",
"0.62331563",
"0.61813086",
"0.61248446",
"0.61185926",
"0.6111412",
"0.61042005",
"0.61034465",
"0.61034465",
"0.608303",
"0.60682464",
"0.60666394",
"0.60559833",
"0.60539407",
"0.6048932",
"0.6044983",
"0.603627",
"0.6035055",
"0.60175943",
"0.6016742",
"0.5987692",
"0.59839803",
"0.59559447",
"0.59483236",
"0.5947856",
"0.59272647",
"0.591731",
"0.588983",
"0.5881557",
"0.58796847",
"0.58675295",
"0.586287",
"0.5859494",
"0.58568525",
"0.5843681",
"0.5824284",
"0.5816827",
"0.58018976",
"0.580035",
"0.5794103",
"0.5788375",
"0.5787775",
"0.5786495",
"0.57802826",
"0.5775455",
"0.5775455",
"0.5775455",
"0.57744443",
"0.57644254",
"0.57589877",
"0.57518315",
"0.57502306",
"0.5749511",
"0.57343763",
"0.573155",
"0.5731389",
"0.5730731",
"0.57231283",
"0.57145846",
"0.5713158",
"0.57091856",
"0.5706903",
"0.568825",
"0.56844705",
"0.56787604",
"0.5677956",
"0.56772083",
"0.5676644",
"0.5667712",
"0.5666101"
] |
0.65195906
|
12
|
DELETE /units/1 DELETE /units/1.json
|
def destroy
@unit.destroy
respond_to do |format|
format.html { redirect_to units_url, notice: '删除成功!' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @base_unit.destroy\n respond_to do |format|\n format.html { redirect_to base_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @unit.blank?\n render json: {error: \"Can't delete unit\"}, status: :unprocessable_entity\n else\n @unit.destroy\n render json: {notice: \"Deleted!\"}, :status => 204\n end\n\n end",
"def destroy\n @item_unit = ItemUnit.find(params[:id])\n @item_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to item_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @unit.destroy\n head :no_content\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url, notice: 'Unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = @lab_rack.units.find(params[:id])\n @unit.destroy\n \n redirect_to @lab_rack, :notice => \"Unit has been deleted\"\n end",
"def destroy\n @unit_name.destroy\n respond_to do |format|\n format.html { redirect_to unit_names_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url, notice: 'Unit was successfully destroye@datasheet.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @extent_unit = ExtentUnit.find(params[:id])\n @extent_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to extent_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retail_unit = RetailUnit.find(params[:id])\n @retail_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to retail_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @first_level_unit.destroy\n respond_to do |format|\n format.html { redirect_to first_level_units_url, notice: 'First level unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @army_unit.destroy\n respond_to do |format|\n format.html { redirect_to army_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage_unit = StorageUnit.find(params[:id])\n @storage_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(storage_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to new_food_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url, notice: \"#{t(:unit)} #{t(:was_successfully_deleted)}\" }\n end\n end",
"def destroy\n @quantity_unit = QuantityUnit.find(params[:id])\n @quantity_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(quantity_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @storage_unit.destroy\n respond_to do |format|\n format.html { redirect_to storage_units_url, notice: 'Storage unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @study_unit = StudyUnit.find(params[:id])\n @study_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to study_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_measure.destroy\n respond_to do |format|\n format.html { redirect_to unit_measures_url, notice: 'Unit measure was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clase_unit.destroy\n respond_to do |format|\n format.html { redirect_to clase_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataunit.destroy\n respond_to do |format|\n format.html { redirect_to dataunits_url, notice: 'Dataunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_of_measure.destroy\n respond_to do |format|\n format.html { redirect_to unit_of_measures_url, notice: 'Unit of measure was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_action.destroy\n respond_to do |format|\n format.html { redirect_to unit_actions_url, notice: 'Unit action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @log_unit = LogUnit.find(params[:id])\n @log_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to log_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @electoral_unit = ElectoralUnit.find(params[:id])\n @electoral_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to electoral_units_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @account_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to account_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @currentunit.destroy\n respond_to do |format|\n format.html { redirect_to currentunits_url, notice: 'Currentunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quotation_unit.destroy\n respond_to do |format|\n format.html { redirect_to quotation_units_url, notice: 'Quotation unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @german_unit.destroy\n respond_to do |format|\n format.html { redirect_to german_units_url, notice: 'German unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad_unit = AdUnit.find(params[:id])\n @ad_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_units_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @unit_fuel.destroy\n respond_to do |format|\n format.html { redirect_to unit_fuels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @building_id = @unit.building_id\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to building_path(@building_id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timeunit = Timeunit.find(params[:id])\n @timeunit.destroy\n\n respond_to do |format|\n format.html { redirect_to(timeunits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @commecial_unit.destroy\n respond_to do |format|\n format.html { redirect_to commecial_units_url, notice: 'Commecial unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_ingredients_unit.destroy\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_units_url, notice: 'Recipe ingredients unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @functional_unit = FunctionalUnit.find(params[:id])\n @functional_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(functional_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @rent_unit.destroy\n respond_to do |format|\n format.html { redirect_to rent_units_url, notice: 'Rent unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sampleunit = Sampleunit.find(params[:id])\n @sampleunit.destroy\n\n respond_to do |format|\n format.html { redirect_to(sampleunits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quantity = Quantity.find(params[:id])\n @quantity.destroy\n\n respond_to do |format|\n format.html { redirect_to quantities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quantity = Quantity.find(params[:id])\n @quantity.destroy\n\n respond_to do |format|\n format.html { redirect_to quantities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @police_unit.destroy\n respond_to do |format|\n format.html { redirect_to police_units_url, notice: 'Police unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teaching_unit.destroy\n respond_to do |format|\n format.html { redirect_to teaching_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_action_type.destroy\n respond_to do |format|\n format.html { redirect_to unit_action_types_url, notice: 'Unit action type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @org_unit.destroy\n respond_to do |format|\n format.html { redirect_to org_units_url, notice: 'Org unit 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_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unit_image.destroy\n respond_to do |format|\n format.html { redirect_to unit_images_url, notice: 'Unit image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_category.destroy\n respond_to do |format|\n format.html { redirect_to unit_categories_url, notice: 'Unit category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n @unit_of_measure.destroy\n get_data\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n @unidade_metrica.destroy\n\n respond_to do |format|\n format.html { redirect_to unidade_metricas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_amenity.destroy\n respond_to do |format|\n format.html { redirect_to unit_amenities_url, notice: 'Unit amenity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commercial_unit.destroy\n respond_to do |format|\n format.html { redirect_to commercial_units_url, notice: 'Commercial unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meter = Meter.find(params[:id])\n @meter.destroy\n\n respond_to do |format|\n format.html { redirect_to meters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @physical_unit = Probe::PhysicalUnit.find(params[:id])\n @physical_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(physical_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uset = Uset.find(params[:id])\n @uset.destroy\n\n respond_to do |format|\n format.html { redirect_to usets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @uom = Uom.find(params[:id])\r\n @uom.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_back_or_default(uoms_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @storage_lun = StorageLun.find(params[:id])\n @storage_lun.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_luns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unitmark.destroy\n respond_to do |format|\n format.html { redirect_to unitmarks_url, notice: 'Unitmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hazmat_unit = HazmatUnit.find(params[:id])\n @hazmat_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(incident_timesheet_path, :notice => 'Hazmat Unit was successfully deleted.') }\n format.xml { head :ok }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @unit_group.destroy\n respond_to do |format|\n format.html { redirect_to unit_groups_url, notice: 'Unit group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shipping_unit = ShippingUnit.find(params[:id])\n @shipping_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(shipping_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relassignunit.destroy\n respond_to do |format|\n format.html { redirect_to relassignunits_url, notice: 'Relassignunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @k_measurement.destroy\n respond_to do |format|\n format.html { redirect_to k_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usage = Usage.find(params[:id])\n @usage.destroy\n\n respond_to do |format|\n format.html { redirect_to usages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @employing_unit = EmployingUnit.find(params[:id])\n @employing_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to employing_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product_unit.destroy\n respond_to do |format|\n format.html { redirect_to @product_unit.product, notice: 'Product unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @standard_unit.destroy\n end",
"def destroy\n @order_unit.destroy\n respond_to do |format|\n format.html { redirect_to order_units_url, notice: '部件信息已删除。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @common_expense_subunit.destroy\n respond_to do |format|\n format.html { redirect_to common_expense_subunits_url, notice: 'Common expense subunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n render status: 200, json: @request_item.destroy\n end",
"def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @m1.destroy\n respond_to do |format|\n format.html { redirect_to m1s_url, notice: 'M1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @standard_measurement = StandardMeasurement.find(params[:id])\n @standard_measurement.destroy\n\n respond_to do |format|\n format.html { redirect_to standard_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @camp_unit = CampUnit.find(params[:id])\n @camp_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(camp_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @programme_unit.destroy\n respond_to do |format|\n format.html { redirect_to programme_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.unit_options.each do |uopt|\n uopt.unit_option_weapons.each do |uoptweapons|\n uoptweapons.destroy\n end\n uopt.destroy\n end\n @unit.destroy\n \n respond_to do |format|\n format.html { redirect_to(admin_army_path(@unit.army)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measure = Measure.find(params[:id])\n @measure.destroy\n\n respond_to do |format|\n format.html { redirect_to measures_url }\n format.json { head :no_content }\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 @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: \"Measurement was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7785851",
"0.76692647",
"0.7640569",
"0.7640569",
"0.7640569",
"0.7640569",
"0.76393604",
"0.75941813",
"0.7526625",
"0.7423007",
"0.7408337",
"0.7406485",
"0.73811907",
"0.73450744",
"0.7330169",
"0.7308755",
"0.7216169",
"0.72083074",
"0.7170146",
"0.7147241",
"0.7145571",
"0.71156025",
"0.707759",
"0.7070075",
"0.70046467",
"0.7001321",
"0.69839895",
"0.6971523",
"0.6969121",
"0.6957415",
"0.6953342",
"0.69130206",
"0.69121057",
"0.690186",
"0.6893319",
"0.6863229",
"0.6858064",
"0.68123436",
"0.6797419",
"0.6776648",
"0.6758938",
"0.67253524",
"0.6716857",
"0.6709751",
"0.67066604",
"0.67029434",
"0.66951007",
"0.66951007",
"0.66691726",
"0.6640785",
"0.6640542",
"0.6633404",
"0.66206706",
"0.6619345",
"0.66145504",
"0.6611158",
"0.6594296",
"0.6586911",
"0.65616786",
"0.65553033",
"0.65521526",
"0.65515256",
"0.6540354",
"0.6537429",
"0.65219915",
"0.65146995",
"0.6506704",
"0.6506332",
"0.64979327",
"0.6496647",
"0.6493019",
"0.6489508",
"0.64777076",
"0.6473865",
"0.647264",
"0.6470023",
"0.6455665",
"0.6452233",
"0.64485264",
"0.6447656",
"0.6437651",
"0.64330333",
"0.6431341",
"0.64281934",
"0.64256674",
"0.64242303",
"0.64237016",
"0.64213324",
"0.6413861",
"0.6411397",
"0.6406957",
"0.64063144",
"0.64044636",
"0.6400151",
"0.63965476",
"0.6391568",
"0.63910997",
"0.6391038",
"0.6391038",
"0.6391038"
] |
0.7450989
|
9
|
Use callbacks to share common setup or constraints between actions.
|
def set_unit
@unit = Unit.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def around_hooks; end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = 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",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def duas1(action)\n action.call\n action.call\nend"
] |
[
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.53314966",
"0.53114754",
"0.52984965",
"0.52977055",
"0.5296272",
"0.5260649",
"0.5245076",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.52388334",
"0.5235081",
"0.52321917",
"0.5228592",
"0.5220735",
"0.52198535",
"0.52139324",
"0.5208539",
"0.5206585",
"0.5178542",
"0.5175199",
"0.5173538",
"0.5167041",
"0.51614195",
"0.51577675",
"0.5153909",
"0.51528823",
"0.5152225",
"0.51429904",
"0.5141399",
"0.51345575",
"0.51145",
"0.5114052",
"0.5114052",
"0.5110216",
"0.5108656",
"0.50935394",
"0.5089196",
"0.5081936",
"0.5079627",
"0.50675833",
"0.5056105",
"0.5053687",
"0.5050475",
"0.5050475",
"0.503471",
"0.5028311",
"0.501982",
"0.50157547",
"0.5013552",
"0.50014806",
"0.50011593",
"0.49976763",
"0.4990292",
"0.4990292",
"0.49882022",
"0.4981269",
"0.49792367",
"0.49766538",
"0.4967978",
"0.49667212",
"0.4958987",
"0.49572337",
"0.49550423",
"0.4954479",
"0.4952353",
"0.494726",
"0.4944055",
"0.4935437",
"0.4931248",
"0.49283475",
"0.49281213",
"0.49268973",
"0.4921738",
"0.49204507",
"0.4918924",
"0.49182287",
"0.4916538",
"0.49158585",
"0.49156788"
] |
0.0
|
-1
|
Only allow a list of trusted parameters through.
|
def unit_params
params.require(:unit).permit(:Unitcode, :name, :Unitaccuracy, :Roundingtype,:fbillstatus,:Creator,:CreateDate,:Approver,:ApproverDate)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] |
[
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.