id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
5,900
jgoizueta/numerals
lib/numerals/numeral.rb
Numerals.Numeral.approximate!
def approximate!(number_of_digits = nil) if number_of_digits.nil? if exact? && !repeating? @repeat = nil end else expand! number_of_digits @digits.truncate! number_of_digits @repeat = nil end self end
ruby
def approximate!(number_of_digits = nil) if number_of_digits.nil? if exact? && !repeating? @repeat = nil end else expand! number_of_digits @digits.truncate! number_of_digits @repeat = nil end self end
[ "def", "approximate!", "(", "number_of_digits", "=", "nil", ")", "if", "number_of_digits", ".", "nil?", "if", "exact?", "&&", "!", "repeating?", "@repeat", "=", "nil", "end", "else", "expand!", "number_of_digits", "@digits", ".", "truncate!", "number_of_digits", ...
Expand to the specified number of digits, then truncate and remove repetitions. If no number of digits is given, then it will be converted to approximate numeral only if it is not repeating.
[ "Expand", "to", "the", "specified", "number", "of", "digits", "then", "truncate", "and", "remove", "repetitions", ".", "If", "no", "number", "of", "digits", "is", "given", "then", "it", "will", "be", "converted", "to", "approximate", "numeral", "only", "if",...
a195e75f689af926537f791441bf8d11590c99c0
https://github.com/jgoizueta/numerals/blob/a195e75f689af926537f791441bf8d11590c99c0/lib/numerals/numeral.rb#L632-L643
5,901
mova-rb/mova
lib/mova/scope.rb
Mova.Scope.flatten
def flatten(translations, current_scope = nil) translations.each_with_object({}) do |(key, value), memo| scope = current_scope ? join(current_scope, key) : key.to_s if value.is_a?(Hash) memo.merge!(flatten(value, scope)) else memo[scope] = value end end ...
ruby
def flatten(translations, current_scope = nil) translations.each_with_object({}) do |(key, value), memo| scope = current_scope ? join(current_scope, key) : key.to_s if value.is_a?(Hash) memo.merge!(flatten(value, scope)) else memo[scope] = value end end ...
[ "def", "flatten", "(", "translations", ",", "current_scope", "=", "nil", ")", "translations", ".", "each_with_object", "(", "{", "}", ")", "do", "|", "(", "key", ",", "value", ")", ",", "memo", "|", "scope", "=", "current_scope", "?", "join", "(", "cur...
Recurrently flattens hash by converting its keys to fully scoped ones. @return [Hash{String => String}] @param translations [Hash{String/Symbol => String/Hash}] with multiple roots allowed @param current_scope for internal use @example Scope.flatten(en: {common: {hello: "hi"}}, de: {hello: "Hallo"}) #=> ...
[ "Recurrently", "flattens", "hash", "by", "converting", "its", "keys", "to", "fully", "scoped", "ones", "." ]
27f981c1f29dc20e5d11068d9342088f0e6bb318
https://github.com/mova-rb/mova/blob/27f981c1f29dc20e5d11068d9342088f0e6bb318/lib/mova/scope.rb#L79-L88
5,902
mova-rb/mova
lib/mova/scope.rb
Mova.Scope.cross_join
def cross_join(locales, keys) locales.flat_map do |locale| keys.map { |key| join(locale, key) } end end
ruby
def cross_join(locales, keys) locales.flat_map do |locale| keys.map { |key| join(locale, key) } end end
[ "def", "cross_join", "(", "locales", ",", "keys", ")", "locales", ".", "flat_map", "do", "|", "locale", "|", "keys", ".", "map", "{", "|", "key", "|", "join", "(", "locale", ",", "key", ")", "}", "end", "end" ]
Combines each locale with all keys. @return [Array<String>] @param locales [Array<String, Symbol>] @param keys [Array<String, Symbol>] @example Scope.cross_join([:de, :en], [:hello, :hi]) #=> ["de.hello", "de.hi", "en.hello", "en.hi"]
[ "Combines", "each", "locale", "with", "all", "keys", "." ]
27f981c1f29dc20e5d11068d9342088f0e6bb318
https://github.com/mova-rb/mova/blob/27f981c1f29dc20e5d11068d9342088f0e6bb318/lib/mova/scope.rb#L99-L103
5,903
korczis/csv2psql
lib/csv2psql/analyzer/analyzer.rb
Csv2Psql.Analyzer.create_column
def create_column(data, column) data[:columns][column] = {} res = data[:columns][column] analyzers.each do |analyzer| analyzer_class = analyzer[:class] res[analyzer[:name]] = { class: analyzer_class.new, results: create_results(analyzer_class) } end ...
ruby
def create_column(data, column) data[:columns][column] = {} res = data[:columns][column] analyzers.each do |analyzer| analyzer_class = analyzer[:class] res[analyzer[:name]] = { class: analyzer_class.new, results: create_results(analyzer_class) } end ...
[ "def", "create_column", "(", "data", ",", "column", ")", "data", "[", ":columns", "]", "[", "column", "]", "=", "{", "}", "res", "=", "data", "[", ":columns", "]", "[", "column", "]", "analyzers", ".", "each", "do", "|", "analyzer", "|", "analyzer_cl...
Create column analyzers
[ "Create", "column", "analyzers" ]
dd1751516524b8218da229cd0587c4046e248133
https://github.com/korczis/csv2psql/blob/dd1751516524b8218da229cd0587c4046e248133/lib/csv2psql/analyzer/analyzer.rb#L64-L77
5,904
korczis/csv2psql
lib/csv2psql/analyzer/analyzer.rb
Csv2Psql.Analyzer.update_numeric_results
def update_numeric_results(ac, ar, val) cval = ac.convert(val) ar[:min] = cval if ar[:min].nil? || cval < ar[:min] ar[:max] = cval if ar[:max].nil? || cval > ar[:max] end
ruby
def update_numeric_results(ac, ar, val) cval = ac.convert(val) ar[:min] = cval if ar[:min].nil? || cval < ar[:min] ar[:max] = cval if ar[:max].nil? || cval > ar[:max] end
[ "def", "update_numeric_results", "(", "ac", ",", "ar", ",", "val", ")", "cval", "=", "ac", ".", "convert", "(", "val", ")", "ar", "[", ":min", "]", "=", "cval", "if", "ar", "[", ":min", "]", ".", "nil?", "||", "cval", "<", "ar", "[", ":min", "]...
Update numeric results @param ac analyzer class @param ar analyzer results @param val value to be analyzed
[ "Update", "numeric", "results" ]
dd1751516524b8218da229cd0587c4046e248133
https://github.com/korczis/csv2psql/blob/dd1751516524b8218da229cd0587c4046e248133/lib/csv2psql/analyzer/analyzer.rb#L143-L147
5,905
Fingertips/peiji-san
lib/peiji_san/view_helper.rb
PeijiSan.ViewHelper.link_to_page
def link_to_page(page, paginated_set, options = {}, html_options = {}) page_parameter = peiji_san_option(:page_parameter, options) # Sinatra/Rails differentiator pageable_params = respond_to?(:controller) ? controller.params : self.params url_options = (page == 1 ? pageable_params....
ruby
def link_to_page(page, paginated_set, options = {}, html_options = {}) page_parameter = peiji_san_option(:page_parameter, options) # Sinatra/Rails differentiator pageable_params = respond_to?(:controller) ? controller.params : self.params url_options = (page == 1 ? pageable_params....
[ "def", "link_to_page", "(", "page", ",", "paginated_set", ",", "options", "=", "{", "}", ",", "html_options", "=", "{", "}", ")", "page_parameter", "=", "peiji_san_option", "(", ":page_parameter", ",", "options", ")", "# Sinatra/Rails differentiator", "pageable_pa...
Creates a link using +link_to+ for a page in a pagination collection. If the specified page is the current page then its class will be `current'. Options: [:page_parameter] The name of the GET parameter used to indicate the page to display. Defaults to <tt>:page</tt>. [:current_class] The CSS cl...
[ "Creates", "a", "link", "using", "+", "link_to", "+", "for", "a", "page", "in", "a", "pagination", "collection", ".", "If", "the", "specified", "page", "is", "the", "current", "page", "then", "its", "class", "will", "be", "current", "." ]
6bd1bc7c152961dcde376a8bcb2ca393b5b45829
https://github.com/Fingertips/peiji-san/blob/6bd1bc7c152961dcde376a8bcb2ca393b5b45829/lib/peiji_san/view_helper.rb#L48-L68
5,906
Fingertips/peiji-san
lib/peiji_san/view_helper.rb
PeijiSan.ViewHelper.pages_to_link_to
def pages_to_link_to(paginated_set, options = {}) current, last = paginated_set.current_page, paginated_set.page_count max = peiji_san_option(:max_visible, options) separator = peiji_san_option(:separator, options) if last <= max (1..last).to_a elsif current <= ((max / 2) + ...
ruby
def pages_to_link_to(paginated_set, options = {}) current, last = paginated_set.current_page, paginated_set.page_count max = peiji_san_option(:max_visible, options) separator = peiji_san_option(:separator, options) if last <= max (1..last).to_a elsif current <= ((max / 2) + ...
[ "def", "pages_to_link_to", "(", "paginated_set", ",", "options", "=", "{", "}", ")", "current", ",", "last", "=", "paginated_set", ".", "current_page", ",", "paginated_set", ".", "page_count", "max", "=", "peiji_san_option", "(", ":max_visible", ",", "options", ...
Returns an array of pages to link to. This array includes the separator, so make sure to keep this in mind when iterating over the array and creating links. For consistency’s sake, it is adviced to use an odd number for <tt>:max_visible</tt>. Options: [:max_visible] The maximum amount of elements in the ...
[ "Returns", "an", "array", "of", "pages", "to", "link", "to", ".", "This", "array", "includes", "the", "separator", "so", "make", "sure", "to", "keep", "this", "in", "mind", "when", "iterating", "over", "the", "array", "and", "creating", "links", "." ]
6bd1bc7c152961dcde376a8bcb2ca393b5b45829
https://github.com/Fingertips/peiji-san/blob/6bd1bc7c152961dcde376a8bcb2ca393b5b45829/lib/peiji_san/view_helper.rb#L106-L121
5,907
gevans/expedition
lib/expedition/client.rb
Expedition.Client.devices
def devices send(:devdetails) do |body| body[:devdetails].collect { |attrs| attrs.delete(:devdetails) attrs[:variant] = attrs.delete(:name).downcase attrs } end end
ruby
def devices send(:devdetails) do |body| body[:devdetails].collect { |attrs| attrs.delete(:devdetails) attrs[:variant] = attrs.delete(:name).downcase attrs } end end
[ "def", "devices", "send", "(", ":devdetails", ")", "do", "|", "body", "|", "body", "[", ":devdetails", "]", ".", "collect", "{", "|", "attrs", "|", "attrs", ".", "delete", "(", ":devdetails", ")", "attrs", "[", ":variant", "]", "=", "attrs", ".", "de...
Initializes a new `Client` for executing commands. @param [String] host The host to connect to. @param [Integer] port The port to connect to. Sends the `devdetails` command, returning an array of devices found in the service's response. @return [Response] An array of devices.
[ "Initializes", "a", "new", "Client", "for", "executing", "commands", "." ]
a9ce897900002469ed57617d065a2bbdefd5ced5
https://github.com/gevans/expedition/blob/a9ce897900002469ed57617d065a2bbdefd5ced5/lib/expedition/client.rb#L38-L46
5,908
gevans/expedition
lib/expedition/client.rb
Expedition.Client.send
def send(command, *parameters, &block) socket = TCPSocket.open(host, port) socket.puts command_json(command, *parameters) parse(socket.gets, &block) ensure socket.close if socket.respond_to?(:close) end
ruby
def send(command, *parameters, &block) socket = TCPSocket.open(host, port) socket.puts command_json(command, *parameters) parse(socket.gets, &block) ensure socket.close if socket.respond_to?(:close) end
[ "def", "send", "(", "command", ",", "*", "parameters", ",", "&", "block", ")", "socket", "=", "TCPSocket", ".", "open", "(", "host", ",", "port", ")", "socket", ".", "puts", "command_json", "(", "command", ",", "parameters", ")", "parse", "(", "socket"...
Sends the supplied `command` with optionally supplied `parameters` to the service and returns the result, if any. **Note:** Since `Object#send` is overridden, use `Object#__send__` to call an actual method. @param [Symbol, String] command The command to send to the service. @param [Array] parameters Optio...
[ "Sends", "the", "supplied", "command", "with", "optionally", "supplied", "parameters", "to", "the", "service", "and", "returns", "the", "result", "if", "any", "." ]
a9ce897900002469ed57617d065a2bbdefd5ced5
https://github.com/gevans/expedition/blob/a9ce897900002469ed57617d065a2bbdefd5ced5/lib/expedition/client.rb#L87-L94
5,909
tatemae/muck-engine
lib/muck-engine/flash_errors.rb
MuckEngine.FlashErrors.output_errors
def output_errors(title, options = {}, fields = nil, flash_only = false) fields = [fields] unless fields.is_a?(Array) flash_html = render(:partial => 'shared/flash_messages') flash.clear css_class = "class=\"#{options[:class] || 'error'}\"" unless options[:class].nil? field_errors = render...
ruby
def output_errors(title, options = {}, fields = nil, flash_only = false) fields = [fields] unless fields.is_a?(Array) flash_html = render(:partial => 'shared/flash_messages') flash.clear css_class = "class=\"#{options[:class] || 'error'}\"" unless options[:class].nil? field_errors = render...
[ "def", "output_errors", "(", "title", ",", "options", "=", "{", "}", ",", "fields", "=", "nil", ",", "flash_only", "=", "false", ")", "fields", "=", "[", "fields", "]", "unless", "fields", ".", "is_a?", "(", "Array", ")", "flash_html", "=", "render", ...
Output flash and object errors
[ "Output", "flash", "and", "object", "errors" ]
41fc072dce3a365b3ce4a73d4f60a4ff24026d51
https://github.com/tatemae/muck-engine/blob/41fc072dce3a365b3ce4a73d4f60a4ff24026d51/lib/muck-engine/flash_errors.rb#L10-L31
5,910
tatemae/muck-engine
lib/muck-engine/flash_errors.rb
MuckEngine.FlashErrors.output_admin_messages
def output_admin_messages(fields = nil, title = '', options = { :class => 'notify-box' }, flash_only = false) output_errors_ajax('admin-messages', title, options, fields, flash_only) end
ruby
def output_admin_messages(fields = nil, title = '', options = { :class => 'notify-box' }, flash_only = false) output_errors_ajax('admin-messages', title, options, fields, flash_only) end
[ "def", "output_admin_messages", "(", "fields", "=", "nil", ",", "title", "=", "''", ",", "options", "=", "{", ":class", "=>", "'notify-box'", "}", ",", "flash_only", "=", "false", ")", "output_errors_ajax", "(", "'admin-messages'", ",", "title", ",", "option...
Output a page update that will display messages in the flash
[ "Output", "a", "page", "update", "that", "will", "display", "messages", "in", "the", "flash" ]
41fc072dce3a365b3ce4a73d4f60a4ff24026d51
https://github.com/tatemae/muck-engine/blob/41fc072dce3a365b3ce4a73d4f60a4ff24026d51/lib/muck-engine/flash_errors.rb#L42-L44
5,911
renz45/table_me
lib/table_me/table_pagination.rb
TableMe.TablePagination.pagination_number_list
def pagination_number_list (0...page_button_count).to_a.map do |n| link_number = n + page_number_offset number_span(link_number) end.join(' ') end
ruby
def pagination_number_list (0...page_button_count).to_a.map do |n| link_number = n + page_number_offset number_span(link_number) end.join(' ') end
[ "def", "pagination_number_list", "(", "0", "...", "page_button_count", ")", ".", "to_a", ".", "map", "do", "|", "n", "|", "link_number", "=", "n", "+", "page_number_offset", "number_span", "(", "link_number", ")", "end", ".", "join", "(", "' '", ")", "end"...
List of number links for the number range between next and previous
[ "List", "of", "number", "links", "for", "the", "number", "range", "between", "next", "and", "previous" ]
a04bd7c26497828b2f8f0178631253b6749025cf
https://github.com/renz45/table_me/blob/a04bd7c26497828b2f8f0178631253b6749025cf/lib/table_me/table_pagination.rb#L56-L61
5,912
riddopic/garcun
lib/garcon/task/copy_on_write_observer_set.rb
Garcon.CopyOnWriteObserverSet.add_observer
def add_observer(observer=nil, func=:update, &block) if observer.nil? && block.nil? raise ArgumentError, 'should pass observer as a first argument or block' elsif observer && block raise ArgumentError.new('cannot provide both an observer and a block') end if block observ...
ruby
def add_observer(observer=nil, func=:update, &block) if observer.nil? && block.nil? raise ArgumentError, 'should pass observer as a first argument or block' elsif observer && block raise ArgumentError.new('cannot provide both an observer and a block') end if block observ...
[ "def", "add_observer", "(", "observer", "=", "nil", ",", "func", "=", ":update", ",", "&", "block", ")", "if", "observer", ".", "nil?", "&&", "block", ".", "nil?", "raise", "ArgumentError", ",", "'should pass observer as a first argument or block'", "elsif", "ob...
Adds an observer to this set. If a block is passed, the observer will be created by this method and no other params should be passed @param [Object] observer the observer to add @param [Symbol] func the function to call on the observer during notification. The default is :update. @return [Object] the...
[ "Adds", "an", "observer", "to", "this", "set", ".", "If", "a", "block", "is", "passed", "the", "observer", "will", "be", "created", "by", "this", "method", "and", "no", "other", "params", "should", "be", "passed" ]
c2409bd8cf9c14b967a719810dab5269d69b42de
https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/copy_on_write_observer_set.rb#L45-L66
5,913
rolandasb/gogcom
lib/gogcom/news.rb
Gogcom.News.parse
def parse(data) rss = SimpleRSS.parse data news = Array.new rss.items.each do |item| news_item = NewsItem.new(item.title, item.link, item.description.force_encoding("UTF-8"), item.pubDate) news.push news_item end unless @limit.nil? news.take(@limit) else ...
ruby
def parse(data) rss = SimpleRSS.parse data news = Array.new rss.items.each do |item| news_item = NewsItem.new(item.title, item.link, item.description.force_encoding("UTF-8"), item.pubDate) news.push news_item end unless @limit.nil? news.take(@limit) else ...
[ "def", "parse", "(", "data", ")", "rss", "=", "SimpleRSS", ".", "parse", "data", "news", "=", "Array", ".", "new", "rss", ".", "items", ".", "each", "do", "|", "item", "|", "news_item", "=", "NewsItem", ".", "new", "(", "item", ".", "title", ",", ...
Parses raw data and returns news items @return [Array]
[ "Parses", "raw", "data", "and", "returns", "news", "items" ]
015de453bb214c9ccb51665ecadce1367e6d987d
https://github.com/rolandasb/gogcom/blob/015de453bb214c9ccb51665ecadce1367e6d987d/lib/gogcom/news.rb#L27-L42
5,914
kevgo/mortadella
lib/mortadella/horizontal.rb
Mortadella.Horizontal.columns_indeces_to_drop
def columns_indeces_to_drop columns result = [] headers = @table[0] headers.each_with_index do |header, i| result << i unless columns.include? header end result end
ruby
def columns_indeces_to_drop columns result = [] headers = @table[0] headers.each_with_index do |header, i| result << i unless columns.include? header end result end
[ "def", "columns_indeces_to_drop", "columns", "result", "=", "[", "]", "headers", "=", "@table", "[", "0", "]", "headers", ".", "each_with_index", "do", "|", "header", ",", "i", "|", "result", "<<", "i", "unless", "columns", ".", "include?", "header", "end"...
Returns the column indeces to drop to make this table have the given columns
[ "Returns", "the", "column", "indeces", "to", "drop", "to", "make", "this", "table", "have", "the", "given", "columns" ]
723d06f7a74fb581bf2679505d9cb06e7b128c88
https://github.com/kevgo/mortadella/blob/723d06f7a74fb581bf2679505d9cb06e7b128c88/lib/mortadella/horizontal.rb#L56-L63
5,915
kevgo/mortadella
lib/mortadella/horizontal.rb
Mortadella.Horizontal.dry_up
def dry_up row return row unless @previous_row row.clone.tap do |result| row.length.times do |i| if can_dry?(@headers[i]) && row[i] == @previous_row[i] result[i] = '' else break end end end end
ruby
def dry_up row return row unless @previous_row row.clone.tap do |result| row.length.times do |i| if can_dry?(@headers[i]) && row[i] == @previous_row[i] result[i] = '' else break end end end end
[ "def", "dry_up", "row", "return", "row", "unless", "@previous_row", "row", ".", "clone", ".", "tap", "do", "|", "result", "|", "row", ".", "length", ".", "times", "do", "|", "i", "|", "if", "can_dry?", "(", "@headers", "[", "i", "]", ")", "&&", "ro...
Returns a dried up version of the given row based on the row that came before in the table In a dried up row, any values that match the previous row are removed, stopping on the first difference
[ "Returns", "a", "dried", "up", "version", "of", "the", "given", "row", "based", "on", "the", "row", "that", "came", "before", "in", "the", "table" ]
723d06f7a74fb581bf2679505d9cb06e7b128c88
https://github.com/kevgo/mortadella/blob/723d06f7a74fb581bf2679505d9cb06e7b128c88/lib/mortadella/horizontal.rb#L71-L82
5,916
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.fetch
def fetch(data, keys, default = nil, format = false) if keys.is_a?(String) || keys.is_a?(Symbol) keys = [ keys ] end keys = keys.flatten.compact key = keys.shift if data.has_key?(key) value = data[key] if keys.empty? return filter(value, format) else retur...
ruby
def fetch(data, keys, default = nil, format = false) if keys.is_a?(String) || keys.is_a?(Symbol) keys = [ keys ] end keys = keys.flatten.compact key = keys.shift if data.has_key?(key) value = data[key] if keys.empty? return filter(value, format) else retur...
[ "def", "fetch", "(", "data", ",", "keys", ",", "default", "=", "nil", ",", "format", "=", "false", ")", "if", "keys", ".", "is_a?", "(", "String", ")", "||", "keys", ".", "is_a?", "(", "Symbol", ")", "keys", "=", "[", "keys", "]", "end", "keys", ...
Recursively fetch value for key path in the configuration object. This method serves as a base accessor to the properties that are defined in the central property collection. It is used and built upon by other accessors defined in the class. Hash data is assumed to already be symbolized. * *Parameters* - [H...
[ "Recursively", "fetch", "value", "for", "key", "path", "in", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L336-L354
5,917
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.modify
def modify(data, keys, value = nil, delete_nil = false, &block) # :yields: key, value, existing if keys.is_a?(String) || keys.is_a?(Symbol) keys = [ keys ] end keys = keys.flatten.compact key = keys.shift has_key = data.has_key?(key) existing = { :key => key, :valu...
ruby
def modify(data, keys, value = nil, delete_nil = false, &block) # :yields: key, value, existing if keys.is_a?(String) || keys.is_a?(Symbol) keys = [ keys ] end keys = keys.flatten.compact key = keys.shift has_key = data.has_key?(key) existing = { :key => key, :valu...
[ "def", "modify", "(", "data", ",", "keys", ",", "value", "=", "nil", ",", "delete_nil", "=", "false", ",", "&", "block", ")", "# :yields: key, value, existing", "if", "keys", ".", "is_a?", "(", "String", ")", "||", "keys", ".", "is_a?", "(", "Symbol", ...
Modify value for key path in the configuration object. This method serves as a base modifier to the properties that are defined in the central property collection. It is used and built upon by other modifiers defined in the class. Hash data is assumed to already be symbolized. * *Parameters* - [Hash] *data*...
[ "Modify", "value", "for", "key", "path", "in", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L385-L416
5,918
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.get
def get(keys, default = nil, format = false) return fetch(@properties, symbol_array(array(keys).flatten), default, format) end
ruby
def get(keys, default = nil, format = false) return fetch(@properties, symbol_array(array(keys).flatten), default, format) end
[ "def", "get", "(", "keys", ",", "default", "=", "nil", ",", "format", "=", "false", ")", "return", "fetch", "(", "@properties", ",", "symbol_array", "(", "array", "(", "keys", ")", ".", "flatten", ")", ",", "default", ",", "format", ")", "end" ]
Fetch value for key path in the configuration object. * *Parameters* - [Array<String, Symbol>, String, Symbol] *keys* Key path to fetch - [ANY] *default* Default value is no value is found for key path - [false, Symbol, String] *format* Format to filter final returned value or false for none * *Returns*...
[ "Fetch", "value", "for", "key", "path", "in", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L437-L439
5,919
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.set
def set(keys, value, delete_nil = false, &code) # :yields: key, value, existing modify(@properties, symbol_array(array(keys).flatten), value, delete_nil, &code) return self end
ruby
def set(keys, value, delete_nil = false, &code) # :yields: key, value, existing modify(@properties, symbol_array(array(keys).flatten), value, delete_nil, &code) return self end
[ "def", "set", "(", "keys", ",", "value", ",", "delete_nil", "=", "false", ",", "&", "code", ")", "# :yields: key, value, existing", "modify", "(", "@properties", ",", "symbol_array", "(", "array", "(", "keys", ")", ".", "flatten", ")", ",", "value", ",", ...
Set value for key path in the configuration object. * *Parameters* - [Array<String, Symbol>, String, Symbol] *keys* Key path to modify - [ANY] *value* Value to set for key path - [Boolean] *delete_nil* Delete nil value (serves as an internal way to delete properties) * *Returns* - [Nucleon::Config] ...
[ "Set", "value", "for", "key", "path", "in", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L550-L553
5,920
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.append
def append(keys, value) modify(@properties, symbol_array(array(keys).flatten), value, false) do |key, processed_value, existing| if existing.is_a?(Array) [ existing, processed_value ].flatten else [ processed_value ] end end return self end
ruby
def append(keys, value) modify(@properties, symbol_array(array(keys).flatten), value, false) do |key, processed_value, existing| if existing.is_a?(Array) [ existing, processed_value ].flatten else [ processed_value ] end end return self end
[ "def", "append", "(", "keys", ",", "value", ")", "modify", "(", "@properties", ",", "symbol_array", "(", "array", "(", "keys", ")", ".", "flatten", ")", ",", "value", ",", "false", ")", "do", "|", "key", ",", "processed_value", ",", "existing", "|", ...
Append a value for an array key path in the configuration object. * *Parameters* - [Array<String, Symbol>, String, Symbol] *keys* Key path to modify - [ANY] *value* Value to set for key path * *Returns* - [Nucleon::Config] Returns reference to self for compound operations * *Errors* See: - #modify ...
[ "Append", "a", "value", "for", "an", "array", "key", "path", "in", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L572-L581
5,921
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.prepend
def prepend(keys, value, reverse = false) modify(@properties, symbol_array(array(keys).flatten), value, false) do |key, processed_value, existing| processed_value = processed_value.reverse if reverse && processed_value.is_a?(Array) if existing.is_a?(Array) [ processed_value, existing ].flatten ...
ruby
def prepend(keys, value, reverse = false) modify(@properties, symbol_array(array(keys).flatten), value, false) do |key, processed_value, existing| processed_value = processed_value.reverse if reverse && processed_value.is_a?(Array) if existing.is_a?(Array) [ processed_value, existing ].flatten ...
[ "def", "prepend", "(", "keys", ",", "value", ",", "reverse", "=", "false", ")", "modify", "(", "@properties", ",", "symbol_array", "(", "array", "(", "keys", ")", ".", "flatten", ")", ",", "value", ",", "false", ")", "do", "|", "key", ",", "processed...
Prepend a value to an array key path in the configuration object. * *Parameters* - [Array<String, Symbol>, String, Symbol] *keys* Key path to modify - [ANY] *value* Value to set for key path - [Boolean] *reverse* Whether or not to reverse any input value arrays given before prepending * *Returns* - [...
[ "Prepend", "a", "value", "to", "an", "array", "key", "path", "in", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L601-L612
5,922
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.delete
def delete(keys, default = nil) existing = modify(@properties, symbol_array(array(keys).flatten), nil, true) return existing[:value] unless existing[:value].nil? return default end
ruby
def delete(keys, default = nil) existing = modify(@properties, symbol_array(array(keys).flatten), nil, true) return existing[:value] unless existing[:value].nil? return default end
[ "def", "delete", "(", "keys", ",", "default", "=", "nil", ")", "existing", "=", "modify", "(", "@properties", ",", "symbol_array", "(", "array", "(", "keys", ")", ".", "flatten", ")", ",", "nil", ",", "true", ")", "return", "existing", "[", ":value", ...
Delete key path from the configuration object. * *Parameters* - [Array<String, Symbol>, String, Symbol] *keys* Key path to remove - [ANY] *default* Default value to return if no existing value found * *Returns* - [ANY] Returns default or last value removed from configuration object * *Errors* See: ...
[ "Delete", "key", "path", "from", "the", "configuration", "object", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L652-L656
5,923
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.defaults
def defaults(defaults, options = {}) config = Config.new(options).set(:import_type, :default) return import_base(defaults, config) end
ruby
def defaults(defaults, options = {}) config = Config.new(options).set(:import_type, :default) return import_base(defaults, config) end
[ "def", "defaults", "(", "defaults", ",", "options", "=", "{", "}", ")", "config", "=", "Config", ".", "new", "(", "options", ")", ".", "set", "(", ":import_type", ",", ":default", ")", "return", "import_base", "(", "defaults", ",", "config", ")", "end"...
Set default property values in the configuration object if they don't exist. If defaults are given as a string or symbol and the configuration object has a lookup method implemented (corl gem) then the defaults will be dynamically looked up and set. * *Parameters* - [String, Symbol, Array, Hash] *defaults* Da...
[ "Set", "default", "property", "values", "in", "the", "configuration", "object", "if", "they", "don", "t", "exist", "." ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L780-L783
5,924
coralnexus/nucleon
lib/core/config.rb
Nucleon.Config.symbol_array
def symbol_array(array) result = [] array.each do |item| result << item.to_sym unless item.nil? end result end
ruby
def symbol_array(array) result = [] array.each do |item| result << item.to_sym unless item.nil? end result end
[ "def", "symbol_array", "(", "array", ")", "result", "=", "[", "]", "array", ".", "each", "do", "|", "item", "|", "result", "<<", "item", ".", "to_sym", "unless", "item", ".", "nil?", "end", "result", "end" ]
Return a symbolized array * *Parameters* - [Array<String, Symbol>] *array* Array of strings or symbols * *Returns* - [Array<Symbol>] Returns array of symbols * *Errors*
[ "Return", "a", "symbolized", "array" ]
3a3c489251139c184e0884feaa55269cf64cad44
https://github.com/coralnexus/nucleon/blob/3a3c489251139c184e0884feaa55269cf64cad44/lib/core/config.rb#L835-L841
5,925
OutlawAndy/stripe_local
lib/stripe_local/instance_delegation.rb
StripeLocal.InstanceDelegation.signup
def signup params plan = params.delete( :plan ) lines = params.delete( :lines ) || [] _customer_ = Stripe::Customer.create( params ) lines.each do |(amount,desc)| _customer_.add_invoice_item({currency: 'usd', amount: amount, description: desc}) end _customer_.update_subscr...
ruby
def signup params plan = params.delete( :plan ) lines = params.delete( :lines ) || [] _customer_ = Stripe::Customer.create( params ) lines.each do |(amount,desc)| _customer_.add_invoice_item({currency: 'usd', amount: amount, description: desc}) end _customer_.update_subscr...
[ "def", "signup", "params", "plan", "=", "params", ".", "delete", "(", ":plan", ")", "lines", "=", "params", ".", "delete", "(", ":lines", ")", "||", "[", "]", "_customer_", "=", "Stripe", "::", "Customer", ".", "create", "(", "params", ")", "lines", ...
==this is the primary interface for subscribing. params:: * +card+ (required) -> the token returned by stripe.js * +plan+ (required) -> the id of the plan being subscribed to * +email+ (optional) -> the client's email address * +description+ (optional) ...
[ "==", "this", "is", "the", "primary", "interface", "for", "subscribing", "." ]
78b685d1b35a848e02d19e4c57015f2a02fdc882
https://github.com/OutlawAndy/stripe_local/blob/78b685d1b35a848e02d19e4c57015f2a02fdc882/lib/stripe_local/instance_delegation.rb#L20-L32
5,926
barkerest/barkest_core
lib/barkest_core/extensions/axlsx_extenstions.rb
Axlsx.Package.simple
def simple(name = nil) workbook.add_worksheet(name: name || 'Sheet 1') do |sheet| yield sheet, workbook.predefined_styles if block_given? sheet.add_row end end
ruby
def simple(name = nil) workbook.add_worksheet(name: name || 'Sheet 1') do |sheet| yield sheet, workbook.predefined_styles if block_given? sheet.add_row end end
[ "def", "simple", "(", "name", "=", "nil", ")", "workbook", ".", "add_worksheet", "(", "name", ":", "name", "||", "'Sheet 1'", ")", "do", "|", "sheet", "|", "yield", "sheet", ",", "workbook", ".", "predefined_styles", "if", "block_given?", "sheet", ".", "...
Creates a simple workbook with one sheet. Predefines multiple styles that can be used to format cells. The +sheet+ and +styles+ are yielded to the provided block. See Axlsx::Workbook#predefined_styles for a list of predefined styles.
[ "Creates", "a", "simple", "workbook", "with", "one", "sheet", "." ]
3eeb025ec870888cacbc9bae252a39ebf9295f61
https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/lib/barkest_core/extensions/axlsx_extenstions.rb#L19-L24
5,927
barkerest/barkest_core
lib/barkest_core/extensions/axlsx_extenstions.rb
Axlsx.Workbook.predefined_styles
def predefined_styles @predefined_styles ||= begin tmp = {} styles do |s| tmp = { bold: s.add_style(b: true, alignment: { vertical: :top }), date: s.add_style(format_code: 'mm/dd/yyyy', alignment: { vertical: :t...
ruby
def predefined_styles @predefined_styles ||= begin tmp = {} styles do |s| tmp = { bold: s.add_style(b: true, alignment: { vertical: :top }), date: s.add_style(format_code: 'mm/dd/yyyy', alignment: { vertical: :t...
[ "def", "predefined_styles", "@predefined_styles", "||=", "begin", "tmp", "=", "{", "}", "styles", "do", "|", "s", "|", "tmp", "=", "{", "bold", ":", "s", ".", "add_style", "(", "b", ":", "true", ",", "alignment", ":", "{", "vertical", ":", ":top", "}...
Gets the predefined style list. The +predefined_styles+ hash contains :bold, :date, :float, :integer, :percent, :currency, :text, :wrapped, and :normal styles for you to use.
[ "Gets", "the", "predefined", "style", "list", "." ]
3eeb025ec870888cacbc9bae252a39ebf9295f61
https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/lib/barkest_core/extensions/axlsx_extenstions.rb#L50-L69
5,928
barkerest/barkest_core
lib/barkest_core/extensions/axlsx_extenstions.rb
Axlsx.Worksheet.add_combined_row
def add_combined_row(row_data, keys = [ :value, :style, :type ]) val_index = keys.index(:value) || keys.index('value') style_index = keys.index(:style) || keys.index('style') type_index = keys.index(:type) || keys.index('type') raise ArgumentError.new('Missing :value key') unless val_index...
ruby
def add_combined_row(row_data, keys = [ :value, :style, :type ]) val_index = keys.index(:value) || keys.index('value') style_index = keys.index(:style) || keys.index('style') type_index = keys.index(:type) || keys.index('type') raise ArgumentError.new('Missing :value key') unless val_index...
[ "def", "add_combined_row", "(", "row_data", ",", "keys", "=", "[", ":value", ",", ":style", ",", ":type", "]", ")", "val_index", "=", "keys", ".", "index", "(", ":value", ")", "||", "keys", ".", "index", "(", "'value'", ")", "style_index", "=", "keys",...
Adds a row to the worksheet with combined data. Currently we support specifying the +values+, +styles+, and +types+ using this method. The +row_data+ value should be an array of arrays. Each subarray represents a value in the row with up to three values specifying the +value+, +style+, and +type+. Value is the on...
[ "Adds", "a", "row", "to", "the", "worksheet", "with", "combined", "data", "." ]
3eeb025ec870888cacbc9bae252a39ebf9295f61
https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/lib/barkest_core/extensions/axlsx_extenstions.rb#L135-L153
5,929
jinx/migrate
spec/csv/join/join_helper.rb
Jinx.JoinHelper.join
def join(source, target, *fields, &block) FileUtils.rm_rf OUTPUT sf = File.expand_path("#{source}.csv", File.dirname(__FILE__)) tf = File.expand_path("#{target}.csv", File.dirname(__FILE__)) Jinx::CsvIO.join(sf, :to => tf, :for => fields, :as => OUTPUT, &block) if File.exists?(OUTPUT) then...
ruby
def join(source, target, *fields, &block) FileUtils.rm_rf OUTPUT sf = File.expand_path("#{source}.csv", File.dirname(__FILE__)) tf = File.expand_path("#{target}.csv", File.dirname(__FILE__)) Jinx::CsvIO.join(sf, :to => tf, :for => fields, :as => OUTPUT, &block) if File.exists?(OUTPUT) then...
[ "def", "join", "(", "source", ",", "target", ",", "*", "fields", ",", "&", "block", ")", "FileUtils", ".", "rm_rf", "OUTPUT", "sf", "=", "File", ".", "expand_path", "(", "\"#{source}.csv\"", ",", "File", ".", "dirname", "(", "__FILE__", ")", ")", "tf",...
Joins the given source fixture to the target fixture on the specified fields. @param [Symbol] source the source file fixture in the join spec directory @param [Symbol] target the target file fixture in the join spec directory @param [<String>] fields the source fields (default is all source fields) @return [<<Stri...
[ "Joins", "the", "given", "source", "fixture", "to", "the", "target", "fixture", "on", "the", "specified", "fields", "." ]
309957a470d72da3bd074f8173dbbe2f12449883
https://github.com/jinx/migrate/blob/309957a470d72da3bd074f8173dbbe2f12449883/spec/csv/join/join_helper.rb#L21-L33
5,930
tatemae/muck-engine
lib/muck-engine/form_builder.rb
MuckEngine.FormBuilder.state_select
def state_select(method, options = {}, html_options = {}, additional_state = nil) country_id_field_name = options.delete(:country_id) || 'country_id' country_id = get_instance_object_value(country_id_field_name) @states = country_id.nil? ? [] : (additional_state ? [additional_state] : []) + State.find...
ruby
def state_select(method, options = {}, html_options = {}, additional_state = nil) country_id_field_name = options.delete(:country_id) || 'country_id' country_id = get_instance_object_value(country_id_field_name) @states = country_id.nil? ? [] : (additional_state ? [additional_state] : []) + State.find...
[ "def", "state_select", "(", "method", ",", "options", "=", "{", "}", ",", "html_options", "=", "{", "}", ",", "additional_state", "=", "nil", ")", "country_id_field_name", "=", "options", ".", "delete", "(", ":country_id", ")", "||", "'country_id'", "country...
creates a select control with states. Default id is 'states'. If 'retain' is passed for the class value the value of this control will be written into a cookie with the key 'states'.
[ "creates", "a", "select", "control", "with", "states", ".", "Default", "id", "is", "states", ".", "If", "retain", "is", "passed", "for", "the", "class", "value", "the", "value", "of", "this", "control", "will", "be", "written", "into", "a", "cookie", "wi...
41fc072dce3a365b3ce4a73d4f60a4ff24026d51
https://github.com/tatemae/muck-engine/blob/41fc072dce3a365b3ce4a73d4f60a4ff24026d51/lib/muck-engine/form_builder.rb#L149-L154
5,931
tatemae/muck-engine
lib/muck-engine/form_builder.rb
MuckEngine.FormBuilder.country_select
def country_select(method, options = {}, html_options = {}, additional_country = nil) @countries ||= (additional_country ? [additional_country] : []) + Country.find(:all, :order => 'sort, name asc') self.menu_select(method, I18n.t('muck.engine.choose_country'), @countries, options.merge(:prompt => I18n.t('m...
ruby
def country_select(method, options = {}, html_options = {}, additional_country = nil) @countries ||= (additional_country ? [additional_country] : []) + Country.find(:all, :order => 'sort, name asc') self.menu_select(method, I18n.t('muck.engine.choose_country'), @countries, options.merge(:prompt => I18n.t('m...
[ "def", "country_select", "(", "method", ",", "options", "=", "{", "}", ",", "html_options", "=", "{", "}", ",", "additional_country", "=", "nil", ")", "@countries", "||=", "(", "additional_country", "?", "[", "additional_country", "]", ":", "[", "]", ")", ...
creates a select control with countries. Default id is 'countries'. If 'retain' is passed for the class value the value of this control will be written into a cookie with the key 'countries'.
[ "creates", "a", "select", "control", "with", "countries", ".", "Default", "id", "is", "countries", ".", "If", "retain", "is", "passed", "for", "the", "class", "value", "the", "value", "of", "this", "control", "will", "be", "written", "into", "a", "cookie",...
41fc072dce3a365b3ce4a73d4f60a4ff24026d51
https://github.com/tatemae/muck-engine/blob/41fc072dce3a365b3ce4a73d4f60a4ff24026d51/lib/muck-engine/form_builder.rb#L158-L161
5,932
tatemae/muck-engine
lib/muck-engine/form_builder.rb
MuckEngine.FormBuilder.language_select
def language_select(method, options = {}, html_options = {}, additional_language = nil) @languages ||= (additional_language ? [additional_language] : []) + Language.find(:all, :order => 'name asc') self.menu_select(method, I18n.t('muck.engine.choose_language'), @languages, options.merge(:prompt => I18n.t('m...
ruby
def language_select(method, options = {}, html_options = {}, additional_language = nil) @languages ||= (additional_language ? [additional_language] : []) + Language.find(:all, :order => 'name asc') self.menu_select(method, I18n.t('muck.engine.choose_language'), @languages, options.merge(:prompt => I18n.t('m...
[ "def", "language_select", "(", "method", ",", "options", "=", "{", "}", ",", "html_options", "=", "{", "}", ",", "additional_language", "=", "nil", ")", "@languages", "||=", "(", "additional_language", "?", "[", "additional_language", "]", ":", "[", "]", "...
creates a select control with languages. Default id is 'languages'. If 'retain' is passed for the class value the value of this control will be written into a cookie with the key 'languages'.
[ "creates", "a", "select", "control", "with", "languages", ".", "Default", "id", "is", "languages", ".", "If", "retain", "is", "passed", "for", "the", "class", "value", "the", "value", "of", "this", "control", "will", "be", "written", "into", "a", "cookie",...
41fc072dce3a365b3ce4a73d4f60a4ff24026d51
https://github.com/tatemae/muck-engine/blob/41fc072dce3a365b3ce4a73d4f60a4ff24026d51/lib/muck-engine/form_builder.rb#L165-L168
5,933
barkerest/incline
lib/incline/auth_engine_base.rb
Incline.AuthEngineBase.add_success_to
def add_success_to(user, message, client_ip) # :doc: Incline::Log::info "LOGIN(#{user}) SUCCESS FROM #{client_ip}: #{message}" purge_old_history_for user user.login_histories.create(ip_address: client_ip, successful: true, message: message) end
ruby
def add_success_to(user, message, client_ip) # :doc: Incline::Log::info "LOGIN(#{user}) SUCCESS FROM #{client_ip}: #{message}" purge_old_history_for user user.login_histories.create(ip_address: client_ip, successful: true, message: message) end
[ "def", "add_success_to", "(", "user", ",", "message", ",", "client_ip", ")", "# :doc:", "Incline", "::", "Log", "::", "info", "\"LOGIN(#{user}) SUCCESS FROM #{client_ip}: #{message}\"", "purge_old_history_for", "user", "user", ".", "login_histories", ".", "create", "(",...
Logs a success message for a user.
[ "Logs", "a", "success", "message", "for", "a", "user", "." ]
1ff08db7aa8ab7f86b223268b700bc67d15bb8aa
https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/auth_engine_base.rb#L53-L57
5,934
khiemns54/sp2db
lib/sp2db/config.rb
Sp2db.Config.credential=
def credential=cr if File.exist?(cr) && File.file?(cr) cr = File.read cr end @credential = case cr when Hash, ActiveSupport::HashWithIndifferentAccess cr when String JSON.parse cr else raise "Invalid data type" end end
ruby
def credential=cr if File.exist?(cr) && File.file?(cr) cr = File.read cr end @credential = case cr when Hash, ActiveSupport::HashWithIndifferentAccess cr when String JSON.parse cr else raise "Invalid data type" end end
[ "def", "credential", "=", "cr", "if", "File", ".", "exist?", "(", "cr", ")", "&&", "File", ".", "file?", "(", "cr", ")", "cr", "=", "File", ".", "read", "cr", "end", "@credential", "=", "case", "cr", "when", "Hash", ",", "ActiveSupport", "::", "Has...
File name or json string or hash
[ "File", "name", "or", "json", "string", "or", "hash" ]
76c78df07ea19d6f1b5ff2e883ae206a0e94de27
https://github.com/khiemns54/sp2db/blob/76c78df07ea19d6f1b5ff2e883ae206a0e94de27/lib/sp2db/config.rb#L53-L66
5,935
PragTob/wingtips
lib/wingtips/slide.rb
Wingtips.Slide.method_missing
def method_missing(method, *args, &blk) if app_should_handle_method? method app.send(method, *args, &blk) else super end end
ruby
def method_missing(method, *args, &blk) if app_should_handle_method? method app.send(method, *args, &blk) else super end end
[ "def", "method_missing", "(", "method", ",", "*", "args", ",", "&", "blk", ")", "if", "app_should_handle_method?", "method", "app", ".", "send", "(", "method", ",", "args", ",", "blk", ")", "else", "super", "end", "end" ]
copied from the URL implementation... weird but I want to have classes not methods for this
[ "copied", "from", "the", "URL", "implementation", "...", "weird", "but", "I", "want", "to", "have", "classes", "not", "methods", "for", "this" ]
df47ecdf19fdd9e7091e96232a24c2d7fb43a3ab
https://github.com/PragTob/wingtips/blob/df47ecdf19fdd9e7091e96232a24c2d7fb43a3ab/lib/wingtips/slide.rb#L43-L49
5,936
right-solutions/usman
app/helpers/usman/authentication_helper.rb
Usman.AuthenticationHelper.require_super_admin
def require_super_admin unless @current_user.super_admin? text = "#{I18n.t("authentication.permission_denied.heading")}: #{I18n.t("authentication.permission_denied.message")}" set_flash_message(text, :error, false) if defined?(flash) && flash redirect_or_popup_to_default_sign_in_page(false...
ruby
def require_super_admin unless @current_user.super_admin? text = "#{I18n.t("authentication.permission_denied.heading")}: #{I18n.t("authentication.permission_denied.message")}" set_flash_message(text, :error, false) if defined?(flash) && flash redirect_or_popup_to_default_sign_in_page(false...
[ "def", "require_super_admin", "unless", "@current_user", ".", "super_admin?", "text", "=", "\"#{I18n.t(\"authentication.permission_denied.heading\")}: #{I18n.t(\"authentication.permission_denied.message\")}\"", "set_flash_message", "(", "text", ",", ":error", ",", "false", ")", "if...
This method is usually used as a before filter from admin controllers to ensure that the logged in user is a super admin
[ "This", "method", "is", "usually", "used", "as", "a", "before", "filter", "from", "admin", "controllers", "to", "ensure", "that", "the", "logged", "in", "user", "is", "a", "super", "admin" ]
66bc427a03d0ed96ab7239c0b3969d566251a7f7
https://github.com/right-solutions/usman/blob/66bc427a03d0ed96ab7239c0b3969d566251a7f7/app/helpers/usman/authentication_helper.rb#L111-L117
5,937
pjb3/curtain
lib/curtain/rendering.rb
Curtain.Rendering.render
def render(*args) name = get_template_name(*args) locals = args.last.is_a?(Hash) ? args.last : {} # TODO: Cache Template objects template_file = self.class.find_template(name) ext = template_file.split('.').last orig_buffer = @output_buffer @output_buffer = Curtain::OutputBu...
ruby
def render(*args) name = get_template_name(*args) locals = args.last.is_a?(Hash) ? args.last : {} # TODO: Cache Template objects template_file = self.class.find_template(name) ext = template_file.split('.').last orig_buffer = @output_buffer @output_buffer = Curtain::OutputBu...
[ "def", "render", "(", "*", "args", ")", "name", "=", "get_template_name", "(", "args", ")", "locals", "=", "args", ".", "last", ".", "is_a?", "(", "Hash", ")", "?", "args", ".", "last", ":", "{", "}", "# TODO: Cache Template objects", "template_file", "=...
Renders the template @example Render the default template view.render @example Render the foo template view.render "foo.slim" @example You can use symbols and omit the extension view.render :foo @example You can specify what the local variables for the template should be view.render :foo, :bar => "b...
[ "Renders", "the", "template" ]
ab4f3dccea9b887148689084137f1375278f2dcf
https://github.com/pjb3/curtain/blob/ab4f3dccea9b887148689084137f1375278f2dcf/lib/curtain/rendering.rb#L30-L53
5,938
Bastes/CellularMap
lib/cellular_map/map.rb
CellularMap.Map.[]
def [](x, y) if x.respond_to?(:to_i) && y.respond_to?(:to_i) Cell.new(x, y, self) else Zone.new(x, y, self) end end
ruby
def [](x, y) if x.respond_to?(:to_i) && y.respond_to?(:to_i) Cell.new(x, y, self) else Zone.new(x, y, self) end end
[ "def", "[]", "(", "x", ",", "y", ")", "if", "x", ".", "respond_to?", "(", ":to_i", ")", "&&", "y", ".", "respond_to?", "(", ":to_i", ")", "Cell", ".", "new", "(", "x", ",", "y", ",", "self", ")", "else", "Zone", ".", "new", "(", "x", ",", "...
Accessing a cell or a zone.
[ "Accessing", "a", "cell", "or", "a", "zone", "." ]
e9cfa44ce820b16cdc5ca5b59291e80e53363d1f
https://github.com/Bastes/CellularMap/blob/e9cfa44ce820b16cdc5ca5b59291e80e53363d1f/lib/cellular_map/map.rb#L21-L27
5,939
Bastes/CellularMap
lib/cellular_map/map.rb
CellularMap.Map.[]=
def []=(x, y, content) if content.nil? @store.delete([x, y]) && nil else @store[[x, y]] = content end end
ruby
def []=(x, y, content) if content.nil? @store.delete([x, y]) && nil else @store[[x, y]] = content end end
[ "def", "[]=", "(", "x", ",", "y", ",", "content", ")", "if", "content", ".", "nil?", "@store", ".", "delete", "(", "[", "x", ",", "y", "]", ")", "&&", "nil", "else", "@store", "[", "[", "x", ",", "y", "]", "]", "=", "content", "end", "end" ]
Putting new content in a cell.
[ "Putting", "new", "content", "in", "a", "cell", "." ]
e9cfa44ce820b16cdc5ca5b59291e80e53363d1f
https://github.com/Bastes/CellularMap/blob/e9cfa44ce820b16cdc5ca5b59291e80e53363d1f/lib/cellular_map/map.rb#L30-L36
5,940
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.create_new_node
def create_new_node(project_root, environment) # Ask the hostname for node hostname = ask_not_existing_hostname(project_root, environment) # Ask IP for node ip = ask_ip(environment) # Node creation node = Bebox::Node.new(environment, project_root, hostname, ip) output = node.cr...
ruby
def create_new_node(project_root, environment) # Ask the hostname for node hostname = ask_not_existing_hostname(project_root, environment) # Ask IP for node ip = ask_ip(environment) # Node creation node = Bebox::Node.new(environment, project_root, hostname, ip) output = node.cr...
[ "def", "create_new_node", "(", "project_root", ",", "environment", ")", "# Ask the hostname for node", "hostname", "=", "ask_not_existing_hostname", "(", "project_root", ",", "environment", ")", "# Ask IP for node", "ip", "=", "ask_ip", "(", "environment", ")", "# Node ...
Create a new node
[ "Create", "a", "new", "node" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L9-L19
5,941
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.remove_node
def remove_node(project_root, environment, hostname) # Ask for a node to remove nodes = Bebox::Node.list(project_root, environment, 'nodes') if nodes.count > 0 hostname = choose_option(nodes, _('wizard.node.choose_node')) else error _('wizard.node.no_nodes')%{environment: environ...
ruby
def remove_node(project_root, environment, hostname) # Ask for a node to remove nodes = Bebox::Node.list(project_root, environment, 'nodes') if nodes.count > 0 hostname = choose_option(nodes, _('wizard.node.choose_node')) else error _('wizard.node.no_nodes')%{environment: environ...
[ "def", "remove_node", "(", "project_root", ",", "environment", ",", "hostname", ")", "# Ask for a node to remove", "nodes", "=", "Bebox", "::", "Node", ".", "list", "(", "project_root", ",", "environment", ",", "'nodes'", ")", "if", "nodes", ".", "count", ">",...
Removes an existing node
[ "Removes", "an", "existing", "node" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L22-L38
5,942
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.set_role
def set_role(project_root, environment) roles = Bebox::Role.list(project_root) nodes = Bebox::Node.list(project_root, environment, 'nodes') node = choose_option(nodes, _('wizard.choose_node')) role = choose_option(roles, _('wizard.choose_role')) output = Bebox::Provision.associate_node_rol...
ruby
def set_role(project_root, environment) roles = Bebox::Role.list(project_root) nodes = Bebox::Node.list(project_root, environment, 'nodes') node = choose_option(nodes, _('wizard.choose_node')) role = choose_option(roles, _('wizard.choose_role')) output = Bebox::Provision.associate_node_rol...
[ "def", "set_role", "(", "project_root", ",", "environment", ")", "roles", "=", "Bebox", "::", "Role", ".", "list", "(", "project_root", ")", "nodes", "=", "Bebox", "::", "Node", ".", "list", "(", "project_root", ",", "environment", ",", "'nodes'", ")", "...
Associate a role with a node in a environment
[ "Associate", "a", "role", "with", "a", "node", "in", "a", "environment" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L41-L49
5,943
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.prepare
def prepare(project_root, environment) # Check already prepared nodes nodes_to_prepare = check_nodes_to_prepare(project_root, environment) # Output the nodes to be prepared if nodes_to_prepare.count > 0 title _('wizard.node.prepare_title') nodes_to_prepare.each{|node| msg(node.ho...
ruby
def prepare(project_root, environment) # Check already prepared nodes nodes_to_prepare = check_nodes_to_prepare(project_root, environment) # Output the nodes to be prepared if nodes_to_prepare.count > 0 title _('wizard.node.prepare_title') nodes_to_prepare.each{|node| msg(node.ho...
[ "def", "prepare", "(", "project_root", ",", "environment", ")", "# Check already prepared nodes", "nodes_to_prepare", "=", "check_nodes_to_prepare", "(", "project_root", ",", "environment", ")", "# Output the nodes to be prepared", "if", "nodes_to_prepare", ".", "count", ">...
Prepare the nodes in a environment
[ "Prepare", "the", "nodes", "in", "a", "environment" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L52-L73
5,944
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.check_nodes_to_prepare
def check_nodes_to_prepare(project_root, environment) nodes_to_prepare = [] nodes = Bebox::Node.nodes_in_environment(project_root, environment, 'nodes') prepared_nodes = Bebox::Node.list(project_root, environment, 'prepared_nodes') nodes.each do |node| if prepared_nodes.include?(node.hos...
ruby
def check_nodes_to_prepare(project_root, environment) nodes_to_prepare = [] nodes = Bebox::Node.nodes_in_environment(project_root, environment, 'nodes') prepared_nodes = Bebox::Node.list(project_root, environment, 'prepared_nodes') nodes.each do |node| if prepared_nodes.include?(node.hos...
[ "def", "check_nodes_to_prepare", "(", "project_root", ",", "environment", ")", "nodes_to_prepare", "=", "[", "]", "nodes", "=", "Bebox", "::", "Node", ".", "nodes_in_environment", "(", "project_root", ",", "environment", ",", "'nodes'", ")", "prepared_nodes", "=",...
Check the nodes already prepared and ask confirmation to re-do-it
[ "Check", "the", "nodes", "already", "prepared", "and", "ask", "confirmation", "to", "re", "-", "do", "-", "it" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L82-L95
5,945
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.ask_not_existing_hostname
def ask_not_existing_hostname(project_root, environment) hostname = ask_hostname(project_root, environment) # Check if the node not exist if node_exists?(project_root, environment, hostname) error _('wizard.node.hostname_exist') ask_hostname(project_root, environment) else ...
ruby
def ask_not_existing_hostname(project_root, environment) hostname = ask_hostname(project_root, environment) # Check if the node not exist if node_exists?(project_root, environment, hostname) error _('wizard.node.hostname_exist') ask_hostname(project_root, environment) else ...
[ "def", "ask_not_existing_hostname", "(", "project_root", ",", "environment", ")", "hostname", "=", "ask_hostname", "(", "project_root", ",", "environment", ")", "# Check if the node not exist", "if", "node_exists?", "(", "project_root", ",", "environment", ",", "hostnam...
Keep asking for a hostname that not exist
[ "Keep", "asking", "for", "a", "hostname", "that", "not", "exist" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L103-L112
5,946
codescrum/bebox
lib/bebox/wizards/node_wizard.rb
Bebox.NodeWizard.ask_ip
def ask_ip(environment) ip = write_input(_('wizard.node.ask_ip'), nil, /\.(.*)/, _('wizard.node.valid_ip')) # If the environment is not vagrant don't check ip free return ip if environment != 'vagrant' # Check if the ip address is free if free_ip?(ip) return ip else e...
ruby
def ask_ip(environment) ip = write_input(_('wizard.node.ask_ip'), nil, /\.(.*)/, _('wizard.node.valid_ip')) # If the environment is not vagrant don't check ip free return ip if environment != 'vagrant' # Check if the ip address is free if free_ip?(ip) return ip else e...
[ "def", "ask_ip", "(", "environment", ")", "ip", "=", "write_input", "(", "_", "(", "'wizard.node.ask_ip'", ")", ",", "nil", ",", "/", "\\.", "/", ",", "_", "(", "'wizard.node.valid_ip'", ")", ")", "# If the environment is not vagrant don't check ip free", "return"...
Ask for the ip until is valid
[ "Ask", "for", "the", "ip", "until", "is", "valid" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/node_wizard.rb#L120-L131
5,947
arscan/mintkit
lib/mintkit/client.rb
Mintkit.Client.transactions
def transactions raw_transactions = @agent.get("https://wwws.mint.com/transactionDownload.event?").body transos = [] raw_transactions.split("\n").each_with_index do |line,index| if index > 1 line_array = line.split(",") transaction = { :date => Date.strptime(...
ruby
def transactions raw_transactions = @agent.get("https://wwws.mint.com/transactionDownload.event?").body transos = [] raw_transactions.split("\n").each_with_index do |line,index| if index > 1 line_array = line.split(",") transaction = { :date => Date.strptime(...
[ "def", "transactions", "raw_transactions", "=", "@agent", ".", "get", "(", "\"https://wwws.mint.com/transactionDownload.event?\"", ")", ".", "body", "transos", "=", "[", "]", "raw_transactions", ".", "split", "(", "\"\\n\"", ")", ".", "each_with_index", "do", "|", ...
login to my account get all the transactions
[ "login", "to", "my", "account", "get", "all", "the", "transactions" ]
b1f7a87b3f10f0e8d7144d6f3e7c778cfbd2b265
https://github.com/arscan/mintkit/blob/b1f7a87b3f10f0e8d7144d6f3e7c778cfbd2b265/lib/mintkit/client.rb#L19-L50
5,948
flyingmachine/whoops_logger
lib/whoops_logger/configuration.rb
WhoopsLogger.Configuration.set_with_string
def set_with_string(config) if File.exists?(config) set_with_yaml(File.read(config)) else set_with_yaml(config) end end
ruby
def set_with_string(config) if File.exists?(config) set_with_yaml(File.read(config)) else set_with_yaml(config) end end
[ "def", "set_with_string", "(", "config", ")", "if", "File", ".", "exists?", "(", "config", ")", "set_with_yaml", "(", "File", ".", "read", "(", "config", ")", ")", "else", "set_with_yaml", "(", "config", ")", "end", "end" ]
String should be either a filename or YAML
[ "String", "should", "be", "either", "a", "filename", "or", "YAML" ]
e1db5362b67c58f60018c9e0d653094fbe286014
https://github.com/flyingmachine/whoops_logger/blob/e1db5362b67c58f60018c9e0d653094fbe286014/lib/whoops_logger/configuration.rb#L106-L112
5,949
kete/kete_trackable_items
lib/kete_trackable_items/list_management_controllers.rb
KeteTrackableItems.ListManagementControllers.remove_from_list
def remove_from_list begin matching_results_ids = session[:matching_results_ids] matching_results_ids.delete(params[:remove_id].to_i) session[:matching_results_ids] = matching_results_ids render :nothing => true rescue render :nothing => true, :status => 500 end...
ruby
def remove_from_list begin matching_results_ids = session[:matching_results_ids] matching_results_ids.delete(params[:remove_id].to_i) session[:matching_results_ids] = matching_results_ids render :nothing => true rescue render :nothing => true, :status => 500 end...
[ "def", "remove_from_list", "begin", "matching_results_ids", "=", "session", "[", ":matching_results_ids", "]", "matching_results_ids", ".", "delete", "(", "params", "[", ":remove_id", "]", ".", "to_i", ")", "session", "[", ":matching_results_ids", "]", "=", "matchin...
assumes matching_results_ids in the session drops a given remove_id from the session variable
[ "assumes", "matching_results_ids", "in", "the", "session", "drops", "a", "given", "remove_id", "from", "the", "session", "variable" ]
5998ecd83967108c1ed1378161e43feb80d6b886
https://github.com/kete/kete_trackable_items/blob/5998ecd83967108c1ed1378161e43feb80d6b886/lib/kete_trackable_items/list_management_controllers.rb#L7-L16
5,950
kete/kete_trackable_items
lib/kete_trackable_items/list_management_controllers.rb
KeteTrackableItems.ListManagementControllers.restore_to_list
def restore_to_list begin matching_results_ids = session[:matching_results_ids] session[:matching_results_ids] = matching_results_ids << params[:restore_id].to_i render :nothing => true rescue render :nothing => true, :status => 500 end end
ruby
def restore_to_list begin matching_results_ids = session[:matching_results_ids] session[:matching_results_ids] = matching_results_ids << params[:restore_id].to_i render :nothing => true rescue render :nothing => true, :status => 500 end end
[ "def", "restore_to_list", "begin", "matching_results_ids", "=", "session", "[", ":matching_results_ids", "]", "session", "[", ":matching_results_ids", "]", "=", "matching_results_ids", "<<", "params", "[", ":restore_id", "]", ".", "to_i", "render", ":nothing", "=>", ...
assumes matching_results_ids in the session puts back a given restore_id in the session variable
[ "assumes", "matching_results_ids", "in", "the", "session", "puts", "back", "a", "given", "restore_id", "in", "the", "session", "variable" ]
5998ecd83967108c1ed1378161e43feb80d6b886
https://github.com/kete/kete_trackable_items/blob/5998ecd83967108c1ed1378161e43feb80d6b886/lib/kete_trackable_items/list_management_controllers.rb#L20-L28
5,951
Thermatix/ruta
lib/ruta/context.rb
Ruta.Context.sub_context
def sub_context id,ref,attribs={} @sub_contexts << ref self.elements[id] = { attributes: attribs, type: :sub_context, content: ref, } end
ruby
def sub_context id,ref,attribs={} @sub_contexts << ref self.elements[id] = { attributes: attribs, type: :sub_context, content: ref, } end
[ "def", "sub_context", "id", ",", "ref", ",", "attribs", "=", "{", "}", "@sub_contexts", "<<", "ref", "self", ".", "elements", "[", "id", "]", "=", "{", "attributes", ":", "attribs", ",", "type", ":", ":sub_context", ",", "content", ":", "ref", ",", "...
mount a context as a sub context here @param [Symbol] id of component to mount context to @param [Symbol] ref of context to be mounted @param [{Symbol => String,Number,Boolean}] list of attributes to attach to tag
[ "mount", "a", "context", "as", "a", "sub", "context", "here" ]
b4a6e3bc7c0c4b66c804023d638b173e3f61e157
https://github.com/Thermatix/ruta/blob/b4a6e3bc7c0c4b66c804023d638b173e3f61e157/lib/ruta/context.rb#L50-L57
5,952
smartdict/smartdict-core
lib/smartdict/translator/base.rb
Smartdict.Translator::Base.call
def call(word, opts) validate_opts!(opts) driver = Smartdict::Core::DriverManager.find(opts[:driver]) translation_model = Models::Translation.find(word, opts[:from_lang], opts[:to_lang], opts[:driver]) unless translation_model translation = driver.translate(word, opts[:from_lang], opts[...
ruby
def call(word, opts) validate_opts!(opts) driver = Smartdict::Core::DriverManager.find(opts[:driver]) translation_model = Models::Translation.find(word, opts[:from_lang], opts[:to_lang], opts[:driver]) unless translation_model translation = driver.translate(word, opts[:from_lang], opts[...
[ "def", "call", "(", "word", ",", "opts", ")", "validate_opts!", "(", "opts", ")", "driver", "=", "Smartdict", "::", "Core", "::", "DriverManager", ".", "find", "(", "opts", "[", ":driver", "]", ")", "translation_model", "=", "Models", "::", "Translation", ...
Just to make the interface compatible
[ "Just", "to", "make", "the", "interface", "compatible" ]
d2a83a7ca10daa085ffb740837891057a9c2bcea
https://github.com/smartdict/smartdict-core/blob/d2a83a7ca10daa085ffb740837891057a9c2bcea/lib/smartdict/translator/base.rb#L8-L19
5,953
mdoza/mongoid_multiparams
lib/mongoid_multiparams.rb
Mongoid.MultiParameterAttributes.process_attributes
def process_attributes(attrs = nil) if attrs errors = [] attributes = attrs.class.new attributes.permit! if attrs.respond_to?(:permitted?) && attrs.permitted? multi_parameter_attributes = {} attrs.each_pair do |key, value| if key =~ /\A([^\(]+)\((\d+)([if])\)$/ ...
ruby
def process_attributes(attrs = nil) if attrs errors = [] attributes = attrs.class.new attributes.permit! if attrs.respond_to?(:permitted?) && attrs.permitted? multi_parameter_attributes = {} attrs.each_pair do |key, value| if key =~ /\A([^\(]+)\((\d+)([if])\)$/ ...
[ "def", "process_attributes", "(", "attrs", "=", "nil", ")", "if", "attrs", "errors", "=", "[", "]", "attributes", "=", "attrs", ".", "class", ".", "new", "attributes", ".", "permit!", "if", "attrs", ".", "respond_to?", "(", ":permitted?", ")", "&&", "att...
Process the provided attributes casting them to their proper values if a field exists for them on the document. This will be limited to only the attributes provided in the suppied +Hash+ so that no extra nil values get put into the document's attributes. @example Process the attributes. person.process_attribute...
[ "Process", "the", "provided", "attributes", "casting", "them", "to", "their", "proper", "values", "if", "a", "field", "exists", "for", "them", "on", "the", "document", ".", "This", "will", "be", "limited", "to", "only", "the", "attributes", "provided", "in",...
9cbc4ed87a27f6635184b472ef2e5c4fc4160f74
https://github.com/mdoza/mongoid_multiparams/blob/9cbc4ed87a27f6635184b472ef2e5c4fc4160f74/lib/mongoid_multiparams.rb#L79-L115
5,954
inside-track/remi
lib/remi/data_subjects/s3_file.rb
Remi.Loader::S3File.load
def load(data) init_kms(@kms_opt) @logger.info "Writing file #{data} to S3 #{@bucket_name} as #{@remote_path}" s3.bucket(@bucket_name).object(@remote_path).upload_file(data, encrypt_args) true end
ruby
def load(data) init_kms(@kms_opt) @logger.info "Writing file #{data} to S3 #{@bucket_name} as #{@remote_path}" s3.bucket(@bucket_name).object(@remote_path).upload_file(data, encrypt_args) true end
[ "def", "load", "(", "data", ")", "init_kms", "(", "@kms_opt", ")", "@logger", ".", "info", "\"Writing file #{data} to S3 #{@bucket_name} as #{@remote_path}\"", "s3", ".", "bucket", "(", "@bucket_name", ")", ".", "object", "(", "@remote_path", ")", ".", "upload_file"...
Copies data to S3 @param data [Object] The path to the file in the temporary work location @return [true] On success
[ "Copies", "data", "to", "S3" ]
f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7
https://github.com/inside-track/remi/blob/f7e5f28f08f8c0403e04cd82d6fc14b6b2c362a7/lib/remi/data_subjects/s3_file.rb#L252-L258
5,955
OiNutter/skeletor
lib/skeletor/builder.rb
Skeletor.Builder.build_skeleton
def build_skeleton(dirs,path=@path) dirs.each{ |node| if node.kind_of?(Hash) && !node.empty?() node.each_pair{ |dir,content| dir = replace_tags(dir) puts 'Creating directory ' + File.join(path,di...
ruby
def build_skeleton(dirs,path=@path) dirs.each{ |node| if node.kind_of?(Hash) && !node.empty?() node.each_pair{ |dir,content| dir = replace_tags(dir) puts 'Creating directory ' + File.join(path,di...
[ "def", "build_skeleton", "(", "dirs", ",", "path", "=", "@path", ")", "dirs", ".", "each", "{", "|", "node", "|", "if", "node", ".", "kind_of?", "(", "Hash", ")", "&&", "!", "node", ".", "empty?", "(", ")", "node", ".", "each_pair", "{", "|", "di...
Builds the directory structure
[ "Builds", "the", "directory", "structure" ]
c3996c346bbf8009f7135855aabfd4f411aaa2e1
https://github.com/OiNutter/skeletor/blob/c3996c346bbf8009f7135855aabfd4f411aaa2e1/lib/skeletor/builder.rb#L46-L76
5,956
OiNutter/skeletor
lib/skeletor/builder.rb
Skeletor.Builder.write_file
def write_file(file,path) #if a pre-existing file is specified in the includes list, copy that, if not write a blank file if @template.includes.has_key?(file) begin content = Includes.copy_include(@template.includes[file],@template.path) file = replace_tags(file) re...
ruby
def write_file(file,path) #if a pre-existing file is specified in the includes list, copy that, if not write a blank file if @template.includes.has_key?(file) begin content = Includes.copy_include(@template.includes[file],@template.path) file = replace_tags(file) re...
[ "def", "write_file", "(", "file", ",", "path", ")", "#if a pre-existing file is specified in the includes list, copy that, if not write a blank file ", "if", "@template", ".", "includes", ".", "has_key?", "(", "file", ")", "begin", "content", "=", "Includes", ".", "c...
Checks if file is listed in the includes list and if so copies it from the given location. If not it creates a blank file.
[ "Checks", "if", "file", "is", "listed", "in", "the", "includes", "list", "and", "if", "so", "copies", "it", "from", "the", "given", "location", ".", "If", "not", "it", "creates", "a", "blank", "file", "." ]
c3996c346bbf8009f7135855aabfd4f411aaa2e1
https://github.com/OiNutter/skeletor/blob/c3996c346bbf8009f7135855aabfd4f411aaa2e1/lib/skeletor/builder.rb#L98-L114
5,957
OiNutter/skeletor
lib/skeletor/builder.rb
Skeletor.Builder.execute_tasks
def execute_tasks(tasks,template_path) if File.exists?(File.expand_path(File.join(template_path,'tasks.rb'))) load File.expand_path(File.join(template_path,'tasks.rb')) end tasks.each{ |task| puts 'Running Task: ' + task task = replace_t...
ruby
def execute_tasks(tasks,template_path) if File.exists?(File.expand_path(File.join(template_path,'tasks.rb'))) load File.expand_path(File.join(template_path,'tasks.rb')) end tasks.each{ |task| puts 'Running Task: ' + task task = replace_t...
[ "def", "execute_tasks", "(", "tasks", ",", "template_path", ")", "if", "File", ".", "exists?", "(", "File", ".", "expand_path", "(", "File", ".", "join", "(", "template_path", ",", "'tasks.rb'", ")", ")", ")", "load", "File", ".", "expand_path", "(", "Fi...
Parses the task string and runs the task. Will check *Skeleton::Tasks* module first before running tasks from the `tasks.rb` file in the template directory.
[ "Parses", "the", "task", "string", "and", "runs", "the", "task", "." ]
c3996c346bbf8009f7135855aabfd4f411aaa2e1
https://github.com/OiNutter/skeletor/blob/c3996c346bbf8009f7135855aabfd4f411aaa2e1/lib/skeletor/builder.rb#L120-L144
5,958
wedesoft/multiarray
lib/multiarray/pointer.rb
Hornetseye.Pointer_.assign
def assign( value ) if @value.respond_to? :assign @value.assign value.simplify.get else @value = value.simplify.get end value end
ruby
def assign( value ) if @value.respond_to? :assign @value.assign value.simplify.get else @value = value.simplify.get end value end
[ "def", "assign", "(", "value", ")", "if", "@value", ".", "respond_to?", ":assign", "@value", ".", "assign", "value", ".", "simplify", ".", "get", "else", "@value", "=", "value", ".", "simplify", ".", "get", "end", "value", "end" ]
Store a value in this native element @param [Object] value New value for native element. @return [Object] Returns +value+. @private
[ "Store", "a", "value", "in", "this", "native", "element" ]
1ae1d98bacb4b941d6f406e44ccb184de12f83d9
https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/pointer.rb#L178-L185
5,959
wedesoft/multiarray
lib/multiarray/pointer.rb
Hornetseye.Pointer_.store
def store( value ) result = value.simplify self.class.target.new(result.get).write @value result end
ruby
def store( value ) result = value.simplify self.class.target.new(result.get).write @value result end
[ "def", "store", "(", "value", ")", "result", "=", "value", ".", "simplify", "self", ".", "class", ".", "target", ".", "new", "(", "result", ".", "get", ")", ".", "write", "@value", "result", "end" ]
Store new value in this pointer @param [Object] value New value for this pointer object. @return [Object] Returns +value+. @private
[ "Store", "new", "value", "in", "this", "pointer" ]
1ae1d98bacb4b941d6f406e44ccb184de12f83d9
https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/pointer.rb#L194-L198
5,960
stormbrew/user_input
lib/user_input/option_parser.rb
UserInput.OptionParser.define_value
def define_value(short_name, long_name, description, flag, default_value, validate = nil) short_name = short_name.to_s long_name = long_name.to_s if (short_name.length != 1) raise ArgumentError, "Short name must be one character long (#{short_name})" end if (long_name.length < 2) raise Argume...
ruby
def define_value(short_name, long_name, description, flag, default_value, validate = nil) short_name = short_name.to_s long_name = long_name.to_s if (short_name.length != 1) raise ArgumentError, "Short name must be one character long (#{short_name})" end if (long_name.length < 2) raise Argume...
[ "def", "define_value", "(", "short_name", ",", "long_name", ",", "description", ",", "flag", ",", "default_value", ",", "validate", "=", "nil", ")", "short_name", "=", "short_name", ".", "to_s", "long_name", "=", "long_name", ".", "to_s", "if", "(", "short_n...
If a block is passed in, it is given self.
[ "If", "a", "block", "is", "passed", "in", "it", "is", "given", "self", "." ]
593a1deb08f0634089d25542971ad0ac57542259
https://github.com/stormbrew/user_input/blob/593a1deb08f0634089d25542971ad0ac57542259/lib/user_input/option_parser.rb#L52-L78
5,961
stormbrew/user_input
lib/user_input/option_parser.rb
UserInput.OptionParser.argument
def argument(short_name, long_name, description, default_value, validate = nil, &block) return define_value(short_name, long_name, description, false, default_value, validate || block) end
ruby
def argument(short_name, long_name, description, default_value, validate = nil, &block) return define_value(short_name, long_name, description, false, default_value, validate || block) end
[ "def", "argument", "(", "short_name", ",", "long_name", ",", "description", ",", "default_value", ",", "validate", "=", "nil", ",", "&", "block", ")", "return", "define_value", "(", "short_name", ",", "long_name", ",", "description", ",", "false", ",", "defa...
This defines a command line argument that takes a value.
[ "This", "defines", "a", "command", "line", "argument", "that", "takes", "a", "value", "." ]
593a1deb08f0634089d25542971ad0ac57542259
https://github.com/stormbrew/user_input/blob/593a1deb08f0634089d25542971ad0ac57542259/lib/user_input/option_parser.rb#L89-L91
5,962
stormbrew/user_input
lib/user_input/option_parser.rb
UserInput.OptionParser.flag
def flag(short_name, long_name, description, &block) return define_value(short_name, long_name, description, true, false, block) end
ruby
def flag(short_name, long_name, description, &block) return define_value(short_name, long_name, description, true, false, block) end
[ "def", "flag", "(", "short_name", ",", "long_name", ",", "description", ",", "&", "block", ")", "return", "define_value", "(", "short_name", ",", "long_name", ",", "description", ",", "true", ",", "false", ",", "block", ")", "end" ]
This defines a command line argument that's either on or off based on the presense of the flag.
[ "This", "defines", "a", "command", "line", "argument", "that", "s", "either", "on", "or", "off", "based", "on", "the", "presense", "of", "the", "flag", "." ]
593a1deb08f0634089d25542971ad0ac57542259
https://github.com/stormbrew/user_input/blob/593a1deb08f0634089d25542971ad0ac57542259/lib/user_input/option_parser.rb#L95-L97
5,963
mrsimonfletcher/roroacms
app/controllers/roroacms/setup_controller.rb
Roroacms.SetupController.create
def create # To do update this table we loop through the fields and update the key with the value. # In order to do this we need to remove any unnecessary keys from the params hash remove_unwanted_keys # loop through the param fields and update the key with the value validation = Setting....
ruby
def create # To do update this table we loop through the fields and update the key with the value. # In order to do this we need to remove any unnecessary keys from the params hash remove_unwanted_keys # loop through the param fields and update the key with the value validation = Setting....
[ "def", "create", "# To do update this table we loop through the fields and update the key with the value.", "# In order to do this we need to remove any unnecessary keys from the params hash", "remove_unwanted_keys", "# loop through the param fields and update the key with the value", "validation", "=...
Create the settings for the Admin panel to work!
[ "Create", "the", "settings", "for", "the", "Admin", "panel", "to", "work!" ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/setup_controller.rb#L22-L46
5,964
mrsimonfletcher/roroacms
app/controllers/roroacms/setup_controller.rb
Roroacms.SetupController.create_user
def create_user @admin = Admin.new(administrator_params) @admin.access_level = 'admin' @admin.overlord = 'Y' respond_to do |format| if @admin.save Setting.save_data({setup_complete: 'Y'}) clear_cache session[:setup_complete] = true format.ht...
ruby
def create_user @admin = Admin.new(administrator_params) @admin.access_level = 'admin' @admin.overlord = 'Y' respond_to do |format| if @admin.save Setting.save_data({setup_complete: 'Y'}) clear_cache session[:setup_complete] = true format.ht...
[ "def", "create_user", "@admin", "=", "Admin", ".", "new", "(", "administrator_params", ")", "@admin", ".", "access_level", "=", "'admin'", "@admin", ".", "overlord", "=", "'Y'", "respond_to", "do", "|", "format", "|", "if", "@admin", ".", "save", "Setting", ...
create a new admin user
[ "create", "a", "new", "admin", "user" ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/setup_controller.rb#L50-L66
5,965
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.compare
def compare(&diff_block) # Get a copy of the outputs before any transformations are applied FileUtils.cp_r("#{temp_transformed_path}/.", temp_raw_path) transform_paths! glob_all(after_path).each do |relative_path| expected = after_path + relative_path next unless expected.file...
ruby
def compare(&diff_block) # Get a copy of the outputs before any transformations are applied FileUtils.cp_r("#{temp_transformed_path}/.", temp_raw_path) transform_paths! glob_all(after_path).each do |relative_path| expected = after_path + relative_path next unless expected.file...
[ "def", "compare", "(", "&", "diff_block", ")", "# Get a copy of the outputs before any transformations are applied", "FileUtils", ".", "cp_r", "(", "\"#{temp_transformed_path}/.\"", ",", "temp_raw_path", ")", "transform_paths!", "glob_all", "(", "after_path", ")", ".", "eac...
Compares the expected and produced directory by using the rules defined in the context @param [Block<(Diff)->()>] diff_block The block, where you will likely define a test for each file to compare. It will receive a Diff of each of the expected and produced files.
[ "Compares", "the", "expected", "and", "produced", "directory", "by", "using", "the", "rules", "defined", "in", "the", "context" ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L121-L138
5,966
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.check_unexpected_files
def check_unexpected_files(&block) expected_files = glob_all after_path produced_files = glob_all unexpected_files = produced_files - expected_files # Select only files unexpected_files.select! { |path| path.file? } # Filter ignored paths unexpected_files.reject! { |path| con...
ruby
def check_unexpected_files(&block) expected_files = glob_all after_path produced_files = glob_all unexpected_files = produced_files - expected_files # Select only files unexpected_files.select! { |path| path.file? } # Filter ignored paths unexpected_files.reject! { |path| con...
[ "def", "check_unexpected_files", "(", "&", "block", ")", "expected_files", "=", "glob_all", "after_path", "produced_files", "=", "glob_all", "unexpected_files", "=", "produced_files", "-", "expected_files", "# Select only files", "unexpected_files", ".", "select!", "{", ...
Compares the expected and produced directory by using the rules defined in the context for unexpected files. This is separate because you probably don't want to define an extra test case for each file, which wasn't expected at all. So you can keep your test cases consistent. @param [Block<(Array)->()>] diff_blo...
[ "Compares", "the", "expected", "and", "produced", "directory", "by", "using", "the", "rules", "defined", "in", "the", "context", "for", "unexpected", "files", "." ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L151-L163
5,967
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.prepare!
def prepare! context.prepare! temp_path.rmtree if temp_path.exist? temp_path.mkdir temp_raw_path.mkdir temp_transformed_path.mkdir end
ruby
def prepare! context.prepare! temp_path.rmtree if temp_path.exist? temp_path.mkdir temp_raw_path.mkdir temp_transformed_path.mkdir end
[ "def", "prepare!", "context", ".", "prepare!", "temp_path", ".", "rmtree", "if", "temp_path", ".", "exist?", "temp_path", ".", "mkdir", "temp_raw_path", ".", "mkdir", "temp_transformed_path", ".", "mkdir", "end" ]
Prepare the temporary directory
[ "Prepare", "the", "temporary", "directory" ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L177-L184
5,968
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.copy_files!
def copy_files! destination = temp_transformed_path if has_base? FileUtils.cp_r("#{base_spec.temp_raw_path}/.", destination) end begin FileUtils.cp_r("#{before_path}/.", destination) rescue Errno::ENOENT => e raise e unless has_base? end ...
ruby
def copy_files! destination = temp_transformed_path if has_base? FileUtils.cp_r("#{base_spec.temp_raw_path}/.", destination) end begin FileUtils.cp_r("#{before_path}/.", destination) rescue Errno::ENOENT => e raise e unless has_base? end ...
[ "def", "copy_files!", "destination", "=", "temp_transformed_path", "if", "has_base?", "FileUtils", ".", "cp_r", "(", "\"#{base_spec.temp_raw_path}/.\"", ",", "destination", ")", "end", "begin", "FileUtils", ".", "cp_r", "(", "\"#{before_path}/.\"", ",", "destination", ...
Copies the before subdirectory of the given tests folder in the raw directory.
[ "Copies", "the", "before", "subdirectory", "of", "the", "given", "tests", "folder", "in", "the", "raw", "directory", "." ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L189-L201
5,969
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.transform_paths!
def transform_paths! glob_all.each do |path| context.transformers_for(path).each do |transformer| transformer.call(path) if path.exist? end path.rmtree if context.ignores?(path) && path.exist? end end
ruby
def transform_paths! glob_all.each do |path| context.transformers_for(path).each do |transformer| transformer.call(path) if path.exist? end path.rmtree if context.ignores?(path) && path.exist? end end
[ "def", "transform_paths!", "glob_all", ".", "each", "do", "|", "path", "|", "context", ".", "transformers_for", "(", "path", ")", ".", "each", "do", "|", "transformer", "|", "transformer", ".", "call", "(", "path", ")", "if", "path", ".", "exist?", "end"...
Applies the in the context configured transformations.
[ "Applies", "the", "in", "the", "context", "configured", "transformations", "." ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L205-L212
5,970
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.glob_all
def glob_all(path=nil) Dir.chdir path || '.' do Pathname.glob("**/*", context.include_hidden_files? ? File::FNM_DOTMATCH : 0).sort.reject do |p| %w(. ..).include?(p.basename.to_s) end end end
ruby
def glob_all(path=nil) Dir.chdir path || '.' do Pathname.glob("**/*", context.include_hidden_files? ? File::FNM_DOTMATCH : 0).sort.reject do |p| %w(. ..).include?(p.basename.to_s) end end end
[ "def", "glob_all", "(", "path", "=", "nil", ")", "Dir", ".", "chdir", "path", "||", "'.'", "do", "Pathname", ".", "glob", "(", "\"**/*\"", ",", "context", ".", "include_hidden_files?", "?", "File", "::", "FNM_DOTMATCH", ":", "0", ")", ".", "sort", ".",...
Searches recursively for all files and take care for including hidden files if this is configured in the context. @param [String] path The relative or absolute path to search in (optional) @return [Array<Pathname>]
[ "Searches", "recursively", "for", "all", "files", "and", "take", "care", "for", "including", "hidden", "files", "if", "this", "is", "configured", "in", "the", "context", "." ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L222-L228
5,971
mrackwitz/CLIntegracon
lib/CLIntegracon/file_tree_spec.rb
CLIntegracon.FileTreeSpec.diff_files
def diff_files(expected, relative_path, &block) produced = temp_transformed_path + relative_path Diff.new(expected, produced, relative_path, &block) end
ruby
def diff_files(expected, relative_path, &block) produced = temp_transformed_path + relative_path Diff.new(expected, produced, relative_path, &block) end
[ "def", "diff_files", "(", "expected", ",", "relative_path", ",", "&", "block", ")", "produced", "=", "temp_transformed_path", "+", "relative_path", "Diff", ".", "new", "(", "expected", ",", "produced", ",", "relative_path", ",", "block", ")", "end" ]
Compares two files to check if they are identical and produces a clear diff to highlight the differences. @param [Pathname] expected The file in the after directory @param [Pathname] relative_path The file in the temp directory @param [Block<(Pathname)->(to_s)>] block the block, whi...
[ "Compares", "two", "files", "to", "check", "if", "they", "are", "identical", "and", "produces", "a", "clear", "diff", "to", "highlight", "the", "differences", "." ]
b675f23762d10e527487aa5576d6a77f9c623485
https://github.com/mrackwitz/CLIntegracon/blob/b675f23762d10e527487aa5576d6a77f9c623485/lib/CLIntegracon/file_tree_spec.rb#L245-L248
5,972
ladder/ladder
lib/ladder/resource.rb
Ladder.Resource.klass_from_predicate
def klass_from_predicate(predicate) field_name = field_from_predicate(predicate) return unless field_name relation = relations[field_name] return unless relation relation.class_name.constantize end
ruby
def klass_from_predicate(predicate) field_name = field_from_predicate(predicate) return unless field_name relation = relations[field_name] return unless relation relation.class_name.constantize end
[ "def", "klass_from_predicate", "(", "predicate", ")", "field_name", "=", "field_from_predicate", "(", "predicate", ")", "return", "unless", "field_name", "relation", "=", "relations", "[", "field_name", "]", "return", "unless", "relation", "relation", ".", "class_na...
Retrieve the class for a relation, based on its defined RDF predicate @param [RDF::URI] predicate a URI for the RDF::Term @return [Ladder::Resource, Ladder::File, nil] related class
[ "Retrieve", "the", "class", "for", "a", "relation", "based", "on", "its", "defined", "RDF", "predicate" ]
fdb17fbeb93e89c670f3ca5d431f29be0a682fd2
https://github.com/ladder/ladder/blob/fdb17fbeb93e89c670f3ca5d431f29be0a682fd2/lib/ladder/resource.rb#L63-L71
5,973
ladder/ladder
lib/ladder/resource.rb
Ladder.Resource.field_from_predicate
def field_from_predicate(predicate) defined_prop = resource_class.properties.find { |_field_name, term| term.predicate == predicate } return unless defined_prop defined_prop.first end
ruby
def field_from_predicate(predicate) defined_prop = resource_class.properties.find { |_field_name, term| term.predicate == predicate } return unless defined_prop defined_prop.first end
[ "def", "field_from_predicate", "(", "predicate", ")", "defined_prop", "=", "resource_class", ".", "properties", ".", "find", "{", "|", "_field_name", ",", "term", "|", "term", ".", "predicate", "==", "predicate", "}", "return", "unless", "defined_prop", "defined...
Retrieve the attribute name for a field or relation, based on its defined RDF predicate @param [RDF::URI] predicate a URI for the RDF::Term @return [String, nil] name for the attribute
[ "Retrieve", "the", "attribute", "name", "for", "a", "field", "or", "relation", "based", "on", "its", "defined", "RDF", "predicate" ]
fdb17fbeb93e89c670f3ca5d431f29be0a682fd2
https://github.com/ladder/ladder/blob/fdb17fbeb93e89c670f3ca5d431f29be0a682fd2/lib/ladder/resource.rb#L79-L84
5,974
ladder/ladder
lib/ladder/resource.rb
Ladder.Resource.update_relation
def update_relation(field_name, *obj) # Should be an Array of RDF::Term objects return unless obj obj.map! { |item| item.is_a?(RDF::URI) ? Ladder::Resource.from_uri(item) : item } relation = send(field_name) if Mongoid::Relations::Targets::Enumerable == relation.class obj.map { |...
ruby
def update_relation(field_name, *obj) # Should be an Array of RDF::Term objects return unless obj obj.map! { |item| item.is_a?(RDF::URI) ? Ladder::Resource.from_uri(item) : item } relation = send(field_name) if Mongoid::Relations::Targets::Enumerable == relation.class obj.map { |...
[ "def", "update_relation", "(", "field_name", ",", "*", "obj", ")", "# Should be an Array of RDF::Term objects", "return", "unless", "obj", "obj", ".", "map!", "{", "|", "item", "|", "item", ".", "is_a?", "(", "RDF", "::", "URI", ")", "?", "Ladder", "::", "...
Set values on a defined relation @param [String] field_name ActiveModel attribute name for the field @param [Array<Object>] obj objects (usually Ladder::Resources) to be set @return [Ladder::Resource, nil]
[ "Set", "values", "on", "a", "defined", "relation" ]
fdb17fbeb93e89c670f3ca5d431f29be0a682fd2
https://github.com/ladder/ladder/blob/fdb17fbeb93e89c670f3ca5d431f29be0a682fd2/lib/ladder/resource.rb#L94-L106
5,975
ladder/ladder
lib/ladder/resource.rb
Ladder.Resource.update_field
def update_field(field_name, *obj) # Should be an Array of RDF::Term objects return unless obj if fields[field_name] && fields[field_name].localized? trans = {} obj.each do |item| lang = item.is_a?(RDF::Literal) && item.has_language? ? item.language.to_s : I18n.locale.to_s ...
ruby
def update_field(field_name, *obj) # Should be an Array of RDF::Term objects return unless obj if fields[field_name] && fields[field_name].localized? trans = {} obj.each do |item| lang = item.is_a?(RDF::Literal) && item.has_language? ? item.language.to_s : I18n.locale.to_s ...
[ "def", "update_field", "(", "field_name", ",", "*", "obj", ")", "# Should be an Array of RDF::Term objects", "return", "unless", "obj", "if", "fields", "[", "field_name", "]", "&&", "fields", "[", "field_name", "]", ".", "localized?", "trans", "=", "{", "}", "...
Set values on a field; this will cast values from RDF types to persistable Mongoid types @param [String] field_name ActiveModel attribute name for the field @param [Array<Object>] obj objects (usually RDF::Terms) to be set @return [Object, nil]
[ "Set", "values", "on", "a", "field", ";", "this", "will", "cast", "values", "from", "RDF", "types", "to", "persistable", "Mongoid", "types" ]
fdb17fbeb93e89c670f3ca5d431f29be0a682fd2
https://github.com/ladder/ladder/blob/fdb17fbeb93e89c670f3ca5d431f29be0a682fd2/lib/ladder/resource.rb#L115-L133
5,976
ladder/ladder
lib/ladder/resource.rb
Ladder.Resource.cast_value
def cast_value(value, opts = {}) case value when Array value.map { |v| cast_value(v, opts) } when String cast_uri = RDF::URI.new(value) cast_uri.valid? ? cast_uri : RDF::Literal.new(value, opts) when Time # Cast DateTimes with 00:00:00 or Date stored as Times in M...
ruby
def cast_value(value, opts = {}) case value when Array value.map { |v| cast_value(v, opts) } when String cast_uri = RDF::URI.new(value) cast_uri.valid? ? cast_uri : RDF::Literal.new(value, opts) when Time # Cast DateTimes with 00:00:00 or Date stored as Times in M...
[ "def", "cast_value", "(", "value", ",", "opts", "=", "{", "}", ")", "case", "value", "when", "Array", "value", ".", "map", "{", "|", "v", "|", "cast_value", "(", "v", ",", "opts", ")", "}", "when", "String", "cast_uri", "=", "RDF", "::", "URI", "...
Cast values from Mongoid types to RDF types @param [Object] value ActiveModel attribute to be cast @param [Hash] opts options to pass to RDF::Literal @return [RDF::Term]
[ "Cast", "values", "from", "Mongoid", "types", "to", "RDF", "types" ]
fdb17fbeb93e89c670f3ca5d431f29be0a682fd2
https://github.com/ladder/ladder/blob/fdb17fbeb93e89c670f3ca5d431f29be0a682fd2/lib/ladder/resource.rb#L141-L155
5,977
ladder/ladder
lib/ladder/file.rb
Ladder.File.data
def data @grid_file ||= self.class.grid.get(id) if persisted? return @grid_file.data if @grid_file file.rewind if file.respond_to? :rewind file.read end
ruby
def data @grid_file ||= self.class.grid.get(id) if persisted? return @grid_file.data if @grid_file file.rewind if file.respond_to? :rewind file.read end
[ "def", "data", "@grid_file", "||=", "self", ".", "class", ".", "grid", ".", "get", "(", "id", ")", "if", "persisted?", "return", "@grid_file", ".", "data", "if", "@grid_file", "file", ".", "rewind", "if", "file", ".", "respond_to?", ":rewind", "file", "....
Output content of object from stored file or readable input @return [String] string-encoded copy of binary data
[ "Output", "content", "of", "object", "from", "stored", "file", "or", "readable", "input" ]
fdb17fbeb93e89c670f3ca5d431f29be0a682fd2
https://github.com/ladder/ladder/blob/fdb17fbeb93e89c670f3ca5d431f29be0a682fd2/lib/ladder/file.rb#L41-L47
5,978
barkerest/incline
lib/incline/extensions/numeric.rb
Incline::Extensions.Numeric.to_human
def to_human Incline::Extensions::Numeric::SHORT_SCALE.each do |(num,label)| if self >= num # Add 0.0001 to the value before rounding it off. # This way we're telling the system that we want it to round up instead of round to even. s = ('%.2f' % ((self.to_f / num) + 0.0001))....
ruby
def to_human Incline::Extensions::Numeric::SHORT_SCALE.each do |(num,label)| if self >= num # Add 0.0001 to the value before rounding it off. # This way we're telling the system that we want it to round up instead of round to even. s = ('%.2f' % ((self.to_f / num) + 0.0001))....
[ "def", "to_human", "Incline", "::", "Extensions", "::", "Numeric", "::", "SHORT_SCALE", ".", "each", "do", "|", "(", "num", ",", "label", ")", "|", "if", "self", ">=", "num", "# Add 0.0001 to the value before rounding it off.", "# This way we're telling the system tha...
Formats the number using the short scale for any number over 1 million.
[ "Formats", "the", "number", "using", "the", "short", "scale", "for", "any", "number", "over", "1", "million", "." ]
1ff08db7aa8ab7f86b223268b700bc67d15bb8aa
https://github.com/barkerest/incline/blob/1ff08db7aa8ab7f86b223268b700bc67d15bb8aa/lib/incline/extensions/numeric.rb#L29-L50
5,979
tbpgr/sublime_sunippetter
lib/sublime_sunippetter.rb
SublimeSunippetter.Core.generate_sunippets
def generate_sunippets sunippet_define = read_sunippetdefine dsl = Dsl.new dsl.instance_eval sunippet_define output_methods(dsl) output_requires(dsl) end
ruby
def generate_sunippets sunippet_define = read_sunippetdefine dsl = Dsl.new dsl.instance_eval sunippet_define output_methods(dsl) output_requires(dsl) end
[ "def", "generate_sunippets", "sunippet_define", "=", "read_sunippetdefine", "dsl", "=", "Dsl", ".", "new", "dsl", ".", "instance_eval", "sunippet_define", "output_methods", "(", "dsl", ")", "output_requires", "(", "dsl", ")", "end" ]
generate sublime text2 sunippets from Sunippetdefine
[ "generate", "sublime", "text2", "sunippets", "from", "Sunippetdefine" ]
a731a8a52fe457d742e78f50a4009b5b01f0640d
https://github.com/tbpgr/sublime_sunippetter/blob/a731a8a52fe457d742e78f50a4009b5b01f0640d/lib/sublime_sunippetter.rb#L21-L27
5,980
andreimaxim/active_metrics
lib/active_metrics/instrumentable.rb
ActiveMetrics.Instrumentable.count
def count(event, number = 1) ActiveMetrics::Collector.record(event, { metric: 'count', value: number }) end
ruby
def count(event, number = 1) ActiveMetrics::Collector.record(event, { metric: 'count', value: number }) end
[ "def", "count", "(", "event", ",", "number", "=", "1", ")", "ActiveMetrics", "::", "Collector", ".", "record", "(", "event", ",", "{", "metric", ":", "'count'", ",", "value", ":", "number", "}", ")", "end" ]
Count log lines are used to submit increments to Librato. You can submit increments as frequently as desired and every minute the current total will be flushed to Librato and reset to zero. @param event [String] The name of the event @param number [Integer] The number to increment the current count (defaults to 1...
[ "Count", "log", "lines", "are", "used", "to", "submit", "increments", "to", "Librato", "." ]
b8ee011e9dccd88bb73f6cd52625106ac8ea5ff8
https://github.com/andreimaxim/active_metrics/blob/b8ee011e9dccd88bb73f6cd52625106ac8ea5ff8/lib/active_metrics/instrumentable.rb#L13-L15
5,981
andreimaxim/active_metrics
lib/active_metrics/instrumentable.rb
ActiveMetrics.Instrumentable.measure
def measure(event, value = 0) if block_given? time = Time.now # Store the value returned by the block for future reference value = yield delta = Time.now - time ActiveMetrics::Collector.record(event, { metric: 'measure', value: delta }) value else Ac...
ruby
def measure(event, value = 0) if block_given? time = Time.now # Store the value returned by the block for future reference value = yield delta = Time.now - time ActiveMetrics::Collector.record(event, { metric: 'measure', value: delta }) value else Ac...
[ "def", "measure", "(", "event", ",", "value", "=", "0", ")", "if", "block_given?", "time", "=", "Time", ".", "now", "# Store the value returned by the block for future reference", "value", "=", "yield", "delta", "=", "Time", ".", "now", "-", "time", "ActiveMetri...
Measure log lines are used to submit individual measurements that comprise a statistical distribution. The most common use case are timings i.e. latency measurements, but it can also be used to represent non-temporal distributions such as counts. You can submit as many measures as you’d like (typically they are s...
[ "Measure", "log", "lines", "are", "used", "to", "submit", "individual", "measurements", "that", "comprise", "a", "statistical", "distribution", ".", "The", "most", "common", "use", "case", "are", "timings", "i", ".", "e", ".", "latency", "measurements", "but",...
b8ee011e9dccd88bb73f6cd52625106ac8ea5ff8
https://github.com/andreimaxim/active_metrics/blob/b8ee011e9dccd88bb73f6cd52625106ac8ea5ff8/lib/active_metrics/instrumentable.rb#L39-L52
5,982
robfors/ruby-sumac
lib/sumac/connection.rb
Sumac.Connection.messenger_received_message
def messenger_received_message(message_string) #puts "receive|#{message_string}" begin message = Messages.from_json(message_string) rescue ProtocolError @scheduler.receive(:invalid_message) return end case message when Messages::CallRequest then @scheduler.rec...
ruby
def messenger_received_message(message_string) #puts "receive|#{message_string}" begin message = Messages.from_json(message_string) rescue ProtocolError @scheduler.receive(:invalid_message) return end case message when Messages::CallRequest then @scheduler.rec...
[ "def", "messenger_received_message", "(", "message_string", ")", "#puts \"receive|#{message_string}\"", "begin", "message", "=", "Messages", ".", "from_json", "(", "message_string", ")", "rescue", "ProtocolError", "@scheduler", ".", "receive", "(", ":invalid_message", ")"...
Submit a message from the messenger. The thread will wait its turn if another event is being processed. @param message_string [String] @return [void]
[ "Submit", "a", "message", "from", "the", "messenger", ".", "The", "thread", "will", "wait", "its", "turn", "if", "another", "event", "is", "being", "processed", "." ]
524fa68b7d1bb10a74baa69cd594ab2b8cae20a3
https://github.com/robfors/ruby-sumac/blob/524fa68b7d1bb10a74baa69cd594ab2b8cae20a3/lib/sumac/connection.rb#L181-L197
5,983
MOZGIII/win-path-utils
lib/win-path-utils.rb
WinPathUtils.Path.add
def add(value, options = {}) # Set defaults options[:duplication_filter] = :do_not_add unless options.key?(:duplication_filter) # Get path path = get_array # Check duplicates if path.member?(value) case options[:duplication_filter] when :do_not_add, :deny ...
ruby
def add(value, options = {}) # Set defaults options[:duplication_filter] = :do_not_add unless options.key?(:duplication_filter) # Get path path = get_array # Check duplicates if path.member?(value) case options[:duplication_filter] when :do_not_add, :deny ...
[ "def", "add", "(", "value", ",", "options", "=", "{", "}", ")", "# Set defaults", "options", "[", ":duplication_filter", "]", "=", ":do_not_add", "unless", "options", ".", "key?", "(", ":duplication_filter", ")", "# Get path", "path", "=", "get_array", "# Chec...
Adds value to the path
[ "Adds", "value", "to", "the", "path" ]
7f12c8f68250bf9e09c7a826e44632fb66f43426
https://github.com/MOZGIII/win-path-utils/blob/7f12c8f68250bf9e09c7a826e44632fb66f43426/lib/win-path-utils.rb#L60-L94
5,984
MOZGIII/win-path-utils
lib/win-path-utils.rb
WinPathUtils.Path.with_reg
def with_reg(access_mask = Win32::Registry::Constants::KEY_ALL_ACCESS, &block) @hkey.open(@reg_path, access_mask, &block) end
ruby
def with_reg(access_mask = Win32::Registry::Constants::KEY_ALL_ACCESS, &block) @hkey.open(@reg_path, access_mask, &block) end
[ "def", "with_reg", "(", "access_mask", "=", "Win32", "::", "Registry", "::", "Constants", "::", "KEY_ALL_ACCESS", ",", "&", "block", ")", "@hkey", ".", "open", "(", "@reg_path", ",", "access_mask", ",", "block", ")", "end" ]
Execute block with the current reg settings
[ "Execute", "block", "with", "the", "current", "reg", "settings" ]
7f12c8f68250bf9e09c7a826e44632fb66f43426
https://github.com/MOZGIII/win-path-utils/blob/7f12c8f68250bf9e09c7a826e44632fb66f43426/lib/win-path-utils.rb#L144-L146
5,985
phildionne/associates
lib/associates/validations.rb
Associates.Validations.valid_with_associates?
def valid_with_associates?(context = nil) # Model validations valid_without_associates?(context) # Associated models validations self.class.associates.each do |associate| model = send(associate.name) model.valid?(context) model.errors.each_entry do |attribute, message| ...
ruby
def valid_with_associates?(context = nil) # Model validations valid_without_associates?(context) # Associated models validations self.class.associates.each do |associate| model = send(associate.name) model.valid?(context) model.errors.each_entry do |attribute, message| ...
[ "def", "valid_with_associates?", "(", "context", "=", "nil", ")", "# Model validations", "valid_without_associates?", "(", "context", ")", "# Associated models validations", "self", ".", "class", ".", "associates", ".", "each", "do", "|", "associate", "|", "model", ...
Runs the model validations plus the associated models validations and merges each messages in the errors hash @return [Boolean]
[ "Runs", "the", "model", "validations", "plus", "the", "associated", "models", "validations", "and", "merges", "each", "messages", "in", "the", "errors", "hash" ]
630edcc47340a73ad787feaf2cdf326b4487bb9f
https://github.com/phildionne/associates/blob/630edcc47340a73ad787feaf2cdf326b4487bb9f/lib/associates/validations.rb#L16-L39
5,986
aetherised/ark-util
lib/ark/log.rb
ARK.Log.say
def say(msg, sym='...', loud=false, indent=0) return false if Conf[:quiet] return false if loud && !Conf[:verbose] unless msg == '' time = "" if Conf[:timed] time = Timer.time.to_s.ljust(4, '0') time = time + " " end indent = " " * indent indent = " " if inde...
ruby
def say(msg, sym='...', loud=false, indent=0) return false if Conf[:quiet] return false if loud && !Conf[:verbose] unless msg == '' time = "" if Conf[:timed] time = Timer.time.to_s.ljust(4, '0') time = time + " " end indent = " " * indent indent = " " if inde...
[ "def", "say", "(", "msg", ",", "sym", "=", "'...'", ",", "loud", "=", "false", ",", "indent", "=", "0", ")", "return", "false", "if", "Conf", "[", ":quiet", "]", "return", "false", "if", "loud", "&&", "!", "Conf", "[", ":verbose", "]", "unless", ...
Write +msg+ to standard output according to verbosity settings. Not meant to be used directly
[ "Write", "+", "msg", "+", "to", "standard", "output", "according", "to", "verbosity", "settings", ".", "Not", "meant", "to", "be", "used", "directly" ]
d7573ad0e44568a394808dfa895b9375de1bc3fd
https://github.com/aetherised/ark-util/blob/d7573ad0e44568a394808dfa895b9375de1bc3fd/lib/ark/log.rb#L18-L33
5,987
madwire/trooper
lib/trooper/configuration.rb
Trooper.Configuration.load_troopfile!
def load_troopfile!(options) if troopfile? eval troopfile.read @loaded = true load_environment! set options else raise Trooper::NoConfigurationFileError, "No Configuration file (#{self[:file_name]}) can be found!" end end
ruby
def load_troopfile!(options) if troopfile? eval troopfile.read @loaded = true load_environment! set options else raise Trooper::NoConfigurationFileError, "No Configuration file (#{self[:file_name]}) can be found!" end end
[ "def", "load_troopfile!", "(", "options", ")", "if", "troopfile?", "eval", "troopfile", ".", "read", "@loaded", "=", "true", "load_environment!", "set", "options", "else", "raise", "Trooper", "::", "NoConfigurationFileError", ",", "\"No Configuration file (#{self[:file_...
loads the troopfile and sets the environment up
[ "loads", "the", "troopfile", "and", "sets", "the", "environment", "up" ]
ca953f9b78adf1614f7acf82c9076055540ee04c
https://github.com/madwire/trooper/blob/ca953f9b78adf1614f7acf82c9076055540ee04c/lib/trooper/configuration.rb#L127-L137
5,988
cknadler/rcomp
lib/rcomp/suite.rb
RComp.Suite.load
def load(pattern=nil) tests = [] # Find all tests in the tests directory Find.find @@conf.test_root do |path| # recurse into all subdirectories next if File.directory? path # filter tests by pattern if present if pattern next unless rel_path(path).match(patt...
ruby
def load(pattern=nil) tests = [] # Find all tests in the tests directory Find.find @@conf.test_root do |path| # recurse into all subdirectories next if File.directory? path # filter tests by pattern if present if pattern next unless rel_path(path).match(patt...
[ "def", "load", "(", "pattern", "=", "nil", ")", "tests", "=", "[", "]", "# Find all tests in the tests directory", "Find", ".", "find", "@@conf", ".", "test_root", "do", "|", "path", "|", "# recurse into all subdirectories", "next", "if", "File", ".", "directory...
Create a test suite pattern - A pattern to filter the tests that are added to the suite Returns an Array of Test objects
[ "Create", "a", "test", "suite" ]
76fe71e1ef3b13923738ea6ab9cd502fe2f64f51
https://github.com/cknadler/rcomp/blob/76fe71e1ef3b13923738ea6ab9cd502fe2f64f51/lib/rcomp/suite.rb#L16-L39
5,989
cknadler/rcomp
lib/rcomp/suite.rb
RComp.Suite.ignored?
def ignored?(path) @@conf.ignore.each do |ignore| return true if rel_path(path).match(ignore) end return false end
ruby
def ignored?(path) @@conf.ignore.each do |ignore| return true if rel_path(path).match(ignore) end return false end
[ "def", "ignored?", "(", "path", ")", "@@conf", ".", "ignore", ".", "each", "do", "|", "ignore", "|", "return", "true", "if", "rel_path", "(", "path", ")", ".", "match", "(", "ignore", ")", "end", "return", "false", "end" ]
Checks all ignore patterns against a given relative path path - A relative path of a test Returns true if any patterns match the path, false otherwise
[ "Checks", "all", "ignore", "patterns", "against", "a", "given", "relative", "path" ]
76fe71e1ef3b13923738ea6ab9cd502fe2f64f51
https://github.com/cknadler/rcomp/blob/76fe71e1ef3b13923738ea6ab9cd502fe2f64f51/lib/rcomp/suite.rb#L48-L53
5,990
wedesoft/multiarray
lib/multiarray/malloc.rb
Hornetseye.Malloc.save
def save( value ) write value.values.pack( value.typecode.directive ) value end
ruby
def save( value ) write value.values.pack( value.typecode.directive ) value end
[ "def", "save", "(", "value", ")", "write", "value", ".", "values", ".", "pack", "(", "value", ".", "typecode", ".", "directive", ")", "value", "end" ]
Write typed value to memory @param [Node] value Value to write to memory. @return [Node] Returns +value+.
[ "Write", "typed", "value", "to", "memory" ]
1ae1d98bacb4b941d6f406e44ccb184de12f83d9
https://github.com/wedesoft/multiarray/blob/1ae1d98bacb4b941d6f406e44ccb184de12f83d9/lib/multiarray/malloc.rb#L39-L42
5,991
mrsimonfletcher/roroacms
app/controllers/roroacms/admin/themes_controller.rb
Roroacms.Admin::ThemesController.create
def create # the theme used is set in the settings area - this does the update of the current theme used Setting.where("setting_name = 'theme_folder'").update_all('setting' => params[:theme]) Setting.reload_settings respond_to do |format| format.html { redirect_to admin_themes_path, noti...
ruby
def create # the theme used is set in the settings area - this does the update of the current theme used Setting.where("setting_name = 'theme_folder'").update_all('setting' => params[:theme]) Setting.reload_settings respond_to do |format| format.html { redirect_to admin_themes_path, noti...
[ "def", "create", "# the theme used is set in the settings area - this does the update of the current theme used", "Setting", ".", "where", "(", "\"setting_name = 'theme_folder'\"", ")", ".", "update_all", "(", "'setting'", "=>", "params", "[", ":theme", "]", ")", "Setting", "...
update the currently used theme
[ "update", "the", "currently", "used", "theme" ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/themes_controller.rb#L23-L30
5,992
mrsimonfletcher/roroacms
app/controllers/roroacms/admin/themes_controller.rb
Roroacms.Admin::ThemesController.destroy
def destroy # remove the directory from the directory structure destory_theme params[:id] respond_to do |format| format.html { redirect_to admin_themes_path, notice: I18n.t("controllers.admin.themes.destroy.flash.success") } end end
ruby
def destroy # remove the directory from the directory structure destory_theme params[:id] respond_to do |format| format.html { redirect_to admin_themes_path, notice: I18n.t("controllers.admin.themes.destroy.flash.success") } end end
[ "def", "destroy", "# remove the directory from the directory structure", "destory_theme", "params", "[", ":id", "]", "respond_to", "do", "|", "format", "|", "format", ".", "html", "{", "redirect_to", "admin_themes_path", ",", "notice", ":", "I18n", ".", "t", "(", ...
remove the theme from the theme folder stopping any future usage.
[ "remove", "the", "theme", "from", "the", "theme", "folder", "stopping", "any", "future", "usage", "." ]
62654a2f2a48e3adb3105f4dafb6e315b460eaf4
https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/themes_controller.rb#L35-L42
5,993
tomash/blasphemy
lib/blasphemy.rb
Faker.CustomIpsum.sentence
def sentence # Determine the number of comma-separated sections and number of words in # each section for this sentence. sections = [] 1.upto(rand(5)+1) do sections << (words(rand(9)+3).join(" ")) end s = sections.join(", ") return s.capitalize + ".?!".slice(rand(3),1) ...
ruby
def sentence # Determine the number of comma-separated sections and number of words in # each section for this sentence. sections = [] 1.upto(rand(5)+1) do sections << (words(rand(9)+3).join(" ")) end s = sections.join(", ") return s.capitalize + ".?!".slice(rand(3),1) ...
[ "def", "sentence", "# Determine the number of comma-separated sections and number of words in", "# each section for this sentence.", "sections", "=", "[", "]", "1", ".", "upto", "(", "rand", "(", "5", ")", "+", "1", ")", "do", "sections", "<<", "(", "words", "(", "r...
Returns a randomly generated sentence of lorem ipsum text. The first word is capitalized, and the sentence ends in either a period or question mark. Commas are added at random.
[ "Returns", "a", "randomly", "generated", "sentence", "of", "lorem", "ipsum", "text", ".", "The", "first", "word", "is", "capitalized", "and", "the", "sentence", "ends", "in", "either", "a", "period", "or", "question", "mark", ".", "Commas", "are", "added", ...
00ba52fe24ec670df3dc45aaad0f99323fa362b4
https://github.com/tomash/blasphemy/blob/00ba52fe24ec670df3dc45aaad0f99323fa362b4/lib/blasphemy.rb#L17-L26
5,994
codescrum/bebox
lib/bebox/wizards/project_wizard.rb
Bebox.ProjectWizard.create_new_project
def create_new_project(project_name) # Check project existence (error(_('wizard.project.name_exist')); return false) if project_exists?(Dir.pwd, project_name) # Setup the bebox boxes directory bebox_boxes_setup # Asks to choose an existing box current_box = choose_box(get_existing_bo...
ruby
def create_new_project(project_name) # Check project existence (error(_('wizard.project.name_exist')); return false) if project_exists?(Dir.pwd, project_name) # Setup the bebox boxes directory bebox_boxes_setup # Asks to choose an existing box current_box = choose_box(get_existing_bo...
[ "def", "create_new_project", "(", "project_name", ")", "# Check project existence", "(", "error", "(", "_", "(", "'wizard.project.name_exist'", ")", ")", ";", "return", "false", ")", "if", "project_exists?", "(", "Dir", ".", "pwd", ",", "project_name", ")", "# S...
Asks for the project parameters and create the project skeleton
[ "Asks", "for", "the", "project", "parameters", "and", "create", "the", "project", "skeleton" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/project_wizard.rb#L10-L27
5,995
codescrum/bebox
lib/bebox/wizards/project_wizard.rb
Bebox.ProjectWizard.uri_valid?
def uri_valid?(vbox_uri) require 'uri' uri = URI.parse(vbox_uri) %w{http https}.include?(uri.scheme) ? http_uri_valid?(uri) : file_uri_valid?(uri) end
ruby
def uri_valid?(vbox_uri) require 'uri' uri = URI.parse(vbox_uri) %w{http https}.include?(uri.scheme) ? http_uri_valid?(uri) : file_uri_valid?(uri) end
[ "def", "uri_valid?", "(", "vbox_uri", ")", "require", "'uri'", "uri", "=", "URI", ".", "parse", "(", "vbox_uri", ")", "%w{", "http", "https", "}", ".", "include?", "(", "uri", ".", "scheme", ")", "?", "http_uri_valid?", "(", "uri", ")", ":", "file_uri_...
Validate uri download or local box existence
[ "Validate", "uri", "download", "or", "local", "box", "existence" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/project_wizard.rb#L77-L81
5,996
codescrum/bebox
lib/bebox/wizards/project_wizard.rb
Bebox.ProjectWizard.get_existing_boxes
def get_existing_boxes # Converts the bebox boxes directory to an absolute pathname expanded_directory = File.expand_path("#{BEBOX_BOXES_PATH}") # Get an array of bebox boxes paths boxes = Dir["#{expanded_directory}/*"].reject {|f| File.directory? f} boxes.map{|box| box.split('/').last} ...
ruby
def get_existing_boxes # Converts the bebox boxes directory to an absolute pathname expanded_directory = File.expand_path("#{BEBOX_BOXES_PATH}") # Get an array of bebox boxes paths boxes = Dir["#{expanded_directory}/*"].reject {|f| File.directory? f} boxes.map{|box| box.split('/').last} ...
[ "def", "get_existing_boxes", "# Converts the bebox boxes directory to an absolute pathname", "expanded_directory", "=", "File", ".", "expand_path", "(", "\"#{BEBOX_BOXES_PATH}\"", ")", "# Get an array of bebox boxes paths", "boxes", "=", "Dir", "[", "\"#{expanded_directory}/*\"", "...
Obtain the current boxes downloaded or linked in the bebox user home
[ "Obtain", "the", "current", "boxes", "downloaded", "or", "linked", "in", "the", "bebox", "user", "home" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/project_wizard.rb#L103-L109
5,997
codescrum/bebox
lib/bebox/wizards/project_wizard.rb
Bebox.ProjectWizard.choose_box
def choose_box(boxes) # Menu to choose vagrant box provider other_box_message = _('wizard.project.download_select_box') boxes << other_box_message current_box = choose_option(boxes, _('wizard.project.choose_box')) current_box = (current_box == other_box_message) ? nil : current_box end
ruby
def choose_box(boxes) # Menu to choose vagrant box provider other_box_message = _('wizard.project.download_select_box') boxes << other_box_message current_box = choose_option(boxes, _('wizard.project.choose_box')) current_box = (current_box == other_box_message) ? nil : current_box end
[ "def", "choose_box", "(", "boxes", ")", "# Menu to choose vagrant box provider", "other_box_message", "=", "_", "(", "'wizard.project.download_select_box'", ")", "boxes", "<<", "other_box_message", "current_box", "=", "choose_option", "(", "boxes", ",", "_", "(", "'wiza...
Asks to choose an existing box in the bebox boxes directory
[ "Asks", "to", "choose", "an", "existing", "box", "in", "the", "bebox", "boxes", "directory" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/project_wizard.rb#L112-L118
5,998
codescrum/bebox
lib/bebox/wizards/project_wizard.rb
Bebox.ProjectWizard.download_box
def download_box(uri) require 'net/http' require 'uri' url = uri.path # Download file to bebox boxes tmp Net::HTTP.start(uri.host) do |http| response = http.request_head(URI.escape(url)) write_remote_file(uri, http, response) end end
ruby
def download_box(uri) require 'net/http' require 'uri' url = uri.path # Download file to bebox boxes tmp Net::HTTP.start(uri.host) do |http| response = http.request_head(URI.escape(url)) write_remote_file(uri, http, response) end end
[ "def", "download_box", "(", "uri", ")", "require", "'net/http'", "require", "'uri'", "url", "=", "uri", ".", "path", "# Download file to bebox boxes tmp", "Net", "::", "HTTP", ".", "start", "(", "uri", ".", "host", ")", "do", "|", "http", "|", "response", ...
Download a box by the specified uri
[ "Download", "a", "box", "by", "the", "specified", "uri" ]
0d19315847103341e599d32837ab0bd75524e5be
https://github.com/codescrum/bebox/blob/0d19315847103341e599d32837ab0bd75524e5be/lib/bebox/wizards/project_wizard.rb#L121-L130
5,999
riddopic/garcun
lib/garcon/task/executor.rb
Garcon.Executor.handle_fallback
def handle_fallback(*args) case @fallback_policy when :abort raise RejectedExecutionError when :discard false when :caller_runs begin yield(*args) rescue => e Chef::Log.debug "Caught exception => #{e}" end true else ...
ruby
def handle_fallback(*args) case @fallback_policy when :abort raise RejectedExecutionError when :discard false when :caller_runs begin yield(*args) rescue => e Chef::Log.debug "Caught exception => #{e}" end true else ...
[ "def", "handle_fallback", "(", "*", "args", ")", "case", "@fallback_policy", "when", ":abort", "raise", "RejectedExecutionError", "when", ":discard", "false", "when", ":caller_runs", "begin", "yield", "(", "args", ")", "rescue", "=>", "e", "Chef", "::", "Log", ...
Handler which executes the `fallback_policy` once the queue size reaches `max_queue`. @param [Array] args The arguments to the task which is being handled. @!visibility private
[ "Handler", "which", "executes", "the", "fallback_policy", "once", "the", "queue", "size", "reaches", "max_queue", "." ]
c2409bd8cf9c14b967a719810dab5269d69b42de
https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/executor.rb#L49-L65