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
19,300
appsignal/appsignal-ruby
lib/appsignal/transaction.rb
Appsignal.Transaction.sanitized_environment
def sanitized_environment env = environment return if env.empty? {}.tap do |out| Appsignal.config[:request_headers].each do |key| out[key] = env[key] if env[key] end end end
ruby
def sanitized_environment env = environment return if env.empty? {}.tap do |out| Appsignal.config[:request_headers].each do |key| out[key] = env[key] if env[key] end end end
[ "def", "sanitized_environment", "env", "=", "environment", "return", "if", "env", ".", "empty?", "{", "}", ".", "tap", "do", "|", "out", "|", "Appsignal", ".", "config", "[", ":request_headers", "]", ".", "each", "do", "|", "key", "|", "out", "[", "key...
Returns sanitized environment for a transaction. The environment of a transaction can contain a lot of information, not all of it useful for debugging. @return [nil] if no environment is present. @return [Hash<String, Object>]
[ "Returns", "sanitized", "environment", "for", "a", "transaction", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/transaction.rb#L401-L410
19,301
appsignal/appsignal-ruby
lib/appsignal/transaction.rb
Appsignal.Transaction.sanitized_session_data
def sanitized_session_data return if Appsignal.config[:skip_session_data] || !request.respond_to?(:session) session = request.session return unless session Appsignal::Utils::HashSanitizer.sanitize( session.to_hash, Appsignal.config[:filter_session_data] ) end
ruby
def sanitized_session_data return if Appsignal.config[:skip_session_data] || !request.respond_to?(:session) session = request.session return unless session Appsignal::Utils::HashSanitizer.sanitize( session.to_hash, Appsignal.config[:filter_session_data] ) end
[ "def", "sanitized_session_data", "return", "if", "Appsignal", ".", "config", "[", ":skip_session_data", "]", "||", "!", "request", ".", "respond_to?", "(", ":session", ")", "session", "=", "request", ".", "session", "return", "unless", "session", "Appsignal", ":...
Returns sanitized session data. The session data is sanitized by the {Appsignal::Utils::HashSanitizer}. @return [nil] if `:skip_session_data` config is set to `true`. @return [nil] if the {#request} object doesn't respond to `#session`. @return [nil] if the {#request} session data is `nil`. @return [Hash<String,...
[ "Returns", "sanitized", "session", "data", "." ]
23a07f6f01857a967921adb83deb98b07d160629
https://github.com/appsignal/appsignal-ruby/blob/23a07f6f01857a967921adb83deb98b07d160629/lib/appsignal/transaction.rb#L420-L429
19,302
d0z0/redis_analytics
lib/redis_analytics/visit.rb
RedisAnalytics.Visit.for_each_time_range
def for_each_time_range(t) RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts| yield(ts) end end
ruby
def for_each_time_range(t) RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts| yield(ts) end end
[ "def", "for_each_time_range", "(", "t", ")", "RedisAnalytics", ".", "redis_key_timestamps", ".", "map", "{", "|", "x", ",", "y", "|", "t", ".", "strftime", "(", "x", ")", "}", ".", "each", "do", "|", "ts", "|", "yield", "(", "ts", ")", "end", "end"...
This class represents one unique visit User may have never visited the site User may have visited before but his visit is expired Everything counted here is unique for a visit helpers
[ "This", "class", "represents", "one", "unique", "visit", "User", "may", "have", "never", "visited", "the", "site", "User", "may", "have", "visited", "before", "but", "his", "visit", "is", "expired", "Everything", "counted", "here", "is", "unique", "for", "a"...
f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd
https://github.com/d0z0/redis_analytics/blob/f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd/lib/redis_analytics/visit.rb#L11-L15
19,303
d0z0/redis_analytics
lib/redis_analytics/visit.rb
RedisAnalytics.Visit.record
def record if @current_visit_seq track("visit_time", @t.to_i - @last_visit_end_time.to_i) else @current_visit_seq ||= counter("visits") track("visits", 1) # track core 'visit' metric if @first_visit_seq track("repeat_visits", 1) else @first_visit_s...
ruby
def record if @current_visit_seq track("visit_time", @t.to_i - @last_visit_end_time.to_i) else @current_visit_seq ||= counter("visits") track("visits", 1) # track core 'visit' metric if @first_visit_seq track("repeat_visits", 1) else @first_visit_s...
[ "def", "record", "if", "@current_visit_seq", "track", "(", "\"visit_time\"", ",", "@t", ".", "to_i", "-", "@last_visit_end_time", ".", "to_i", ")", "else", "@current_visit_seq", "||=", "counter", "(", "\"visits\"", ")", "track", "(", "\"visits\"", ",", "1", ")...
method used in analytics.rb to initialize visit called from analytics.rb
[ "method", "used", "in", "analytics", ".", "rb", "to", "initialize", "visit", "called", "from", "analytics", ".", "rb" ]
f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd
https://github.com/d0z0/redis_analytics/blob/f29c9db9b7425f0ee80bdd8cf572295e79d3d2bd/lib/redis_analytics/visit.rb#L45-L64
19,304
7even/vkontakte_api
lib/vkontakte_api/configuration.rb
VkontakteApi.Configuration.reset
def reset @adapter = DEFAULT_ADAPTER @http_verb = DEFAULT_HTTP_VERB @faraday_options = {} @max_retries = DEFAULT_MAX_RETRIES @logger = ::Logger.new(STDOUT) @log_requests = DEFAULT_LOGGER_OPTIONS[:requests] @log_errors = DEFAULT_LOGGER_OPTIONS[...
ruby
def reset @adapter = DEFAULT_ADAPTER @http_verb = DEFAULT_HTTP_VERB @faraday_options = {} @max_retries = DEFAULT_MAX_RETRIES @logger = ::Logger.new(STDOUT) @log_requests = DEFAULT_LOGGER_OPTIONS[:requests] @log_errors = DEFAULT_LOGGER_OPTIONS[...
[ "def", "reset", "@adapter", "=", "DEFAULT_ADAPTER", "@http_verb", "=", "DEFAULT_HTTP_VERB", "@faraday_options", "=", "{", "}", "@max_retries", "=", "DEFAULT_MAX_RETRIES", "@logger", "=", "::", "Logger", ".", "new", "(", "STDOUT", ")", "@log_requests", "=", "DEFAUL...
Reset all configuration options to defaults.
[ "Reset", "all", "configuration", "options", "to", "defaults", "." ]
daa4a9126d816926d31421bdcfd31538ac25d83b
https://github.com/7even/vkontakte_api/blob/daa4a9126d816926d31421bdcfd31538ac25d83b/lib/vkontakte_api/configuration.rb#L58-L68
19,305
7even/vkontakte_api
lib/vkontakte_api/method.rb
VkontakteApi.Method.call
def call(args = {}, &block) response = API.call(full_name, args, token) Result.process(response, type, block) end
ruby
def call(args = {}, &block) response = API.call(full_name, args, token) Result.process(response, type, block) end
[ "def", "call", "(", "args", "=", "{", "}", ",", "&", "block", ")", "response", "=", "API", ".", "call", "(", "full_name", ",", "args", ",", "token", ")", "Result", ".", "process", "(", "response", ",", "type", ",", "block", ")", "end" ]
Calling the API method. It delegates the network request to `API.call` and result processing to `Result.process`. @param [Hash] args Arguments for the API method.
[ "Calling", "the", "API", "method", ".", "It", "delegates", "the", "network", "request", "to", "API", ".", "call", "and", "result", "processing", "to", "Result", ".", "process", "." ]
daa4a9126d816926d31421bdcfd31538ac25d83b
https://github.com/7even/vkontakte_api/blob/daa4a9126d816926d31421bdcfd31538ac25d83b/lib/vkontakte_api/method.rb#L12-L15
19,306
7even/vkontakte_api
lib/vkontakte_api/authorization.rb
VkontakteApi.Authorization.authorization_url
def authorization_url(options = {}) type = options.delete(:type) || :site # redirect_uri passed in options overrides the global setting options[:redirect_uri] ||= VkontakteApi.redirect_uri options[:scope] = VkontakteApi::Utils.flatten_argument(options[:scope]) if options[:scope] cas...
ruby
def authorization_url(options = {}) type = options.delete(:type) || :site # redirect_uri passed in options overrides the global setting options[:redirect_uri] ||= VkontakteApi.redirect_uri options[:scope] = VkontakteApi::Utils.flatten_argument(options[:scope]) if options[:scope] cas...
[ "def", "authorization_url", "(", "options", "=", "{", "}", ")", "type", "=", "options", ".", "delete", "(", ":type", ")", "||", ":site", "# redirect_uri passed in options overrides the global setting", "options", "[", ":redirect_uri", "]", "||=", "VkontakteApi", "."...
URL for redirecting the user to VK where he gives the application all the requested access rights. @option options [Symbol] :type The type of authorization being used (`:site` and `:client` supported). @option options [String] :redirect_uri URL for redirecting the user back to the application (overrides the global co...
[ "URL", "for", "redirecting", "the", "user", "to", "VK", "where", "he", "gives", "the", "application", "all", "the", "requested", "access", "rights", "." ]
daa4a9126d816926d31421bdcfd31538ac25d83b
https://github.com/7even/vkontakte_api/blob/daa4a9126d816926d31421bdcfd31538ac25d83b/lib/vkontakte_api/authorization.rb#L24-L38
19,307
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.add_series
def add_series(params) # Check that the required input has been specified. unless params.has_key?(:values) raise "Must specify ':values' in add_series" end if @requires_category != 0 && !params.has_key?(:categories) raise "Must specify ':categories' in add_series for this chart...
ruby
def add_series(params) # Check that the required input has been specified. unless params.has_key?(:values) raise "Must specify ':values' in add_series" end if @requires_category != 0 && !params.has_key?(:categories) raise "Must specify ':categories' in add_series for this chart...
[ "def", "add_series", "(", "params", ")", "# Check that the required input has been specified.", "unless", "params", ".", "has_key?", "(", ":values", ")", "raise", "\"Must specify ':values' in add_series\"", "end", "if", "@requires_category", "!=", "0", "&&", "!", "params"...
Add a series and it's properties to a chart.
[ "Add", "a", "series", "and", "it", "s", "properties", "to", "a", "chart", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L247-L285
19,308
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.set_size
def set_size(params = {}) @width = params[:width] if params[:width] @height = params[:height] if params[:height] @x_scale = params[:x_scale] if params[:x_scale] @y_scale = params[:y_scale] if params[:y_scale] @x_offset = params[:x_offset] if params[:x_offset] @y_offset ...
ruby
def set_size(params = {}) @width = params[:width] if params[:width] @height = params[:height] if params[:height] @x_scale = params[:x_scale] if params[:x_scale] @y_scale = params[:y_scale] if params[:y_scale] @x_offset = params[:x_offset] if params[:x_offset] @y_offset ...
[ "def", "set_size", "(", "params", "=", "{", "}", ")", "@width", "=", "params", "[", ":width", "]", "if", "params", "[", ":width", "]", "@height", "=", "params", "[", ":height", "]", "if", "params", "[", ":height", "]", "@x_scale", "=", "params", "[",...
Set dimensions for scale for the chart.
[ "Set", "dimensions", "for", "scale", "for", "the", "chart", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L392-L399
19,309
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.set_up_down_bars
def set_up_down_bars(params = {}) # Map border to line. [:up, :down].each do |up_down| if params[up_down] params[up_down][:line] = params[up_down][:border] if params[up_down][:border] else params[up_down] = {} end end # Set the up and down bar propert...
ruby
def set_up_down_bars(params = {}) # Map border to line. [:up, :down].each do |up_down| if params[up_down] params[up_down][:line] = params[up_down][:border] if params[up_down][:border] else params[up_down] = {} end end # Set the up and down bar propert...
[ "def", "set_up_down_bars", "(", "params", "=", "{", "}", ")", "# Map border to line.", "[", ":up", ",", ":down", "]", ".", "each", "do", "|", "up_down", "|", "if", "params", "[", "up_down", "]", "params", "[", "up_down", "]", "[", ":line", "]", "=", ...
Set properties for the chart up-down bars.
[ "Set", "properties", "for", "the", "chart", "up", "-", "down", "bars", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L415-L430
19,310
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.convert_font_args
def convert_font_args(params) return unless params font = params_to_font(params) # Convert font size units. font[:_size] *= 100 if font[:_size] && font[:_size] != 0 # Convert rotation into 60,000ths of a degree. if ptrue?(font[:_rotation]) font[:_rotation] = 60_000 * font[:...
ruby
def convert_font_args(params) return unless params font = params_to_font(params) # Convert font size units. font[:_size] *= 100 if font[:_size] && font[:_size] != 0 # Convert rotation into 60,000ths of a degree. if ptrue?(font[:_rotation]) font[:_rotation] = 60_000 * font[:...
[ "def", "convert_font_args", "(", "params", ")", "return", "unless", "params", "font", "=", "params_to_font", "(", "params", ")", "# Convert font size units.", "font", "[", ":_size", "]", "*=", "100", "if", "font", "[", ":_size", "]", "&&", "font", "[", ":_si...
Convert user defined font values into private hash values.
[ "Convert", "user", "defined", "font", "values", "into", "private", "hash", "values", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L513-L526
19,311
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.process_names
def process_names(name = nil, name_formula = nil) # :nodoc: # Name looks like a formula, use it to set name_formula. if name.respond_to?(:to_ary) cell = xl_rowcol_to_cell(name[1], name[2], 1, 1) name_formula = "#{quote_sheetname(name[0])}!#{cell}" name = '' elsif name &...
ruby
def process_names(name = nil, name_formula = nil) # :nodoc: # Name looks like a formula, use it to set name_formula. if name.respond_to?(:to_ary) cell = xl_rowcol_to_cell(name[1], name[2], 1, 1) name_formula = "#{quote_sheetname(name[0])}!#{cell}" name = '' elsif name &...
[ "def", "process_names", "(", "name", "=", "nil", ",", "name_formula", "=", "nil", ")", "# :nodoc:", "# Name looks like a formula, use it to set name_formula.", "if", "name", ".", "respond_to?", "(", ":to_ary", ")", "cell", "=", "xl_rowcol_to_cell", "(", "name", "[",...
Switch name and name_formula parameters if required.
[ "Switch", "name", "and", "name_formula", "parameters", "if", "required", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L546-L559
19,312
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.get_data_type
def get_data_type(data) # :nodoc: # Check for no data in the series. return 'none' unless data return 'none' if data.empty? return 'multi_str' if data.first.kind_of?(Array) # If the token isn't a number assume it is a string. data.each do |token| next unless token re...
ruby
def get_data_type(data) # :nodoc: # Check for no data in the series. return 'none' unless data return 'none' if data.empty? return 'multi_str' if data.first.kind_of?(Array) # If the token isn't a number assume it is a string. data.each do |token| next unless token re...
[ "def", "get_data_type", "(", "data", ")", "# :nodoc:", "# Check for no data in the series.", "return", "'none'", "unless", "data", "return", "'none'", "if", "data", ".", "empty?", "return", "'multi_str'", "if", "data", ".", "first", ".", "kind_of?", "(", "Array", ...
Find the overall type of the data associated with a series. TODO. Need to handle date type.
[ "Find", "the", "overall", "type", "of", "the", "data", "associated", "with", "a", "series", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L649-L663
19,313
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.color
def color(color_code) # :nodoc: if color_code and color_code =~ /^#[0-9a-fA-F]{6}$/ # Convert a HTML style #RRGGBB color. color_code.sub(/^#/, '').upcase else index = Format.color(color_code) raise "Unknown color '#{color_code}' used in chart formatting." unless index ...
ruby
def color(color_code) # :nodoc: if color_code and color_code =~ /^#[0-9a-fA-F]{6}$/ # Convert a HTML style #RRGGBB color. color_code.sub(/^#/, '').upcase else index = Format.color(color_code) raise "Unknown color '#{color_code}' used in chart formatting." unless index ...
[ "def", "color", "(", "color_code", ")", "# :nodoc:", "if", "color_code", "and", "color_code", "=~", "/", "/", "# Convert a HTML style #RRGGBB color.", "color_code", ".", "sub", "(", "/", "/", ",", "''", ")", ".", "upcase", "else", "index", "=", "Format", "."...
Convert the user specified colour index or string to a rgb colour.
[ "Convert", "the", "user", "specified", "colour", "index", "or", "string", "to", "a", "rgb", "colour", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L668-L677
19,314
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.get_font_style_attributes
def get_font_style_attributes(font) return [] unless font attributes = [] attributes << ['sz', font[:_size]] if ptrue?(font[:_size]) attributes << ['b', font[:_bold]] if font[:_bold] attributes << ['i', font[:_italic]] if font[:_italic] attributes << ['u', 'sng'] ...
ruby
def get_font_style_attributes(font) return [] unless font attributes = [] attributes << ['sz', font[:_size]] if ptrue?(font[:_size]) attributes << ['b', font[:_bold]] if font[:_bold] attributes << ['i', font[:_italic]] if font[:_italic] attributes << ['u', 'sng'] ...
[ "def", "get_font_style_attributes", "(", "font", ")", "return", "[", "]", "unless", "font", "attributes", "=", "[", "]", "attributes", "<<", "[", "'sz'", ",", "font", "[", ":_size", "]", "]", "if", "ptrue?", "(", "font", "[", ":_size", "]", ")", "attri...
Get the font style attributes from a font hash.
[ "Get", "the", "font", "style", "attributes", "from", "a", "font", "hash", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L719-L733
19,315
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.get_font_latin_attributes
def get_font_latin_attributes(font) return [] unless font attributes = [] attributes << ['typeface', font[:_name]] if ptrue?(font[:_name]) attributes << ['pitchFamily', font[:_pitch_family]] if font[:_pitch_family] attributes << ['charset', font[:_charset]] if font[:_c...
ruby
def get_font_latin_attributes(font) return [] unless font attributes = [] attributes << ['typeface', font[:_name]] if ptrue?(font[:_name]) attributes << ['pitchFamily', font[:_pitch_family]] if font[:_pitch_family] attributes << ['charset', font[:_charset]] if font[:_c...
[ "def", "get_font_latin_attributes", "(", "font", ")", "return", "[", "]", "unless", "font", "attributes", "=", "[", "]", "attributes", "<<", "[", "'typeface'", ",", "font", "[", ":_name", "]", "]", "if", "ptrue?", "(", "font", "[", ":_name", "]", ")", ...
Get the font latin attributes from a font hash.
[ "Get", "the", "font", "latin", "attributes", "from", "a", "font", "hash", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L738-L747
19,316
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_series_name
def write_series_name(series) # :nodoc: if series.name_formula write_tx_formula(series.name_formula, series.name_id) elsif series.name write_tx_value(series.name) end end
ruby
def write_series_name(series) # :nodoc: if series.name_formula write_tx_formula(series.name_formula, series.name_id) elsif series.name write_tx_value(series.name) end end
[ "def", "write_series_name", "(", "series", ")", "# :nodoc:", "if", "series", ".", "name_formula", "write_tx_formula", "(", "series", ".", "name_formula", ",", "series", ".", "name_id", ")", "elsif", "series", ".", "name", "write_tx_value", "(", "series", ".", ...
Write the series name.
[ "Write", "the", "series", "name", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L1074-L1080
19,317
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_axis_font
def write_axis_font(font) # :nodoc: return unless font @writer.tag_elements('c:txPr') do write_a_body_pr(font[:_rotation]) write_a_lst_style @writer.tag_elements('a:p') do write_a_p_pr_rich(font) write_a_end_para_rpr end end end
ruby
def write_axis_font(font) # :nodoc: return unless font @writer.tag_elements('c:txPr') do write_a_body_pr(font[:_rotation]) write_a_lst_style @writer.tag_elements('a:p') do write_a_p_pr_rich(font) write_a_end_para_rpr end end end
[ "def", "write_axis_font", "(", "font", ")", "# :nodoc:", "return", "unless", "font", "@writer", ".", "tag_elements", "(", "'c:txPr'", ")", "do", "write_a_body_pr", "(", "font", "[", ":_rotation", "]", ")", "write_a_lst_style", "@writer", ".", "tag_elements", "("...
Write the axis font elements.
[ "Write", "the", "axis", "font", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L2504-L2515
19,318
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_error_bars
def write_error_bars(error_bars) return unless ptrue?(error_bars) if error_bars[:_x_error_bars] write_err_bars('x', error_bars[:_x_error_bars]) end if error_bars[:_y_error_bars] write_err_bars('y', error_bars[:_y_error_bars]) end end
ruby
def write_error_bars(error_bars) return unless ptrue?(error_bars) if error_bars[:_x_error_bars] write_err_bars('x', error_bars[:_x_error_bars]) end if error_bars[:_y_error_bars] write_err_bars('y', error_bars[:_y_error_bars]) end end
[ "def", "write_error_bars", "(", "error_bars", ")", "return", "unless", "ptrue?", "(", "error_bars", ")", "if", "error_bars", "[", ":_x_error_bars", "]", "write_err_bars", "(", "'x'", ",", "error_bars", "[", ":_x_error_bars", "]", ")", "end", "if", "error_bars", ...
Write the X and Y error bars.
[ "Write", "the", "X", "and", "Y", "error", "bars", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L2534-L2543
19,319
cxn03651/write_xlsx
lib/write_xlsx/chart.rb
Writexlsx.Chart.write_custom_error
def write_custom_error(error_bars) if ptrue?(error_bars.plus_values) write_custom_error_base('c:plus', error_bars.plus_values, error_bars.plus_data) write_custom_error_base('c:minus', error_bars.minus_values, error_bars.minus_data) end end
ruby
def write_custom_error(error_bars) if ptrue?(error_bars.plus_values) write_custom_error_base('c:plus', error_bars.plus_values, error_bars.plus_data) write_custom_error_base('c:minus', error_bars.minus_values, error_bars.minus_data) end end
[ "def", "write_custom_error", "(", "error_bars", ")", "if", "ptrue?", "(", "error_bars", ".", "plus_values", ")", "write_custom_error_base", "(", "'c:plus'", ",", "error_bars", ".", "plus_values", ",", "error_bars", ".", "plus_data", ")", "write_custom_error_base", "...
Write the custom error bars type.
[ "Write", "the", "custom", "error", "bars", "type", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/chart.rb#L2620-L2625
19,320
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.protect
def protect(password = nil, options = {}) check_parameter(options, protect_default_settings.keys, 'protect') @protect = protect_default_settings.merge(options) # Set the password after the user defined values. @protect[:password] = sprintf("%X", encode_password(password)) if password &&...
ruby
def protect(password = nil, options = {}) check_parameter(options, protect_default_settings.keys, 'protect') @protect = protect_default_settings.merge(options) # Set the password after the user defined values. @protect[:password] = sprintf("%X", encode_password(password)) if password &&...
[ "def", "protect", "(", "password", "=", "nil", ",", "options", "=", "{", "}", ")", "check_parameter", "(", "options", ",", "protect_default_settings", ".", "keys", ",", "'protect'", ")", "@protect", "=", "protect_default_settings", ".", "merge", "(", "options"...
Set the worksheet protection flags to prevent modification of worksheet objects. The protect() method is used to protect a worksheet from modification: worksheet.protect The protect() method also has the effect of enabling a cell's locked and hidden properties if they have been set. A locked cell cannot be ...
[ "Set", "the", "worksheet", "protection", "flags", "to", "prevent", "modification", "of", "worksheet", "objects", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L602-L609
19,321
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.set_header
def set_header(string = '', margin = 0.3, options = {}) raise 'Header string must be less than 255 characters' if string.length >= 255 # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.header = string.gsub(/&\[Picture\]/, '&G') if string.size >= 255 raise 'Hea...
ruby
def set_header(string = '', margin = 0.3, options = {}) raise 'Header string must be less than 255 characters' if string.length >= 255 # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.header = string.gsub(/&\[Picture\]/, '&G') if string.size >= 255 raise 'Hea...
[ "def", "set_header", "(", "string", "=", "''", ",", "margin", "=", "0.3", ",", "options", "=", "{", "}", ")", "raise", "'Header string must be less than 255 characters'", "if", "string", ".", "length", ">=", "255", "# Replace the Excel placeholder &[Picture] with the ...
Set the page header caption and optional margin. Headers and footers are generated using a string which is a combination of plain text and control characters. The margin parameter is optional. The available control character are: Control Category Description ======= ==...
[ "Set", "the", "page", "header", "caption", "and", "optional", "margin", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1198-L1239
19,322
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.set_footer
def set_footer(string = '', margin = 0.3, options = {}) raise 'Footer string must be less than 255 characters' if string.length >= 255 @page_setup.footer = string.dup # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.footer = string.gsub(/&\[Picture\]/...
ruby
def set_footer(string = '', margin = 0.3, options = {}) raise 'Footer string must be less than 255 characters' if string.length >= 255 @page_setup.footer = string.dup # Replace the Excel placeholder &[Picture] with the internal &G. @page_setup.footer = string.gsub(/&\[Picture\]/...
[ "def", "set_footer", "(", "string", "=", "''", ",", "margin", "=", "0.3", ",", "options", "=", "{", "}", ")", "raise", "'Footer string must be less than 255 characters'", "if", "string", ".", "length", ">=", "255", "@page_setup", ".", "footer", "=", "string", ...
Set the page footer caption and optional margin. The syntax of the set_footer() method is the same as set_header()
[ "Set", "the", "page", "footer", "caption", "and", "optional", "margin", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1246-L1290
19,323
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.repeat_rows
def repeat_rows(row_min, row_max = nil) row_max ||= row_min # Convert to 1 based. row_min += 1 row_max += 1 area = "$#{row_min}:$#{row_max}" # Build up the print titles "Sheet1!$1:$2" sheetname = quote_sheetname(@name) @page_setup.repeat_rows = "#{sheetname}!#{area}" ...
ruby
def repeat_rows(row_min, row_max = nil) row_max ||= row_min # Convert to 1 based. row_min += 1 row_max += 1 area = "$#{row_min}:$#{row_max}" # Build up the print titles "Sheet1!$1:$2" sheetname = quote_sheetname(@name) @page_setup.repeat_rows = "#{sheetname}!#{area}" ...
[ "def", "repeat_rows", "(", "row_min", ",", "row_max", "=", "nil", ")", "row_max", "||=", "row_min", "# Convert to 1 based.", "row_min", "+=", "1", "row_max", "+=", "1", "area", "=", "\"$#{row_min}:$#{row_max}\"", "# Build up the print titles \"Sheet1!$1:$2\"", "sheetnam...
Set the number of rows to repeat at the top of each printed page. For large Excel documents it is often desirable to have the first row or rows of the worksheet print out at the top of each page. This can be achieved by using the repeat_rows() method. The parameters first_row and last_row are zero based. The last_...
[ "Set", "the", "number", "of", "rows", "to", "repeat", "at", "the", "top", "of", "each", "printed", "page", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1482-L1494
19,324
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.print_across
def print_across(across = true) if across @page_setup.across = true @page_setup.page_setup_changed = true else @page_setup.across = false end end
ruby
def print_across(across = true) if across @page_setup.across = true @page_setup.page_setup_changed = true else @page_setup.across = false end end
[ "def", "print_across", "(", "across", "=", "true", ")", "if", "across", "@page_setup", ".", "across", "=", "true", "@page_setup", ".", "page_setup_changed", "=", "true", "else", "@page_setup", ".", "across", "=", "false", "end", "end" ]
Set the order in which pages are printed. The print_across method is used to change the default print direction. This is referred to by Excel as the sheet "page order". worksheet.print_across The default page order is shown below for a worksheet that extends over 4 pages. The order is called "down then acro...
[ "Set", "the", "order", "in", "which", "pages", "are", "printed", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L1685-L1692
19,325
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.filter_column
def filter_column(col, expression) raise "Must call autofilter before filter_column" unless @autofilter_area col = prepare_filter_column(col) tokens = extract_filter_tokens(expression) unless tokens.size == 3 || tokens.size == 7 raise "Incorrect number of tokens in expression '#{expre...
ruby
def filter_column(col, expression) raise "Must call autofilter before filter_column" unless @autofilter_area col = prepare_filter_column(col) tokens = extract_filter_tokens(expression) unless tokens.size == 3 || tokens.size == 7 raise "Incorrect number of tokens in expression '#{expre...
[ "def", "filter_column", "(", "col", ",", "expression", ")", "raise", "\"Must call autofilter before filter_column\"", "unless", "@autofilter_area", "col", "=", "prepare_filter_column", "(", "col", ")", "tokens", "=", "extract_filter_tokens", "(", "expression", ")", "unl...
Set the column filter criteria. The filter_column method can be used to filter columns in a autofilter range based on simple conditions. NOTE: It isn't sufficient to just specify the filter condition. You must also hide any rows that don't match the filter condition. Rows are hidden using the set_row() +visible+...
[ "Set", "the", "column", "filter", "criteria", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5389-L5417
19,326
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.filter_column_list
def filter_column_list(col, *tokens) tokens.flatten! raise "Incorrect number of arguments to filter_column_list" if tokens.empty? raise "Must call autofilter before filter_column_list" unless @autofilter_area col = prepare_filter_column(col) @filter_cols[col] = tokens @filter_type[...
ruby
def filter_column_list(col, *tokens) tokens.flatten! raise "Incorrect number of arguments to filter_column_list" if tokens.empty? raise "Must call autofilter before filter_column_list" unless @autofilter_area col = prepare_filter_column(col) @filter_cols[col] = tokens @filter_type[...
[ "def", "filter_column_list", "(", "col", ",", "*", "tokens", ")", "tokens", ".", "flatten!", "raise", "\"Incorrect number of arguments to filter_column_list\"", "if", "tokens", ".", "empty?", "raise", "\"Must call autofilter before filter_column_list\"", "unless", "@autofilte...
Set the column filter criteria in Excel 2007 list style. Prior to Excel 2007 it was only possible to have either 1 or 2 filter conditions such as the ones shown above in the filter_column method. Excel 2007 introduced a new list style filter where it is possible to specify 1 or more 'or' style criteria. For examp...
[ "Set", "the", "column", "filter", "criteria", "in", "Excel", "2007", "list", "style", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5462-L5472
19,327
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.set_h_pagebreaks
def set_h_pagebreaks(*args) breaks = args.collect do |brk| Array(brk) end.flatten @page_setup.hbreaks += breaks end
ruby
def set_h_pagebreaks(*args) breaks = args.collect do |brk| Array(brk) end.flatten @page_setup.hbreaks += breaks end
[ "def", "set_h_pagebreaks", "(", "*", "args", ")", "breaks", "=", "args", ".", "collect", "do", "|", "brk", "|", "Array", "(", "brk", ")", "end", ".", "flatten", "@page_setup", ".", "hbreaks", "+=", "breaks", "end" ]
Store the horizontal page breaks on a worksheet. Add horizontal page breaks to a worksheet. A page break causes all the data that follows it to be printed on the next page. Horizontal page breaks act between rows. To create a page break between rows 20 and 21 you must specify the break at row 21. However in zero i...
[ "Store", "the", "horizontal", "page", "breaks", "on", "a", "worksheet", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5498-L5503
19,328
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.get_range_data
def get_range_data(row_start, col_start, row_end, col_end) # :nodoc: # TODO. Check for worksheet limits. # Iterate through the table data. data = [] (row_start .. row_end).each do |row_num| # Store nil if row doesn't exist. if !@cell_data_table[row_num] data << nil ...
ruby
def get_range_data(row_start, col_start, row_end, col_end) # :nodoc: # TODO. Check for worksheet limits. # Iterate through the table data. data = [] (row_start .. row_end).each do |row_num| # Store nil if row doesn't exist. if !@cell_data_table[row_num] data << nil ...
[ "def", "get_range_data", "(", "row_start", ",", "col_start", ",", "row_end", ",", "col_end", ")", "# :nodoc:", "# TODO. Check for worksheet limits.", "# Iterate through the table data.", "data", "=", "[", "]", "(", "row_start", "..", "row_end", ")", ".", "each", "do...
Returns a range of data from the worksheet _table to be used in chart cached data. Strings are returned as SST ids and decoded in the workbook. Return nils for data that doesn't exist since Excel can chart series with data missing.
[ "Returns", "a", "range", "of", "data", "from", "the", "worksheet", "_table", "to", "be", "used", "in", "chart", "cached", "data", ".", "Strings", "are", "returned", "as", "SST", "ids", "and", "decoded", "in", "the", "workbook", ".", "Return", "nils", "fo...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5646-L5669
19,329
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.position_object_pixels
def position_object_pixels(col_start, row_start, x1, y1, width, height) #:nodoc: # Calculate the absolute x offset of the top-left vertex. if @col_size_changed x_abs = (0 .. col_start-1).inject(0) {|sum, col| sum += size_col(col)} else # Optimisation for when the column widths haven't ...
ruby
def position_object_pixels(col_start, row_start, x1, y1, width, height) #:nodoc: # Calculate the absolute x offset of the top-left vertex. if @col_size_changed x_abs = (0 .. col_start-1).inject(0) {|sum, col| sum += size_col(col)} else # Optimisation for when the column widths haven't ...
[ "def", "position_object_pixels", "(", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "width", ",", "height", ")", "#:nodoc:", "# Calculate the absolute x offset of the top-left vertex.", "if", "@col_size_changed", "x_abs", "=", "(", "0", "..", "col_start", ...
Calculate the vertices that define the position of a graphical object within the worksheet in pixels. +------------+------------+ | A | B | +-----+------------+------------+ | |(x1,y1) | | | 1 |(A1)._______|______ | | | | | ...
[ "Calculate", "the", "vertices", "that", "define", "the", "position", "of", "a", "graphical", "object", "within", "the", "worksheet", "in", "pixels", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5718-L5762
19,330
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.prepare_vml_objects
def prepare_vml_objects(vml_data_id, vml_shape_id, vml_drawing_id, comment_id) set_external_vml_links(vml_drawing_id) set_external_comment_links(comment_id) if has_comments? # The VML o:idmap data id contains a comma separated range when there is # more than one 1024 block of comments, like thi...
ruby
def prepare_vml_objects(vml_data_id, vml_shape_id, vml_drawing_id, comment_id) set_external_vml_links(vml_drawing_id) set_external_comment_links(comment_id) if has_comments? # The VML o:idmap data id contains a comma separated range when there is # more than one 1024 block of comments, like thi...
[ "def", "prepare_vml_objects", "(", "vml_data_id", ",", "vml_shape_id", ",", "vml_drawing_id", ",", "comment_id", ")", "set_external_vml_links", "(", "vml_drawing_id", ")", "set_external_comment_links", "(", "comment_id", ")", "if", "has_comments?", "# The VML o:idmap data i...
Turn the HoH that stores the comments into an array for easier handling and set the external links for comments and buttons.
[ "Turn", "the", "HoH", "that", "stores", "the", "comments", "into", "an", "array", "for", "easier", "handling", "and", "set", "the", "external", "links", "for", "comments", "and", "buttons", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5846-L5858
19,331
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.prepare_tables
def prepare_tables(table_id) if tables_count > 0 id = table_id tables.each do |table| table.prepare(id) # Store the link used for the rels file. @external_table_links << ['/table', "../tables/table#{id}.xml"] id += 1 end end tables_count...
ruby
def prepare_tables(table_id) if tables_count > 0 id = table_id tables.each do |table| table.prepare(id) # Store the link used for the rels file. @external_table_links << ['/table', "../tables/table#{id}.xml"] id += 1 end end tables_count...
[ "def", "prepare_tables", "(", "table_id", ")", "if", "tables_count", ">", "0", "id", "=", "table_id", "tables", ".", "each", "do", "|", "table", "|", "table", ".", "prepare", "(", "id", ")", "# Store the link used for the rels file.", "@external_table_links", "<...
Set the table ids for the worksheet tables.
[ "Set", "the", "table", "ids", "for", "the", "worksheet", "tables", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5871-L5883
19,332
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.write_formatted_blank_to_area
def write_formatted_blank_to_area(row_first, row_last, col_first, col_last, format) (row_first .. row_last).each do |row| (col_first .. col_last).each do |col| next if row == row_first && col == col_first write_blank(row, col, format) end end end
ruby
def write_formatted_blank_to_area(row_first, row_last, col_first, col_last, format) (row_first .. row_last).each do |row| (col_first .. col_last).each do |col| next if row == row_first && col == col_first write_blank(row, col, format) end end end
[ "def", "write_formatted_blank_to_area", "(", "row_first", ",", "row_last", ",", "col_first", ",", "col_last", ",", "format", ")", "(", "row_first", "..", "row_last", ")", ".", "each", "do", "|", "row", "|", "(", "col_first", "..", "col_last", ")", ".", "ea...
Pad out the rest of the area with formatted blank cells.
[ "Pad", "out", "the", "rest", "of", "the", "area", "with", "formatted", "blank", "cells", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L5998-L6005
19,333
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.parse_filter_tokens
def parse_filter_tokens(expression, tokens) #:nodoc: operators = { '==' => 2, '=' => 2, '=~' => 2, 'eq' => 2, '!=' => 5, '!~' => 5, 'ne' => 5, '<>' => 5, '<' => 1, '<=' => 3, '>' => 4, '>=' => 6, } ...
ruby
def parse_filter_tokens(expression, tokens) #:nodoc: operators = { '==' => 2, '=' => 2, '=~' => 2, 'eq' => 2, '!=' => 5, '!~' => 5, 'ne' => 5, '<>' => 5, '<' => 1, '<=' => 3, '>' => 4, '>=' => 6, } ...
[ "def", "parse_filter_tokens", "(", "expression", ",", "tokens", ")", "#:nodoc:", "operators", "=", "{", "'=='", "=>", "2", ",", "'='", "=>", "2", ",", "'=~'", "=>", "2", ",", "'eq'", "=>", "2", ",", "'!='", "=>", "5", ",", "'!~'", "=>", "5", ",", ...
Parse the 3 tokens of a filter expression and return the operator and token.
[ "Parse", "the", "3", "tokens", "of", "a", "filter", "expression", "and", "return", "the", "operator", "and", "token", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6078-L6164
19,334
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.position_object_emus
def position_object_emus(col_start, row_start, x1, y1, width, height, x_dpi = 96, y_dpi = 96) #:nodoc: col_start, row_start, x1, y1, col_end, row_end, x2, y2, x_abs, y_abs = position_object_pixels(col_start, row_start, x1, y1, width, height) # Convert the pixel values to EMUs. See above. x1 ...
ruby
def position_object_emus(col_start, row_start, x1, y1, width, height, x_dpi = 96, y_dpi = 96) #:nodoc: col_start, row_start, x1, y1, col_end, row_end, x2, y2, x_abs, y_abs = position_object_pixels(col_start, row_start, x1, y1, width, height) # Convert the pixel values to EMUs. See above. x1 ...
[ "def", "position_object_emus", "(", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "width", ",", "height", ",", "x_dpi", "=", "96", ",", "y_dpi", "=", "96", ")", "#:nodoc:", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "col_end"...
Calculate the vertices that define the position of a graphical object within the worksheet in EMUs. The vertices are expressed as English Metric Units (EMUs). There are 12,700 EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per pixel.
[ "Calculate", "the", "vertices", "that", "define", "the", "position", "of", "a", "graphical", "object", "within", "the", "worksheet", "in", "EMUs", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6212-L6225
19,335
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.size_col
def size_col(col) #:nodoc: # Look up the cell value to see if it has been changed. if @col_sizes[col] width = @col_sizes[col] # Convert to pixels. if width == 0 pixels = 0 elsif width < 1 pixels = (width * (MAX_DIGIT_WIDTH + PADDING) + 0.5).to_i e...
ruby
def size_col(col) #:nodoc: # Look up the cell value to see if it has been changed. if @col_sizes[col] width = @col_sizes[col] # Convert to pixels. if width == 0 pixels = 0 elsif width < 1 pixels = (width * (MAX_DIGIT_WIDTH + PADDING) + 0.5).to_i e...
[ "def", "size_col", "(", "col", ")", "#:nodoc:", "# Look up the cell value to see if it has been changed.", "if", "@col_sizes", "[", "col", "]", "width", "=", "@col_sizes", "[", "col", "]", "# Convert to pixels.", "if", "width", "==", "0", "pixels", "=", "0", "elsi...
Convert the width of a cell from user's units to pixels. Excel rounds the column width to the nearest pixel. If the width hasn't been set by the user we use the default value. If the column is hidden it has a value of zero.
[ "Convert", "the", "width", "of", "a", "cell", "from", "user", "s", "units", "to", "pixels", ".", "Excel", "rounds", "the", "column", "width", "to", "the", "nearest", "pixel", ".", "If", "the", "width", "hasn", "t", "been", "set", "by", "the", "user", ...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6232-L6249
19,336
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.size_row
def size_row(row) #:nodoc: # Look up the cell value to see if it has been changed if @row_sizes[row] height = @row_sizes[row] if height == 0 pixels = 0 else pixels = (4 / 3.0 * height).to_i end else pixels = (4 / 3.0 * @default_row_height).t...
ruby
def size_row(row) #:nodoc: # Look up the cell value to see if it has been changed if @row_sizes[row] height = @row_sizes[row] if height == 0 pixels = 0 else pixels = (4 / 3.0 * height).to_i end else pixels = (4 / 3.0 * @default_row_height).t...
[ "def", "size_row", "(", "row", ")", "#:nodoc:", "# Look up the cell value to see if it has been changed", "if", "@row_sizes", "[", "row", "]", "height", "=", "@row_sizes", "[", "row", "]", "if", "height", "==", "0", "pixels", "=", "0", "else", "pixels", "=", "...
Convert the height of a cell from user's units to pixels. If the height hasn't been set by the user we use the default value. If the row is hidden it has a value of zero.
[ "Convert", "the", "height", "of", "a", "cell", "from", "user", "s", "units", "to", "pixels", ".", "If", "the", "height", "hasn", "t", "been", "set", "by", "the", "user", "we", "use", "the", "default", "value", ".", "If", "the", "row", "is", "hidden",...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6256-L6270
19,337
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.prepare_shape
def prepare_shape(index, drawing_id) shape = @shapes[index] # Create a Drawing object to use with worksheet unless one already exists. unless drawing? @drawing = Drawing.new @drawing.embedded = 1 @external_drawing_links << ['/drawing', "../drawings/drawing#{drawing_id}.xml"] ...
ruby
def prepare_shape(index, drawing_id) shape = @shapes[index] # Create a Drawing object to use with worksheet unless one already exists. unless drawing? @drawing = Drawing.new @drawing.embedded = 1 @external_drawing_links << ['/drawing', "../drawings/drawing#{drawing_id}.xml"] ...
[ "def", "prepare_shape", "(", "index", ",", "drawing_id", ")", "shape", "=", "@shapes", "[", "index", "]", "# Create a Drawing object to use with worksheet unless one already exists.", "unless", "drawing?", "@drawing", "=", "Drawing", ".", "new", "@drawing", ".", "embedd...
Set up drawing shapes
[ "Set", "up", "drawing", "shapes" ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6410-L6427
19,338
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.button_params
def button_params(row, col, params) button = Writexlsx::Package::Button.new button_number = 1 + @buttons_array.size # Set the button caption. caption = params[:caption] || "Button #{button_number}" button.font = { :_caption => caption } # Set the macro name. if params[:macr...
ruby
def button_params(row, col, params) button = Writexlsx::Package::Button.new button_number = 1 + @buttons_array.size # Set the button caption. caption = params[:caption] || "Button #{button_number}" button.font = { :_caption => caption } # Set the macro name. if params[:macr...
[ "def", "button_params", "(", "row", ",", "col", ",", "params", ")", "button", "=", "Writexlsx", "::", "Package", "::", "Button", ".", "new", "button_number", "=", "1", "+", "@buttons_array", ".", "size", "# Set the button caption.", "caption", "=", "params", ...
This method handles the parameters passed to insert_button as well as calculating the comment object position and vertices.
[ "This", "method", "handles", "the", "parameters", "passed", "to", "insert_button", "as", "well", "as", "calculating", "the", "comment", "object", "position", "and", "vertices", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6434-L6492
19,339
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.write_rows
def write_rows #:nodoc: calculate_spans (@dim_rowmin .. @dim_rowmax).each do |row_num| # Skip row if it doesn't contain row formatting or cell data. next if not_contain_formatting_or_data?(row_num) span_index = row_num / 16 span = @row_spans[span_index] # Wri...
ruby
def write_rows #:nodoc: calculate_spans (@dim_rowmin .. @dim_rowmax).each do |row_num| # Skip row if it doesn't contain row formatting or cell data. next if not_contain_formatting_or_data?(row_num) span_index = row_num / 16 span = @row_spans[span_index] # Wri...
[ "def", "write_rows", "#:nodoc:", "calculate_spans", "(", "@dim_rowmin", "..", "@dim_rowmax", ")", ".", "each", "do", "|", "row_num", "|", "# Skip row if it doesn't contain row formatting or cell data.", "next", "if", "not_contain_formatting_or_data?", "(", "row_num", ")", ...
Write out the worksheet data as a series of rows and cells.
[ "Write", "out", "the", "worksheet", "data", "as", "a", "series", "of", "rows", "and", "cells", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6761-L6784
19,340
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.calculate_x_split_width
def calculate_x_split_width(width) #:nodoc: # Convert to pixels. if width < 1 pixels = int(width * 12 + 0.5) else pixels = (width * MAX_DIGIT_WIDTH + 0.5).to_i + PADDING end # Convert to points. points = pixels * 3 / 4 # Convert to twips (twentieths of a point...
ruby
def calculate_x_split_width(width) #:nodoc: # Convert to pixels. if width < 1 pixels = int(width * 12 + 0.5) else pixels = (width * MAX_DIGIT_WIDTH + 0.5).to_i + PADDING end # Convert to points. points = pixels * 3 / 4 # Convert to twips (twentieths of a point...
[ "def", "calculate_x_split_width", "(", "width", ")", "#:nodoc:", "# Convert to pixels.", "if", "width", "<", "1", "pixels", "=", "int", "(", "width", "*", "12", "+", "0.5", ")", "else", "pixels", "=", "(", "width", "*", "MAX_DIGIT_WIDTH", "+", "0.5", ")", ...
Convert column width from user units to pane split width.
[ "Convert", "column", "width", "from", "user", "units", "to", "pane", "split", "width", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L6937-L6953
19,341
cxn03651/write_xlsx
lib/write_xlsx/worksheet.rb
Writexlsx.Worksheet.write_autofilters
def write_autofilters #:nodoc: col1, col2 = @filter_range (col1 .. col2).each do |col| # Skip if column doesn't have an active filter. next unless @filter_cols[col] # Retrieve the filter tokens and write the autofilter records. tokens = @filter_cols[col] type = @f...
ruby
def write_autofilters #:nodoc: col1, col2 = @filter_range (col1 .. col2).each do |col| # Skip if column doesn't have an active filter. next unless @filter_cols[col] # Retrieve the filter tokens and write the autofilter records. tokens = @filter_cols[col] type = @f...
[ "def", "write_autofilters", "#:nodoc:", "col1", ",", "col2", "=", "@filter_range", "(", "col1", "..", "col2", ")", ".", "each", "do", "|", "col", "|", "# Skip if column doesn't have an active filter.", "next", "unless", "@filter_cols", "[", "col", "]", "# Retrieve...
Function to iterate through the columns that form part of an autofilter range and write the appropriate filters.
[ "Function", "to", "iterate", "through", "the", "columns", "that", "form", "part", "of", "an", "autofilter", "range", "and", "write", "the", "appropriate", "filters", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/worksheet.rb#L7108-L7122
19,342
cxn03651/write_xlsx
lib/write_xlsx/shape.rb
Writexlsx.Shape.calc_position_emus
def calc_position_emus(worksheet) c_start, r_start, xx1, yy1, c_end, r_end, xx2, yy2, x_abslt, y_abslt = worksheet.position_object_pixels( @column_start, @row_start, @x_offset, @y_of...
ruby
def calc_position_emus(worksheet) c_start, r_start, xx1, yy1, c_end, r_end, xx2, yy2, x_abslt, y_abslt = worksheet.position_object_pixels( @column_start, @row_start, @x_offset, @y_of...
[ "def", "calc_position_emus", "(", "worksheet", ")", "c_start", ",", "r_start", ",", "xx1", ",", "yy1", ",", "c_end", ",", "r_end", ",", "xx2", ",", "yy2", ",", "x_abslt", ",", "y_abslt", "=", "worksheet", ".", "position_object_pixels", "(", "@column_start", ...
Calculate the vertices that define the position of a shape object within the worksheet in EMUs. Save the vertices with the object. The vertices are expressed as English Metric Units (EMUs). There are 12,700 EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per pixel.
[ "Calculate", "the", "vertices", "that", "define", "the", "position", "of", "a", "shape", "object", "within", "the", "worksheet", "in", "EMUs", ".", "Save", "the", "vertices", "with", "the", "object", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/shape.rb#L156-L184
19,343
cxn03651/write_xlsx
lib/write_xlsx/shape.rb
Writexlsx.Shape.auto_locate_connectors
def auto_locate_connectors(shapes, shape_hash) # Valid connector shapes. connector_shapes = { :straightConnector => 1, :Connector => 1, :bentConnector => 1, :curvedConnector => 1, :line => 1 } shape_base = @type.chop.to_sym # Re...
ruby
def auto_locate_connectors(shapes, shape_hash) # Valid connector shapes. connector_shapes = { :straightConnector => 1, :Connector => 1, :bentConnector => 1, :curvedConnector => 1, :line => 1 } shape_base = @type.chop.to_sym # Re...
[ "def", "auto_locate_connectors", "(", "shapes", ",", "shape_hash", ")", "# Valid connector shapes.", "connector_shapes", "=", "{", ":straightConnector", "=>", "1", ",", ":Connector", "=>", "1", ",", ":bentConnector", "=>", "1", ",", ":curvedConnector", "=>", "1", ...
Re-size connector shapes if they are connected to other shapes.
[ "Re", "-", "size", "connector", "shapes", "if", "they", "are", "connected", "to", "other", "shapes", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/shape.rb#L201-L282
19,344
cxn03651/write_xlsx
lib/write_xlsx/shape.rb
Writexlsx.Shape.validate
def validate(index) unless %w[l ctr r just].include?(@align) raise "Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\n" end unless %w[t ctr b].include?(@valign) raise "Shape #{index} (#{@type}) vertical alignment (#{@valign}) not in ['t', 'ctr', 'v']\n"...
ruby
def validate(index) unless %w[l ctr r just].include?(@align) raise "Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\n" end unless %w[t ctr b].include?(@valign) raise "Shape #{index} (#{@type}) vertical alignment (#{@valign}) not in ['t', 'ctr', 'v']\n"...
[ "def", "validate", "(", "index", ")", "unless", "%w[", "l", "ctr", "r", "just", "]", ".", "include?", "(", "@align", ")", "raise", "\"Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\\n\"", "end", "unless", "%w[", "t", "ctr", "b", "]"...
Check shape attributes to ensure they are valid.
[ "Check", "shape", "attributes", "to", "ensure", "they", "are", "valid", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/shape.rb#L287-L295
19,345
cxn03651/write_xlsx
lib/write_xlsx/format.rb
Writexlsx.Format.copy
def copy(other) reserve = [ :xf_index, :dxf_index, :xdf_format_indices, :palette ] (instance_variables - reserve).each do |v| instance_variable_set(v, other.instance_variable_get(v)) end end
ruby
def copy(other) reserve = [ :xf_index, :dxf_index, :xdf_format_indices, :palette ] (instance_variables - reserve).each do |v| instance_variable_set(v, other.instance_variable_get(v)) end end
[ "def", "copy", "(", "other", ")", "reserve", "=", "[", ":xf_index", ",", ":dxf_index", ",", ":xdf_format_indices", ",", ":palette", "]", "(", "instance_variables", "-", "reserve", ")", ".", "each", "do", "|", "v", "|", "instance_variable_set", "(", "v", ",...
Copy the attributes of another Format object.
[ "Copy", "the", "attributes", "of", "another", "Format", "object", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/format.rb#L248-L258
19,346
cxn03651/write_xlsx
lib/write_xlsx/utility.rb
Writexlsx.Utility.layout_properties
def layout_properties(args, is_text = false) return unless ptrue?(args) properties = is_text ? [:x, :y] : [:x, :y, :width, :height] # Check for valid properties. args.keys.each do |key| unless properties.include?(key.to_sym) raise "Property '#{key}' not allowed in layout op...
ruby
def layout_properties(args, is_text = false) return unless ptrue?(args) properties = is_text ? [:x, :y] : [:x, :y, :width, :height] # Check for valid properties. args.keys.each do |key| unless properties.include?(key.to_sym) raise "Property '#{key}' not allowed in layout op...
[ "def", "layout_properties", "(", "args", ",", "is_text", "=", "false", ")", "return", "unless", "ptrue?", "(", "args", ")", "properties", "=", "is_text", "?", "[", ":x", ",", ":y", "]", ":", "[", ":x", ",", ":y", ",", ":width", ",", ":height", "]", ...
Convert user defined layout properties to the format required internally.
[ "Convert", "user", "defined", "layout", "properties", "to", "the", "format", "required", "internally", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/utility.rb#L365-L386
19,347
cxn03651/write_xlsx
lib/write_xlsx/utility.rb
Writexlsx.Utility.pixels_to_points
def pixels_to_points(vertices) col_start, row_start, x1, y1, col_end, row_end, x2, y2, left, top, width, height = vertices.flatten left *= 0.75 top *= 0.75 width *= 0.75 height *= 0.75 [left, top, width, height] end
ruby
def pixels_to_points(vertices) col_start, row_start, x1, y1, col_end, row_end, x2, y2, left, top, width, height = vertices.flatten left *= 0.75 top *= 0.75 width *= 0.75 height *= 0.75 [left, top, width, height] end
[ "def", "pixels_to_points", "(", "vertices", ")", "col_start", ",", "row_start", ",", "x1", ",", "y1", ",", "col_end", ",", "row_end", ",", "x2", ",", "y2", ",", "left", ",", "top", ",", "width", ",", "height", "=", "vertices", ".", "flatten", "left", ...
Convert vertices from pixels to points.
[ "Convert", "vertices", "from", "pixels", "to", "points", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/utility.rb#L391-L402
19,348
cxn03651/write_xlsx
lib/write_xlsx/sparkline.rb
Writexlsx.Sparkline.write_spark_color
def write_spark_color(element, color) # :nodoc: attr = [] attr << ['rgb', color[:_rgb]] if color[:_rgb] attr << ['theme', color[:_theme]] if color[:_theme] attr << ['tint', color[:_tint]] if color[:_tint] @writer.empty_tag(element, attr) end
ruby
def write_spark_color(element, color) # :nodoc: attr = [] attr << ['rgb', color[:_rgb]] if color[:_rgb] attr << ['theme', color[:_theme]] if color[:_theme] attr << ['tint', color[:_tint]] if color[:_tint] @writer.empty_tag(element, attr) end
[ "def", "write_spark_color", "(", "element", ",", "color", ")", "# :nodoc:", "attr", "=", "[", "]", "attr", "<<", "[", "'rgb'", ",", "color", "[", ":_rgb", "]", "]", "if", "color", "[", ":_rgb", "]", "attr", "<<", "[", "'theme'", ",", "color", "[", ...
Helper function for the sparkline color functions below.
[ "Helper", "function", "for", "the", "sparkline", "color", "functions", "below", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/sparkline.rb#L272-L280
19,349
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.assemble_xml_file
def assemble_xml_file #:nodoc: return unless @writer # Prepare format object for passing to Style.rb. prepare_format_properties write_xml_declaration do # Write the root workbook element. write_workbook do # Write the XLSX file version. write_file_version...
ruby
def assemble_xml_file #:nodoc: return unless @writer # Prepare format object for passing to Style.rb. prepare_format_properties write_xml_declaration do # Write the root workbook element. write_workbook do # Write the XLSX file version. write_file_version...
[ "def", "assemble_xml_file", "#:nodoc:", "return", "unless", "@writer", "# Prepare format object for passing to Style.rb.", "prepare_format_properties", "write_xml_declaration", "do", "# Write the root workbook element.", "write_workbook", "do", "# Write the XLSX file version.", "write_fi...
user must not use. it is internal method.
[ "user", "must", "not", "use", ".", "it", "is", "internal", "method", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L257-L290
19,350
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.add_format
def add_format(property_hash = {}) properties = {} if @excel2003_style properties.update(:font => 'Arial', :size => 10, :theme => -1) end properties.update(property_hash) format = Format.new(@formats, properties) @formats.formats.push(format) # Store format reference ...
ruby
def add_format(property_hash = {}) properties = {} if @excel2003_style properties.update(:font => 'Arial', :size => 10, :theme => -1) end properties.update(property_hash) format = Format.new(@formats, properties) @formats.formats.push(format) # Store format reference ...
[ "def", "add_format", "(", "property_hash", "=", "{", "}", ")", "properties", "=", "{", "}", "if", "@excel2003_style", "properties", ".", "update", "(", ":font", "=>", "'Arial'", ",", ":size", "=>", "10", ",", ":theme", "=>", "-", "1", ")", "end", "prop...
The +add_format+ method can be used to create new Format objects which are used to apply formatting to a cell. You can either define the properties at creation time via a hash of property values or later via method calls. format1 = workbook.add_format(property_hash) # Set properties at creation format2 = ...
[ "The", "+", "add_format", "+", "method", "can", "be", "used", "to", "create", "new", "Format", "objects", "which", "are", "used", "to", "apply", "formatting", "to", "a", "cell", ".", "You", "can", "either", "define", "the", "properties", "at", "creation", ...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L427-L439
19,351
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.add_shape
def add_shape(properties = {}) shape = Shape.new(properties) shape.palette = @palette @shapes ||= [] @shapes << shape #Store shape reference. shape end
ruby
def add_shape(properties = {}) shape = Shape.new(properties) shape.palette = @palette @shapes ||= [] @shapes << shape #Store shape reference. shape end
[ "def", "add_shape", "(", "properties", "=", "{", "}", ")", "shape", "=", "Shape", ".", "new", "(", "properties", ")", "shape", ".", "palette", "=", "@palette", "@shapes", "||=", "[", "]", "@shapes", "<<", "shape", "#Store shape reference.", "shape", "end" ...
The +add_shape+ method can be used to create new shapes that may be inserted into a worksheet. You can either define the properties at creation time via a hash of property values or later via method calls. # Set properties at creation. plus = workbook.add_shape( :type => 'plus', ...
[ "The", "+", "add_shape", "+", "method", "can", "be", "used", "to", "create", "new", "shapes", "that", "may", "be", "inserted", "into", "a", "worksheet", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L675-L682
19,352
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.set_properties
def set_properties(params) # Ignore if no args were passed. return -1 if params.empty? # List of valid input parameters. valid = { :title => 1, :subject => 1, :author => 1, :keywords => 1, :comments => 1, :last_author => 1, ...
ruby
def set_properties(params) # Ignore if no args were passed. return -1 if params.empty? # List of valid input parameters. valid = { :title => 1, :subject => 1, :author => 1, :keywords => 1, :comments => 1, :last_author => 1, ...
[ "def", "set_properties", "(", "params", ")", "# Ignore if no args were passed.", "return", "-", "1", "if", "params", ".", "empty?", "# List of valid input parameters.", "valid", "=", "{", ":title", "=>", "1", ",", ":subject", "=>", "1", ",", ":author", "=>", "1"...
The set_properties method can be used to set the document properties of the Excel file created by WriteXLSX. These properties are visible when you use the Office Button -> Prepare -> Properties option in Excel and are also available to external applications that read or index windows files. The properties should ...
[ "The", "set_properties", "method", "can", "be", "used", "to", "set", "the", "document", "properties", "of", "the", "Excel", "file", "created", "by", "WriteXLSX", ".", "These", "properties", "are", "visible", "when", "you", "use", "the", "Office", "Button", "...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L782-L810
19,353
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.set_custom_color
def set_custom_color(index, red = 0, green = 0, blue = 0) # Match a HTML #xxyyzz style parameter if red =~ /^#(\w\w)(\w\w)(\w\w)/ red = $1.hex green = $2.hex blue = $3.hex end # Check that the colour index is the right range if index < 8 || index > 64 ra...
ruby
def set_custom_color(index, red = 0, green = 0, blue = 0) # Match a HTML #xxyyzz style parameter if red =~ /^#(\w\w)(\w\w)(\w\w)/ red = $1.hex green = $2.hex blue = $3.hex end # Check that the colour index is the right range if index < 8 || index > 64 ra...
[ "def", "set_custom_color", "(", "index", ",", "red", "=", "0", ",", "green", "=", "0", ",", "blue", "=", "0", ")", "# Match a HTML #xxyyzz style parameter", "if", "red", "=~", "/", "\\w", "\\w", "\\w", "\\w", "\\w", "\\w", "/", "red", "=", "$1", ".", ...
Change the RGB components of the elements in the colour palette. The set_custom_color method can be used to override one of the built-in palette values with a more suitable colour. The value for +index+ should be in the range 8..63, see "COLOURS IN EXCEL". The default named colours use the following indices: ...
[ "Change", "the", "RGB", "components", "of", "the", "elements", "in", "the", "colour", "palette", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L927-L956
19,354
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.store_workbook
def store_workbook #:nodoc: # Add a default worksheet if non have been added. add_worksheet if @worksheets.empty? # Ensure that at least one worksheet has been selected. @worksheets.visible_first.select if @activesheet == 0 # Set the active sheet. @activesheet = @worksheets.visible...
ruby
def store_workbook #:nodoc: # Add a default worksheet if non have been added. add_worksheet if @worksheets.empty? # Ensure that at least one worksheet has been selected. @worksheets.visible_first.select if @activesheet == 0 # Set the active sheet. @activesheet = @worksheets.visible...
[ "def", "store_workbook", "#:nodoc:", "# Add a default worksheet if non have been added.", "add_worksheet", "if", "@worksheets", ".", "empty?", "# Ensure that at least one worksheet has been selected.", "@worksheets", ".", "visible_first", ".", "select", "if", "@activesheet", "==", ...
Assemble worksheets into a workbook.
[ "Assemble", "worksheets", "into", "a", "workbook", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1291-L1327
19,355
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_formats
def prepare_formats #:nodoc: @formats.formats.each do |format| xf_index = format.xf_index dxf_index = format.dxf_index @xf_formats[xf_index] = format if xf_index @dxf_formats[dxf_index] = format if dxf_index end end
ruby
def prepare_formats #:nodoc: @formats.formats.each do |format| xf_index = format.xf_index dxf_index = format.dxf_index @xf_formats[xf_index] = format if xf_index @dxf_formats[dxf_index] = format if dxf_index end end
[ "def", "prepare_formats", "#:nodoc:", "@formats", ".", "formats", ".", "each", "do", "|", "format", "|", "xf_index", "=", "format", ".", "xf_index", "dxf_index", "=", "format", ".", "dxf_index", "@xf_formats", "[", "xf_index", "]", "=", "format", "if", "xf_i...
Iterate through the XF Format objects and separate them into XF and DXF formats.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "separate", "them", "into", "XF", "and", "DXF", "formats", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1371-L1379
19,356
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_fonts
def prepare_fonts #:nodoc: fonts = {} @xf_formats.each { |format| format.set_font_info(fonts) } @font_count = fonts.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| # The only font properties that can change for a DXF...
ruby
def prepare_fonts #:nodoc: fonts = {} @xf_formats.each { |format| format.set_font_info(fonts) } @font_count = fonts.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| # The only font properties that can change for a DXF...
[ "def", "prepare_fonts", "#:nodoc:", "fonts", "=", "{", "}", "@xf_formats", ".", "each", "{", "|", "format", "|", "format", ".", "set_font_info", "(", "fonts", ")", "}", "@font_count", "=", "fonts", ".", "size", "# For the DXF formats we only need to check if the p...
Iterate through the XF Format objects and give them an index to non-default font elements.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "font", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1385-L1400
19,357
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_num_formats
def prepare_num_formats #:nodoc: num_formats = {} index = 164 num_format_count = 0 (@xf_formats + @dxf_formats).each do |format| num_format = format.num_format # Check if num_format is an index to a built-in number format. # Also check for a string of ze...
ruby
def prepare_num_formats #:nodoc: num_formats = {} index = 164 num_format_count = 0 (@xf_formats + @dxf_formats).each do |format| num_format = format.num_format # Check if num_format is an index to a built-in number format. # Also check for a string of ze...
[ "def", "prepare_num_formats", "#:nodoc:", "num_formats", "=", "{", "}", "index", "=", "164", "num_format_count", "=", "0", "(", "@xf_formats", "+", "@dxf_formats", ")", ".", "each", "do", "|", "format", "|", "num_format", "=", "format", ".", "num_format", "#...
Iterate through the XF Format objects and give them an index to non-default number format elements. User defined records start from index 0xA4.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "number", "format", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1408-L1441
19,358
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_borders
def prepare_borders #:nodoc: borders = {} @xf_formats.each { |format| format.set_border_info(borders) } @border_count = borders.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| key = format.get_border_key form...
ruby
def prepare_borders #:nodoc: borders = {} @xf_formats.each { |format| format.set_border_info(borders) } @border_count = borders.size # For the DXF formats we only need to check if the properties have changed. @dxf_formats.each do |format| key = format.get_border_key form...
[ "def", "prepare_borders", "#:nodoc:", "borders", "=", "{", "}", "@xf_formats", ".", "each", "{", "|", "format", "|", "format", ".", "set_border_info", "(", "borders", ")", "}", "@border_count", "=", "borders", ".", "size", "# For the DXF formats we only need to ch...
Iterate through the XF Format objects and give them an index to non-default border elements.
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "border", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1447-L1459
19,359
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_fills
def prepare_fills #:nodoc: fills = {} index = 2 # Start from 2. See above. # Add the default fills. fills['0:0:0'] = 0 fills['17:0:0'] = 1 # Store the DXF colors separately since them may be reversed below. @dxf_formats.each do |format| if format.pattern != 0 || ...
ruby
def prepare_fills #:nodoc: fills = {} index = 2 # Start from 2. See above. # Add the default fills. fills['0:0:0'] = 0 fills['17:0:0'] = 1 # Store the DXF colors separately since them may be reversed below. @dxf_formats.each do |format| if format.pattern != 0 || ...
[ "def", "prepare_fills", "#:nodoc:", "fills", "=", "{", "}", "index", "=", "2", "# Start from 2. See above.", "# Add the default fills.", "fills", "[", "'0:0:0'", "]", "=", "0", "fills", "[", "'17:0:0'", "]", "=", "1", "# Store the DXF colors separately since them may ...
Iterate through the XF Format objects and give them an index to non-default fill elements. The user defined fill properties start from 2 since there are 2 default fills: patternType="none" and patternType="gray125".
[ "Iterate", "through", "the", "XF", "Format", "objects", "and", "give", "them", "an", "index", "to", "non", "-", "default", "fill", "elements", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1468-L1521
19,360
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_defined_names
def prepare_defined_names #:nodoc: @worksheets.each do |sheet| # Check for Print Area settings. if sheet.autofilter_area @defined_names << [ '_xlnm._FilterDatabase', sheet.index, sheet.autofilter_area,...
ruby
def prepare_defined_names #:nodoc: @worksheets.each do |sheet| # Check for Print Area settings. if sheet.autofilter_area @defined_names << [ '_xlnm._FilterDatabase', sheet.index, sheet.autofilter_area,...
[ "def", "prepare_defined_names", "#:nodoc:", "@worksheets", ".", "each", "do", "|", "sheet", "|", "# Check for Print Area settings.", "if", "sheet", ".", "autofilter_area", "@defined_names", "<<", "[", "'_xlnm._FilterDatabase'", ",", "sheet", ".", "index", ",", "sheet"...
Iterate through the worksheets and store any defined names in addition to any user defined names. Stores the defined names for the Workbook.xml and the named ranges for App.xml.
[ "Iterate", "through", "the", "worksheets", "and", "store", "any", "defined", "names", "in", "addition", "to", "any", "user", "defined", "names", ".", "Stores", "the", "defined", "names", "for", "the", "Workbook", ".", "xml", "and", "the", "named", "ranges", ...
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1536-L1572
19,361
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_vml_objects
def prepare_vml_objects #:nodoc: comment_id = 0 vml_drawing_id = 0 vml_data_id = 1 vml_header_id = 0 vml_shape_id = 1024 comment_files = 0 has_button = false @worksheets.each do |sheet| next if !sheet.has_vml? && !sheet.has_header_vml? if ...
ruby
def prepare_vml_objects #:nodoc: comment_id = 0 vml_drawing_id = 0 vml_data_id = 1 vml_header_id = 0 vml_shape_id = 1024 comment_files = 0 has_button = false @worksheets.each do |sheet| next if !sheet.has_vml? && !sheet.has_header_vml? if ...
[ "def", "prepare_vml_objects", "#:nodoc:", "comment_id", "=", "0", "vml_drawing_id", "=", "0", "vml_data_id", "=", "1", "vml_header_id", "=", "0", "vml_shape_id", "=", "1024", "comment_files", "=", "0", "has_button", "=", "false", "@worksheets", ".", "each", "do"...
Iterate through the worksheets and set up the VML objects.
[ "Iterate", "through", "the", "worksheets", "and", "set", "up", "the", "VML", "objects", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1577-L1626
19,362
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.extract_named_ranges
def extract_named_ranges(defined_names) #:nodoc: named_ranges = [] defined_names.each do |defined_name| name, index, range = defined_name # Skip autoFilter ranges. next if name == '_xlnm._FilterDatabase' # We are only interested in defined names with ranges. if ran...
ruby
def extract_named_ranges(defined_names) #:nodoc: named_ranges = [] defined_names.each do |defined_name| name, index, range = defined_name # Skip autoFilter ranges. next if name == '_xlnm._FilterDatabase' # We are only interested in defined names with ranges. if ran...
[ "def", "extract_named_ranges", "(", "defined_names", ")", "#:nodoc:", "named_ranges", "=", "[", "]", "defined_names", ".", "each", "do", "|", "defined_name", "|", "name", ",", "index", ",", "range", "=", "defined_name", "# Skip autoFilter ranges.", "next", "if", ...
Extract the named ranges from the sorted list of defined names. These are used in the App.xml file.
[ "Extract", "the", "named", "ranges", "from", "the", "sorted", "list", "of", "defined", "names", ".", "These", "are", "used", "in", "the", "App", ".", "xml", "file", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1770-L1796
19,363
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.prepare_drawings
def prepare_drawings #:nodoc: chart_ref_id = 0 image_ref_id = 0 drawing_id = 0 @worksheets.each do |sheet| chart_count = sheet.charts.size image_count = sheet.images.size shape_count = sheet.shapes.size header_image_count = sheet.header_images.size foote...
ruby
def prepare_drawings #:nodoc: chart_ref_id = 0 image_ref_id = 0 drawing_id = 0 @worksheets.each do |sheet| chart_count = sheet.charts.size image_count = sheet.images.size shape_count = sheet.shapes.size header_image_count = sheet.header_images.size foote...
[ "def", "prepare_drawings", "#:nodoc:", "chart_ref_id", "=", "0", "image_ref_id", "=", "0", "drawing_id", "=", "0", "@worksheets", ".", "each", "do", "|", "sheet", "|", "chart_count", "=", "sheet", ".", "charts", ".", "size", "image_count", "=", "sheet", ".",...
Iterate through the worksheets and set up any chart or image drawings.
[ "Iterate", "through", "the", "worksheets", "and", "set", "up", "any", "chart", "or", "image", "drawings", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1801-L1880
19,364
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.get_image_properties
def get_image_properties(filename) # Note the image_id, and previous_images mechanism isn't currently used. x_dpi = 96 y_dpi = 96 # Open the image file and import the data. data = File.binread(filename) if data.unpack('x A3')[0] == 'PNG' # Test for PNGs. type, width,...
ruby
def get_image_properties(filename) # Note the image_id, and previous_images mechanism isn't currently used. x_dpi = 96 y_dpi = 96 # Open the image file and import the data. data = File.binread(filename) if data.unpack('x A3')[0] == 'PNG' # Test for PNGs. type, width,...
[ "def", "get_image_properties", "(", "filename", ")", "# Note the image_id, and previous_images mechanism isn't currently used.", "x_dpi", "=", "96", "y_dpi", "=", "96", "# Open the image file and import the data.", "data", "=", "File", ".", "binread", "(", "filename", ")", ...
Extract information from the image file such as dimension, type, filename, and extension. Also keep track of previously seen images to optimise out any duplicates.
[ "Extract", "information", "from", "the", "image", "file", "such", "as", "dimension", "type", "filename", "and", "extension", ".", "Also", "keep", "track", "of", "previously", "seen", "images", "to", "optimise", "out", "any", "duplicates", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1887-L1914
19,365
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.process_png
def process_png(data) type = 'png' width = 0 height = 0 x_dpi = 96 y_dpi = 96 offset = 8 data_length = data.size # Search through the image data to read the height and width in th the # IHDR element. Also read the DPI in the pHYs element. while offset <...
ruby
def process_png(data) type = 'png' width = 0 height = 0 x_dpi = 96 y_dpi = 96 offset = 8 data_length = data.size # Search through the image data to read the height and width in th the # IHDR element. Also read the DPI in the pHYs element. while offset <...
[ "def", "process_png", "(", "data", ")", "type", "=", "'png'", "width", "=", "0", "height", "=", "0", "x_dpi", "=", "96", "y_dpi", "=", "96", "offset", "=", "8", "data_length", "=", "data", ".", "size", "# Search through the image data to read the height and wi...
Extract width and height information from a PNG file.
[ "Extract", "width", "and", "height", "information", "from", "a", "PNG", "file", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L1919-L1958
19,366
cxn03651/write_xlsx
lib/write_xlsx/workbook.rb
Writexlsx.Workbook.process_bmp
def process_bmp(data, filename) #:nodoc: type = 'bmp' # Check that the file is big enough to be a bitmap. raise "#{filename} doesn't contain enough data." if data.bytesize <= 0x36 # Read the bitmap width and height. Verify the sizes. width, height = data.unpack("x18 V2") ...
ruby
def process_bmp(data, filename) #:nodoc: type = 'bmp' # Check that the file is big enough to be a bitmap. raise "#{filename} doesn't contain enough data." if data.bytesize <= 0x36 # Read the bitmap width and height. Verify the sizes. width, height = data.unpack("x18 V2") ...
[ "def", "process_bmp", "(", "data", ",", "filename", ")", "#:nodoc:", "type", "=", "'bmp'", "# Check that the file is big enough to be a bitmap.", "raise", "\"#{filename} doesn't contain enough data.\"", "if", "data", ".", "bytesize", "<=", "0x36", "# Read the bitmap width and...
Extract width and height information from a BMP file.
[ "Extract", "width", "and", "height", "information", "from", "a", "BMP", "file", "." ]
6d658b29512e5ab63b947e2b03e67df70a83b55c
https://github.com/cxn03651/write_xlsx/blob/6d658b29512e5ab63b947e2b03e67df70a83b55c/lib/write_xlsx/workbook.rb#L2001-L2021
19,367
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/configuration.rb
XRay.Configuration.daemon_address=
def daemon_address=(v) v = ENV[DaemonConfig::DAEMON_ADDRESS_KEY] || v config = DaemonConfig.new(addr: v) emitter.daemon_config = config sampler.daemon_config = config if sampler.respond_to?(:daemon_config=) end
ruby
def daemon_address=(v) v = ENV[DaemonConfig::DAEMON_ADDRESS_KEY] || v config = DaemonConfig.new(addr: v) emitter.daemon_config = config sampler.daemon_config = config if sampler.respond_to?(:daemon_config=) end
[ "def", "daemon_address", "=", "(", "v", ")", "v", "=", "ENV", "[", "DaemonConfig", "::", "DAEMON_ADDRESS_KEY", "]", "||", "v", "config", "=", "DaemonConfig", ".", "new", "(", "addr", ":", "v", ")", "emitter", ".", "daemon_config", "=", "config", "sampler...
setting daemon address for components communicate with X-Ray daemon.
[ "setting", "daemon", "address", "for", "components", "communicate", "with", "X", "-", "Ray", "daemon", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/configuration.rb#L43-L48
19,368
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/model/subsegment.rb
XRay.Subsegment.all_children_count
def all_children_count size = subsegments.count subsegments.each { |v| size += v.all_children_count } size end
ruby
def all_children_count size = subsegments.count subsegments.each { |v| size += v.all_children_count } size end
[ "def", "all_children_count", "size", "=", "subsegments", ".", "count", "subsegments", ".", "each", "{", "|", "v", "|", "size", "+=", "v", ".", "all_children_count", "}", "size", "end" ]
Returns the number of its direct and indirect children. This is useful when we remove the reference to a subsegment and need to keep remaining subsegment size accurate.
[ "Returns", "the", "number", "of", "its", "direct", "and", "indirect", "children", ".", "This", "is", "useful", "when", "we", "remove", "the", "reference", "to", "a", "subsegment", "and", "need", "to", "keep", "remaining", "subsegment", "size", "accurate", "....
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/model/subsegment.rb#L52-L56
19,369
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/sampling/local/sampler.rb
XRay.LocalSampler.sample_request?
def sample_request?(sampling_req) sample = sample? return sample if sampling_req.nil? || sampling_req.empty? @custom_rules ||= [] @custom_rules.each do |c| return should_sample?(c) if c.applies?(sampling_req) end # use previously made decision based on default rule # if...
ruby
def sample_request?(sampling_req) sample = sample? return sample if sampling_req.nil? || sampling_req.empty? @custom_rules ||= [] @custom_rules.each do |c| return should_sample?(c) if c.applies?(sampling_req) end # use previously made decision based on default rule # if...
[ "def", "sample_request?", "(", "sampling_req", ")", "sample", "=", "sample?", "return", "sample", "if", "sampling_req", ".", "nil?", "||", "sampling_req", ".", "empty?", "@custom_rules", "||=", "[", "]", "@custom_rules", ".", "each", "do", "|", "c", "|", "re...
Return True if the sampler decide to sample based on input information and sampling rules. It will first check if any custom rule should be applied, if not it falls back to the default sampling rule. All arugments are extracted from incoming requests by X-Ray middleware to perform path based sampling.
[ "Return", "True", "if", "the", "sampler", "decide", "to", "sample", "based", "on", "input", "information", "and", "sampling", "rules", ".", "It", "will", "first", "check", "if", "any", "custom", "rule", "should", "be", "applied", "if", "not", "it", "falls"...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/sampling/local/sampler.rb#L56-L66
19,370
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.begin_segment
def begin_segment(name, trace_id: nil, parent_id: nil, sampled: nil) seg_name = name || config.name raise SegmentNameMissingError if seg_name.to_s.empty? # sampling decision comes from outside has higher precedence. sample = sampled.nil? ? config.sample? : sampled if sample segmen...
ruby
def begin_segment(name, trace_id: nil, parent_id: nil, sampled: nil) seg_name = name || config.name raise SegmentNameMissingError if seg_name.to_s.empty? # sampling decision comes from outside has higher precedence. sample = sampled.nil? ? config.sample? : sampled if sample segmen...
[ "def", "begin_segment", "(", "name", ",", "trace_id", ":", "nil", ",", "parent_id", ":", "nil", ",", "sampled", ":", "nil", ")", "seg_name", "=", "name", "||", "config", ".", "name", "raise", "SegmentNameMissingError", "if", "seg_name", ".", "to_s", ".", ...
Begin a segment for the current context. The recorder only keeps one segment at a time. Create a second one without closing existing one will overwrite the existing one. @return [Segment] thew newly created segment.
[ "Begin", "a", "segment", "for", "the", "current", "context", ".", "The", "recorder", "only", "keeps", "one", "segment", "at", "a", "time", ".", "Create", "a", "second", "one", "without", "closing", "existing", "one", "will", "overwrite", "the", "existing", ...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L27-L41
19,371
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.end_segment
def end_segment(end_time: nil) segment = current_segment return unless segment segment.close end_time: end_time context.clear! emitter.send_entity entity: segment if segment.ready_to_send? end
ruby
def end_segment(end_time: nil) segment = current_segment return unless segment segment.close end_time: end_time context.clear! emitter.send_entity entity: segment if segment.ready_to_send? end
[ "def", "end_segment", "(", "end_time", ":", "nil", ")", "segment", "=", "current_segment", "return", "unless", "segment", "segment", ".", "close", "end_time", ":", "end_time", "context", ".", "clear!", "emitter", ".", "send_entity", "entity", ":", "segment", "...
End the current segment and send it to X-Ray daemon if it is ready.
[ "End", "the", "current", "segment", "and", "send", "it", "to", "X", "-", "Ray", "daemon", "if", "it", "is", "ready", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L51-L57
19,372
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.begin_subsegment
def begin_subsegment(name, namespace: nil, segment: nil) entity = segment || current_entity return unless entity if entity.sampled subsegment = Subsegment.new name: name, segment: entity.segment, namespace: namespace else subsegment = DummySubsegment.new name: name, segment: enti...
ruby
def begin_subsegment(name, namespace: nil, segment: nil) entity = segment || current_entity return unless entity if entity.sampled subsegment = Subsegment.new name: name, segment: entity.segment, namespace: namespace else subsegment = DummySubsegment.new name: name, segment: enti...
[ "def", "begin_subsegment", "(", "name", ",", "namespace", ":", "nil", ",", "segment", ":", "nil", ")", "entity", "=", "segment", "||", "current_entity", "return", "unless", "entity", "if", "entity", ".", "sampled", "subsegment", "=", "Subsegment", ".", "new"...
Begin a new subsegment and add it to be the child of the current active subsegment or segment. Also tie the new created subsegment to the current context. Its sampling decision will follow its parent. @return [Subsegment] the newly created subsegment. It could be `nil` if no active entity can be found and `contex...
[ "Begin", "a", "new", "subsegment", "and", "add", "it", "to", "be", "the", "child", "of", "the", "current", "active", "subsegment", "or", "segment", ".", "Also", "tie", "the", "new", "created", "subsegment", "to", "the", "current", "context", ".", "Its", ...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L64-L77
19,373
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.end_subsegment
def end_subsegment(end_time: nil) entity = current_entity return unless entity.is_a?(Subsegment) entity.close end_time: end_time # update current context if entity.parent.closed? context.clear! else context.store_entity entity: entity.parent end # check if...
ruby
def end_subsegment(end_time: nil) entity = current_entity return unless entity.is_a?(Subsegment) entity.close end_time: end_time # update current context if entity.parent.closed? context.clear! else context.store_entity entity: entity.parent end # check if...
[ "def", "end_subsegment", "(", "end_time", ":", "nil", ")", "entity", "=", "current_entity", "return", "unless", "entity", ".", "is_a?", "(", "Subsegment", ")", "entity", ".", "close", "end_time", ":", "end_time", "# update current context", "if", "entity", ".", ...
End the current active subsegment. It also send the entire segment if this subsegment is the last one open or stream out subsegments of its parent segment if the stream threshold is breached.
[ "End", "the", "current", "active", "subsegment", ".", "It", "also", "send", "the", "entire", "segment", "if", "this", "subsegment", "is", "the", "last", "one", "open", "or", "stream", "out", "subsegments", "of", "its", "parent", "segment", "if", "the", "st...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L89-L107
19,374
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.capture
def capture(name, namespace: nil, segment: nil) subsegment = begin_subsegment name, namespace: namespace, segment: segment # prevent passed block from failing in case of context missing with log error if subsegment.nil? segment = DummySegment.new name: name subsegment = DummySubsegment...
ruby
def capture(name, namespace: nil, segment: nil) subsegment = begin_subsegment name, namespace: namespace, segment: segment # prevent passed block from failing in case of context missing with log error if subsegment.nil? segment = DummySegment.new name: name subsegment = DummySubsegment...
[ "def", "capture", "(", "name", ",", "namespace", ":", "nil", ",", "segment", ":", "nil", ")", "subsegment", "=", "begin_subsegment", "name", ",", "namespace", ":", "namespace", ",", "segment", ":", "segment", "# prevent passed block from failing in case of context m...
Record the passed block as a subsegment. If `context_missing` is set to `LOG_ERROR` and no active entity can be found, the passed block will be executed as normal but it will not be recorded.
[ "Record", "the", "passed", "block", "as", "a", "subsegment", ".", "If", "context_missing", "is", "set", "to", "LOG_ERROR", "and", "no", "active", "entity", "can", "be", "found", "the", "passed", "block", "will", "be", "executed", "as", "normal", "but", "it...
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L112-L128
19,375
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/recorder.rb
XRay.Recorder.metadata
def metadata(namespace: :default) entity = current_entity if entity entity.metadata(namespace: namespace) else FacadeMetadata end end
ruby
def metadata(namespace: :default) entity = current_entity if entity entity.metadata(namespace: namespace) else FacadeMetadata end end
[ "def", "metadata", "(", "namespace", ":", ":default", ")", "entity", "=", "current_entity", "if", "entity", "entity", ".", "metadata", "(", "namespace", ":", "namespace", ")", "else", "FacadeMetadata", "end", "end" ]
A proxy method to get the metadata under provided namespace from the current active entity.
[ "A", "proxy", "method", "to", "get", "the", "metadata", "under", "provided", "namespace", "from", "the", "current", "active", "entity", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/recorder.rb#L168-L175
19,376
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/sampling/reservoir.rb
XRay.Reservoir.borrow_or_take
def borrow_or_take(now, borrowable) @lock.synchronize do reset_new_sec(now) # Don't borrow if the quota is available and fresh. if quota_fresh?(now) return SamplingDecision::NOT_SAMPLE if @taken_this_sec >= @quota @taken_this_sec += 1 return SamplingDecision::...
ruby
def borrow_or_take(now, borrowable) @lock.synchronize do reset_new_sec(now) # Don't borrow if the quota is available and fresh. if quota_fresh?(now) return SamplingDecision::NOT_SAMPLE if @taken_this_sec >= @quota @taken_this_sec += 1 return SamplingDecision::...
[ "def", "borrow_or_take", "(", "now", ",", "borrowable", ")", "@lock", ".", "synchronize", "do", "reset_new_sec", "(", "now", ")", "# Don't borrow if the quota is available and fresh.", "if", "quota_fresh?", "(", "now", ")", "return", "SamplingDecision", "::", "NOT_SAM...
Decide whether to borrow or take one quota from the reservoir. Return `false` if it can neither borrow nor take. This method is thread-safe.
[ "Decide", "whether", "to", "borrow", "or", "take", "one", "quota", "from", "the", "reservoir", ".", "Return", "false", "if", "it", "can", "neither", "borrow", "nor", "take", ".", "This", "method", "is", "thread", "-", "safe", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/sampling/reservoir.rb#L27-L47
19,377
aws/aws-xray-sdk-ruby
lib/aws-xray-sdk/sampling/default_sampler.rb
XRay.DefaultSampler.sample_request?
def sample_request?(sampling_req) start unless @started now = Time.now.to_i if sampling_req.nil? sampling_req = { service_type: @origin } if @origin elsif !sampling_req.key?(:service_type) sampling_req[:service_type] = @origin if @origin end matched_rule = @cache.get...
ruby
def sample_request?(sampling_req) start unless @started now = Time.now.to_i if sampling_req.nil? sampling_req = { service_type: @origin } if @origin elsif !sampling_req.key?(:service_type) sampling_req[:service_type] = @origin if @origin end matched_rule = @cache.get...
[ "def", "sample_request?", "(", "sampling_req", ")", "start", "unless", "@started", "now", "=", "Time", ".", "now", ".", "to_i", "if", "sampling_req", ".", "nil?", "sampling_req", "=", "{", "service_type", ":", "@origin", "}", "if", "@origin", "elsif", "!", ...
Return the rule name if it decides to sample based on a service sampling rule matching. If there is no match it will fallback to local defined sampling rules.
[ "Return", "the", "rule", "name", "if", "it", "decides", "to", "sample", "based", "on", "a", "service", "sampling", "rule", "matching", ".", "If", "there", "is", "no", "match", "it", "will", "fallback", "to", "local", "defined", "sampling", "rules", "." ]
5134f203a0a0c7681e137aa6045ad64fc645c8fe
https://github.com/aws/aws-xray-sdk-ruby/blob/5134f203a0a0c7681e137aa6045ad64fc645c8fe/lib/aws-xray-sdk/sampling/default_sampler.rb#L42-L59
19,378
bigcommerce/bigcommerce-api-ruby
lib/bigcommerce/request.rb
Bigcommerce.PathBuilder.build
def build(keys = []) keys = [] if keys.nil? keys = [keys] if keys.is_a? Numeric ids = uri.scan('%d').count + uri.scan('%s').count str = ids > keys.size ? uri.chomp('%d').chomp('%s').chomp('/') : uri (str % keys).chomp('/') end
ruby
def build(keys = []) keys = [] if keys.nil? keys = [keys] if keys.is_a? Numeric ids = uri.scan('%d').count + uri.scan('%s').count str = ids > keys.size ? uri.chomp('%d').chomp('%s').chomp('/') : uri (str % keys).chomp('/') end
[ "def", "build", "(", "keys", "=", "[", "]", ")", "keys", "=", "[", "]", "if", "keys", ".", "nil?", "keys", "=", "[", "keys", "]", "if", "keys", ".", "is_a?", "Numeric", "ids", "=", "uri", ".", "scan", "(", "'%d'", ")", ".", "count", "+", "uri...
This takes the @uri and inserts the keys to form a path. To start we make sure that for nil/numeric values, we wrap those into an array. We then scan the string for %d and %s to find the number of times we possibly need to insert keys into the URI. Next, we check the size of the keys array, if the keys size is less...
[ "This", "takes", "the" ]
f2f885a324041cfea1fef99077b58dfaa0ad9264
https://github.com/bigcommerce/bigcommerce-api-ruby/blob/f2f885a324041cfea1fef99077b58dfaa0ad9264/lib/bigcommerce/request.rb#L19-L25
19,379
bigcommerce/bigcommerce-api-ruby
lib/bigcommerce/resources/customers/customer.rb
Bigcommerce.Customer.login_token
def login_token(config: Bigcommerce.config) payload = { 'iss' => config.client_id, 'iat' => Time.now.to_i, 'jti' => SecureRandom.uuid, 'operation' => 'customer_login', 'store_hash' => config.store_hash, 'customer_id' => id } JWT.encode(payload, config.c...
ruby
def login_token(config: Bigcommerce.config) payload = { 'iss' => config.client_id, 'iat' => Time.now.to_i, 'jti' => SecureRandom.uuid, 'operation' => 'customer_login', 'store_hash' => config.store_hash, 'customer_id' => id } JWT.encode(payload, config.c...
[ "def", "login_token", "(", "config", ":", "Bigcommerce", ".", "config", ")", "payload", "=", "{", "'iss'", "=>", "config", ".", "client_id", ",", "'iat'", "=>", "Time", ".", "now", ".", "to_i", ",", "'jti'", "=>", "SecureRandom", ".", "uuid", ",", "'op...
Generate a token that can be used to log the customer into the storefront. This requires your app to have the store_v2_customers_login scope and to be installed in the store.
[ "Generate", "a", "token", "that", "can", "be", "used", "to", "log", "the", "customer", "into", "the", "storefront", ".", "This", "requires", "your", "app", "to", "have", "the", "store_v2_customers_login", "scope", "and", "to", "be", "installed", "in", "the",...
f2f885a324041cfea1fef99077b58dfaa0ad9264
https://github.com/bigcommerce/bigcommerce-api-ruby/blob/f2f885a324041cfea1fef99077b58dfaa0ad9264/lib/bigcommerce/resources/customers/customer.rb#L37-L48
19,380
searls/jasmine-rails
lib/jasmine_rails/offline_asset_paths.rb
JasmineRails.OfflineAssetPaths.compute_public_path
def compute_public_path(source, dir, options={}) JasmineRails::OfflineAssetPaths.disabled ? super : compute_asset_path(source, options) end
ruby
def compute_public_path(source, dir, options={}) JasmineRails::OfflineAssetPaths.disabled ? super : compute_asset_path(source, options) end
[ "def", "compute_public_path", "(", "source", ",", "dir", ",", "options", "=", "{", "}", ")", "JasmineRails", "::", "OfflineAssetPaths", ".", "disabled", "?", "super", ":", "compute_asset_path", "(", "source", ",", "options", ")", "end" ]
For Rails 3.2 support
[ "For", "Rails", "3", ".", "2", "support" ]
4f0a61d2be4f5156dfa7ab9722276e0184494a75
https://github.com/searls/jasmine-rails/blob/4f0a61d2be4f5156dfa7ab9722276e0184494a75/lib/jasmine_rails/offline_asset_paths.rb#L30-L32
19,381
searls/jasmine-rails
lib/jasmine_rails/save_fixture.rb
JasmineRails.SaveFixture.save_fixture
def save_fixture(file_name, content = rendered) fixture_path = File.join(Rails.root, FIXTURE_DIRECTORY, file_name) fixture_directory = File.dirname(fixture_path) FileUtils.mkdir_p fixture_directory unless File.exists?(fixture_directory) File.open(fixture_path, 'w') do |file| file.puts(c...
ruby
def save_fixture(file_name, content = rendered) fixture_path = File.join(Rails.root, FIXTURE_DIRECTORY, file_name) fixture_directory = File.dirname(fixture_path) FileUtils.mkdir_p fixture_directory unless File.exists?(fixture_directory) File.open(fixture_path, 'w') do |file| file.puts(c...
[ "def", "save_fixture", "(", "file_name", ",", "content", "=", "rendered", ")", "fixture_path", "=", "File", ".", "join", "(", "Rails", ".", "root", ",", "FIXTURE_DIRECTORY", ",", "file_name", ")", "fixture_directory", "=", "File", ".", "dirname", "(", "fixtu...
Saves the rendered as a fixture file.
[ "Saves", "the", "rendered", "as", "a", "fixture", "file", "." ]
4f0a61d2be4f5156dfa7ab9722276e0184494a75
https://github.com/searls/jasmine-rails/blob/4f0a61d2be4f5156dfa7ab9722276e0184494a75/lib/jasmine_rails/save_fixture.rb#L22-L32
19,382
mattbrictson/airbrussh
lib/airbrussh/console.rb
Airbrussh.Console.print_line
def print_line(obj="") string = obj.to_s string = truncate_to_console_width(string) if console_width string = strip_ascii_color(string) unless color_enabled? write(string + "\n") output.flush end
ruby
def print_line(obj="") string = obj.to_s string = truncate_to_console_width(string) if console_width string = strip_ascii_color(string) unless color_enabled? write(string + "\n") output.flush end
[ "def", "print_line", "(", "obj", "=", "\"\"", ")", "string", "=", "obj", ".", "to_s", "string", "=", "truncate_to_console_width", "(", "string", ")", "if", "console_width", "string", "=", "strip_ascii_color", "(", "string", ")", "unless", "color_enabled?", "wr...
Writes to the IO after first truncating the output to fit the console width. If the underlying IO is not a TTY, ANSI colors are removed from the output. A newline is always added. Color output can be forced by setting the SSHKIT_COLOR environment variable.
[ "Writes", "to", "the", "IO", "after", "first", "truncating", "the", "output", "to", "fit", "the", "console", "width", ".", "If", "the", "underlying", "IO", "is", "not", "a", "TTY", "ANSI", "colors", "are", "removed", "from", "the", "output", ".", "A", ...
eac9bbe3fbf0990cf655746c36a9ba4e1c47950d
https://github.com/mattbrictson/airbrussh/blob/eac9bbe3fbf0990cf655746c36a9ba4e1c47950d/lib/airbrussh/console.rb#L24-L32
19,383
codegram/spinach
lib/spinach/runner.rb
Spinach.Runner.init_reporters
def init_reporters Spinach.config[:reporter_classes].each do |reporter_class| reporter_options = default_reporter_options.merge(Spinach.config.reporter_options) reporter = Support.constantize(reporter_class).new(reporter_options) reporter.bind end end
ruby
def init_reporters Spinach.config[:reporter_classes].each do |reporter_class| reporter_options = default_reporter_options.merge(Spinach.config.reporter_options) reporter = Support.constantize(reporter_class).new(reporter_options) reporter.bind end end
[ "def", "init_reporters", "Spinach", ".", "config", "[", ":reporter_classes", "]", ".", "each", "do", "|", "reporter_class", "|", "reporter_options", "=", "default_reporter_options", ".", "merge", "(", "Spinach", ".", "config", ".", "reporter_options", ")", "report...
Initializes the runner with a parsed feature @param [Array<String>] filenames A list of feature filenames to run @param [Hash] options @option options [String] :step_definitions_path The path in which step definitions are found. @option options [String] :support_path The path with the support ruby file...
[ "Initializes", "the", "runner", "with", "a", "parsed", "feature" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/runner.rb#L43-L50
19,384
codegram/spinach
lib/spinach/runner.rb
Spinach.Runner.run
def run require_dependencies require_frameworks init_reporters suite_passed = true Spinach.hooks.run_before_run features_to_run.each do |feature| feature_passed = FeatureRunner.new(feature, orderer: orderer).run suite_passed &&= feature_passed break if fai...
ruby
def run require_dependencies require_frameworks init_reporters suite_passed = true Spinach.hooks.run_before_run features_to_run.each do |feature| feature_passed = FeatureRunner.new(feature, orderer: orderer).run suite_passed &&= feature_passed break if fai...
[ "def", "run", "require_dependencies", "require_frameworks", "init_reporters", "suite_passed", "=", "true", "Spinach", ".", "hooks", ".", "run_before_run", "features_to_run", ".", "each", "do", "|", "feature", "|", "feature_passed", "=", "FeatureRunner", ".", "new", ...
Runs this runner and outputs the results in a colorful manner. @return [true, false] Whether the run was succesful. @api public
[ "Runs", "this", "runner", "and", "outputs", "the", "results", "in", "a", "colorful", "manner", "." ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/runner.rb#L58-L77
19,385
codegram/spinach
lib/spinach/runner.rb
Spinach.Runner.orderer
def orderer @orderer ||= Support.constantize(Spinach.config[:orderer_class]).new( seed: Spinach.config.seed ) end
ruby
def orderer @orderer ||= Support.constantize(Spinach.config[:orderer_class]).new( seed: Spinach.config.seed ) end
[ "def", "orderer", "@orderer", "||=", "Support", ".", "constantize", "(", "Spinach", ".", "config", "[", ":orderer_class", "]", ")", ".", "new", "(", "seed", ":", "Spinach", ".", "config", ".", "seed", ")", "end" ]
The orderer for this run. @api public
[ "The", "orderer", "for", "this", "run", "." ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/runner.rb#L135-L139
19,386
codegram/spinach
lib/spinach/config.rb
Spinach.Config.parse_from_file
def parse_from_file parsed_opts = YAML.load_file(config_path) parsed_opts.delete_if{|k| k.to_s == 'config_path'} parsed_opts.each_pair{|k,v| self[k] = v} true rescue Errno::ENOENT false end
ruby
def parse_from_file parsed_opts = YAML.load_file(config_path) parsed_opts.delete_if{|k| k.to_s == 'config_path'} parsed_opts.each_pair{|k,v| self[k] = v} true rescue Errno::ENOENT false end
[ "def", "parse_from_file", "parsed_opts", "=", "YAML", ".", "load_file", "(", "config_path", ")", "parsed_opts", ".", "delete_if", "{", "|", "k", "|", "k", ".", "to_s", "==", "'config_path'", "}", "parsed_opts", ".", "each_pair", "{", "|", "k", ",", "v", ...
Parse options from the config file @return [Boolean] If the config was parsed from the file
[ "Parse", "options", "from", "the", "config", "file" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/config.rb#L213-L220
19,387
codegram/spinach
lib/spinach/hooks.rb
Spinach.Hooks.on_tag
def on_tag(tag) before_scenario do |scenario, step_definitions| tags = scenario.tags next unless tags.any? yield(scenario, step_definitions) if tags.include? tag.to_s end end
ruby
def on_tag(tag) before_scenario do |scenario, step_definitions| tags = scenario.tags next unless tags.any? yield(scenario, step_definitions) if tags.include? tag.to_s end end
[ "def", "on_tag", "(", "tag", ")", "before_scenario", "do", "|", "scenario", ",", "step_definitions", "|", "tags", "=", "scenario", ".", "tags", "next", "unless", "tags", ".", "any?", "yield", "(", "scenario", ",", "step_definitions", ")", "if", "tags", "."...
Runs before running a scenario with a particular tag @param [String] tag the tag to match @example Spinach.hooks.on_tag('javascript') do # change capybara driver end
[ "Runs", "before", "running", "a", "scenario", "with", "a", "particular", "tag" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/hooks.rb#L168-L174
19,388
codegram/spinach
lib/spinach/auditor.rb
Spinach.Auditor.get_feature_and_defs
def get_feature_and_defs(file) feature = Parser.open_file(file).parse [feature, Spinach.find_step_definitions(feature.name)] end
ruby
def get_feature_and_defs(file) feature = Parser.open_file(file).parse [feature, Spinach.find_step_definitions(feature.name)] end
[ "def", "get_feature_and_defs", "(", "file", ")", "feature", "=", "Parser", ".", "open_file", "(", "file", ")", ".", "parse", "[", "feature", ",", "Spinach", ".", "find_step_definitions", "(", "feature", ".", "name", ")", "]", "end" ]
Get the feature and its definitions from the appropriate files
[ "Get", "the", "feature", "and", "its", "definitions", "from", "the", "appropriate", "files" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/auditor.rb#L70-L73
19,389
codegram/spinach
lib/spinach/auditor.rb
Spinach.Auditor.step_missing?
def step_missing?(step, step_defs) method_name = Spinach::Support.underscore step.name return true unless step_defs.respond_to?(method_name) # Remember that we have used this step used_steps << step_defs.step_location_for(step.name).join(':') false end
ruby
def step_missing?(step, step_defs) method_name = Spinach::Support.underscore step.name return true unless step_defs.respond_to?(method_name) # Remember that we have used this step used_steps << step_defs.step_location_for(step.name).join(':') false end
[ "def", "step_missing?", "(", "step", ",", "step_defs", ")", "method_name", "=", "Spinach", "::", "Support", ".", "underscore", "step", ".", "name", "return", "true", "unless", "step_defs", ".", "respond_to?", "(", "method_name", ")", "# Remember that we have used ...
Process a step from the feature file using the given step_defs. If it is missing, return true. Otherwise, add it to the used_steps for the report at the end and return false.
[ "Process", "a", "step", "from", "the", "feature", "file", "using", "the", "given", "step_defs", ".", "If", "it", "is", "missing", "return", "true", ".", "Otherwise", "add", "it", "to", "the", "used_steps", "for", "the", "report", "at", "the", "end", "and...
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/auditor.rb#L78-L84
19,390
codegram/spinach
lib/spinach/auditor.rb
Spinach.Auditor.store_unused_steps
def store_unused_steps(names, step_defs) names.each do |name| location = step_defs.step_location_for(name).join(':') unused_steps[location] = name end end
ruby
def store_unused_steps(names, step_defs) names.each do |name| location = step_defs.step_location_for(name).join(':') unused_steps[location] = name end end
[ "def", "store_unused_steps", "(", "names", ",", "step_defs", ")", "names", ".", "each", "do", "|", "name", "|", "location", "=", "step_defs", ".", "step_location_for", "(", "name", ")", ".", "join", "(", "':'", ")", "unused_steps", "[", "location", "]", ...
Store any unused step names for the report at the end of the audit
[ "Store", "any", "unused", "step", "names", "for", "the", "report", "at", "the", "end", "of", "the", "audit" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/auditor.rb#L87-L92
19,391
codegram/spinach
lib/spinach/auditor.rb
Spinach.Auditor.step_names_for_class
def step_names_for_class(klass) klass.ancestors.map { |a| a.respond_to?(:steps) ? a.steps : [] }.flatten end
ruby
def step_names_for_class(klass) klass.ancestors.map { |a| a.respond_to?(:steps) ? a.steps : [] }.flatten end
[ "def", "step_names_for_class", "(", "klass", ")", "klass", ".", "ancestors", ".", "map", "{", "|", "a", "|", "a", ".", "respond_to?", "(", ":steps", ")", "?", "a", ".", "steps", ":", "[", "]", "}", ".", "flatten", "end" ]
Get the step names for all steps in the given class, including those in common modules
[ "Get", "the", "step", "names", "for", "all", "steps", "in", "the", "given", "class", "including", "those", "in", "common", "modules" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/auditor.rb#L104-L106
19,392
codegram/spinach
lib/spinach/auditor.rb
Spinach.Auditor.report_unused_steps
def report_unused_steps # Remove any unused_steps that were in common modules and used # in another feature used_steps.each { |location| unused_steps.delete location } unused_steps.each do |location, name| puts "\n" + "Unused step: #{location} ".colorize(:yellow) + "'#{name}...
ruby
def report_unused_steps # Remove any unused_steps that were in common modules and used # in another feature used_steps.each { |location| unused_steps.delete location } unused_steps.each do |location, name| puts "\n" + "Unused step: #{location} ".colorize(:yellow) + "'#{name}...
[ "def", "report_unused_steps", "# Remove any unused_steps that were in common modules and used", "# in another feature", "used_steps", ".", "each", "{", "|", "location", "|", "unused_steps", ".", "delete", "location", "}", "unused_steps", ".", "each", "do", "|", "location", ...
Produce a report of unused steps that were not found anywhere in the audit
[ "Produce", "a", "report", "of", "unused", "steps", "that", "were", "not", "found", "anywhere", "in", "the", "audit" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/auditor.rb#L109-L117
19,393
codegram/spinach
lib/spinach/auditor.rb
Spinach.Auditor.report_missing_steps
def report_missing_steps(steps) puts "\nMissing steps:".colorize(:light_cyan) steps.each do |step| puts Generators::StepGenerator.new(step).generate.gsub(/^/, ' ') .colorize(:cyan) end end
ruby
def report_missing_steps(steps) puts "\nMissing steps:".colorize(:light_cyan) steps.each do |step| puts Generators::StepGenerator.new(step).generate.gsub(/^/, ' ') .colorize(:cyan) end end
[ "def", "report_missing_steps", "(", "steps", ")", "puts", "\"\\nMissing steps:\"", ".", "colorize", "(", ":light_cyan", ")", "steps", ".", "each", "do", "|", "step", "|", "puts", "Generators", "::", "StepGenerator", ".", "new", "(", "step", ")", ".", "genera...
Print a report of the missing step objects provided
[ "Print", "a", "report", "of", "the", "missing", "step", "objects", "provided" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/auditor.rb#L120-L126
19,394
codegram/spinach
lib/spinach/reporter.rb
Spinach.Reporter.bind
def bind Spinach.hooks.tap do |hooks| hooks.before_run { |*args| before_run(*args) } hooks.after_run { |*args| after_run(*args) } hooks.before_feature { |*args| before_feature_run(*args) } hooks.after_feature { |*args| after_feature_run(*args) } hooks.on_undefined_feature {...
ruby
def bind Spinach.hooks.tap do |hooks| hooks.before_run { |*args| before_run(*args) } hooks.after_run { |*args| after_run(*args) } hooks.before_feature { |*args| before_feature_run(*args) } hooks.after_feature { |*args| after_feature_run(*args) } hooks.on_undefined_feature {...
[ "def", "bind", "Spinach", ".", "hooks", ".", "tap", "do", "|", "hooks", "|", "hooks", ".", "before_run", "{", "|", "*", "args", "|", "before_run", "(", "args", ")", "}", "hooks", ".", "after_run", "{", "|", "*", "args", "|", "after_run", "(", "args...
Hooks the reporter to the runner endpoints
[ "Hooks", "the", "reporter", "to", "the", "runner", "endpoints" ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/reporter.rb#L29-L51
19,395
codegram/spinach
lib/spinach/cli.rb
Spinach.Cli.feature_files
def feature_files files_to_run = [] @args.each do |arg| if arg.match(/\.feature/) if File.exists? arg.gsub(/:\d*/, '') files_to_run << arg else fail! "#{arg} could not be found" end elsif File.directory?(arg) files_to_run << Di...
ruby
def feature_files files_to_run = [] @args.each do |arg| if arg.match(/\.feature/) if File.exists? arg.gsub(/:\d*/, '') files_to_run << arg else fail! "#{arg} could not be found" end elsif File.directory?(arg) files_to_run << Di...
[ "def", "feature_files", "files_to_run", "=", "[", "]", "@args", ".", "each", "do", "|", "arg", "|", "if", "arg", ".", "match", "(", "/", "\\.", "/", ")", "if", "File", ".", "exists?", "arg", ".", "gsub", "(", "/", "\\d", "/", ",", "''", ")", "f...
Uses given args to list the feature files to run. It will find a single feature, features in a folder and subfolders or every feature file in the feature path. @return [Array] An array with the feature file names. @api public
[ "Uses", "given", "args", "to", "list", "the", "feature", "files", "to", "run", ".", "It", "will", "find", "a", "single", "feature", "features", "in", "a", "folder", "and", "subfolders", "or", "every", "feature", "file", "in", "the", "feature", "path", "....
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/cli.rb#L54-L76
19,396
codegram/spinach
lib/spinach/cli.rb
Spinach.Cli.parse_options
def parse_options config = {} begin OptionParser.new do |opts| opts.on('-c', '--config_path PATH', 'Parse options from file (will get overriden by flags)') do |file| Spinach.config[:config_path] = file end opts.on('-b', '--backtrace', ...
ruby
def parse_options config = {} begin OptionParser.new do |opts| opts.on('-c', '--config_path PATH', 'Parse options from file (will get overriden by flags)') do |file| Spinach.config[:config_path] = file end opts.on('-b', '--backtrace', ...
[ "def", "parse_options", "config", "=", "{", "}", "begin", "OptionParser", ".", "new", "do", "|", "opts", "|", "opts", ".", "on", "(", "'-c'", ",", "'--config_path PATH'", ",", "'Parse options from file (will get overriden by flags)'", ")", "do", "|", "file", "|"...
Parses the arguments into options. @return [Hash] A hash of options separated by its type. @api private
[ "Parses", "the", "arguments", "into", "options", "." ]
09ba608a2e9eccad0f0c92ace33aa550a199014a
https://github.com/codegram/spinach/blob/09ba608a2e9eccad0f0c92ace33aa550a199014a/lib/spinach/cli.rb#L86-L166
19,397
matschaffer/knife-solo
lib/knife-solo/ssh_command.rb
KnifeSolo.SshCommand.run_with_fallbacks
def run_with_fallbacks(commands, options = {}) commands.each do |command| result = run_command(command, options) return result if result.success? end SshConnection::ExecResult.new(1) end
ruby
def run_with_fallbacks(commands, options = {}) commands.each do |command| result = run_command(command, options) return result if result.success? end SshConnection::ExecResult.new(1) end
[ "def", "run_with_fallbacks", "(", "commands", ",", "options", "=", "{", "}", ")", "commands", ".", "each", "do", "|", "command", "|", "result", "=", "run_command", "(", "command", ",", "options", ")", "return", "result", "if", "result", ".", "success?", ...
Runs commands from the specified array until successful. Returns the result of the successful command or an ExecResult with exit_code 1 if all fail.
[ "Runs", "commands", "from", "the", "specified", "array", "until", "successful", ".", "Returns", "the", "result", "of", "the", "successful", "command", "or", "an", "ExecResult", "with", "exit_code", "1", "if", "all", "fail", "." ]
ce8c2237af961394059351260471f6ef417967ba
https://github.com/matschaffer/knife-solo/blob/ce8c2237af961394059351260471f6ef417967ba/lib/knife-solo/ssh_command.rb#L310-L316
19,398
neo4jrb/neo4j-core
lib/neo4j/transaction.rb
Neo4j.Transaction.run
def run(*args) session, run_in_tx = session_and_run_in_tx_from_args(args) fail ArgumentError, 'Expected a block to run in Transaction.run' unless block_given? return yield(nil) unless run_in_tx tx = Neo4j::Transaction.new(session) yield tx rescue Exception => e # rubocop:disable Lin...
ruby
def run(*args) session, run_in_tx = session_and_run_in_tx_from_args(args) fail ArgumentError, 'Expected a block to run in Transaction.run' unless block_given? return yield(nil) unless run_in_tx tx = Neo4j::Transaction.new(session) yield tx rescue Exception => e # rubocop:disable Lin...
[ "def", "run", "(", "*", "args", ")", "session", ",", "run_in_tx", "=", "session_and_run_in_tx_from_args", "(", "args", ")", "fail", "ArgumentError", ",", "'Expected a block to run in Transaction.run'", "unless", "block_given?", "return", "yield", "(", "nil", ")", "u...
Runs the given block in a new transaction. @param [Boolean] run_in_tx if true a new transaction will not be created, instead if will simply yield to the given block @@yield [Neo4j::Transaction::Instance]
[ "Runs", "the", "given", "block", "in", "a", "new", "transaction", "." ]
293eb02cc11210e88bfa69d778f563e61f2b0de7
https://github.com/neo4jrb/neo4j-core/blob/293eb02cc11210e88bfa69d778f563e61f2b0de7/lib/neo4j/transaction.rb#L127-L143
19,399
neo4jrb/neo4j-core
lib/neo4j/transaction.rb
Neo4j.Transaction.session_and_run_in_tx_from_args
def session_and_run_in_tx_from_args(args) fail ArgumentError, 'Too few arguments' if args.empty? fail ArgumentError, 'Too many arguments' if args.size > 2 if args.size == 1 fail ArgumentError, 'Session must be specified' if !args[0].is_a?(Neo4j::Core::CypherSession) [args[0], true] ...
ruby
def session_and_run_in_tx_from_args(args) fail ArgumentError, 'Too few arguments' if args.empty? fail ArgumentError, 'Too many arguments' if args.size > 2 if args.size == 1 fail ArgumentError, 'Session must be specified' if !args[0].is_a?(Neo4j::Core::CypherSession) [args[0], true] ...
[ "def", "session_and_run_in_tx_from_args", "(", "args", ")", "fail", "ArgumentError", ",", "'Too few arguments'", "if", "args", ".", "empty?", "fail", "ArgumentError", ",", "'Too many arguments'", "if", "args", ".", "size", ">", "2", "if", "args", ".", "size", "=...
To support old syntax of providing run_in_tx first But session first is ideal
[ "To", "support", "old", "syntax", "of", "providing", "run_in_tx", "first", "But", "session", "first", "is", "ideal" ]
293eb02cc11210e88bfa69d778f563e61f2b0de7
https://github.com/neo4jrb/neo4j-core/blob/293eb02cc11210e88bfa69d778f563e61f2b0de7/lib/neo4j/transaction.rb#L147-L158