| 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 | 
|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 
	varvet/stomp_parser | 
	lib/stomp_parser/frame.rb | 
	StompParser.Frame.content_encoding | 
	def content_encoding
      if content_type = headers["content-type"]
        mime_type, charset = content_type.split(SEMICOLON, 2)
        charset = charset[CHARSET_OFFSET] if charset
        charset ||= EMPTY
        if charset.empty? and mime_type.start_with?("text/")
          Encoding::UTF_8
        elsif charset.empty?
          Encoding::BINARY
        else
          ENCODINGS[charset] or raise StompParser::InvalidEncodingError, "invalid encoding #{charset.inspect}"
        end
      else
        Encoding::BINARY
      end
    end | 
	ruby | 
	def content_encoding
      if content_type = headers["content-type"]
        mime_type, charset = content_type.split(SEMICOLON, 2)
        charset = charset[CHARSET_OFFSET] if charset
        charset ||= EMPTY
        if charset.empty? and mime_type.start_with?("text/")
          Encoding::UTF_8
        elsif charset.empty?
          Encoding::BINARY
        else
          ENCODINGS[charset] or raise StompParser::InvalidEncodingError, "invalid encoding #{charset.inspect}"
        end
      else
        Encoding::BINARY
      end
    end | 
	[
  "def",
  "content_encoding",
  "if",
  "content_type",
  "=",
  "headers",
  "[",
  "\"content-type\"",
  "]",
  "mime_type",
  ",",
  "charset",
  "=",
  "content_type",
  ".",
  "split",
  "(",
  "SEMICOLON",
  ",",
  "2",
  ")",
  "charset",
  "=",
  "charset",
  "[",
  "CHARSET_OFFSET",
  "]",
  "if",
  "charset",
  "charset",
  "||=",
  "EMPTY",
  "if",
  "charset",
  ".",
  "empty?",
  "and",
  "mime_type",
  ".",
  "start_with?",
  "(",
  "\"text/\"",
  ")",
  "Encoding",
  "::",
  "UTF_8",
  "elsif",
  "charset",
  ".",
  "empty?",
  "Encoding",
  "::",
  "BINARY",
  "else",
  "ENCODINGS",
  "[",
  "charset",
  "]",
  "or",
  "raise",
  "StompParser",
  "::",
  "InvalidEncodingError",
  ",",
  "\"invalid encoding #{charset.inspect}\"",
  "end",
  "else",
  "Encoding",
  "::",
  "BINARY",
  "end",
  "end"
] | 
	Determine content encoding by reviewing message headers.
 @raise [InvalidEncodingError] if encoding does not exist in Ruby
 @return [Encoding] | 
	[
  "Determine",
  "content",
  "encoding",
  "by",
  "reviewing",
  "message",
  "headers",
  "."
] | 
	039f6fa417ac2deef7a0ba4787f9d738dfdc6549 | 
	https://github.com/varvet/stomp_parser/blob/039f6fa417ac2deef7a0ba4787f9d738dfdc6549/lib/stomp_parser/frame.rb#L112-L128 | 
| 101 | 
	varvet/stomp_parser | 
	lib/stomp_parser/frame.rb | 
	StompParser.Frame.write_header | 
	def write_header(key, value)
      # @see http://stomp.github.io/stomp-specification-1.2.html#Repeated_Header_Entries
      key = decode_header(key)
      @headers[key] = decode_header(value) unless @headers.has_key?(key)
    end | 
	ruby | 
	def write_header(key, value)
      # @see http://stomp.github.io/stomp-specification-1.2.html#Repeated_Header_Entries
      key = decode_header(key)
      @headers[key] = decode_header(value) unless @headers.has_key?(key)
    end | 
	[
  "def",
  "write_header",
  "(",
  "key",
  ",",
  "value",
  ")",
  "# @see http://stomp.github.io/stomp-specification-1.2.html#Repeated_Header_Entries",
  "key",
  "=",
  "decode_header",
  "(",
  "key",
  ")",
  "@headers",
  "[",
  "key",
  "]",
  "=",
  "decode_header",
  "(",
  "value",
  ")",
  "unless",
  "@headers",
  ".",
  "has_key?",
  "(",
  "key",
  ")",
  "end"
] | 
	Write a single header to this frame.
 @param [String] key
 @param [String] value | 
	[
  "Write",
  "a",
  "single",
  "header",
  "to",
  "this",
  "frame",
  "."
] | 
	039f6fa417ac2deef7a0ba4787f9d738dfdc6549 | 
	https://github.com/varvet/stomp_parser/blob/039f6fa417ac2deef7a0ba4787f9d738dfdc6549/lib/stomp_parser/frame.rb#L141-L145 | 
| 102 | 
	ejlangev/citibike | 
	lib/citibike/client.rb | 
	Citibike.Client.stations | 
	def stations
      resp = self.connection.request(
        :get,
        Citibike::Station.path
      )
      return resp if @options[:unwrapped]
      Citibike::Responses::Station.new(resp)
    end | 
	ruby | 
	def stations
      resp = self.connection.request(
        :get,
        Citibike::Station.path
      )
      return resp if @options[:unwrapped]
      Citibike::Responses::Station.new(resp)
    end | 
	[
  "def",
  "stations",
  "resp",
  "=",
  "self",
  ".",
  "connection",
  ".",
  "request",
  "(",
  ":get",
  ",",
  "Citibike",
  "::",
  "Station",
  ".",
  "path",
  ")",
  "return",
  "resp",
  "if",
  "@options",
  "[",
  ":unwrapped",
  "]",
  "Citibike",
  "::",
  "Responses",
  "::",
  "Station",
  ".",
  "new",
  "(",
  "resp",
  ")",
  "end"
] | 
	Wrapper around a call to list all stations
 @return [Response] [A response object unless] | 
	[
  "Wrapper",
  "around",
  "a",
  "call",
  "to",
  "list",
  "all",
  "stations"
] | 
	40ae300dacb299468985fa9c2fdf5dba7a235c93 | 
	https://github.com/ejlangev/citibike/blob/40ae300dacb299468985fa9c2fdf5dba7a235c93/lib/citibike/client.rb#L35-L44 | 
| 103 | 
	message-driver/message-driver | 
	lib/message_driver/broker.rb | 
	MessageDriver.Broker.find_destination | 
	def find_destination(destination_name)
      destination = @destinations[destination_name]
      if destination.nil?
        raise MessageDriver::NoSuchDestinationError, "no destination #{destination_name} has been configured"
      end
      destination
    end | 
	ruby | 
	def find_destination(destination_name)
      destination = @destinations[destination_name]
      if destination.nil?
        raise MessageDriver::NoSuchDestinationError, "no destination #{destination_name} has been configured"
      end
      destination
    end | 
	[
  "def",
  "find_destination",
  "(",
  "destination_name",
  ")",
  "destination",
  "=",
  "@destinations",
  "[",
  "destination_name",
  "]",
  "if",
  "destination",
  ".",
  "nil?",
  "raise",
  "MessageDriver",
  "::",
  "NoSuchDestinationError",
  ",",
  "\"no destination #{destination_name} has been configured\"",
  "end",
  "destination",
  "end"
] | 
	Find a previously declared Destination
 @param destination_name [Symbol] the name of the destination
 @return [Destination::Base] the requested destination
 @raise [MessageDriver::NoSuchDestinationError] if there is no destination with that name | 
	[
  "Find",
  "a",
  "previously",
  "declared",
  "Destination"
] | 
	72a2b1b889a9aaaeab9101e223020500741636e7 | 
	https://github.com/message-driver/message-driver/blob/72a2b1b889a9aaaeab9101e223020500741636e7/lib/message_driver/broker.rb#L165-L171 | 
| 104 | 
	hmans/slodown | 
	lib/slodown/formatter.rb | 
	Slodown.Formatter.extract_metadata | 
	def extract_metadata
      @metadata = {}
      convert do |current|
        current.each_line.drop_while do |line|
          next false if line !~ /^#\+([a-z_]+): (.*)/
          key, value = $1, $2
          @metadata[key.to_sym] = value
        end.join('')
      end
    end | 
	ruby | 
	def extract_metadata
      @metadata = {}
      convert do |current|
        current.each_line.drop_while do |line|
          next false if line !~ /^#\+([a-z_]+): (.*)/
          key, value = $1, $2
          @metadata[key.to_sym] = value
        end.join('')
      end
    end | 
	[
  "def",
  "extract_metadata",
  "@metadata",
  "=",
  "{",
  "}",
  "convert",
  "do",
  "|",
  "current",
  "|",
  "current",
  ".",
  "each_line",
  ".",
  "drop_while",
  "do",
  "|",
  "line",
  "|",
  "next",
  "false",
  "if",
  "line",
  "!~",
  "/",
  "\\+",
  "/",
  "key",
  ",",
  "value",
  "=",
  "$1",
  ",",
  "$2",
  "@metadata",
  "[",
  "key",
  ".",
  "to_sym",
  "]",
  "=",
  "value",
  "end",
  ".",
  "join",
  "(",
  "''",
  ")",
  "end",
  "end"
] | 
	Extract metadata from the document. | 
	[
  "Extract",
  "metadata",
  "from",
  "the",
  "document",
  "."
] | 
	e867a8d1f079c2e039470e285d48cac5045ba4f3 | 
	https://github.com/hmans/slodown/blob/e867a8d1f079c2e039470e285d48cac5045ba4f3/lib/slodown/formatter.rb#L48-L59 | 
| 105 | 
	hmans/slodown | 
	lib/slodown/formatter.rb | 
	Slodown.Formatter.embed_transformer | 
	def embed_transformer
      lambda do |env|
        node      = env[:node]
        node_name = env[:node_name]
        # We're fine with a bunch of stuff -- but not <iframe> and <embed> tags.
        return if env[:is_whitelisted] || !env[:node].element?
        return unless %w[iframe embed].include? env[:node_name]
        # We're dealing with an <iframe> or <embed> tag! Let's check its src attribute.
        # If its host name matches our regular expression, we can whitelist it.
        uri = URI(env[:node]['src'])
        return unless uri.host =~ allowed_iframe_hosts
        Sanitize.clean_node!(node, {
          elements: %w[iframe embed],
          attributes: {
            all: %w[allowfullscreen frameborder height src width]
          }
        })
        { node_whitelist: [node] }
      end
    end | 
	ruby | 
	def embed_transformer
      lambda do |env|
        node      = env[:node]
        node_name = env[:node_name]
        # We're fine with a bunch of stuff -- but not <iframe> and <embed> tags.
        return if env[:is_whitelisted] || !env[:node].element?
        return unless %w[iframe embed].include? env[:node_name]
        # We're dealing with an <iframe> or <embed> tag! Let's check its src attribute.
        # If its host name matches our regular expression, we can whitelist it.
        uri = URI(env[:node]['src'])
        return unless uri.host =~ allowed_iframe_hosts
        Sanitize.clean_node!(node, {
          elements: %w[iframe embed],
          attributes: {
            all: %w[allowfullscreen frameborder height src width]
          }
        })
        { node_whitelist: [node] }
      end
    end | 
	[
  "def",
  "embed_transformer",
  "lambda",
  "do",
  "|",
  "env",
  "|",
  "node",
  "=",
  "env",
  "[",
  ":node",
  "]",
  "node_name",
  "=",
  "env",
  "[",
  ":node_name",
  "]",
  "# We're fine with a bunch of stuff -- but not <iframe> and <embed> tags.",
  "return",
  "if",
  "env",
  "[",
  ":is_whitelisted",
  "]",
  "||",
  "!",
  "env",
  "[",
  ":node",
  "]",
  ".",
  "element?",
  "return",
  "unless",
  "%w[",
  "iframe",
  "embed",
  "]",
  ".",
  "include?",
  "env",
  "[",
  ":node_name",
  "]",
  "# We're dealing with an <iframe> or <embed> tag! Let's check its src attribute.",
  "# If its host name matches our regular expression, we can whitelist it.",
  "uri",
  "=",
  "URI",
  "(",
  "env",
  "[",
  ":node",
  "]",
  "[",
  "'src'",
  "]",
  ")",
  "return",
  "unless",
  "uri",
  ".",
  "host",
  "=~",
  "allowed_iframe_hosts",
  "Sanitize",
  ".",
  "clean_node!",
  "(",
  "node",
  ",",
  "{",
  "elements",
  ":",
  "%w[",
  "iframe",
  "embed",
  "]",
  ",",
  "attributes",
  ":",
  "{",
  "all",
  ":",
  "%w[",
  "allowfullscreen",
  "frameborder",
  "height",
  "src",
  "width",
  "]",
  "}",
  "}",
  ")",
  "{",
  "node_whitelist",
  ":",
  "[",
  "node",
  "]",
  "}",
  "end",
  "end"
] | 
	A sanitize transformer that will check the document for IFRAME tags and
 validate them against +allowed_iframe_hosts+. | 
	[
  "A",
  "sanitize",
  "transformer",
  "that",
  "will",
  "check",
  "the",
  "document",
  "for",
  "IFRAME",
  "tags",
  "and",
  "validate",
  "them",
  "against",
  "+",
  "allowed_iframe_hosts",
  "+",
  "."
] | 
	e867a8d1f079c2e039470e285d48cac5045ba4f3 | 
	https://github.com/hmans/slodown/blob/e867a8d1f079c2e039470e285d48cac5045ba4f3/lib/slodown/formatter.rb#L141-L164 | 
| 106 | 
	tscolari/tenanfy | 
	lib/tenanfy/helpers.rb | 
	Tenanfy.Helpers.append_tenant_theme_to_assets | 
	def append_tenant_theme_to_assets(*assets)
      assets.map! do |asset|
        if should_add_tenant_theme_to_asset?(asset) && current_tenant
          "#{current_tenant.themes.first}/#{asset}"
        else
          asset
        end
      end
      assets
    end | 
	ruby | 
	def append_tenant_theme_to_assets(*assets)
      assets.map! do |asset|
        if should_add_tenant_theme_to_asset?(asset) && current_tenant
          "#{current_tenant.themes.first}/#{asset}"
        else
          asset
        end
      end
      assets
    end | 
	[
  "def",
  "append_tenant_theme_to_assets",
  "(",
  "*",
  "assets",
  ")",
  "assets",
  ".",
  "map!",
  "do",
  "|",
  "asset",
  "|",
  "if",
  "should_add_tenant_theme_to_asset?",
  "(",
  "asset",
  ")",
  "&&",
  "current_tenant",
  "\"#{current_tenant.themes.first}/#{asset}\"",
  "else",
  "asset",
  "end",
  "end",
  "assets",
  "end"
] | 
	updates the asset list with tenant theme where it's
 necessary | 
	[
  "updates",
  "the",
  "asset",
  "list",
  "with",
  "tenant",
  "theme",
  "where",
  "it",
  "s",
  "necessary"
] | 
	3dfe960b4569032d69a7626a631c200acf640c2f | 
	https://github.com/tscolari/tenanfy/blob/3dfe960b4569032d69a7626a631c200acf640c2f/lib/tenanfy/helpers.rb#L24-L33 | 
| 107 | 
	ECHOInternational/your_membership | 
	lib/your_membership/session.rb | 
	YourMembership.Session.authenticate | 
	def authenticate(user_name, password)
      options = {}
      options[:Username] = user_name
      options[:Password] = password
      response = self.class.post('/', :body => self.class.build_XML_request('Auth.Authenticate', self, options))
      self.class.response_valid? response
      if response['YourMembership_Response']['Auth.Authenticate']
        get_authenticated_user
      else
        false
      end
    end | 
	ruby | 
	def authenticate(user_name, password)
      options = {}
      options[:Username] = user_name
      options[:Password] = password
      response = self.class.post('/', :body => self.class.build_XML_request('Auth.Authenticate', self, options))
      self.class.response_valid? response
      if response['YourMembership_Response']['Auth.Authenticate']
        get_authenticated_user
      else
        false
      end
    end | 
	[
  "def",
  "authenticate",
  "(",
  "user_name",
  ",",
  "password",
  ")",
  "options",
  "=",
  "{",
  "}",
  "options",
  "[",
  ":Username",
  "]",
  "=",
  "user_name",
  "options",
  "[",
  ":Password",
  "]",
  "=",
  "password",
  "response",
  "=",
  "self",
  ".",
  "class",
  ".",
  "post",
  "(",
  "'/'",
  ",",
  ":body",
  "=>",
  "self",
  ".",
  "class",
  ".",
  "build_XML_request",
  "(",
  "'Auth.Authenticate'",
  ",",
  "self",
  ",",
  "options",
  ")",
  ")",
  "self",
  ".",
  "class",
  ".",
  "response_valid?",
  "response",
  "if",
  "response",
  "[",
  "'YourMembership_Response'",
  "]",
  "[",
  "'Auth.Authenticate'",
  "]",
  "get_authenticated_user",
  "else",
  "false",
  "end",
  "end"
] | 
	Authenticates a member's username and password and binds them to the current API session.
 @see https://api.yourmembership.com/reference/2_00/Auth_Authenticate.htm
 @param user_name [String] The username of the member that is being authenticated.
 @param password [String] The clear text password of the member that is being authenticated.
 @return [Hash] Returns the member's ID and WebsiteID. The returned WebsiteID represents the numeric identifier
  used by the YourMembership.com application for navigation purposes. It may be used to provide direct navigation to
  a member's profile, photo gallery, personal blog, etc. | 
	[
  "Authenticates",
  "a",
  "member",
  "s",
  "username",
  "and",
  "password",
  "and",
  "binds",
  "them",
  "to",
  "the",
  "current",
  "API",
  "session",
  "."
] | 
	b0154e668c265283b63c7986861db26426f9b700 | 
	https://github.com/ECHOInternational/your_membership/blob/b0154e668c265283b63c7986861db26426f9b700/lib/your_membership/session.rb#L94-L107 | 
| 108 | 
	3scale/xcflushd | 
	lib/xcflushd/authorizer.rb | 
	Xcflushd.Authorizer.sorted_metrics | 
	def sorted_metrics(metrics, hierarchy)
      # 'hierarchy' is a hash where the keys are metric names and the values
      # are arrays with the names of the children metrics. Only metrics with
      # children and with at least one usage limit appear as keys.
      parent_metrics = hierarchy.keys
      child_metrics = metrics - parent_metrics
      parent_metrics + child_metrics
    end | 
	ruby | 
	def sorted_metrics(metrics, hierarchy)
      # 'hierarchy' is a hash where the keys are metric names and the values
      # are arrays with the names of the children metrics. Only metrics with
      # children and with at least one usage limit appear as keys.
      parent_metrics = hierarchy.keys
      child_metrics = metrics - parent_metrics
      parent_metrics + child_metrics
    end | 
	[
  "def",
  "sorted_metrics",
  "(",
  "metrics",
  ",",
  "hierarchy",
  ")",
  "# 'hierarchy' is a hash where the keys are metric names and the values",
  "# are arrays with the names of the children metrics. Only metrics with",
  "# children and with at least one usage limit appear as keys.",
  "parent_metrics",
  "=",
  "hierarchy",
  ".",
  "keys",
  "child_metrics",
  "=",
  "metrics",
  "-",
  "parent_metrics",
  "parent_metrics",
  "+",
  "child_metrics",
  "end"
] | 
	Returns an array of metric names. The array is guaranteed to have all the
 parents first, and then the rest.
 In 3scale, metric hierarchies only have 2 levels. In other words, a
 metric that has a parent cannot have children. | 
	[
  "Returns",
  "an",
  "array",
  "of",
  "metric",
  "names",
  ".",
  "The",
  "array",
  "is",
  "guaranteed",
  "to",
  "have",
  "all",
  "the",
  "parents",
  "first",
  "and",
  "then",
  "the",
  "rest",
  ".",
  "In",
  "3scale",
  "metric",
  "hierarchies",
  "only",
  "have",
  "2",
  "levels",
  ".",
  "In",
  "other",
  "words",
  "a",
  "metric",
  "that",
  "has",
  "a",
  "parent",
  "cannot",
  "have",
  "children",
  "."
] | 
	ca29b7674c3cd952a2a50c0604a99f04662bf27d | 
	https://github.com/3scale/xcflushd/blob/ca29b7674c3cd952a2a50c0604a99f04662bf27d/lib/xcflushd/authorizer.rb#L79-L86 | 
| 109 | 
	ejlangev/citibike | 
	lib/citibike/response.rb | 
	Citibike.Response.all_near | 
	def all_near(obj, dist)
      @data.select do |d|
        if d.id == obj.id
          false
        else
          d.distance_from(obj.latitude, obj.longitude) < dist
        end
      end
    end | 
	ruby | 
	def all_near(obj, dist)
      @data.select do |d|
        if d.id == obj.id
          false
        else
          d.distance_from(obj.latitude, obj.longitude) < dist
        end
      end
    end | 
	[
  "def",
  "all_near",
  "(",
  "obj",
  ",",
  "dist",
  ")",
  "@data",
  ".",
  "select",
  "do",
  "|",
  "d",
  "|",
  "if",
  "d",
  ".",
  "id",
  "==",
  "obj",
  ".",
  "id",
  "false",
  "else",
  "d",
  ".",
  "distance_from",
  "(",
  "obj",
  ".",
  "latitude",
  ",",
  "obj",
  ".",
  "longitude",
  ")",
  "<",
  "dist",
  "end",
  "end",
  "end"
] | 
	Returns every object within dist miles
 of obj
 @param  obj [Api] [Api Object]
 @param  dist [Float] [Distance to consider]
 @return [type] [description] | 
	[
  "Returns",
  "every",
  "object",
  "within",
  "dist",
  "miles",
  "of",
  "obj"
] | 
	40ae300dacb299468985fa9c2fdf5dba7a235c93 | 
	https://github.com/ejlangev/citibike/blob/40ae300dacb299468985fa9c2fdf5dba7a235c93/lib/citibike/response.rb#L98-L106 | 
| 110 | 
	ejlangev/citibike | 
	lib/citibike/response.rb | 
	Citibike.Response.method_missing | 
	def method_missing(sym, *args, &block)
      if self.data.respond_to?(sym)
        return self.data.send(sym, *args, &block)
      end
      super
    end | 
	ruby | 
	def method_missing(sym, *args, &block)
      if self.data.respond_to?(sym)
        return self.data.send(sym, *args, &block)
      end
      super
    end | 
	[
  "def",
  "method_missing",
  "(",
  "sym",
  ",",
  "*",
  "args",
  ",",
  "&",
  "block",
  ")",
  "if",
  "self",
  ".",
  "data",
  ".",
  "respond_to?",
  "(",
  "sym",
  ")",
  "return",
  "self",
  ".",
  "data",
  ".",
  "send",
  "(",
  "sym",
  ",",
  "args",
  ",",
  "block",
  ")",
  "end",
  "super",
  "end"
] | 
	Delegates any undefined methods to the underlying data | 
	[
  "Delegates",
  "any",
  "undefined",
  "methods",
  "to",
  "the",
  "underlying",
  "data"
] | 
	40ae300dacb299468985fa9c2fdf5dba7a235c93 | 
	https://github.com/ejlangev/citibike/blob/40ae300dacb299468985fa9c2fdf5dba7a235c93/lib/citibike/response.rb#L109-L115 | 
| 111 | 
	rightscale/right_chimp | 
	lib/right_chimp/queue/queue_worker.rb | 
	Chimp.QueueWorker.run | 
	def run
      while @never_exit
        work_item = ChimpQueue.instance.shift()
        begin
          if work_item != nil
            job_uuid = work_item.job_uuid
            group = work_item.group.group_id
            work_item.retry_count = @retry_count
            work_item.owner = Thread.current.object_id
            ChimpDaemon.instance.semaphore.synchronize do
              # only do this if we are running with chimpd
              if ChimpDaemon.instance.queue.processing[group].nil?
                # no op
              else
                # remove from the processing queue
                if ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] == 0
                  Log.debug 'Completed processing task ' + job_uuid.to_s
                  Log.debug 'Deleting ' + job_uuid.to_s
                  ChimpDaemon.instance.queue.processing[group].delete(job_uuid.to_sym)
                  Log.debug ChimpDaemon.instance.queue.processing.inspect
                  ChimpDaemon.instance.proc_counter -= 1
                else
                  if ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym].nil?
                    Log.debug 'Job group was already deleted, no counter to decrease.'
                  else
                    Log.debug 'Decreasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s +
                              ') for [' + job_uuid.to_s + '] group: ' + group.to_s
                    ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] -= 1
                    Log.debug 'Processing counter now (' + ChimpDaemon.instance.proc_counter.to_s +
                              ') for [' + job_uuid.to_s + '] group: ' + group.to_s
                    Log.debug ChimpDaemon.instance.queue.processing[group].inspect
                    Log.debug 'Still counting down for ' + job_uuid.to_s
                    ChimpDaemon.instance.proc_counter -= 1
                  end
                end
              end
            end
            work_item.run
          else
            sleep 1
          end
        rescue Exception => ex
          Log.error "Exception in QueueWorker.run: #{ex}"
          Log.debug ex.inspect
          Log.debug ex.backtrace
          work_item.status = Executor::STATUS_ERROR
          work_item.error = ex
        end
      end
    end | 
	ruby | 
	def run
      while @never_exit
        work_item = ChimpQueue.instance.shift()
        begin
          if work_item != nil
            job_uuid = work_item.job_uuid
            group = work_item.group.group_id
            work_item.retry_count = @retry_count
            work_item.owner = Thread.current.object_id
            ChimpDaemon.instance.semaphore.synchronize do
              # only do this if we are running with chimpd
              if ChimpDaemon.instance.queue.processing[group].nil?
                # no op
              else
                # remove from the processing queue
                if ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] == 0
                  Log.debug 'Completed processing task ' + job_uuid.to_s
                  Log.debug 'Deleting ' + job_uuid.to_s
                  ChimpDaemon.instance.queue.processing[group].delete(job_uuid.to_sym)
                  Log.debug ChimpDaemon.instance.queue.processing.inspect
                  ChimpDaemon.instance.proc_counter -= 1
                else
                  if ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym].nil?
                    Log.debug 'Job group was already deleted, no counter to decrease.'
                  else
                    Log.debug 'Decreasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s +
                              ') for [' + job_uuid.to_s + '] group: ' + group.to_s
                    ChimpDaemon.instance.queue.processing[group][job_uuid.to_sym] -= 1
                    Log.debug 'Processing counter now (' + ChimpDaemon.instance.proc_counter.to_s +
                              ') for [' + job_uuid.to_s + '] group: ' + group.to_s
                    Log.debug ChimpDaemon.instance.queue.processing[group].inspect
                    Log.debug 'Still counting down for ' + job_uuid.to_s
                    ChimpDaemon.instance.proc_counter -= 1
                  end
                end
              end
            end
            work_item.run
          else
            sleep 1
          end
        rescue Exception => ex
          Log.error "Exception in QueueWorker.run: #{ex}"
          Log.debug ex.inspect
          Log.debug ex.backtrace
          work_item.status = Executor::STATUS_ERROR
          work_item.error = ex
        end
      end
    end | 
	[
  "def",
  "run",
  "while",
  "@never_exit",
  "work_item",
  "=",
  "ChimpQueue",
  ".",
  "instance",
  ".",
  "shift",
  "(",
  ")",
  "begin",
  "if",
  "work_item",
  "!=",
  "nil",
  "job_uuid",
  "=",
  "work_item",
  ".",
  "job_uuid",
  "group",
  "=",
  "work_item",
  ".",
  "group",
  ".",
  "group_id",
  "work_item",
  ".",
  "retry_count",
  "=",
  "@retry_count",
  "work_item",
  ".",
  "owner",
  "=",
  "Thread",
  ".",
  "current",
  ".",
  "object_id",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "semaphore",
  ".",
  "synchronize",
  "do",
  "# only do this if we are running with chimpd",
  "if",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "group",
  "]",
  ".",
  "nil?",
  "# no op",
  "else",
  "# remove from the processing queue",
  "if",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "group",
  "]",
  "[",
  "job_uuid",
  ".",
  "to_sym",
  "]",
  "==",
  "0",
  "Log",
  ".",
  "debug",
  "'Completed processing task '",
  "+",
  "job_uuid",
  ".",
  "to_s",
  "Log",
  ".",
  "debug",
  "'Deleting '",
  "+",
  "job_uuid",
  ".",
  "to_s",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "group",
  "]",
  ".",
  "delete",
  "(",
  "job_uuid",
  ".",
  "to_sym",
  ")",
  "Log",
  ".",
  "debug",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  ".",
  "inspect",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  "-=",
  "1",
  "else",
  "if",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "group",
  "]",
  "[",
  "job_uuid",
  ".",
  "to_sym",
  "]",
  ".",
  "nil?",
  "Log",
  ".",
  "debug",
  "'Job group was already deleted, no counter to decrease.'",
  "else",
  "Log",
  ".",
  "debug",
  "'Decreasing processing counter ('",
  "+",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  ".",
  "to_s",
  "+",
  "') for ['",
  "+",
  "job_uuid",
  ".",
  "to_s",
  "+",
  "'] group: '",
  "+",
  "group",
  ".",
  "to_s",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "group",
  "]",
  "[",
  "job_uuid",
  ".",
  "to_sym",
  "]",
  "-=",
  "1",
  "Log",
  ".",
  "debug",
  "'Processing counter now ('",
  "+",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  ".",
  "to_s",
  "+",
  "') for ['",
  "+",
  "job_uuid",
  ".",
  "to_s",
  "+",
  "'] group: '",
  "+",
  "group",
  ".",
  "to_s",
  "Log",
  ".",
  "debug",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "group",
  "]",
  ".",
  "inspect",
  "Log",
  ".",
  "debug",
  "'Still counting down for '",
  "+",
  "job_uuid",
  ".",
  "to_s",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  "-=",
  "1",
  "end",
  "end",
  "end",
  "end",
  "work_item",
  ".",
  "run",
  "else",
  "sleep",
  "1",
  "end",
  "rescue",
  "Exception",
  "=>",
  "ex",
  "Log",
  ".",
  "error",
  "\"Exception in QueueWorker.run: #{ex}\"",
  "Log",
  ".",
  "debug",
  "ex",
  ".",
  "inspect",
  "Log",
  ".",
  "debug",
  "ex",
  ".",
  "backtrace",
  "work_item",
  ".",
  "status",
  "=",
  "Executor",
  "::",
  "STATUS_ERROR",
  "work_item",
  ".",
  "error",
  "=",
  "ex",
  "end",
  "end",
  "end"
] | 
	Grab work items from the ChimpQueue and process them
 Only stop is @ever_exit is false | 
	[
  "Grab",
  "work",
  "items",
  "from",
  "the",
  "ChimpQueue",
  "and",
  "process",
  "them",
  "Only",
  "stop",
  "is"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/queue/queue_worker.rb#L19-L81 | 
| 112 | 
	arvicco/win_gui | 
	old_code/lib/win_gui/def_api.rb | 
	WinGui.DefApi.enforce_count | 
	def enforce_count(args, params, diff = 0)
      num_args = args.size
      num_params = params == 'V' ? 0 : params.size + diff
      if num_args != num_params
        raise ArgumentError, "wrong number of parameters: expected #{num_params}, got #{num_args}"
      end
    end | 
	ruby | 
	def enforce_count(args, params, diff = 0)
      num_args = args.size
      num_params = params == 'V' ? 0 : params.size + diff
      if num_args != num_params
        raise ArgumentError, "wrong number of parameters: expected #{num_params}, got #{num_args}"
      end
    end | 
	[
  "def",
  "enforce_count",
  "(",
  "args",
  ",",
  "params",
  ",",
  "diff",
  "=",
  "0",
  ")",
  "num_args",
  "=",
  "args",
  ".",
  "size",
  "num_params",
  "=",
  "params",
  "==",
  "'V'",
  "?",
  "0",
  ":",
  "params",
  ".",
  "size",
  "+",
  "diff",
  "if",
  "num_args",
  "!=",
  "num_params",
  "raise",
  "ArgumentError",
  ",",
  "\"wrong number of parameters: expected #{num_params}, got #{num_args}\"",
  "end",
  "end"
] | 
	Ensures that args count is equal to params count plus diff | 
	[
  "Ensures",
  "that",
  "args",
  "count",
  "is",
  "equal",
  "to",
  "params",
  "count",
  "plus",
  "diff"
] | 
	a3a4c18db2391144fcb535e4be2f0fb47e9dcec7 | 
	https://github.com/arvicco/win_gui/blob/a3a4c18db2391144fcb535e4be2f0fb47e9dcec7/old_code/lib/win_gui/def_api.rb#L78-L84 | 
| 113 | 
	arvicco/win_gui | 
	old_code/lib/win_gui/def_api.rb | 
	WinGui.DefApi.return_enum | 
	def return_enum
      lambda do |api, *args, &block|
        WinGui.enforce_count( args, api.prototype, -1)
        handles = []
        cb = if block
          callback('LP', 'I', &block)
        else
          callback('LP', 'I') do |handle, message|
            handles << handle
            true
          end
        end
        args[api.prototype.find_index('K'), 0] = cb # Insert callback into appropriate place of args Array
        api.call *args
        handles
      end
    end | 
	ruby | 
	def return_enum
      lambda do |api, *args, &block|
        WinGui.enforce_count( args, api.prototype, -1)
        handles = []
        cb = if block
          callback('LP', 'I', &block)
        else
          callback('LP', 'I') do |handle, message|
            handles << handle
            true
          end
        end
        args[api.prototype.find_index('K'), 0] = cb # Insert callback into appropriate place of args Array
        api.call *args
        handles
      end
    end | 
	[
  "def",
  "return_enum",
  "lambda",
  "do",
  "|",
  "api",
  ",",
  "*",
  "args",
  ",",
  "&",
  "block",
  "|",
  "WinGui",
  ".",
  "enforce_count",
  "(",
  "args",
  ",",
  "api",
  ".",
  "prototype",
  ",",
  "-",
  "1",
  ")",
  "handles",
  "=",
  "[",
  "]",
  "cb",
  "=",
  "if",
  "block",
  "callback",
  "(",
  "'LP'",
  ",",
  "'I'",
  ",",
  "block",
  ")",
  "else",
  "callback",
  "(",
  "'LP'",
  ",",
  "'I'",
  ")",
  "do",
  "|",
  "handle",
  ",",
  "message",
  "|",
  "handles",
  "<<",
  "handle",
  "true",
  "end",
  "end",
  "args",
  "[",
  "api",
  ".",
  "prototype",
  ".",
  "find_index",
  "(",
  "'K'",
  ")",
  ",",
  "0",
  "]",
  "=",
  "cb",
  "# Insert callback into appropriate place of args Array",
  "api",
  ".",
  "call",
  "args",
  "handles",
  "end",
  "end"
] | 
	Procedure that calls api function expecting a callback. If runtime block is given
 it is converted into actual callback, otherwise procedure returns an array of all
 handles pushed into callback by api enumeration | 
	[
  "Procedure",
  "that",
  "calls",
  "api",
  "function",
  "expecting",
  "a",
  "callback",
  ".",
  "If",
  "runtime",
  "block",
  "is",
  "given",
  "it",
  "is",
  "converted",
  "into",
  "actual",
  "callback",
  "otherwise",
  "procedure",
  "returns",
  "an",
  "array",
  "of",
  "all",
  "handles",
  "pushed",
  "into",
  "callback",
  "by",
  "api",
  "enumeration"
] | 
	a3a4c18db2391144fcb535e4be2f0fb47e9dcec7 | 
	https://github.com/arvicco/win_gui/blob/a3a4c18db2391144fcb535e4be2f0fb47e9dcec7/old_code/lib/win_gui/def_api.rb#L125-L141 | 
| 114 | 
	Aupajo/oulipo | 
	lib/oulipo/string_extensions.rb | 
	Oulipo.StringExtensions.alliterativity | 
	def alliterativity
      words = self.downcase.gsub(/[^a-z\s]/, '').split
      leading_letters = words.map(&:chr)
      
      # { 'a' => 3, 'b' => 1, ... }
      leading_letter_counts = leading_letters.inject({}) do |result, letter|
        result[letter] ||= 0
        result[letter] += 1
        result
      end
      
      most_used_count = leading_letter_counts.max_by { |kv| kv.last }.pop
      most_used_count.to_f / words.length
    end | 
	ruby | 
	def alliterativity
      words = self.downcase.gsub(/[^a-z\s]/, '').split
      leading_letters = words.map(&:chr)
      
      # { 'a' => 3, 'b' => 1, ... }
      leading_letter_counts = leading_letters.inject({}) do |result, letter|
        result[letter] ||= 0
        result[letter] += 1
        result
      end
      
      most_used_count = leading_letter_counts.max_by { |kv| kv.last }.pop
      most_used_count.to_f / words.length
    end | 
	[
  "def",
  "alliterativity",
  "words",
  "=",
  "self",
  ".",
  "downcase",
  ".",
  "gsub",
  "(",
  "/",
  "\\s",
  "/",
  ",",
  "''",
  ")",
  ".",
  "split",
  "leading_letters",
  "=",
  "words",
  ".",
  "map",
  "(",
  ":chr",
  ")",
  "# { 'a' => 3, 'b' => 1, ... }",
  "leading_letter_counts",
  "=",
  "leading_letters",
  ".",
  "inject",
  "(",
  "{",
  "}",
  ")",
  "do",
  "|",
  "result",
  ",",
  "letter",
  "|",
  "result",
  "[",
  "letter",
  "]",
  "||=",
  "0",
  "result",
  "[",
  "letter",
  "]",
  "+=",
  "1",
  "result",
  "end",
  "most_used_count",
  "=",
  "leading_letter_counts",
  ".",
  "max_by",
  "{",
  "|",
  "kv",
  "|",
  "kv",
  ".",
  "last",
  "}",
  ".",
  "pop",
  "most_used_count",
  ".",
  "to_f",
  "/",
  "words",
  ".",
  "length",
  "end"
] | 
	A score between 0 and 1 representing the level of alliteration | 
	[
  "A",
  "score",
  "between",
  "0",
  "and",
  "1",
  "representing",
  "the",
  "level",
  "of",
  "alliteration"
] | 
	dff71355efe0c050cfbf79b0a2cef9855bcc4923 | 
	https://github.com/Aupajo/oulipo/blob/dff71355efe0c050cfbf79b0a2cef9855bcc4923/lib/oulipo/string_extensions.rb#L16-L29 | 
| 115 | 
	Aupajo/oulipo | 
	lib/oulipo/string_extensions.rb | 
	Oulipo.StringExtensions.n_plus | 
	def n_plus(places, word_list)
      analysis = Analysis.new(self, :nouns => word_list)
      substitutor = Substitutor.new(analysis)
      substitutor.replace(:nouns).increment(places)
    end | 
	ruby | 
	def n_plus(places, word_list)
      analysis = Analysis.new(self, :nouns => word_list)
      substitutor = Substitutor.new(analysis)
      substitutor.replace(:nouns).increment(places)
    end | 
	[
  "def",
  "n_plus",
  "(",
  "places",
  ",",
  "word_list",
  ")",
  "analysis",
  "=",
  "Analysis",
  ".",
  "new",
  "(",
  "self",
  ",",
  ":nouns",
  "=>",
  "word_list",
  ")",
  "substitutor",
  "=",
  "Substitutor",
  ".",
  "new",
  "(",
  "analysis",
  ")",
  "substitutor",
  ".",
  "replace",
  "(",
  ":nouns",
  ")",
  ".",
  "increment",
  "(",
  "places",
  ")",
  "end"
] | 
	Replace the words in the word list with the word n places after it | 
	[
  "Replace",
  "the",
  "words",
  "in",
  "the",
  "word",
  "list",
  "with",
  "the",
  "word",
  "n",
  "places",
  "after",
  "it"
] | 
	dff71355efe0c050cfbf79b0a2cef9855bcc4923 | 
	https://github.com/Aupajo/oulipo/blob/dff71355efe0c050cfbf79b0a2cef9855bcc4923/lib/oulipo/string_extensions.rb#L38-L42 | 
| 116 | 
	Aupajo/oulipo | 
	lib/oulipo/string_extensions.rb | 
	Oulipo.StringExtensions.snowball? | 
	def snowball?
      words = self.split
      self.chaterism? && words.first.length < words.last.length
    end | 
	ruby | 
	def snowball?
      words = self.split
      self.chaterism? && words.first.length < words.last.length
    end | 
	[
  "def",
  "snowball?",
  "words",
  "=",
  "self",
  ".",
  "split",
  "self",
  ".",
  "chaterism?",
  "&&",
  "words",
  ".",
  "first",
  ".",
  "length",
  "<",
  "words",
  ".",
  "last",
  ".",
  "length",
  "end"
] | 
	Returns true if each word is one letter larger than the previous | 
	[
  "Returns",
  "true",
  "if",
  "each",
  "word",
  "is",
  "one",
  "letter",
  "larger",
  "than",
  "the",
  "previous"
] | 
	dff71355efe0c050cfbf79b0a2cef9855bcc4923 | 
	https://github.com/Aupajo/oulipo/blob/dff71355efe0c050cfbf79b0a2cef9855bcc4923/lib/oulipo/string_extensions.rb#L45-L48 | 
| 117 | 
	Aupajo/oulipo | 
	lib/oulipo/string_extensions.rb | 
	Oulipo.StringExtensions.chaterism? | 
	def chaterism?
      words = self.gsub(/[^a-z\s]/i, '').split
      # Find the direction we're traveling
      flen, llen = words.first.length, words.last.length
      direction = flen > llen ? :downto : :upto
      
      # Compare the pattern of word lengths against a range-turned-array of expected word lengths
      words.map(&:length) == flen.send(direction, llen).to_a
    end | 
	ruby | 
	def chaterism?
      words = self.gsub(/[^a-z\s]/i, '').split
      # Find the direction we're traveling
      flen, llen = words.first.length, words.last.length
      direction = flen > llen ? :downto : :upto
      
      # Compare the pattern of word lengths against a range-turned-array of expected word lengths
      words.map(&:length) == flen.send(direction, llen).to_a
    end | 
	[
  "def",
  "chaterism?",
  "words",
  "=",
  "self",
  ".",
  "gsub",
  "(",
  "/",
  "\\s",
  "/i",
  ",",
  "''",
  ")",
  ".",
  "split",
  "# Find the direction we're traveling",
  "flen",
  ",",
  "llen",
  "=",
  "words",
  ".",
  "first",
  ".",
  "length",
  ",",
  "words",
  ".",
  "last",
  ".",
  "length",
  "direction",
  "=",
  "flen",
  ">",
  "llen",
  "?",
  ":downto",
  ":",
  ":upto",
  "# Compare the pattern of word lengths against a range-turned-array of expected word lengths",
  "words",
  ".",
  "map",
  "(",
  ":length",
  ")",
  "==",
  "flen",
  ".",
  "send",
  "(",
  "direction",
  ",",
  "llen",
  ")",
  ".",
  "to_a",
  "end"
] | 
	Returns true if the string is a sequence of words in each of which is one letter larger than the
 previous, or each word in the sequence is one letter less than the previous | 
	[
  "Returns",
  "true",
  "if",
  "the",
  "string",
  "is",
  "a",
  "sequence",
  "of",
  "words",
  "in",
  "each",
  "of",
  "which",
  "is",
  "one",
  "letter",
  "larger",
  "than",
  "the",
  "previous",
  "or",
  "each",
  "word",
  "in",
  "the",
  "sequence",
  "is",
  "one",
  "letter",
  "less",
  "than",
  "the",
  "previous"
] | 
	dff71355efe0c050cfbf79b0a2cef9855bcc4923 | 
	https://github.com/Aupajo/oulipo/blob/dff71355efe0c050cfbf79b0a2cef9855bcc4923/lib/oulipo/string_extensions.rb#L57-L66 | 
| 118 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line/edit/edit_window/sync_window.rb | 
	MiniReadline.EditWindow.sync_window | 
	def sync_window(edit_buffer, edit_posn)
      unless check_margins(edit_buffer.length, edit_posn)
        window_buffer.clear
        @show_prompt = true
      end
      image = build_screen_image(edit_buffer)
      update_screen(image)
      @window_buffer = image
    end | 
	ruby | 
	def sync_window(edit_buffer, edit_posn)
      unless check_margins(edit_buffer.length, edit_posn)
        window_buffer.clear
        @show_prompt = true
      end
      image = build_screen_image(edit_buffer)
      update_screen(image)
      @window_buffer = image
    end | 
	[
  "def",
  "sync_window",
  "(",
  "edit_buffer",
  ",",
  "edit_posn",
  ")",
  "unless",
  "check_margins",
  "(",
  "edit_buffer",
  ".",
  "length",
  ",",
  "edit_posn",
  ")",
  "window_buffer",
  ".",
  "clear",
  "@show_prompt",
  "=",
  "true",
  "end",
  "image",
  "=",
  "build_screen_image",
  "(",
  "edit_buffer",
  ")",
  "update_screen",
  "(",
  "image",
  ")",
  "@window_buffer",
  "=",
  "image",
  "end"
] | 
	Keep the edit window in sync! | 
	[
  "Keep",
  "the",
  "edit",
  "window",
  "in",
  "sync!"
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line/edit/edit_window/sync_window.rb#L10-L19 | 
| 119 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line/edit/edit_window/sync_window.rb | 
	MiniReadline.EditWindow.build_screen_image | 
	def build_screen_image(edit_buffer)
      working_region = edit_buffer[left_margin..right_margin]
      if (mask = @options[:secret_mask])
        mask[0] * working_region.length
      else
        working_region
      end.ljust(active_width)
    end | 
	ruby | 
	def build_screen_image(edit_buffer)
      working_region = edit_buffer[left_margin..right_margin]
      if (mask = @options[:secret_mask])
        mask[0] * working_region.length
      else
        working_region
      end.ljust(active_width)
    end | 
	[
  "def",
  "build_screen_image",
  "(",
  "edit_buffer",
  ")",
  "working_region",
  "=",
  "edit_buffer",
  "[",
  "left_margin",
  "..",
  "right_margin",
  "]",
  "if",
  "(",
  "mask",
  "=",
  "@options",
  "[",
  ":secret_mask",
  "]",
  ")",
  "mask",
  "[",
  "0",
  "]",
  "*",
  "working_region",
  ".",
  "length",
  "else",
  "working_region",
  "end",
  ".",
  "ljust",
  "(",
  "active_width",
  ")",
  "end"
] | 
	Compute what should be on the screen. | 
	[
  "Compute",
  "what",
  "should",
  "be",
  "on",
  "the",
  "screen",
  "."
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line/edit/edit_window/sync_window.rb#L37-L45 | 
| 120 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line/edit/edit_window/sync_window.rb | 
	MiniReadline.EditWindow.update_screen | 
	def update_screen(image)
      if @show_prompt
        MiniTerm.print("\r#{prompt.text}\r")
        @show_prompt = false
      end
      (0...active_width).each do |index|
        if (image_char = image[index]) != window_buffer[index]
          MiniTerm.set_posn(column: prompt.length + index)
          MiniTerm.print(image_char)
        end
      end
    end | 
	ruby | 
	def update_screen(image)
      if @show_prompt
        MiniTerm.print("\r#{prompt.text}\r")
        @show_prompt = false
      end
      (0...active_width).each do |index|
        if (image_char = image[index]) != window_buffer[index]
          MiniTerm.set_posn(column: prompt.length + index)
          MiniTerm.print(image_char)
        end
      end
    end | 
	[
  "def",
  "update_screen",
  "(",
  "image",
  ")",
  "if",
  "@show_prompt",
  "MiniTerm",
  ".",
  "print",
  "(",
  "\"\\r#{prompt.text}\\r\"",
  ")",
  "@show_prompt",
  "=",
  "false",
  "end",
  "(",
  "0",
  "...",
  "active_width",
  ")",
  ".",
  "each",
  "do",
  "|",
  "index",
  "|",
  "if",
  "(",
  "image_char",
  "=",
  "image",
  "[",
  "index",
  "]",
  ")",
  "!=",
  "window_buffer",
  "[",
  "index",
  "]",
  "MiniTerm",
  ".",
  "set_posn",
  "(",
  "column",
  ":",
  "prompt",
  ".",
  "length",
  "+",
  "index",
  ")",
  "MiniTerm",
  ".",
  "print",
  "(",
  "image_char",
  ")",
  "end",
  "end",
  "end"
] | 
	Bring the screen into agreement with the image. | 
	[
  "Bring",
  "the",
  "screen",
  "into",
  "agreement",
  "with",
  "the",
  "image",
  "."
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line/edit/edit_window/sync_window.rb#L48-L60 | 
| 121 | 
	iHiD/mandate | 
	lib/mandate/memoize.rb | 
	Mandate.Memoize.__mandate_memoize | 
	def __mandate_memoize(method_name)
      memoizer = Module.new do
        define_method method_name do
          @__mandate_memoized_results ||= {}
          if @__mandate_memoized_results.include?(method_name)
            @__mandate_memoized_results[method_name]
          else
            @__mandate_memoized_results[method_name] = super()
          end
        end
      end
      prepend memoizer
    end | 
	ruby | 
	def __mandate_memoize(method_name)
      memoizer = Module.new do
        define_method method_name do
          @__mandate_memoized_results ||= {}
          if @__mandate_memoized_results.include?(method_name)
            @__mandate_memoized_results[method_name]
          else
            @__mandate_memoized_results[method_name] = super()
          end
        end
      end
      prepend memoizer
    end | 
	[
  "def",
  "__mandate_memoize",
  "(",
  "method_name",
  ")",
  "memoizer",
  "=",
  "Module",
  ".",
  "new",
  "do",
  "define_method",
  "method_name",
  "do",
  "@__mandate_memoized_results",
  "||=",
  "{",
  "}",
  "if",
  "@__mandate_memoized_results",
  ".",
  "include?",
  "(",
  "method_name",
  ")",
  "@__mandate_memoized_results",
  "[",
  "method_name",
  "]",
  "else",
  "@__mandate_memoized_results",
  "[",
  "method_name",
  "]",
  "=",
  "super",
  "(",
  ")",
  "end",
  "end",
  "end",
  "prepend",
  "memoizer",
  "end"
] | 
	Create an anonymous module that defines a method
 with the same name as main method being defined.
 Add some memoize code to check whether the method
 has been previously called or not. If it's not
 been then call the underlying method and store the result.
 We then prepend this module so that its method
 comes first in the method-lookup chain. | 
	[
  "Create",
  "an",
  "anonymous",
  "module",
  "that",
  "defines",
  "a",
  "method",
  "with",
  "the",
  "same",
  "name",
  "as",
  "main",
  "method",
  "being",
  "defined",
  ".",
  "Add",
  "some",
  "memoize",
  "code",
  "to",
  "check",
  "whether",
  "the",
  "method",
  "has",
  "been",
  "previously",
  "called",
  "or",
  "not",
  ".",
  "If",
  "it",
  "s",
  "not",
  "been",
  "then",
  "call",
  "the",
  "underlying",
  "method",
  "and",
  "store",
  "the",
  "result",
  "."
] | 
	bded81c497837d8755b81ab460033c912c9f95ab | 
	https://github.com/iHiD/mandate/blob/bded81c497837d8755b81ab460033c912c9f95ab/lib/mandate/memoize.rb#L31-L44 | 
| 122 | 
	fixrb/aw | 
	lib/aw/fork.rb | 
	Aw.Fork.call | 
	def call(*, **, &block)
      pid = fork_and_return_pid(&block)
      write.close
      result = read.read
      Process.wait(pid)
      # rubocop:disable MarshalLoad
      Marshal.load(result)
      # rubocop:enable MarshalLoad
    end | 
	ruby | 
	def call(*, **, &block)
      pid = fork_and_return_pid(&block)
      write.close
      result = read.read
      Process.wait(pid)
      # rubocop:disable MarshalLoad
      Marshal.load(result)
      # rubocop:enable MarshalLoad
    end | 
	[
  "def",
  "call",
  "(",
  "*",
  ",",
  "**",
  ",",
  "&",
  "block",
  ")",
  "pid",
  "=",
  "fork_and_return_pid",
  "(",
  "block",
  ")",
  "write",
  ".",
  "close",
  "result",
  "=",
  "read",
  ".",
  "read",
  "Process",
  ".",
  "wait",
  "(",
  "pid",
  ")",
  "# rubocop:disable MarshalLoad",
  "Marshal",
  ".",
  "load",
  "(",
  "result",
  ")",
  "# rubocop:enable MarshalLoad",
  "end"
] | 
	Run the block inside a subprocess, and return the value.
 @return [#object_id] The result. | 
	[
  "Run",
  "the",
  "block",
  "inside",
  "a",
  "subprocess",
  "and",
  "return",
  "the",
  "value",
  "."
] | 
	2ca162e1744b4354eed2d374d46db8d750129f94 | 
	https://github.com/fixrb/aw/blob/2ca162e1744b4354eed2d374d46db8d750129f94/lib/aw/fork.rb#L31-L40 | 
| 123 | 
	cldwalker/boson-more | 
	lib/boson/commands/web_core.rb | 
	Boson::Commands::WebCore.Get.get_body | 
	def get_body
      uri = URI.parse(@url)
      @response = get_response(uri)
      (@options[:any_response] || @response.code == '200') ? @response.body : nil
    rescue
      @options[:raise_error] ? raise : puts("Error: GET '#{@url}' -> #{$!.class}: #{$!.message}")
    end | 
	ruby | 
	def get_body
      uri = URI.parse(@url)
      @response = get_response(uri)
      (@options[:any_response] || @response.code == '200') ? @response.body : nil
    rescue
      @options[:raise_error] ? raise : puts("Error: GET '#{@url}' -> #{$!.class}: #{$!.message}")
    end | 
	[
  "def",
  "get_body",
  "uri",
  "=",
  "URI",
  ".",
  "parse",
  "(",
  "@url",
  ")",
  "@response",
  "=",
  "get_response",
  "(",
  "uri",
  ")",
  "(",
  "@options",
  "[",
  ":any_response",
  "]",
  "||",
  "@response",
  ".",
  "code",
  "==",
  "'200'",
  ")",
  "?",
  "@response",
  ".",
  "body",
  ":",
  "nil",
  "rescue",
  "@options",
  "[",
  ":raise_error",
  "]",
  "?",
  "raise",
  ":",
  "puts",
  "(",
  "\"Error: GET '#{@url}' -> #{$!.class}: #{$!.message}\"",
  ")",
  "end"
] | 
	Returns body string if successful or nil if not. | 
	[
  "Returns",
  "body",
  "string",
  "if",
  "successful",
  "or",
  "nil",
  "if",
  "not",
  "."
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/commands/web_core.rb#L114-L120 | 
| 124 | 
	cldwalker/boson-more | 
	lib/boson/commands/web_core.rb | 
	Boson::Commands::WebCore.Get.parse_body | 
	def parse_body(body)
      format = determine_format(@options[:parse])
      case format
      when :json
        unless ::Boson::Util.safe_require 'json'
          return puts("Install the json gem to parse json: sudo gem install json")
        end
        JSON.parse body
      when :yaml
        YAML::load body
      else
        puts "Can't parse this format."
      end
    rescue
      @options[:raise_error] ? raise : puts("Error while parsing #{format} response of '#{@url}': #{$!.class}")
    end | 
	ruby | 
	def parse_body(body)
      format = determine_format(@options[:parse])
      case format
      when :json
        unless ::Boson::Util.safe_require 'json'
          return puts("Install the json gem to parse json: sudo gem install json")
        end
        JSON.parse body
      when :yaml
        YAML::load body
      else
        puts "Can't parse this format."
      end
    rescue
      @options[:raise_error] ? raise : puts("Error while parsing #{format} response of '#{@url}': #{$!.class}")
    end | 
	[
  "def",
  "parse_body",
  "(",
  "body",
  ")",
  "format",
  "=",
  "determine_format",
  "(",
  "@options",
  "[",
  ":parse",
  "]",
  ")",
  "case",
  "format",
  "when",
  ":json",
  "unless",
  "::",
  "Boson",
  "::",
  "Util",
  ".",
  "safe_require",
  "'json'",
  "return",
  "puts",
  "(",
  "\"Install the json gem to parse json: sudo gem install json\"",
  ")",
  "end",
  "JSON",
  ".",
  "parse",
  "body",
  "when",
  ":yaml",
  "YAML",
  "::",
  "load",
  "body",
  "else",
  "puts",
  "\"Can't parse this format.\"",
  "end",
  "rescue",
  "@options",
  "[",
  ":raise_error",
  "]",
  "?",
  "raise",
  ":",
  "puts",
  "(",
  "\"Error while parsing #{format} response of '#{@url}': #{$!.class}\"",
  ")",
  "end"
] | 
	Returns nil if dependencies or parsing fails | 
	[
  "Returns",
  "nil",
  "if",
  "dependencies",
  "or",
  "parsing",
  "fails"
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/commands/web_core.rb#L130-L145 | 
| 125 | 
	angelim/rails_redshift_replicator | 
	lib/rails_redshift_replicator/file_manager.rb | 
	RailsRedshiftReplicator.FileManager.write_csv | 
	def write_csv(file_name, records)
      line_number = exporter.connection_adapter.write(local_file(file_name), records)
    end | 
	ruby | 
	def write_csv(file_name, records)
      line_number = exporter.connection_adapter.write(local_file(file_name), records)
    end | 
	[
  "def",
  "write_csv",
  "(",
  "file_name",
  ",",
  "records",
  ")",
  "line_number",
  "=",
  "exporter",
  ".",
  "connection_adapter",
  ".",
  "write",
  "(",
  "local_file",
  "(",
  "file_name",
  ")",
  ",",
  "records",
  ")",
  "end"
] | 
	Writes all results to one file for future splitting.
 @param file_name [String] name of the local export file
 @return [Integer] number of records to export. | 
	[
  "Writes",
  "all",
  "results",
  "to",
  "one",
  "file",
  "for",
  "future",
  "splitting",
  "."
] | 
	823f6da36f43a39f340a3ca7eb159df58a86766d | 
	https://github.com/angelim/rails_redshift_replicator/blob/823f6da36f43a39f340a3ca7eb159df58a86766d/lib/rails_redshift_replicator/file_manager.rb#L49-L51 | 
| 126 | 
	angelim/rails_redshift_replicator | 
	lib/rails_redshift_replicator/file_manager.rb | 
	RailsRedshiftReplicator.FileManager.file_key_in_format | 
	def file_key_in_format(file_name, format)
      if format == "gzip"
        self.class.s3_file_key exporter.source_table, gzipped(file_name)
      else
        self.class.s3_file_key exporter.source_table, file_name
      end
    end | 
	ruby | 
	def file_key_in_format(file_name, format)
      if format == "gzip"
        self.class.s3_file_key exporter.source_table, gzipped(file_name)
      else
        self.class.s3_file_key exporter.source_table, file_name
      end
    end | 
	[
  "def",
  "file_key_in_format",
  "(",
  "file_name",
  ",",
  "format",
  ")",
  "if",
  "format",
  "==",
  "\"gzip\"",
  "self",
  ".",
  "class",
  ".",
  "s3_file_key",
  "exporter",
  ".",
  "source_table",
  ",",
  "gzipped",
  "(",
  "file_name",
  ")",
  "else",
  "self",
  ".",
  "class",
  ".",
  "s3_file_key",
  "exporter",
  ".",
  "source_table",
  ",",
  "file_name",
  "end",
  "end"
] | 
	Returns the s3 key to be used
 @return [String] file key with extension | 
	[
  "Returns",
  "the",
  "s3",
  "key",
  "to",
  "be",
  "used"
] | 
	823f6da36f43a39f340a3ca7eb159df58a86766d | 
	https://github.com/angelim/rails_redshift_replicator/blob/823f6da36f43a39f340a3ca7eb159df58a86766d/lib/rails_redshift_replicator/file_manager.rb#L80-L86 | 
| 127 | 
	angelim/rails_redshift_replicator | 
	lib/rails_redshift_replicator/file_manager.rb | 
	RailsRedshiftReplicator.FileManager.upload_csv | 
	def upload_csv(files)
      files.each do |file|
        basename = File.basename(file)
        next if basename == File.basename(exporter.replication.key)
        RailsRedshiftReplicator.logger.info I18n.t(:uploading_notice,
                                                   file: file,
                                                   key: self.class.s3_file_key(exporter.source_table, basename),
                                                   scope: :rails_redshift_replicator)
        s3_client.put_object(
          key: self.class.s3_file_key(exporter.source_table, basename),
          body: File.open(file),
          bucket: bucket
        )
      end
      files.each { |f| FileUtils.rm f }
    end | 
	ruby | 
	def upload_csv(files)
      files.each do |file|
        basename = File.basename(file)
        next if basename == File.basename(exporter.replication.key)
        RailsRedshiftReplicator.logger.info I18n.t(:uploading_notice,
                                                   file: file,
                                                   key: self.class.s3_file_key(exporter.source_table, basename),
                                                   scope: :rails_redshift_replicator)
        s3_client.put_object(
          key: self.class.s3_file_key(exporter.source_table, basename),
          body: File.open(file),
          bucket: bucket
        )
      end
      files.each { |f| FileUtils.rm f }
    end | 
	[
  "def",
  "upload_csv",
  "(",
  "files",
  ")",
  "files",
  ".",
  "each",
  "do",
  "|",
  "file",
  "|",
  "basename",
  "=",
  "File",
  ".",
  "basename",
  "(",
  "file",
  ")",
  "next",
  "if",
  "basename",
  "==",
  "File",
  ".",
  "basename",
  "(",
  "exporter",
  ".",
  "replication",
  ".",
  "key",
  ")",
  "RailsRedshiftReplicator",
  ".",
  "logger",
  ".",
  "info",
  "I18n",
  ".",
  "t",
  "(",
  ":uploading_notice",
  ",",
  "file",
  ":",
  "file",
  ",",
  "key",
  ":",
  "self",
  ".",
  "class",
  ".",
  "s3_file_key",
  "(",
  "exporter",
  ".",
  "source_table",
  ",",
  "basename",
  ")",
  ",",
  "scope",
  ":",
  ":rails_redshift_replicator",
  ")",
  "s3_client",
  ".",
  "put_object",
  "(",
  "key",
  ":",
  "self",
  ".",
  "class",
  ".",
  "s3_file_key",
  "(",
  "exporter",
  ".",
  "source_table",
  ",",
  "basename",
  ")",
  ",",
  "body",
  ":",
  "File",
  ".",
  "open",
  "(",
  "file",
  ")",
  ",",
  "bucket",
  ":",
  "bucket",
  ")",
  "end",
  "files",
  ".",
  "each",
  "{",
  "|",
  "f",
  "|",
  "FileUtils",
  ".",
  "rm",
  "f",
  "}",
  "end"
] | 
	Uploads splitted CSVs
 @param files [Array<String>] array of files paths to upload | 
	[
  "Uploads",
  "splitted",
  "CSVs"
] | 
	823f6da36f43a39f340a3ca7eb159df58a86766d | 
	https://github.com/angelim/rails_redshift_replicator/blob/823f6da36f43a39f340a3ca7eb159df58a86766d/lib/rails_redshift_replicator/file_manager.rb#L117-L132 | 
| 128 | 
	rightscale/right_chimp | 
	lib/right_chimp/exec/executor.rb | 
	Chimp.Executor.run_with_retry | 
	def run_with_retry(&block)
      Log.debug "Running job '#{@job_id}' with status '#{@status}'"
      # If we are not the first job in this group, wait @delay
      ChimpDaemon.instance.semaphore.synchronize do
        if @group.started >= @concurrency && @delay.nonzero?
          Log.info "[#{@job_uuid}] Sleeping #{@delay} seconds between tasks"
          sleep @delay
        end
        @group.started += 1
      end
      @status = STATUS_RUNNING
      @time_start = Time.now
      Log.info self.describe_work_start unless @quiet
      #
      # The inner level of exception handling here tries to catch anything
      # that can be easily retired or failed-- normal exceptions.
      #
      # The outer level of exception handling handles weird stuff; for example,
      # sometimes rest_connection raises RuntimeError exceptions...
      #
      # This fixes acu75562.
      #
      begin
        begin
          yield if not @dry_run
          if @owner != nil
            @status = STATUS_DONE
            @group.job_completed
          else
            Log.warn "[#{@job_uuid}][#{@job_id}] Ownership of job_id #{job_id} lost. User cancelled operation?"
          end
        rescue SystemExit, Interrupt => ex
          $stderr.puts 'Exiting!'
          raise ex
        rescue Interrupt => ex
          name = @array['name'] if @array
          name = @server['name'] || @server['nickname'] if @server
          Log.error self.describe_work_error
          if @retry_count > 0
            @status = STATUS_RETRYING
            Log.error "[#{@job_uuid}][#{@job_id}] Error executing on \"#{name}\". Retrying in #{@retry_sleep} seconds..."
            @retry_count -= 1
            sleep @retry_sleep
            retry
          end
          @status = STATUS_ERROR
          @error = ex
          Log.error "[#{@job_uuid}][#{@job_id}] Error executing on \"#{name}\": #{ex}"
        ensure
          @time_end = Time.now
          Log.info self.describe_work_done unless @quiet
        end
      rescue RuntimeError => ex
        err = ex.message + "IP: #{@server.params["ip_address"]}\n" if @server.params['ip_address']
        err += " Group: #{@group.group_id}\n" if @group.group_id
        err += " Notes: #{@job_notes}\n" if @job_notes
        err += " Notes: #{@job_notes}\n" if @job_notes
        Log.error "[#{@job_uuid}][#{@job_id}] Caught RuntimeError: #{err} Job failed.\n"
        @status = STATUS_ERROR
        @error = ex
      end
    end | 
	ruby | 
	def run_with_retry(&block)
      Log.debug "Running job '#{@job_id}' with status '#{@status}'"
      # If we are not the first job in this group, wait @delay
      ChimpDaemon.instance.semaphore.synchronize do
        if @group.started >= @concurrency && @delay.nonzero?
          Log.info "[#{@job_uuid}] Sleeping #{@delay} seconds between tasks"
          sleep @delay
        end
        @group.started += 1
      end
      @status = STATUS_RUNNING
      @time_start = Time.now
      Log.info self.describe_work_start unless @quiet
      #
      # The inner level of exception handling here tries to catch anything
      # that can be easily retired or failed-- normal exceptions.
      #
      # The outer level of exception handling handles weird stuff; for example,
      # sometimes rest_connection raises RuntimeError exceptions...
      #
      # This fixes acu75562.
      #
      begin
        begin
          yield if not @dry_run
          if @owner != nil
            @status = STATUS_DONE
            @group.job_completed
          else
            Log.warn "[#{@job_uuid}][#{@job_id}] Ownership of job_id #{job_id} lost. User cancelled operation?"
          end
        rescue SystemExit, Interrupt => ex
          $stderr.puts 'Exiting!'
          raise ex
        rescue Interrupt => ex
          name = @array['name'] if @array
          name = @server['name'] || @server['nickname'] if @server
          Log.error self.describe_work_error
          if @retry_count > 0
            @status = STATUS_RETRYING
            Log.error "[#{@job_uuid}][#{@job_id}] Error executing on \"#{name}\". Retrying in #{@retry_sleep} seconds..."
            @retry_count -= 1
            sleep @retry_sleep
            retry
          end
          @status = STATUS_ERROR
          @error = ex
          Log.error "[#{@job_uuid}][#{@job_id}] Error executing on \"#{name}\": #{ex}"
        ensure
          @time_end = Time.now
          Log.info self.describe_work_done unless @quiet
        end
      rescue RuntimeError => ex
        err = ex.message + "IP: #{@server.params["ip_address"]}\n" if @server.params['ip_address']
        err += " Group: #{@group.group_id}\n" if @group.group_id
        err += " Notes: #{@job_notes}\n" if @job_notes
        err += " Notes: #{@job_notes}\n" if @job_notes
        Log.error "[#{@job_uuid}][#{@job_id}] Caught RuntimeError: #{err} Job failed.\n"
        @status = STATUS_ERROR
        @error = ex
      end
    end | 
	[
  "def",
  "run_with_retry",
  "(",
  "&",
  "block",
  ")",
  "Log",
  ".",
  "debug",
  "\"Running job '#{@job_id}' with status '#{@status}'\"",
  "# If we are not the first job in this group, wait @delay",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "semaphore",
  ".",
  "synchronize",
  "do",
  "if",
  "@group",
  ".",
  "started",
  ">=",
  "@concurrency",
  "&&",
  "@delay",
  ".",
  "nonzero?",
  "Log",
  ".",
  "info",
  "\"[#{@job_uuid}] Sleeping #{@delay} seconds between tasks\"",
  "sleep",
  "@delay",
  "end",
  "@group",
  ".",
  "started",
  "+=",
  "1",
  "end",
  "@status",
  "=",
  "STATUS_RUNNING",
  "@time_start",
  "=",
  "Time",
  ".",
  "now",
  "Log",
  ".",
  "info",
  "self",
  ".",
  "describe_work_start",
  "unless",
  "@quiet",
  "#",
  "# The inner level of exception handling here tries to catch anything",
  "# that can be easily retired or failed-- normal exceptions.",
  "#",
  "# The outer level of exception handling handles weird stuff; for example,",
  "# sometimes rest_connection raises RuntimeError exceptions...",
  "#",
  "# This fixes acu75562.",
  "#",
  "begin",
  "begin",
  "yield",
  "if",
  "not",
  "@dry_run",
  "if",
  "@owner",
  "!=",
  "nil",
  "@status",
  "=",
  "STATUS_DONE",
  "@group",
  ".",
  "job_completed",
  "else",
  "Log",
  ".",
  "warn",
  "\"[#{@job_uuid}][#{@job_id}] Ownership of job_id #{job_id} lost. User cancelled operation?\"",
  "end",
  "rescue",
  "SystemExit",
  ",",
  "Interrupt",
  "=>",
  "ex",
  "$stderr",
  ".",
  "puts",
  "'Exiting!'",
  "raise",
  "ex",
  "rescue",
  "Interrupt",
  "=>",
  "ex",
  "name",
  "=",
  "@array",
  "[",
  "'name'",
  "]",
  "if",
  "@array",
  "name",
  "=",
  "@server",
  "[",
  "'name'",
  "]",
  "||",
  "@server",
  "[",
  "'nickname'",
  "]",
  "if",
  "@server",
  "Log",
  ".",
  "error",
  "self",
  ".",
  "describe_work_error",
  "if",
  "@retry_count",
  ">",
  "0",
  "@status",
  "=",
  "STATUS_RETRYING",
  "Log",
  ".",
  "error",
  "\"[#{@job_uuid}][#{@job_id}] Error executing on \\\"#{name}\\\". Retrying in #{@retry_sleep} seconds...\"",
  "@retry_count",
  "-=",
  "1",
  "sleep",
  "@retry_sleep",
  "retry",
  "end",
  "@status",
  "=",
  "STATUS_ERROR",
  "@error",
  "=",
  "ex",
  "Log",
  ".",
  "error",
  "\"[#{@job_uuid}][#{@job_id}] Error executing on \\\"#{name}\\\": #{ex}\"",
  "ensure",
  "@time_end",
  "=",
  "Time",
  ".",
  "now",
  "Log",
  ".",
  "info",
  "self",
  ".",
  "describe_work_done",
  "unless",
  "@quiet",
  "end",
  "rescue",
  "RuntimeError",
  "=>",
  "ex",
  "err",
  "=",
  "ex",
  ".",
  "message",
  "+",
  "\"IP: #{@server.params[\"ip_address\"]}\\n\"",
  "if",
  "@server",
  ".",
  "params",
  "[",
  "'ip_address'",
  "]",
  "err",
  "+=",
  "\" Group: #{@group.group_id}\\n\"",
  "if",
  "@group",
  ".",
  "group_id",
  "err",
  "+=",
  "\" Notes: #{@job_notes}\\n\"",
  "if",
  "@job_notes",
  "err",
  "+=",
  "\" Notes: #{@job_notes}\\n\"",
  "if",
  "@job_notes",
  "Log",
  ".",
  "error",
  "\"[#{@job_uuid}][#{@job_id}] Caught RuntimeError: #{err} Job failed.\\n\"",
  "@status",
  "=",
  "STATUS_ERROR",
  "@error",
  "=",
  "ex",
  "end",
  "end"
] | 
	Run a unit of work with retries
 This is called from the subclass with a code block to yield to | 
	[
  "Run",
  "a",
  "unit",
  "of",
  "work",
  "with",
  "retries",
  "This",
  "is",
  "called",
  "from",
  "the",
  "subclass",
  "with",
  "a",
  "code",
  "block",
  "to",
  "yield",
  "to"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/exec/executor.rb#L108-L179 | 
| 129 | 
	catarse/catarse_pagarme | 
	app/models/catarse_pagarme/payment_delegator.rb | 
	CatarsePagarme.PaymentDelegator.transfer_funds | 
	def transfer_funds
      raise "payment must be paid" if !payment.paid?
      bank_account = PagarMe::BankAccount.new(bank_account_attributes.delete(:bank_account))
      bank_account.create
      raise "unable to create an bank account" unless bank_account.id.present?
      transfer = PagarMe::Transfer.new({
        bank_account_id: bank_account.id,
        amount: value_for_transaction
      })
      transfer.create
      raise "unable to create a transfer" unless transfer.id.present?
      #avoid sending notification
      payment.update_attributes(state: 'pending_refund')
      payment.payment_transfers.create!({
        user: payment.user,
        transfer_id: transfer.id,
        transfer_data: transfer.to_json
      })
    end | 
	ruby | 
	def transfer_funds
      raise "payment must be paid" if !payment.paid?
      bank_account = PagarMe::BankAccount.new(bank_account_attributes.delete(:bank_account))
      bank_account.create
      raise "unable to create an bank account" unless bank_account.id.present?
      transfer = PagarMe::Transfer.new({
        bank_account_id: bank_account.id,
        amount: value_for_transaction
      })
      transfer.create
      raise "unable to create a transfer" unless transfer.id.present?
      #avoid sending notification
      payment.update_attributes(state: 'pending_refund')
      payment.payment_transfers.create!({
        user: payment.user,
        transfer_id: transfer.id,
        transfer_data: transfer.to_json
      })
    end | 
	[
  "def",
  "transfer_funds",
  "raise",
  "\"payment must be paid\"",
  "if",
  "!",
  "payment",
  ".",
  "paid?",
  "bank_account",
  "=",
  "PagarMe",
  "::",
  "BankAccount",
  ".",
  "new",
  "(",
  "bank_account_attributes",
  ".",
  "delete",
  "(",
  ":bank_account",
  ")",
  ")",
  "bank_account",
  ".",
  "create",
  "raise",
  "\"unable to create an bank account\"",
  "unless",
  "bank_account",
  ".",
  "id",
  ".",
  "present?",
  "transfer",
  "=",
  "PagarMe",
  "::",
  "Transfer",
  ".",
  "new",
  "(",
  "{",
  "bank_account_id",
  ":",
  "bank_account",
  ".",
  "id",
  ",",
  "amount",
  ":",
  "value_for_transaction",
  "}",
  ")",
  "transfer",
  ".",
  "create",
  "raise",
  "\"unable to create a transfer\"",
  "unless",
  "transfer",
  ".",
  "id",
  ".",
  "present?",
  "#avoid sending notification",
  "payment",
  ".",
  "update_attributes",
  "(",
  "state",
  ":",
  "'pending_refund'",
  ")",
  "payment",
  ".",
  "payment_transfers",
  ".",
  "create!",
  "(",
  "{",
  "user",
  ":",
  "payment",
  ".",
  "user",
  ",",
  "transfer_id",
  ":",
  "transfer",
  ".",
  "id",
  ",",
  "transfer_data",
  ":",
  "transfer",
  ".",
  "to_json",
  "}",
  ")",
  "end"
] | 
	Transfer payment amount to payer bank account via transfers API | 
	[
  "Transfer",
  "payment",
  "amount",
  "to",
  "payer",
  "bank",
  "account",
  "via",
  "transfers",
  "API"
] | 
	5990bdbfddb3f2309c805d3074ea4dc04140d198 | 
	https://github.com/catarse/catarse_pagarme/blob/5990bdbfddb3f2309c805d3074ea4dc04140d198/app/models/catarse_pagarme/payment_delegator.rb#L112-L133 | 
| 130 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.run | 
	def run
      queue = ChimpQueue.instance
      arguments = []
      ARGV.each { |arg| arguments << arg.clone }
      self.cli_args=arguments.collect {|param|
        param.gsub(/(?<==).*/) do |match|
          match='"'+match+'"'
        end
      }.join(" ")
      parse_command_line if @interactive
      check_option_validity if @interactive
      disable_logging unless @@verbose
      puts "chimp #{VERSION} executing..." if (@interactive and not @use_chimpd) and not @@quiet
      #
      # Wait for chimpd to complete tasks
      #
      if @chimpd_wait_until_done
        chimpd_wait_until_done
        exit
      end
      #
      # Send the command to chimpd for execution
      #
      if @use_chimpd
        timestamp = Time.now.to_i
        length = 6
        self.job_uuid = (36**(length - 1) + rand(36**length - 36**(length - 1))).to_s(36)
        ChimpDaemonClient.submit(@chimpd_host, @chimpd_port, self, job_uuid)
        exit
      else
        # Connect to the Api
        Connection.instance
        if @interactive
          Connection.connect
        else
          Connection.connect_and_cache
        end
      end
      # If we're processing the command ourselves, then go
      # ahead and start making API calls to select the objects
      # to operate upon
      #
      # Get elements if --array has been passed
      get_array_info
      # Get elements if we are searching by tags
      get_server_info
      # At this stage @servers should be populated with our findings
      # Get ST info for all elements
      if not @servers.empty?
        get_template_info unless @servers.empty?
        puts "Looking for the rightscripts (This might take some time)" if (@interactive and not @use_chimpd) and not @@quiet
        get_executable_info
      end
      if Chimp.failure
        #This is the failure point when executing standalone
        Log.error "##################################################"
        Log.error "[#{Chimp.get_job_uuid}] API CALL FAILED FOR:"
        Log.error "[#{Chimp.get_job_uuid}] chimp #{@cli_args} "
        Log.error "[#{Chimp.get_job_uuid}] Run manually!"
        Log.error "##################################################"
        exit 1
      end
      #
      # Optionally display the list of objects to operate on
      # and prompt the user
      #
      if @prompt and @interactive
        list_of_objects = make_human_readable_list_of_objects
        confirm = (list_of_objects.size > 0 and @action != :action_none) or @action == :action_none
        if @script_to_run.nil?
          verify("Your command will be executed on the following:", list_of_objects, confirm)
        else
          verify("Your command \""+@script_to_run.params['right_script']['name']+"\" will be executed on the following:", list_of_objects, confirm)
        end
      end
      #
      # Load the queue with work
      #
      if not @servers.first.nil? and ( not @executable.nil? or @action == :action_ssh or @action == :action_report)
        jobs = generate_jobs(@servers, @server_template, @executable)
        add_to_queue(jobs)
      end
      #
      # Exit early if there is nothing to do
      #
      if @action == :action_none or ( queue.group[@group].nil? || queue.group[@group].size == 0)
        puts "No actions to perform." unless self.quiet
      else
        do_work
      end
    end | 
	ruby | 
	def run
      queue = ChimpQueue.instance
      arguments = []
      ARGV.each { |arg| arguments << arg.clone }
      self.cli_args=arguments.collect {|param|
        param.gsub(/(?<==).*/) do |match|
          match='"'+match+'"'
        end
      }.join(" ")
      parse_command_line if @interactive
      check_option_validity if @interactive
      disable_logging unless @@verbose
      puts "chimp #{VERSION} executing..." if (@interactive and not @use_chimpd) and not @@quiet
      #
      # Wait for chimpd to complete tasks
      #
      if @chimpd_wait_until_done
        chimpd_wait_until_done
        exit
      end
      #
      # Send the command to chimpd for execution
      #
      if @use_chimpd
        timestamp = Time.now.to_i
        length = 6
        self.job_uuid = (36**(length - 1) + rand(36**length - 36**(length - 1))).to_s(36)
        ChimpDaemonClient.submit(@chimpd_host, @chimpd_port, self, job_uuid)
        exit
      else
        # Connect to the Api
        Connection.instance
        if @interactive
          Connection.connect
        else
          Connection.connect_and_cache
        end
      end
      # If we're processing the command ourselves, then go
      # ahead and start making API calls to select the objects
      # to operate upon
      #
      # Get elements if --array has been passed
      get_array_info
      # Get elements if we are searching by tags
      get_server_info
      # At this stage @servers should be populated with our findings
      # Get ST info for all elements
      if not @servers.empty?
        get_template_info unless @servers.empty?
        puts "Looking for the rightscripts (This might take some time)" if (@interactive and not @use_chimpd) and not @@quiet
        get_executable_info
      end
      if Chimp.failure
        #This is the failure point when executing standalone
        Log.error "##################################################"
        Log.error "[#{Chimp.get_job_uuid}] API CALL FAILED FOR:"
        Log.error "[#{Chimp.get_job_uuid}] chimp #{@cli_args} "
        Log.error "[#{Chimp.get_job_uuid}] Run manually!"
        Log.error "##################################################"
        exit 1
      end
      #
      # Optionally display the list of objects to operate on
      # and prompt the user
      #
      if @prompt and @interactive
        list_of_objects = make_human_readable_list_of_objects
        confirm = (list_of_objects.size > 0 and @action != :action_none) or @action == :action_none
        if @script_to_run.nil?
          verify("Your command will be executed on the following:", list_of_objects, confirm)
        else
          verify("Your command \""+@script_to_run.params['right_script']['name']+"\" will be executed on the following:", list_of_objects, confirm)
        end
      end
      #
      # Load the queue with work
      #
      if not @servers.first.nil? and ( not @executable.nil? or @action == :action_ssh or @action == :action_report)
        jobs = generate_jobs(@servers, @server_template, @executable)
        add_to_queue(jobs)
      end
      #
      # Exit early if there is nothing to do
      #
      if @action == :action_none or ( queue.group[@group].nil? || queue.group[@group].size == 0)
        puts "No actions to perform." unless self.quiet
      else
        do_work
      end
    end | 
	[
  "def",
  "run",
  "queue",
  "=",
  "ChimpQueue",
  ".",
  "instance",
  "arguments",
  "=",
  "[",
  "]",
  "ARGV",
  ".",
  "each",
  "{",
  "|",
  "arg",
  "|",
  "arguments",
  "<<",
  "arg",
  ".",
  "clone",
  "}",
  "self",
  ".",
  "cli_args",
  "=",
  "arguments",
  ".",
  "collect",
  "{",
  "|",
  "param",
  "|",
  "param",
  ".",
  "gsub",
  "(",
  "/",
  "/",
  ")",
  "do",
  "|",
  "match",
  "|",
  "match",
  "=",
  "'\"'",
  "+",
  "match",
  "+",
  "'\"'",
  "end",
  "}",
  ".",
  "join",
  "(",
  "\" \"",
  ")",
  "parse_command_line",
  "if",
  "@interactive",
  "check_option_validity",
  "if",
  "@interactive",
  "disable_logging",
  "unless",
  "@@verbose",
  "puts",
  "\"chimp #{VERSION} executing...\"",
  "if",
  "(",
  "@interactive",
  "and",
  "not",
  "@use_chimpd",
  ")",
  "and",
  "not",
  "@@quiet",
  "#",
  "# Wait for chimpd to complete tasks",
  "#",
  "if",
  "@chimpd_wait_until_done",
  "chimpd_wait_until_done",
  "exit",
  "end",
  "#",
  "# Send the command to chimpd for execution",
  "#",
  "if",
  "@use_chimpd",
  "timestamp",
  "=",
  "Time",
  ".",
  "now",
  ".",
  "to_i",
  "length",
  "=",
  "6",
  "self",
  ".",
  "job_uuid",
  "=",
  "(",
  "36",
  "**",
  "(",
  "length",
  "-",
  "1",
  ")",
  "+",
  "rand",
  "(",
  "36",
  "**",
  "length",
  "-",
  "36",
  "**",
  "(",
  "length",
  "-",
  "1",
  ")",
  ")",
  ")",
  ".",
  "to_s",
  "(",
  "36",
  ")",
  "ChimpDaemonClient",
  ".",
  "submit",
  "(",
  "@chimpd_host",
  ",",
  "@chimpd_port",
  ",",
  "self",
  ",",
  "job_uuid",
  ")",
  "exit",
  "else",
  "# Connect to the Api",
  "Connection",
  ".",
  "instance",
  "if",
  "@interactive",
  "Connection",
  ".",
  "connect",
  "else",
  "Connection",
  ".",
  "connect_and_cache",
  "end",
  "end",
  "# If we're processing the command ourselves, then go",
  "# ahead and start making API calls to select the objects",
  "# to operate upon",
  "#",
  "# Get elements if --array has been passed",
  "get_array_info",
  "# Get elements if we are searching by tags",
  "get_server_info",
  "# At this stage @servers should be populated with our findings",
  "# Get ST info for all elements",
  "if",
  "not",
  "@servers",
  ".",
  "empty?",
  "get_template_info",
  "unless",
  "@servers",
  ".",
  "empty?",
  "puts",
  "\"Looking for the rightscripts (This might take some time)\"",
  "if",
  "(",
  "@interactive",
  "and",
  "not",
  "@use_chimpd",
  ")",
  "and",
  "not",
  "@@quiet",
  "get_executable_info",
  "end",
  "if",
  "Chimp",
  ".",
  "failure",
  "#This is the failure point when executing standalone",
  "Log",
  ".",
  "error",
  "\"##################################################\"",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] API CALL FAILED FOR:\"",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] chimp #{@cli_args} \"",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] Run manually!\"",
  "Log",
  ".",
  "error",
  "\"##################################################\"",
  "exit",
  "1",
  "end",
  "#",
  "# Optionally display the list of objects to operate on",
  "# and prompt the user",
  "#",
  "if",
  "@prompt",
  "and",
  "@interactive",
  "list_of_objects",
  "=",
  "make_human_readable_list_of_objects",
  "confirm",
  "=",
  "(",
  "list_of_objects",
  ".",
  "size",
  ">",
  "0",
  "and",
  "@action",
  "!=",
  ":action_none",
  ")",
  "or",
  "@action",
  "==",
  ":action_none",
  "if",
  "@script_to_run",
  ".",
  "nil?",
  "verify",
  "(",
  "\"Your command will be executed on the following:\"",
  ",",
  "list_of_objects",
  ",",
  "confirm",
  ")",
  "else",
  "verify",
  "(",
  "\"Your command \\\"\"",
  "+",
  "@script_to_run",
  ".",
  "params",
  "[",
  "'right_script'",
  "]",
  "[",
  "'name'",
  "]",
  "+",
  "\"\\\" will be executed on the following:\"",
  ",",
  "list_of_objects",
  ",",
  "confirm",
  ")",
  "end",
  "end",
  "#",
  "# Load the queue with work",
  "#",
  "if",
  "not",
  "@servers",
  ".",
  "first",
  ".",
  "nil?",
  "and",
  "(",
  "not",
  "@executable",
  ".",
  "nil?",
  "or",
  "@action",
  "==",
  ":action_ssh",
  "or",
  "@action",
  "==",
  ":action_report",
  ")",
  "jobs",
  "=",
  "generate_jobs",
  "(",
  "@servers",
  ",",
  "@server_template",
  ",",
  "@executable",
  ")",
  "add_to_queue",
  "(",
  "jobs",
  ")",
  "end",
  "#",
  "# Exit early if there is nothing to do",
  "#",
  "if",
  "@action",
  "==",
  ":action_none",
  "or",
  "(",
  "queue",
  ".",
  "group",
  "[",
  "@group",
  "]",
  ".",
  "nil?",
  "||",
  "queue",
  ".",
  "group",
  "[",
  "@group",
  "]",
  ".",
  "size",
  "==",
  "0",
  ")",
  "puts",
  "\"No actions to perform.\"",
  "unless",
  "self",
  ".",
  "quiet",
  "else",
  "do_work",
  "end",
  "end"
] | 
	Set up reasonable defaults
 Entry point for the chimp command line application | 
	[
  "Set",
  "up",
  "reasonable",
  "defaults"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L97-L205 | 
| 131 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.check_option_validity | 
	def check_option_validity
      if @hold && !@array_names.empty?
        puts "ERROR: Holding of array objects is not yet supported"
        exit 1
      end
      if @tags.empty? and @array_names.empty? and @deployment_names.empty? and not @chimpd_wait_until_done
        puts "ERROR: Please select the objects to operate upon."
        help
        exit 1
      end
      if not @array_names.empty? and ( not @tags.empty? or not @deployment_names.empty? )
        puts "ERROR: You cannot mix ServerArray queries with other types of queries."
        help
        exit 1
      end
    end | 
	ruby | 
	def check_option_validity
      if @hold && !@array_names.empty?
        puts "ERROR: Holding of array objects is not yet supported"
        exit 1
      end
      if @tags.empty? and @array_names.empty? and @deployment_names.empty? and not @chimpd_wait_until_done
        puts "ERROR: Please select the objects to operate upon."
        help
        exit 1
      end
      if not @array_names.empty? and ( not @tags.empty? or not @deployment_names.empty? )
        puts "ERROR: You cannot mix ServerArray queries with other types of queries."
        help
        exit 1
      end
    end | 
	[
  "def",
  "check_option_validity",
  "if",
  "@hold",
  "&&",
  "!",
  "@array_names",
  ".",
  "empty?",
  "puts",
  "\"ERROR: Holding of array objects is not yet supported\"",
  "exit",
  "1",
  "end",
  "if",
  "@tags",
  ".",
  "empty?",
  "and",
  "@array_names",
  ".",
  "empty?",
  "and",
  "@deployment_names",
  ".",
  "empty?",
  "and",
  "not",
  "@chimpd_wait_until_done",
  "puts",
  "\"ERROR: Please select the objects to operate upon.\"",
  "help",
  "exit",
  "1",
  "end",
  "if",
  "not",
  "@array_names",
  ".",
  "empty?",
  "and",
  "(",
  "not",
  "@tags",
  ".",
  "empty?",
  "or",
  "not",
  "@deployment_names",
  ".",
  "empty?",
  ")",
  "puts",
  "\"ERROR: You cannot mix ServerArray queries with other types of queries.\"",
  "help",
  "exit",
  "1",
  "end",
  "end"
] | 
	Check for any invalid combinations of command line options | 
	[
  "Check",
  "for",
  "any",
  "invalid",
  "combinations",
  "of",
  "command",
  "line",
  "options"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L485-L502 | 
| 132 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.get_servers_by_tag | 
	def get_servers_by_tag(tags)
      # Take tags and collapse it,
      # Default case, tag is AND
      if @match_all
        t = tags.join("&tag=")
        filter = "tag=#{t}"
        servers = Connection.instances(filter)
      else
        t = tags.join(",")
        filter = "tag=#{t}"
        servers = Connection.instances(filter)
      end
      if servers.nil?
        if @ignore_errors
          Log.warn "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}"
        else
          raise "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}\n"
        end
      elsif servers.empty?
        if @ignore_errors
          Log.warn "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}"
        else
          raise "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}\n"
        end
      end
      servers = verify_tagged_instances(servers,tags)
      return(servers)
    end | 
	ruby | 
	def get_servers_by_tag(tags)
      # Take tags and collapse it,
      # Default case, tag is AND
      if @match_all
        t = tags.join("&tag=")
        filter = "tag=#{t}"
        servers = Connection.instances(filter)
      else
        t = tags.join(",")
        filter = "tag=#{t}"
        servers = Connection.instances(filter)
      end
      if servers.nil?
        if @ignore_errors
          Log.warn "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}"
        else
          raise "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}\n"
        end
      elsif servers.empty?
        if @ignore_errors
          Log.warn "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}"
        else
          raise "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}\n"
        end
      end
      servers = verify_tagged_instances(servers,tags)
      return(servers)
    end | 
	[
  "def",
  "get_servers_by_tag",
  "(",
  "tags",
  ")",
  "# Take tags and collapse it,",
  "# Default case, tag is AND",
  "if",
  "@match_all",
  "t",
  "=",
  "tags",
  ".",
  "join",
  "(",
  "\"&tag=\"",
  ")",
  "filter",
  "=",
  "\"tag=#{t}\"",
  "servers",
  "=",
  "Connection",
  ".",
  "instances",
  "(",
  "filter",
  ")",
  "else",
  "t",
  "=",
  "tags",
  ".",
  "join",
  "(",
  "\",\"",
  ")",
  "filter",
  "=",
  "\"tag=#{t}\"",
  "servers",
  "=",
  "Connection",
  ".",
  "instances",
  "(",
  "filter",
  ")",
  "end",
  "if",
  "servers",
  ".",
  "nil?",
  "if",
  "@ignore_errors",
  "Log",
  ".",
  "warn",
  "\"[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(\" \")}\"",
  "else",
  "raise",
  "\"[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(\" \")}\\n\"",
  "end",
  "elsif",
  "servers",
  ".",
  "empty?",
  "if",
  "@ignore_errors",
  "Log",
  ".",
  "warn",
  "\"[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(\" \")}\"",
  "else",
  "raise",
  "\"[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(\" \")}\\n\"",
  "end",
  "end",
  "servers",
  "=",
  "verify_tagged_instances",
  "(",
  "servers",
  ",",
  "tags",
  ")",
  "return",
  "(",
  "servers",
  ")",
  "end"
] | 
	Api1.6 equivalent | 
	[
  "Api1",
  ".",
  "6",
  "equivalent"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L507-L537 | 
| 133 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.verify_tagged_instances | 
	def verify_tagged_instances(servers,tags)
      array_list = servers
      # servers is an array of hashes
      # verify that each object contains the tags.
      if @match_all
        # has to contain BOTH
        matching_servers = array_list.select { |instance| (tags - instance['tags']).empty? }
      else
        # has to contain ANY
        matching_servers = array_list.select { |instance| tags.any? {|tag| instance['tags'].include?(tag)  }}
      end
      # Shall there be a discrepancy, we need to raise an error and end the run.
      if matching_servers.size != servers.size
        if @ignore_errors
          Log.error "[#{Chimp.get_job_uuid}] #{servers.size - matching_servers.size} instances didnt match tag selection."
          Log.error "[#{Chimp.get_job_uuid}] #{tags.join(" ")}"
          Chimp.set_failure(true)
          Log.error "[#{Chimp.get_job_uuid}] Set failure to true because of discrepancy"
          servers = []
        else
          raise "[#{Chimp.get_job_uuid}] #{servers.size - matching_servers.size} instances didnt match tag selection"
        end
      end
      return servers
    end | 
	ruby | 
	def verify_tagged_instances(servers,tags)
      array_list = servers
      # servers is an array of hashes
      # verify that each object contains the tags.
      if @match_all
        # has to contain BOTH
        matching_servers = array_list.select { |instance| (tags - instance['tags']).empty? }
      else
        # has to contain ANY
        matching_servers = array_list.select { |instance| tags.any? {|tag| instance['tags'].include?(tag)  }}
      end
      # Shall there be a discrepancy, we need to raise an error and end the run.
      if matching_servers.size != servers.size
        if @ignore_errors
          Log.error "[#{Chimp.get_job_uuid}] #{servers.size - matching_servers.size} instances didnt match tag selection."
          Log.error "[#{Chimp.get_job_uuid}] #{tags.join(" ")}"
          Chimp.set_failure(true)
          Log.error "[#{Chimp.get_job_uuid}] Set failure to true because of discrepancy"
          servers = []
        else
          raise "[#{Chimp.get_job_uuid}] #{servers.size - matching_servers.size} instances didnt match tag selection"
        end
      end
      return servers
    end | 
	[
  "def",
  "verify_tagged_instances",
  "(",
  "servers",
  ",",
  "tags",
  ")",
  "array_list",
  "=",
  "servers",
  "# servers is an array of hashes",
  "# verify that each object contains the tags.",
  "if",
  "@match_all",
  "# has to contain BOTH",
  "matching_servers",
  "=",
  "array_list",
  ".",
  "select",
  "{",
  "|",
  "instance",
  "|",
  "(",
  "tags",
  "-",
  "instance",
  "[",
  "'tags'",
  "]",
  ")",
  ".",
  "empty?",
  "}",
  "else",
  "# has to contain ANY",
  "matching_servers",
  "=",
  "array_list",
  ".",
  "select",
  "{",
  "|",
  "instance",
  "|",
  "tags",
  ".",
  "any?",
  "{",
  "|",
  "tag",
  "|",
  "instance",
  "[",
  "'tags'",
  "]",
  ".",
  "include?",
  "(",
  "tag",
  ")",
  "}",
  "}",
  "end",
  "# Shall there be a discrepancy, we need to raise an error and end the run.",
  "if",
  "matching_servers",
  ".",
  "size",
  "!=",
  "servers",
  ".",
  "size",
  "if",
  "@ignore_errors",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] #{servers.size - matching_servers.size} instances didnt match tag selection.\"",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] #{tags.join(\" \")}\"",
  "Chimp",
  ".",
  "set_failure",
  "(",
  "true",
  ")",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] Set failure to true because of discrepancy\"",
  "servers",
  "=",
  "[",
  "]",
  "else",
  "raise",
  "\"[#{Chimp.get_job_uuid}] #{servers.size - matching_servers.size} instances didnt match tag selection\"",
  "end",
  "end",
  "return",
  "servers",
  "end"
] | 
	Verify that all returned instances from the API match our tag request | 
	[
  "Verify",
  "that",
  "all",
  "returned",
  "instances",
  "from",
  "the",
  "API",
  "match",
  "our",
  "tag",
  "request"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L542-L570 | 
| 134 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.get_hrefs_for_arrays | 
	def get_hrefs_for_arrays(names)
      result = []
      arrays_hrefs = []
      if names.size > 0
        names.each do |array_name|
          # Find if arrays exist, if not raise warning.
          # One API call per array
          begin
            Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index(:filter => [#{array_name}])"
            tries ||= 3
            result = Connection.client.server_arrays.index(:filter => ["name==#{array_name}"])
          rescue
            Log.error "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index failed (retrying)."
            sleep 30
            retry unless (tries -= 1).zero?
            Log.error "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index failed (giving up)."
          end
          # Result is an array with all the server arrays
          if result.size != 0
            if @exact
              #remove results that do not exactly match
              result.each{ |r|
                if array_names.include?(r.raw['name'])
                  arrays_hrefs += [ r.href ]
                end
              }
            else
              arrays_hrefs += result.collect(&:href)
            end
          else
            if @ignore_errors
              Log.debug "[#{Chimp.get_job_uuid}] Could not find array \"#{array_name}\""
            else
              Log.error "[#{Chimp.get_job_uuid}] Could not find array \"#{array_name}\""
            end
          end
        end
        if ( arrays_hrefs.empty? )
          Log.debug "[#{Chimp.get_job_uuid}] Did not find any arrays that matched!" unless names.size == 1
        end
        return(arrays_hrefs)
      end
    end | 
	ruby | 
	def get_hrefs_for_arrays(names)
      result = []
      arrays_hrefs = []
      if names.size > 0
        names.each do |array_name|
          # Find if arrays exist, if not raise warning.
          # One API call per array
          begin
            Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index(:filter => [#{array_name}])"
            tries ||= 3
            result = Connection.client.server_arrays.index(:filter => ["name==#{array_name}"])
          rescue
            Log.error "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index failed (retrying)."
            sleep 30
            retry unless (tries -= 1).zero?
            Log.error "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index failed (giving up)."
          end
          # Result is an array with all the server arrays
          if result.size != 0
            if @exact
              #remove results that do not exactly match
              result.each{ |r|
                if array_names.include?(r.raw['name'])
                  arrays_hrefs += [ r.href ]
                end
              }
            else
              arrays_hrefs += result.collect(&:href)
            end
          else
            if @ignore_errors
              Log.debug "[#{Chimp.get_job_uuid}] Could not find array \"#{array_name}\""
            else
              Log.error "[#{Chimp.get_job_uuid}] Could not find array \"#{array_name}\""
            end
          end
        end
        if ( arrays_hrefs.empty? )
          Log.debug "[#{Chimp.get_job_uuid}] Did not find any arrays that matched!" unless names.size == 1
        end
        return(arrays_hrefs)
      end
    end | 
	[
  "def",
  "get_hrefs_for_arrays",
  "(",
  "names",
  ")",
  "result",
  "=",
  "[",
  "]",
  "arrays_hrefs",
  "=",
  "[",
  "]",
  "if",
  "names",
  ".",
  "size",
  ">",
  "0",
  "names",
  ".",
  "each",
  "do",
  "|",
  "array_name",
  "|",
  "# Find if arrays exist, if not raise warning.",
  "# One API call per array",
  "begin",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index(:filter => [#{array_name}])\"",
  "tries",
  "||=",
  "3",
  "result",
  "=",
  "Connection",
  ".",
  "client",
  ".",
  "server_arrays",
  ".",
  "index",
  "(",
  ":filter",
  "=>",
  "[",
  "\"name==#{array_name}\"",
  "]",
  ")",
  "rescue",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index failed (retrying).\"",
  "sleep",
  "30",
  "retry",
  "unless",
  "(",
  "tries",
  "-=",
  "1",
  ")",
  ".",
  "zero?",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index failed (giving up).\"",
  "end",
  "# Result is an array with all the server arrays",
  "if",
  "result",
  ".",
  "size",
  "!=",
  "0",
  "if",
  "@exact",
  "#remove results that do not exactly match",
  "result",
  ".",
  "each",
  "{",
  "|",
  "r",
  "|",
  "if",
  "array_names",
  ".",
  "include?",
  "(",
  "r",
  ".",
  "raw",
  "[",
  "'name'",
  "]",
  ")",
  "arrays_hrefs",
  "+=",
  "[",
  "r",
  ".",
  "href",
  "]",
  "end",
  "}",
  "else",
  "arrays_hrefs",
  "+=",
  "result",
  ".",
  "collect",
  "(",
  ":href",
  ")",
  "end",
  "else",
  "if",
  "@ignore_errors",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Could not find array \\\"#{array_name}\\\"\"",
  "else",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] Could not find array \\\"#{array_name}\\\"\"",
  "end",
  "end",
  "end",
  "if",
  "(",
  "arrays_hrefs",
  ".",
  "empty?",
  ")",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Did not find any arrays that matched!\"",
  "unless",
  "names",
  ".",
  "size",
  "==",
  "1",
  "end",
  "return",
  "(",
  "arrays_hrefs",
  ")",
  "end",
  "end"
] | 
	Given some array names, return the arrays hrefs
 Api1.5 | 
	[
  "Given",
  "some",
  "array",
  "names",
  "return",
  "the",
  "arrays",
  "hrefs",
  "Api1",
  ".",
  "5"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L592-L636 | 
| 135 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.detect_server_template | 
	def detect_server_template(servers)
      Log.debug "[#{Chimp.get_job_uuid}] Looking for server template"
      st = []
      if servers[0].nil?
        return (st)
      end
      st += servers.collect { |s|
        [s['href'],s['server_template']]
      }.uniq {|a| a[0]}
      #
      # We return an array of server_template resources
      # of the type [ st_href, st object ]
      #
      Log.debug "[#{Chimp.get_job_uuid}] Found server templates"
      return(st)
    end | 
	ruby | 
	def detect_server_template(servers)
      Log.debug "[#{Chimp.get_job_uuid}] Looking for server template"
      st = []
      if servers[0].nil?
        return (st)
      end
      st += servers.collect { |s|
        [s['href'],s['server_template']]
      }.uniq {|a| a[0]}
      #
      # We return an array of server_template resources
      # of the type [ st_href, st object ]
      #
      Log.debug "[#{Chimp.get_job_uuid}] Found server templates"
      return(st)
    end | 
	[
  "def",
  "detect_server_template",
  "(",
  "servers",
  ")",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Looking for server template\"",
  "st",
  "=",
  "[",
  "]",
  "if",
  "servers",
  "[",
  "0",
  "]",
  ".",
  "nil?",
  "return",
  "(",
  "st",
  ")",
  "end",
  "st",
  "+=",
  "servers",
  ".",
  "collect",
  "{",
  "|",
  "s",
  "|",
  "[",
  "s",
  "[",
  "'href'",
  "]",
  ",",
  "s",
  "[",
  "'server_template'",
  "]",
  "]",
  "}",
  ".",
  "uniq",
  "{",
  "|",
  "a",
  "|",
  "a",
  "[",
  "0",
  "]",
  "}",
  "#",
  "# We return an array of server_template resources",
  "# of the type [ st_href, st object ]",
  "#",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Found server templates\"",
  "return",
  "(",
  "st",
  ")",
  "end"
] | 
	Given a list of servers | 
	[
  "Given",
  "a",
  "list",
  "of",
  "servers"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L641-L660 | 
| 136 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.detect_right_script | 
	def detect_right_script(st, script)
      Log.debug  "[#{Chimp.get_job_uuid}] Looking for rightscript"
      executable = nil
      # In the event that chimpd find @op_scripts as nil, set it as an array.
      if @op_scripts.nil?
        @op_scripts = []
      end
      if st.nil?
        return executable
      end
      # Take the sts and extract all operational scripts
      @op_scripts = extract_operational_scripts(st)
      # if script is empty, we will list all common scripts
      # if not empty, we will list the first matching one
      if @script == "" and @script != nil
        # list all operational scripts
        reduce_to_common_scripts(st.size)
        script_id = list_and_select_op_script
        # Provide the name + href
        s = Executable.new
        s.params['right_script']['href'] = @op_scripts[script_id][1].right_script.href
        s.params['right_script']['name'] = @op_scripts[script_id][0]
        @script_to_run = s
      else
        # Try to find the rightscript in our list of common operational scripts
        @op_scripts.each  do |rb|
          script_name = rb[0]
          if script_name.downcase.include?(script.downcase)
            # We only need the name and the href
            s = Executable.new
            s.params['right_script']['href'] = rb[1].right_script.href
            s.params['right_script']['name'] = script_name
            @script_to_run = s
            Log.debug "[#{Chimp.get_job_uuid}] Found rightscript"
            return @script_to_run
          end
        end
        #
        # If we reach here it means we didnt find the script in the operationals
        #
        if @script_to_run == nil
          # Search outside common op scripts
          search_for_script_in_sts(script, st)
          if @script_to_run.nil?
            if @interactive
              puts "ERROR: Sorry, didnt find that ( "+script+" ), provide an URI instead"
              puts "I searched in:"
              st.each { |s|
                puts "   *  "+s[1]['name']+"  [Rev"+s[1]['version'].to_s+"]"
              }
              if not @ignore_errors
                exit 1
              end
            else
              Log.error "["+self.job_uuid+"] Sorry, didnt find the script: ( "+script+" )!"
              return nil
            end
          else
            if self.job_uuid.nil?
              self.job_uuid = ""
            end
            Log.warn "["+self.job_uuid+"] \"#{@script_to_run.params['right_script']['name']}\" is not a common operational script!"
            return @script_to_run
          end
        end
      end
    end | 
	ruby | 
	def detect_right_script(st, script)
      Log.debug  "[#{Chimp.get_job_uuid}] Looking for rightscript"
      executable = nil
      # In the event that chimpd find @op_scripts as nil, set it as an array.
      if @op_scripts.nil?
        @op_scripts = []
      end
      if st.nil?
        return executable
      end
      # Take the sts and extract all operational scripts
      @op_scripts = extract_operational_scripts(st)
      # if script is empty, we will list all common scripts
      # if not empty, we will list the first matching one
      if @script == "" and @script != nil
        # list all operational scripts
        reduce_to_common_scripts(st.size)
        script_id = list_and_select_op_script
        # Provide the name + href
        s = Executable.new
        s.params['right_script']['href'] = @op_scripts[script_id][1].right_script.href
        s.params['right_script']['name'] = @op_scripts[script_id][0]
        @script_to_run = s
      else
        # Try to find the rightscript in our list of common operational scripts
        @op_scripts.each  do |rb|
          script_name = rb[0]
          if script_name.downcase.include?(script.downcase)
            # We only need the name and the href
            s = Executable.new
            s.params['right_script']['href'] = rb[1].right_script.href
            s.params['right_script']['name'] = script_name
            @script_to_run = s
            Log.debug "[#{Chimp.get_job_uuid}] Found rightscript"
            return @script_to_run
          end
        end
        #
        # If we reach here it means we didnt find the script in the operationals
        #
        if @script_to_run == nil
          # Search outside common op scripts
          search_for_script_in_sts(script, st)
          if @script_to_run.nil?
            if @interactive
              puts "ERROR: Sorry, didnt find that ( "+script+" ), provide an URI instead"
              puts "I searched in:"
              st.each { |s|
                puts "   *  "+s[1]['name']+"  [Rev"+s[1]['version'].to_s+"]"
              }
              if not @ignore_errors
                exit 1
              end
            else
              Log.error "["+self.job_uuid+"] Sorry, didnt find the script: ( "+script+" )!"
              return nil
            end
          else
            if self.job_uuid.nil?
              self.job_uuid = ""
            end
            Log.warn "["+self.job_uuid+"] \"#{@script_to_run.params['right_script']['name']}\" is not a common operational script!"
            return @script_to_run
          end
        end
      end
    end | 
	[
  "def",
  "detect_right_script",
  "(",
  "st",
  ",",
  "script",
  ")",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Looking for rightscript\"",
  "executable",
  "=",
  "nil",
  "# In the event that chimpd find @op_scripts as nil, set it as an array.",
  "if",
  "@op_scripts",
  ".",
  "nil?",
  "@op_scripts",
  "=",
  "[",
  "]",
  "end",
  "if",
  "st",
  ".",
  "nil?",
  "return",
  "executable",
  "end",
  "# Take the sts and extract all operational scripts",
  "@op_scripts",
  "=",
  "extract_operational_scripts",
  "(",
  "st",
  ")",
  "# if script is empty, we will list all common scripts",
  "# if not empty, we will list the first matching one",
  "if",
  "@script",
  "==",
  "\"\"",
  "and",
  "@script",
  "!=",
  "nil",
  "# list all operational scripts",
  "reduce_to_common_scripts",
  "(",
  "st",
  ".",
  "size",
  ")",
  "script_id",
  "=",
  "list_and_select_op_script",
  "# Provide the name + href",
  "s",
  "=",
  "Executable",
  ".",
  "new",
  "s",
  ".",
  "params",
  "[",
  "'right_script'",
  "]",
  "[",
  "'href'",
  "]",
  "=",
  "@op_scripts",
  "[",
  "script_id",
  "]",
  "[",
  "1",
  "]",
  ".",
  "right_script",
  ".",
  "href",
  "s",
  ".",
  "params",
  "[",
  "'right_script'",
  "]",
  "[",
  "'name'",
  "]",
  "=",
  "@op_scripts",
  "[",
  "script_id",
  "]",
  "[",
  "0",
  "]",
  "@script_to_run",
  "=",
  "s",
  "else",
  "# Try to find the rightscript in our list of common operational scripts",
  "@op_scripts",
  ".",
  "each",
  "do",
  "|",
  "rb",
  "|",
  "script_name",
  "=",
  "rb",
  "[",
  "0",
  "]",
  "if",
  "script_name",
  ".",
  "downcase",
  ".",
  "include?",
  "(",
  "script",
  ".",
  "downcase",
  ")",
  "# We only need the name and the href",
  "s",
  "=",
  "Executable",
  ".",
  "new",
  "s",
  ".",
  "params",
  "[",
  "'right_script'",
  "]",
  "[",
  "'href'",
  "]",
  "=",
  "rb",
  "[",
  "1",
  "]",
  ".",
  "right_script",
  ".",
  "href",
  "s",
  ".",
  "params",
  "[",
  "'right_script'",
  "]",
  "[",
  "'name'",
  "]",
  "=",
  "script_name",
  "@script_to_run",
  "=",
  "s",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Found rightscript\"",
  "return",
  "@script_to_run",
  "end",
  "end",
  "#",
  "# If we reach here it means we didnt find the script in the operationals",
  "#",
  "if",
  "@script_to_run",
  "==",
  "nil",
  "# Search outside common op scripts",
  "search_for_script_in_sts",
  "(",
  "script",
  ",",
  "st",
  ")",
  "if",
  "@script_to_run",
  ".",
  "nil?",
  "if",
  "@interactive",
  "puts",
  "\"ERROR: Sorry, didnt find that ( \"",
  "+",
  "script",
  "+",
  "\" ), provide an URI instead\"",
  "puts",
  "\"I searched in:\"",
  "st",
  ".",
  "each",
  "{",
  "|",
  "s",
  "|",
  "puts",
  "\"   *  \"",
  "+",
  "s",
  "[",
  "1",
  "]",
  "[",
  "'name'",
  "]",
  "+",
  "\"  [Rev\"",
  "+",
  "s",
  "[",
  "1",
  "]",
  "[",
  "'version'",
  "]",
  ".",
  "to_s",
  "+",
  "\"]\"",
  "}",
  "if",
  "not",
  "@ignore_errors",
  "exit",
  "1",
  "end",
  "else",
  "Log",
  ".",
  "error",
  "\"[\"",
  "+",
  "self",
  ".",
  "job_uuid",
  "+",
  "\"] Sorry, didnt find the script: ( \"",
  "+",
  "script",
  "+",
  "\" )!\"",
  "return",
  "nil",
  "end",
  "else",
  "if",
  "self",
  ".",
  "job_uuid",
  ".",
  "nil?",
  "self",
  ".",
  "job_uuid",
  "=",
  "\"\"",
  "end",
  "Log",
  ".",
  "warn",
  "\"[\"",
  "+",
  "self",
  ".",
  "job_uuid",
  "+",
  "\"] \\\"#{@script_to_run.params['right_script']['name']}\\\" is not a common operational script!\"",
  "return",
  "@script_to_run",
  "end",
  "end",
  "end",
  "end"
] | 
	This function returns @script_to_run which is extracted from matching
 the desired script against all server templates or the script URL | 
	[
  "This",
  "function",
  "returns"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L666-L737 | 
| 137 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.reduce_to_common_scripts | 
	def reduce_to_common_scripts(number_of_st)
        counts = Hash.new 0
        @op_scripts.each { |s| counts[s[0]] +=1 }
        b = @op_scripts.inject({}) do |res, row|
          res[row[0]] ||= []
          res[row[0]] << row[1]
          res
        end
        b.inject([]) do |res, (key, values)|
          res << [key, values.first] if values.size >= number_of_st
          @op_scripts = res
        end
    end | 
	ruby | 
	def reduce_to_common_scripts(number_of_st)
        counts = Hash.new 0
        @op_scripts.each { |s| counts[s[0]] +=1 }
        b = @op_scripts.inject({}) do |res, row|
          res[row[0]] ||= []
          res[row[0]] << row[1]
          res
        end
        b.inject([]) do |res, (key, values)|
          res << [key, values.first] if values.size >= number_of_st
          @op_scripts = res
        end
    end | 
	[
  "def",
  "reduce_to_common_scripts",
  "(",
  "number_of_st",
  ")",
  "counts",
  "=",
  "Hash",
  ".",
  "new",
  "0",
  "@op_scripts",
  ".",
  "each",
  "{",
  "|",
  "s",
  "|",
  "counts",
  "[",
  "s",
  "[",
  "0",
  "]",
  "]",
  "+=",
  "1",
  "}",
  "b",
  "=",
  "@op_scripts",
  ".",
  "inject",
  "(",
  "{",
  "}",
  ")",
  "do",
  "|",
  "res",
  ",",
  "row",
  "|",
  "res",
  "[",
  "row",
  "[",
  "0",
  "]",
  "]",
  "||=",
  "[",
  "]",
  "res",
  "[",
  "row",
  "[",
  "0",
  "]",
  "]",
  "<<",
  "row",
  "[",
  "1",
  "]",
  "res",
  "end",
  "b",
  ".",
  "inject",
  "(",
  "[",
  "]",
  ")",
  "do",
  "|",
  "res",
  ",",
  "(",
  "key",
  ",",
  "values",
  ")",
  "|",
  "res",
  "<<",
  "[",
  "key",
  ",",
  "values",
  ".",
  "first",
  "]",
  "if",
  "values",
  ".",
  "size",
  ">=",
  "number_of_st",
  "@op_scripts",
  "=",
  "res",
  "end",
  "end"
] | 
	Takes the number of st's to search in,
 and reduces @op_scripts to only those who are
 repeated enough times. | 
	[
  "Takes",
  "the",
  "number",
  "of",
  "st",
  "s",
  "to",
  "search",
  "in",
  "and",
  "reduces"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L798-L812 | 
| 138 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.extract_operational_scripts | 
	def extract_operational_scripts(st)
      op_scripts = []
      size = st.size
      st.each do |s|
        # Example of s structure
        # ["/api/server_templates/351930003",
        #   {"id"=>351930003,
        #    "name"=>"RightScale Right_Site - 2015q1",
        #    "kind"=>"cm#server_template",
        #    "version"=>5,
        #    "href"=>"/api/server_templates/351930003"} ]
        Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (ST)"
        begin
          tries ||= 3
          temp = Connection.client.resource(s[1]['href'])
          Log.debug "[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) complete"
          temp.runnable_bindings.index.each do |x|
            # only add the operational ones
            if x.sequence == 'operational'
              name = x.raw['right_script']['name']
              op_scripts.push([name, x])
            end
          end
        rescue  Exception => e
          Log.error "[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) failed (retrying)"
          Log.error "[#{Chimp.get_job_uuid}] #{e.message}"
          sleep 30
          retry unless (tries -= 1).zero?
          Log.error "[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) failed (giving up)"
        end
      end
      #We now only have operational runnable_bindings under the script_objects array
      if op_scripts.length < 1
        raise "ERROR: No operational scripts found on the server(s). "
        st.each {|s|
          puts "         (Search performed on server template '#{s[1]['name']}')"
        }
      end
      return op_scripts
    end | 
	ruby | 
	def extract_operational_scripts(st)
      op_scripts = []
      size = st.size
      st.each do |s|
        # Example of s structure
        # ["/api/server_templates/351930003",
        #   {"id"=>351930003,
        #    "name"=>"RightScale Right_Site - 2015q1",
        #    "kind"=>"cm#server_template",
        #    "version"=>5,
        #    "href"=>"/api/server_templates/351930003"} ]
        Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (ST)"
        begin
          tries ||= 3
          temp = Connection.client.resource(s[1]['href'])
          Log.debug "[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) complete"
          temp.runnable_bindings.index.each do |x|
            # only add the operational ones
            if x.sequence == 'operational'
              name = x.raw['right_script']['name']
              op_scripts.push([name, x])
            end
          end
        rescue  Exception => e
          Log.error "[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) failed (retrying)"
          Log.error "[#{Chimp.get_job_uuid}] #{e.message}"
          sleep 30
          retry unless (tries -= 1).zero?
          Log.error "[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) failed (giving up)"
        end
      end
      #We now only have operational runnable_bindings under the script_objects array
      if op_scripts.length < 1
        raise "ERROR: No operational scripts found on the server(s). "
        st.each {|s|
          puts "         (Search performed on server template '#{s[1]['name']}')"
        }
      end
      return op_scripts
    end | 
	[
  "def",
  "extract_operational_scripts",
  "(",
  "st",
  ")",
  "op_scripts",
  "=",
  "[",
  "]",
  "size",
  "=",
  "st",
  ".",
  "size",
  "st",
  ".",
  "each",
  "do",
  "|",
  "s",
  "|",
  "# Example of s structure",
  "# [\"/api/server_templates/351930003\",",
  "#   {\"id\"=>351930003,",
  "#    \"name\"=>\"RightScale Right_Site - 2015q1\",",
  "#    \"kind\"=>\"cm#server_template\",",
  "#    \"version\"=>5,",
  "#    \"href\"=>\"/api/server_templates/351930003\"} ]",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (ST)\"",
  "begin",
  "tries",
  "||=",
  "3",
  "temp",
  "=",
  "Connection",
  ".",
  "client",
  ".",
  "resource",
  "(",
  "s",
  "[",
  "1",
  "]",
  "[",
  "'href'",
  "]",
  ")",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) complete\"",
  "temp",
  ".",
  "runnable_bindings",
  ".",
  "index",
  ".",
  "each",
  "do",
  "|",
  "x",
  "|",
  "# only add the operational ones",
  "if",
  "x",
  ".",
  "sequence",
  "==",
  "'operational'",
  "name",
  "=",
  "x",
  ".",
  "raw",
  "[",
  "'right_script'",
  "]",
  "[",
  "'name'",
  "]",
  "op_scripts",
  ".",
  "push",
  "(",
  "[",
  "name",
  ",",
  "x",
  "]",
  ")",
  "end",
  "end",
  "rescue",
  "Exception",
  "=>",
  "e",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) failed (retrying)\"",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] #{e.message}\"",
  "sleep",
  "30",
  "retry",
  "unless",
  "(",
  "tries",
  "-=",
  "1",
  ")",
  ".",
  "zero?",
  "Log",
  ".",
  "error",
  "\"[#{Chimp.get_job_uuid}] API 1.5 call client.resource (ST) failed (giving up)\"",
  "end",
  "end",
  "#We now only have operational runnable_bindings under the script_objects array",
  "if",
  "op_scripts",
  ".",
  "length",
  "<",
  "1",
  "raise",
  "\"ERROR: No operational scripts found on the server(s). \"",
  "st",
  ".",
  "each",
  "{",
  "|",
  "s",
  "|",
  "puts",
  "\"         (Search performed on server template '#{s[1]['name']}')\"",
  "}",
  "end",
  "return",
  "op_scripts",
  "end"
] | 
	Returns all matching operational scripts in the st list passed | 
	[
  "Returns",
  "all",
  "matching",
  "operational",
  "scripts",
  "in",
  "the",
  "st",
  "list",
  "passed"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L817-L857 | 
| 139 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.queue_runner | 
	def queue_runner(concurrency, delay, retry_count, progress)
      queue = ChimpQueue.instance
      queue.max_threads = concurrency
      queue.delay = delay
      queue.retry_count = retry_count
      total_queue_size = queue.size
      puts "Executing..." unless progress or not quiet
      pbar = ProgressBar.new("Executing", 100) if progress
      queue.start
      queue.wait_until_done(@group) do
        pbar.set(((total_queue_size.to_f - queue.size.to_f)/total_queue_size.to_f*100).to_i) if progress
      end
      pbar.finish if progress
    end | 
	ruby | 
	def queue_runner(concurrency, delay, retry_count, progress)
      queue = ChimpQueue.instance
      queue.max_threads = concurrency
      queue.delay = delay
      queue.retry_count = retry_count
      total_queue_size = queue.size
      puts "Executing..." unless progress or not quiet
      pbar = ProgressBar.new("Executing", 100) if progress
      queue.start
      queue.wait_until_done(@group) do
        pbar.set(((total_queue_size.to_f - queue.size.to_f)/total_queue_size.to_f*100).to_i) if progress
      end
      pbar.finish if progress
    end | 
	[
  "def",
  "queue_runner",
  "(",
  "concurrency",
  ",",
  "delay",
  ",",
  "retry_count",
  ",",
  "progress",
  ")",
  "queue",
  "=",
  "ChimpQueue",
  ".",
  "instance",
  "queue",
  ".",
  "max_threads",
  "=",
  "concurrency",
  "queue",
  ".",
  "delay",
  "=",
  "delay",
  "queue",
  ".",
  "retry_count",
  "=",
  "retry_count",
  "total_queue_size",
  "=",
  "queue",
  ".",
  "size",
  "puts",
  "\"Executing...\"",
  "unless",
  "progress",
  "or",
  "not",
  "quiet",
  "pbar",
  "=",
  "ProgressBar",
  ".",
  "new",
  "(",
  "\"Executing\"",
  ",",
  "100",
  ")",
  "if",
  "progress",
  "queue",
  ".",
  "start",
  "queue",
  ".",
  "wait_until_done",
  "(",
  "@group",
  ")",
  "do",
  "pbar",
  ".",
  "set",
  "(",
  "(",
  "(",
  "total_queue_size",
  ".",
  "to_f",
  "-",
  "queue",
  ".",
  "size",
  ".",
  "to_f",
  ")",
  "/",
  "total_queue_size",
  ".",
  "to_f",
  "100",
  ")",
  ".",
  "to_i",
  ")",
  "if",
  "progress",
  "end",
  "pbar",
  ".",
  "finish",
  "if",
  "progress",
  "end"
] | 
	Execute the user's command and provide for retrys etc. | 
	[
  "Execute",
  "the",
  "user",
  "s",
  "command",
  "and",
  "provide",
  "for",
  "retrys",
  "etc",
  "."
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L987-L1003 | 
| 140 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.verify_results | 
	def verify_results(group = :default)
      failed_workers, results_display = get_results(group)
      #
      # If no workers failed, then we're done.
      #
      if failed_workers.empty?
        @paused = false
        return "continue"
      end
      #
      # Some workers failed; offer the user a chance to retry them
      #
      verify("The following objects failed:", results_display, false) unless @paused
      if !@prompt || @paused
        @paused = true
        sleep 15
        return "pause"
      end
      while true
        puts "(R)etry failed jobs"
        puts "(A)bort chimp run"
        puts "(I)gnore errors and continue"
        command = gets()
        if command.nil?
          #
          # if command is nil, stdin is closed or its source ended
          #  probably because we are in an automated environment,
          #  then we pause like in '--no-prompt' scenario
          #
          puts 'Warning! stdin empty, using pause behaviour, use --no-prompt to avoid this message'
          @paused = true
          return 'pause'
        end
        if command =~ /^a/i
          puts "Aborting!"
          exit 1
        elsif command =~ /^i/i
          puts "Ignoring errors and continuing"
          exit 0
        elsif command =~ /^r/i
          puts "Retrying..."
          ChimpQueue.instance.group[group].requeue_failed_jobs!
          return 'retry'
        end
      end
    end | 
	ruby | 
	def verify_results(group = :default)
      failed_workers, results_display = get_results(group)
      #
      # If no workers failed, then we're done.
      #
      if failed_workers.empty?
        @paused = false
        return "continue"
      end
      #
      # Some workers failed; offer the user a chance to retry them
      #
      verify("The following objects failed:", results_display, false) unless @paused
      if !@prompt || @paused
        @paused = true
        sleep 15
        return "pause"
      end
      while true
        puts "(R)etry failed jobs"
        puts "(A)bort chimp run"
        puts "(I)gnore errors and continue"
        command = gets()
        if command.nil?
          #
          # if command is nil, stdin is closed or its source ended
          #  probably because we are in an automated environment,
          #  then we pause like in '--no-prompt' scenario
          #
          puts 'Warning! stdin empty, using pause behaviour, use --no-prompt to avoid this message'
          @paused = true
          return 'pause'
        end
        if command =~ /^a/i
          puts "Aborting!"
          exit 1
        elsif command =~ /^i/i
          puts "Ignoring errors and continuing"
          exit 0
        elsif command =~ /^r/i
          puts "Retrying..."
          ChimpQueue.instance.group[group].requeue_failed_jobs!
          return 'retry'
        end
      end
    end | 
	[
  "def",
  "verify_results",
  "(",
  "group",
  "=",
  ":default",
  ")",
  "failed_workers",
  ",",
  "results_display",
  "=",
  "get_results",
  "(",
  "group",
  ")",
  "#",
  "# If no workers failed, then we're done.",
  "#",
  "if",
  "failed_workers",
  ".",
  "empty?",
  "@paused",
  "=",
  "false",
  "return",
  "\"continue\"",
  "end",
  "#",
  "# Some workers failed; offer the user a chance to retry them",
  "#",
  "verify",
  "(",
  "\"The following objects failed:\"",
  ",",
  "results_display",
  ",",
  "false",
  ")",
  "unless",
  "@paused",
  "if",
  "!",
  "@prompt",
  "||",
  "@paused",
  "@paused",
  "=",
  "true",
  "sleep",
  "15",
  "return",
  "\"pause\"",
  "end",
  "while",
  "true",
  "puts",
  "\"(R)etry failed jobs\"",
  "puts",
  "\"(A)bort chimp run\"",
  "puts",
  "\"(I)gnore errors and continue\"",
  "command",
  "=",
  "gets",
  "(",
  ")",
  "if",
  "command",
  ".",
  "nil?",
  "#",
  "# if command is nil, stdin is closed or its source ended",
  "#  probably because we are in an automated environment,",
  "#  then we pause like in '--no-prompt' scenario",
  "#",
  "puts",
  "'Warning! stdin empty, using pause behaviour, use --no-prompt to avoid this message'",
  "@paused",
  "=",
  "true",
  "return",
  "'pause'",
  "end",
  "if",
  "command",
  "=~",
  "/",
  "/i",
  "puts",
  "\"Aborting!\"",
  "exit",
  "1",
  "elsif",
  "command",
  "=~",
  "/",
  "/i",
  "puts",
  "\"Ignoring errors and continuing\"",
  "exit",
  "0",
  "elsif",
  "command",
  "=~",
  "/",
  "/i",
  "puts",
  "\"Retrying...\"",
  "ChimpQueue",
  ".",
  "instance",
  ".",
  "group",
  "[",
  "group",
  "]",
  ".",
  "requeue_failed_jobs!",
  "return",
  "'retry'",
  "end",
  "end",
  "end"
] | 
	Allow user to verify results and retry if necessary | 
	[
  "Allow",
  "user",
  "to",
  "verify",
  "results",
  "and",
  "retry",
  "if",
  "necessary"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L1016-L1065 | 
| 141 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.get_results | 
	def get_results(group_name)
      queue = ChimpQueue.instance
      Log.debug("getting results for group #{group_name}")
      results = queue.group[@group].results()
      failed_workers = []
      results_display = []
      results.each do |result|
        next if result == nil
        if result[:status] == :error
          name = result[:host] || "unknown"
          message = result[:error].to_s || "unknown"
          message.sub!("\n", "")
          failed_workers << result[:worker]
          results_display << "#{name[0..40]}  >> #{message}"
        end
      end
      return [failed_workers, results_display]
    end | 
	ruby | 
	def get_results(group_name)
      queue = ChimpQueue.instance
      Log.debug("getting results for group #{group_name}")
      results = queue.group[@group].results()
      failed_workers = []
      results_display = []
      results.each do |result|
        next if result == nil
        if result[:status] == :error
          name = result[:host] || "unknown"
          message = result[:error].to_s || "unknown"
          message.sub!("\n", "")
          failed_workers << result[:worker]
          results_display << "#{name[0..40]}  >> #{message}"
        end
      end
      return [failed_workers, results_display]
    end | 
	[
  "def",
  "get_results",
  "(",
  "group_name",
  ")",
  "queue",
  "=",
  "ChimpQueue",
  ".",
  "instance",
  "Log",
  ".",
  "debug",
  "(",
  "\"getting results for group #{group_name}\"",
  ")",
  "results",
  "=",
  "queue",
  ".",
  "group",
  "[",
  "@group",
  "]",
  ".",
  "results",
  "(",
  ")",
  "failed_workers",
  "=",
  "[",
  "]",
  "results_display",
  "=",
  "[",
  "]",
  "results",
  ".",
  "each",
  "do",
  "|",
  "result",
  "|",
  "next",
  "if",
  "result",
  "==",
  "nil",
  "if",
  "result",
  "[",
  ":status",
  "]",
  "==",
  ":error",
  "name",
  "=",
  "result",
  "[",
  ":host",
  "]",
  "||",
  "\"unknown\"",
  "message",
  "=",
  "result",
  "[",
  ":error",
  "]",
  ".",
  "to_s",
  "||",
  "\"unknown\"",
  "message",
  ".",
  "sub!",
  "(",
  "\"\\n\"",
  ",",
  "\"\"",
  ")",
  "failed_workers",
  "<<",
  "result",
  "[",
  ":worker",
  "]",
  "results_display",
  "<<",
  "\"#{name[0..40]}  >> #{message}\"",
  "end",
  "end",
  "return",
  "[",
  "failed_workers",
  ",",
  "results_display",
  "]",
  "end"
] | 
	Get the results from the QueueRunner and format them
 in a way that's easy to display to the user | 
	[
  "Get",
  "the",
  "results",
  "from",
  "the",
  "QueueRunner",
  "and",
  "format",
  "them",
  "in",
  "a",
  "way",
  "that",
  "s",
  "easy",
  "to",
  "display",
  "to",
  "the",
  "user"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L1071-L1091 | 
| 142 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.process | 
	def process
      Chimp.set_failure(false)
      Chimp.set_job_uuid(job_uuid)
      Log.debug "[#{job_uuid}] Processing task"
      # Add to our "processing" counter
      Log.debug "[#{job_uuid}] Trying to get array_info" unless Chimp.failure
      get_array_info unless Chimp.failure
      Log.debug "[#{job_uuid}] Trying to get server_info" unless Chimp.failure
      get_server_info unless Chimp.failure
      Log.debug "[#{job_uuid}] Trying to get template_info" unless Chimp.failure
      get_template_info unless Chimp.failure
      Log.debug "[#{job_uuid}] Trying to get executable_info" unless Chimp.failure
      get_executable_info unless Chimp.failure
      # All elements of task have been processed
      if Chimp.failure
        Log.error '##################################################'
        Log.error '[' + job_uuid + '] API CALL FAILED FOR:'
        Log.error '[' + job_uuid + "] chimp #{@cli_args} "
        Log.error '[' + job_uuid + '] Run manually!'
        Log.error '##################################################'
        return []
      elsif @servers.first.nil? || @executable.nil?
        Log.warn "[#{Chimp.get_job_uuid}] Nothing to do for \"chimp #{@cli_args}\"."
        # decrease our counter
        ChimpDaemon.instance.queue.processing[@group].delete(job_uuid.to_sym)
        ChimpDaemon.instance.proc_counter -= 1
        return []
      else
        Log.debug "[#{Chimp.get_job_uuid}] Generating job(s)..."
        # @servers might be > 1, but we might be using limit_start
        number_of_servers = if @limit_start.to_i > 0 || @limit_end.to_i > 0
                              @limit_end.to_i - @limit_start.to_i
                            else
                              # reminder, we already are accounting for at least 1
                              @servers.size - 1
                            end
        Log.debug 'Increasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s + ') + ' +
                  number_of_servers.to_s + ' for group ' + @group.to_s
        ChimpDaemon.instance.queue.processing[@group][job_uuid.to_sym] += number_of_servers
        ChimpDaemon.instance.proc_counter += number_of_servers
        Log.debug 'Processing counter now (' + ChimpDaemon.instance.proc_counter.to_s + ') for group ' +
                  @group.to_s
        return generate_jobs(@servers, @server_template, @executable)
      end
    end | 
	ruby | 
	def process
      Chimp.set_failure(false)
      Chimp.set_job_uuid(job_uuid)
      Log.debug "[#{job_uuid}] Processing task"
      # Add to our "processing" counter
      Log.debug "[#{job_uuid}] Trying to get array_info" unless Chimp.failure
      get_array_info unless Chimp.failure
      Log.debug "[#{job_uuid}] Trying to get server_info" unless Chimp.failure
      get_server_info unless Chimp.failure
      Log.debug "[#{job_uuid}] Trying to get template_info" unless Chimp.failure
      get_template_info unless Chimp.failure
      Log.debug "[#{job_uuid}] Trying to get executable_info" unless Chimp.failure
      get_executable_info unless Chimp.failure
      # All elements of task have been processed
      if Chimp.failure
        Log.error '##################################################'
        Log.error '[' + job_uuid + '] API CALL FAILED FOR:'
        Log.error '[' + job_uuid + "] chimp #{@cli_args} "
        Log.error '[' + job_uuid + '] Run manually!'
        Log.error '##################################################'
        return []
      elsif @servers.first.nil? || @executable.nil?
        Log.warn "[#{Chimp.get_job_uuid}] Nothing to do for \"chimp #{@cli_args}\"."
        # decrease our counter
        ChimpDaemon.instance.queue.processing[@group].delete(job_uuid.to_sym)
        ChimpDaemon.instance.proc_counter -= 1
        return []
      else
        Log.debug "[#{Chimp.get_job_uuid}] Generating job(s)..."
        # @servers might be > 1, but we might be using limit_start
        number_of_servers = if @limit_start.to_i > 0 || @limit_end.to_i > 0
                              @limit_end.to_i - @limit_start.to_i
                            else
                              # reminder, we already are accounting for at least 1
                              @servers.size - 1
                            end
        Log.debug 'Increasing processing counter (' + ChimpDaemon.instance.proc_counter.to_s + ') + ' +
                  number_of_servers.to_s + ' for group ' + @group.to_s
        ChimpDaemon.instance.queue.processing[@group][job_uuid.to_sym] += number_of_servers
        ChimpDaemon.instance.proc_counter += number_of_servers
        Log.debug 'Processing counter now (' + ChimpDaemon.instance.proc_counter.to_s + ') for group ' +
                  @group.to_s
        return generate_jobs(@servers, @server_template, @executable)
      end
    end | 
	[
  "def",
  "process",
  "Chimp",
  ".",
  "set_failure",
  "(",
  "false",
  ")",
  "Chimp",
  ".",
  "set_job_uuid",
  "(",
  "job_uuid",
  ")",
  "Log",
  ".",
  "debug",
  "\"[#{job_uuid}] Processing task\"",
  "# Add to our \"processing\" counter",
  "Log",
  ".",
  "debug",
  "\"[#{job_uuid}] Trying to get array_info\"",
  "unless",
  "Chimp",
  ".",
  "failure",
  "get_array_info",
  "unless",
  "Chimp",
  ".",
  "failure",
  "Log",
  ".",
  "debug",
  "\"[#{job_uuid}] Trying to get server_info\"",
  "unless",
  "Chimp",
  ".",
  "failure",
  "get_server_info",
  "unless",
  "Chimp",
  ".",
  "failure",
  "Log",
  ".",
  "debug",
  "\"[#{job_uuid}] Trying to get template_info\"",
  "unless",
  "Chimp",
  ".",
  "failure",
  "get_template_info",
  "unless",
  "Chimp",
  ".",
  "failure",
  "Log",
  ".",
  "debug",
  "\"[#{job_uuid}] Trying to get executable_info\"",
  "unless",
  "Chimp",
  ".",
  "failure",
  "get_executable_info",
  "unless",
  "Chimp",
  ".",
  "failure",
  "# All elements of task have been processed",
  "if",
  "Chimp",
  ".",
  "failure",
  "Log",
  ".",
  "error",
  "'##################################################'",
  "Log",
  ".",
  "error",
  "'['",
  "+",
  "job_uuid",
  "+",
  "'] API CALL FAILED FOR:'",
  "Log",
  ".",
  "error",
  "'['",
  "+",
  "job_uuid",
  "+",
  "\"] chimp #{@cli_args} \"",
  "Log",
  ".",
  "error",
  "'['",
  "+",
  "job_uuid",
  "+",
  "'] Run manually!'",
  "Log",
  ".",
  "error",
  "'##################################################'",
  "return",
  "[",
  "]",
  "elsif",
  "@servers",
  ".",
  "first",
  ".",
  "nil?",
  "||",
  "@executable",
  ".",
  "nil?",
  "Log",
  ".",
  "warn",
  "\"[#{Chimp.get_job_uuid}] Nothing to do for \\\"chimp #{@cli_args}\\\".\"",
  "# decrease our counter",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "@group",
  "]",
  ".",
  "delete",
  "(",
  "job_uuid",
  ".",
  "to_sym",
  ")",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  "-=",
  "1",
  "return",
  "[",
  "]",
  "else",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Generating job(s)...\"",
  "# @servers might be > 1, but we might be using limit_start",
  "number_of_servers",
  "=",
  "if",
  "@limit_start",
  ".",
  "to_i",
  ">",
  "0",
  "||",
  "@limit_end",
  ".",
  "to_i",
  ">",
  "0",
  "@limit_end",
  ".",
  "to_i",
  "-",
  "@limit_start",
  ".",
  "to_i",
  "else",
  "# reminder, we already are accounting for at least 1",
  "@servers",
  ".",
  "size",
  "-",
  "1",
  "end",
  "Log",
  ".",
  "debug",
  "'Increasing processing counter ('",
  "+",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  ".",
  "to_s",
  "+",
  "') + '",
  "+",
  "number_of_servers",
  ".",
  "to_s",
  "+",
  "' for group '",
  "+",
  "@group",
  ".",
  "to_s",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "queue",
  ".",
  "processing",
  "[",
  "@group",
  "]",
  "[",
  "job_uuid",
  ".",
  "to_sym",
  "]",
  "+=",
  "number_of_servers",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  "+=",
  "number_of_servers",
  "Log",
  ".",
  "debug",
  "'Processing counter now ('",
  "+",
  "ChimpDaemon",
  ".",
  "instance",
  ".",
  "proc_counter",
  ".",
  "to_s",
  "+",
  "') for group '",
  "+",
  "@group",
  ".",
  "to_s",
  "return",
  "generate_jobs",
  "(",
  "@servers",
  ",",
  "@server_template",
  ",",
  "@executable",
  ")",
  "end",
  "end"
] | 
	Completely process a non-interactive chimp object command
 This is used by chimpd, when processing a task. | 
	[
  "Completely",
  "process",
  "a",
  "non",
  "-",
  "interactive",
  "chimp",
  "object",
  "command",
  "This",
  "is",
  "used",
  "by",
  "chimpd",
  "when",
  "processing",
  "a",
  "task",
  "."
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L1134-L1189 | 
| 143 | 
	rightscale/right_chimp | 
	lib/right_chimp/chimp.rb | 
	Chimp.Chimp.chimpd_wait_until_done | 
	def chimpd_wait_until_done
      local_queue = ChimpQueue.instance
      $stdout.print "Waiting for chimpd jobs to complete for group #{@group}..."
      begin
        while !@dry_run
          local_queue = ChimpQueue.instance
          #
          # load up remote chimpd jobs into the local queue
          # this makes all the standard queue control methods available to us
          #
          sleeping_counter = 0
          while true
            local_queue.reset!
            begin
              all = ChimpDaemonClient.retrieve_group_info(@chimpd_host, @chimpd_port, @group, :all)
            rescue RestClient::ResourceNotFound
              sleep 5
              $stdout.print "\nINFO: Waiting on group #{@group} to populate"
              retry
            end
            ChimpQueue.instance.create_group(@group)
            ChimpQueue[@group].set_jobs(all)
            if ChimpQueue[@group].done?
              Log.debug 'Group ' + @group.to_s + ' is completed'
              jobs = ChimpQueue[@group].size
              $stdout.print "\nINFO: Group #{@group} has completed (#{jobs} jobs)"
              break
            else
              Log.debug 'Group ' + @group.to_s + ' is not done.'
            end
            if sleeping_counter % 240 == 0
              $stdout.print "\n(Still) Waiting for group #{@group}" unless sleeping_counter == 0
            end
            $stdout.print "."
            $stdout.flush
            sleeping_counter += 5
            sleep 5
          end
          #
          # If verify_results returns false, then ask chimpd to requeue all failed jobs.
          #
          case verify_results(@group)
          when 'continue'
            break
          when 'retry'
            ChimpDaemonClient.retry_group(@chimpd_host, @chimpd_port, @group)
          when 'pause'
            @paused = true
            #stuck in this loop until action is taken
          end
        end
      ensure
        #$stdout.print " done\n"
      end
    end | 
	ruby | 
	def chimpd_wait_until_done
      local_queue = ChimpQueue.instance
      $stdout.print "Waiting for chimpd jobs to complete for group #{@group}..."
      begin
        while !@dry_run
          local_queue = ChimpQueue.instance
          #
          # load up remote chimpd jobs into the local queue
          # this makes all the standard queue control methods available to us
          #
          sleeping_counter = 0
          while true
            local_queue.reset!
            begin
              all = ChimpDaemonClient.retrieve_group_info(@chimpd_host, @chimpd_port, @group, :all)
            rescue RestClient::ResourceNotFound
              sleep 5
              $stdout.print "\nINFO: Waiting on group #{@group} to populate"
              retry
            end
            ChimpQueue.instance.create_group(@group)
            ChimpQueue[@group].set_jobs(all)
            if ChimpQueue[@group].done?
              Log.debug 'Group ' + @group.to_s + ' is completed'
              jobs = ChimpQueue[@group].size
              $stdout.print "\nINFO: Group #{@group} has completed (#{jobs} jobs)"
              break
            else
              Log.debug 'Group ' + @group.to_s + ' is not done.'
            end
            if sleeping_counter % 240 == 0
              $stdout.print "\n(Still) Waiting for group #{@group}" unless sleeping_counter == 0
            end
            $stdout.print "."
            $stdout.flush
            sleeping_counter += 5
            sleep 5
          end
          #
          # If verify_results returns false, then ask chimpd to requeue all failed jobs.
          #
          case verify_results(@group)
          when 'continue'
            break
          when 'retry'
            ChimpDaemonClient.retry_group(@chimpd_host, @chimpd_port, @group)
          when 'pause'
            @paused = true
            #stuck in this loop until action is taken
          end
        end
      ensure
        #$stdout.print " done\n"
      end
    end | 
	[
  "def",
  "chimpd_wait_until_done",
  "local_queue",
  "=",
  "ChimpQueue",
  ".",
  "instance",
  "$stdout",
  ".",
  "print",
  "\"Waiting for chimpd jobs to complete for group #{@group}...\"",
  "begin",
  "while",
  "!",
  "@dry_run",
  "local_queue",
  "=",
  "ChimpQueue",
  ".",
  "instance",
  "#",
  "# load up remote chimpd jobs into the local queue",
  "# this makes all the standard queue control methods available to us",
  "#",
  "sleeping_counter",
  "=",
  "0",
  "while",
  "true",
  "local_queue",
  ".",
  "reset!",
  "begin",
  "all",
  "=",
  "ChimpDaemonClient",
  ".",
  "retrieve_group_info",
  "(",
  "@chimpd_host",
  ",",
  "@chimpd_port",
  ",",
  "@group",
  ",",
  ":all",
  ")",
  "rescue",
  "RestClient",
  "::",
  "ResourceNotFound",
  "sleep",
  "5",
  "$stdout",
  ".",
  "print",
  "\"\\nINFO: Waiting on group #{@group} to populate\"",
  "retry",
  "end",
  "ChimpQueue",
  ".",
  "instance",
  ".",
  "create_group",
  "(",
  "@group",
  ")",
  "ChimpQueue",
  "[",
  "@group",
  "]",
  ".",
  "set_jobs",
  "(",
  "all",
  ")",
  "if",
  "ChimpQueue",
  "[",
  "@group",
  "]",
  ".",
  "done?",
  "Log",
  ".",
  "debug",
  "'Group '",
  "+",
  "@group",
  ".",
  "to_s",
  "+",
  "' is completed'",
  "jobs",
  "=",
  "ChimpQueue",
  "[",
  "@group",
  "]",
  ".",
  "size",
  "$stdout",
  ".",
  "print",
  "\"\\nINFO: Group #{@group} has completed (#{jobs} jobs)\"",
  "break",
  "else",
  "Log",
  ".",
  "debug",
  "'Group '",
  "+",
  "@group",
  ".",
  "to_s",
  "+",
  "' is not done.'",
  "end",
  "if",
  "sleeping_counter",
  "%",
  "240",
  "==",
  "0",
  "$stdout",
  ".",
  "print",
  "\"\\n(Still) Waiting for group #{@group}\"",
  "unless",
  "sleeping_counter",
  "==",
  "0",
  "end",
  "$stdout",
  ".",
  "print",
  "\".\"",
  "$stdout",
  ".",
  "flush",
  "sleeping_counter",
  "+=",
  "5",
  "sleep",
  "5",
  "end",
  "#",
  "# If verify_results returns false, then ask chimpd to requeue all failed jobs.",
  "#",
  "case",
  "verify_results",
  "(",
  "@group",
  ")",
  "when",
  "'continue'",
  "break",
  "when",
  "'retry'",
  "ChimpDaemonClient",
  ".",
  "retry_group",
  "(",
  "@chimpd_host",
  ",",
  "@chimpd_port",
  ",",
  "@group",
  ")",
  "when",
  "'pause'",
  "@paused",
  "=",
  "true",
  "#stuck in this loop until action is taken",
  "end",
  "end",
  "ensure",
  "#$stdout.print \" done\\n\"",
  "end",
  "end"
] | 
	Connect to chimpd and wait for the work queue to empty, and
 prompt the user if there are any errors. | 
	[
  "Connect",
  "to",
  "chimpd",
  "and",
  "wait",
  "for",
  "the",
  "work",
  "queue",
  "to",
  "empty",
  "and",
  "prompt",
  "the",
  "user",
  "if",
  "there",
  "are",
  "any",
  "errors",
  "."
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/chimp.rb#L1209-L1269 | 
| 144 | 
	bithavoc/background_bunnies | 
	lib/background_bunnies/bunny.rb | 
	BackgroundBunnies.Bunny.start | 
	def start(connection_or_group)
      @connection = connection_or_group
      @channel = AMQP::Channel.new(@connection)
      queue_options = {}
      name = queue_name
      if queue_type == :broadcast
        queue_options[:exclusive] = true
        queue_options[:auto_delete] = true
        name = "#{Socket.gethostname}-#{Process.pid}-#{self.object_id}"
        @queue = @channel.queue(name, queue_options)
        @exchange = @channel.fanout(BackgroundBunnies.broadcast_exchange_name(queue_name))
        @queue.bind(@exchange)
      else
        queue_options[:durable] = true
        @queue = @channel.queue(queue_name, queue_options)
      end
      @consumer = @queue.subscribe(:ack=>true) do |metadata, payload|
        info = metadata
        properties = nil
        begin 
          job = Job.new(JSON.parse!(payload), info, properties)
          err = nil
          self.process(job) 
          metadata.ack
        rescue =>err
          # processing went wrong, requeing message
          job = Job.new(nil, info, properties) unless job
          unless on_error(job, err)
            metadata.reject(:requeue=>true)
          else
            metadata.ack
          end
        end
      end
    end | 
	ruby | 
	def start(connection_or_group)
      @connection = connection_or_group
      @channel = AMQP::Channel.new(@connection)
      queue_options = {}
      name = queue_name
      if queue_type == :broadcast
        queue_options[:exclusive] = true
        queue_options[:auto_delete] = true
        name = "#{Socket.gethostname}-#{Process.pid}-#{self.object_id}"
        @queue = @channel.queue(name, queue_options)
        @exchange = @channel.fanout(BackgroundBunnies.broadcast_exchange_name(queue_name))
        @queue.bind(@exchange)
      else
        queue_options[:durable] = true
        @queue = @channel.queue(queue_name, queue_options)
      end
      @consumer = @queue.subscribe(:ack=>true) do |metadata, payload|
        info = metadata
        properties = nil
        begin 
          job = Job.new(JSON.parse!(payload), info, properties)
          err = nil
          self.process(job) 
          metadata.ack
        rescue =>err
          # processing went wrong, requeing message
          job = Job.new(nil, info, properties) unless job
          unless on_error(job, err)
            metadata.reject(:requeue=>true)
          else
            metadata.ack
          end
        end
      end
    end | 
	[
  "def",
  "start",
  "(",
  "connection_or_group",
  ")",
  "@connection",
  "=",
  "connection_or_group",
  "@channel",
  "=",
  "AMQP",
  "::",
  "Channel",
  ".",
  "new",
  "(",
  "@connection",
  ")",
  "queue_options",
  "=",
  "{",
  "}",
  "name",
  "=",
  "queue_name",
  "if",
  "queue_type",
  "==",
  ":broadcast",
  "queue_options",
  "[",
  ":exclusive",
  "]",
  "=",
  "true",
  "queue_options",
  "[",
  ":auto_delete",
  "]",
  "=",
  "true",
  "name",
  "=",
  "\"#{Socket.gethostname}-#{Process.pid}-#{self.object_id}\"",
  "@queue",
  "=",
  "@channel",
  ".",
  "queue",
  "(",
  "name",
  ",",
  "queue_options",
  ")",
  "@exchange",
  "=",
  "@channel",
  ".",
  "fanout",
  "(",
  "BackgroundBunnies",
  ".",
  "broadcast_exchange_name",
  "(",
  "queue_name",
  ")",
  ")",
  "@queue",
  ".",
  "bind",
  "(",
  "@exchange",
  ")",
  "else",
  "queue_options",
  "[",
  ":durable",
  "]",
  "=",
  "true",
  "@queue",
  "=",
  "@channel",
  ".",
  "queue",
  "(",
  "queue_name",
  ",",
  "queue_options",
  ")",
  "end",
  "@consumer",
  "=",
  "@queue",
  ".",
  "subscribe",
  "(",
  ":ack",
  "=>",
  "true",
  ")",
  "do",
  "|",
  "metadata",
  ",",
  "payload",
  "|",
  "info",
  "=",
  "metadata",
  "properties",
  "=",
  "nil",
  "begin",
  "job",
  "=",
  "Job",
  ".",
  "new",
  "(",
  "JSON",
  ".",
  "parse!",
  "(",
  "payload",
  ")",
  ",",
  "info",
  ",",
  "properties",
  ")",
  "err",
  "=",
  "nil",
  "self",
  ".",
  "process",
  "(",
  "job",
  ")",
  "metadata",
  ".",
  "ack",
  "rescue",
  "=>",
  "err",
  "# processing went wrong, requeing message",
  "job",
  "=",
  "Job",
  ".",
  "new",
  "(",
  "nil",
  ",",
  "info",
  ",",
  "properties",
  ")",
  "unless",
  "job",
  "unless",
  "on_error",
  "(",
  "job",
  ",",
  "err",
  ")",
  "metadata",
  ".",
  "reject",
  "(",
  ":requeue",
  "=>",
  "true",
  ")",
  "else",
  "metadata",
  ".",
  "ack",
  "end",
  "end",
  "end",
  "end"
] | 
	Starts the Worker with the given connection or group name | 
	[
  "Starts",
  "the",
  "Worker",
  "with",
  "the",
  "given",
  "connection",
  "or",
  "group",
  "name"
] | 
	7d266b73f98b4283e68d4c7e478b1791333a91ff | 
	https://github.com/bithavoc/background_bunnies/blob/7d266b73f98b4283e68d4c7e478b1791333a91ff/lib/background_bunnies/bunny.rb#L92-L126 | 
| 145 | 
	arvicco/win_gui | 
	old_code/lib/win_gui/window.rb | 
	WinGui.Window.click | 
	def click(id)
      h = child(id).handle
      rectangle = [0, 0, 0, 0].pack 'LLLL'
      get_window_rect h, rectangle
      left, top, right, bottom = rectangle.unpack 'LLLL'
      center = [(left + right) / 2, (top + bottom) / 2]
      set_cursor_pos *center
      mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
      mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    end | 
	ruby | 
	def click(id)
      h = child(id).handle
      rectangle = [0, 0, 0, 0].pack 'LLLL'
      get_window_rect h, rectangle
      left, top, right, bottom = rectangle.unpack 'LLLL'
      center = [(left + right) / 2, (top + bottom) / 2]
      set_cursor_pos *center
      mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
      mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
    end | 
	[
  "def",
  "click",
  "(",
  "id",
  ")",
  "h",
  "=",
  "child",
  "(",
  "id",
  ")",
  ".",
  "handle",
  "rectangle",
  "=",
  "[",
  "0",
  ",",
  "0",
  ",",
  "0",
  ",",
  "0",
  "]",
  ".",
  "pack",
  "'LLLL'",
  "get_window_rect",
  "h",
  ",",
  "rectangle",
  "left",
  ",",
  "top",
  ",",
  "right",
  ",",
  "bottom",
  "=",
  "rectangle",
  ".",
  "unpack",
  "'LLLL'",
  "center",
  "=",
  "[",
  "(",
  "left",
  "+",
  "right",
  ")",
  "/",
  "2",
  ",",
  "(",
  "top",
  "+",
  "bottom",
  ")",
  "/",
  "2",
  "]",
  "set_cursor_pos",
  "center",
  "mouse_event",
  "MOUSEEVENTF_LEFTDOWN",
  ",",
  "0",
  ",",
  "0",
  ",",
  "0",
  ",",
  "0",
  "mouse_event",
  "MOUSEEVENTF_LEFTUP",
  ",",
  "0",
  ",",
  "0",
  ",",
  "0",
  ",",
  "0",
  "end"
] | 
	emulate click of the control identified by id | 
	[
  "emulate",
  "click",
  "of",
  "the",
  "control",
  "identified",
  "by",
  "id"
] | 
	a3a4c18db2391144fcb535e4be2f0fb47e9dcec7 | 
	https://github.com/arvicco/win_gui/blob/a3a4c18db2391144fcb535e4be2f0fb47e9dcec7/old_code/lib/win_gui/window.rb#L43-L52 | 
| 146 | 
	nixme/pandora_client | 
	lib/pandora/song.rb | 
	Pandora.Song.load_explorer_data | 
	def load_explorer_data
      document = Nokogiri::XML(Faraday.get(@song_explorer_url).body)
      @id = document.search('songExplorer').first['musicId']
    end | 
	ruby | 
	def load_explorer_data
      document = Nokogiri::XML(Faraday.get(@song_explorer_url).body)
      @id = document.search('songExplorer').first['musicId']
    end | 
	[
  "def",
  "load_explorer_data",
  "document",
  "=",
  "Nokogiri",
  "::",
  "XML",
  "(",
  "Faraday",
  ".",
  "get",
  "(",
  "@song_explorer_url",
  ")",
  ".",
  "body",
  ")",
  "@id",
  "=",
  "document",
  ".",
  "search",
  "(",
  "'songExplorer'",
  ")",
  ".",
  "first",
  "[",
  "'musicId'",
  "]",
  "end"
] | 
	Unfortunately the Tuner API track JSON doesn't include the musicId, a
 track identifier that's constant among different user sessions. However,
 we can fetch it via the Song's Explorer XML URL. | 
	[
  "Unfortunately",
  "the",
  "Tuner",
  "API",
  "track",
  "JSON",
  "doesn",
  "t",
  "include",
  "the",
  "musicId",
  "a",
  "track",
  "identifier",
  "that",
  "s",
  "constant",
  "among",
  "different",
  "user",
  "sessions",
  ".",
  "However",
  "we",
  "can",
  "fetch",
  "it",
  "via",
  "the",
  "Song",
  "s",
  "Explorer",
  "XML",
  "URL",
  "."
] | 
	45510334c9f84bc9cb974af97fa93ebf2913410a | 
	https://github.com/nixme/pandora_client/blob/45510334c9f84bc9cb974af97fa93ebf2913410a/lib/pandora/song.rb#L80-L83 | 
| 147 | 
	rightscale/right_chimp | 
	lib/right_chimp/resources/server.rb | 
	Chimp.Server.run_executable | 
	def run_executable(exec, options)
      script_href = "right_script_href="+exec.href
      # Construct the parameters to pass for the inputs
      params=options.collect { |k, v|
        "&inputs[][name]=#{k}&inputs[][value]=#{v}" unless k == :ignore_lock
        }.join('&')
      if options[:ignore_lock]
        params+="&ignore_lock=true"
      end
      # self is the actual Server object
      Log.debug "[#{Chimp.get_job_uuid}] Running executable"
      task = self.object.run_executable(script_href + params)
      return task
    end | 
	ruby | 
	def run_executable(exec, options)
      script_href = "right_script_href="+exec.href
      # Construct the parameters to pass for the inputs
      params=options.collect { |k, v|
        "&inputs[][name]=#{k}&inputs[][value]=#{v}" unless k == :ignore_lock
        }.join('&')
      if options[:ignore_lock]
        params+="&ignore_lock=true"
      end
      # self is the actual Server object
      Log.debug "[#{Chimp.get_job_uuid}] Running executable"
      task = self.object.run_executable(script_href + params)
      return task
    end | 
	[
  "def",
  "run_executable",
  "(",
  "exec",
  ",",
  "options",
  ")",
  "script_href",
  "=",
  "\"right_script_href=\"",
  "+",
  "exec",
  ".",
  "href",
  "# Construct the parameters to pass for the inputs",
  "params",
  "=",
  "options",
  ".",
  "collect",
  "{",
  "|",
  "k",
  ",",
  "v",
  "|",
  "\"&inputs[][name]=#{k}&inputs[][value]=#{v}\"",
  "unless",
  "k",
  "==",
  ":ignore_lock",
  "}",
  ".",
  "join",
  "(",
  "'&'",
  ")",
  "if",
  "options",
  "[",
  ":ignore_lock",
  "]",
  "params",
  "+=",
  "\"&ignore_lock=true\"",
  "end",
  "# self is the actual Server object",
  "Log",
  ".",
  "debug",
  "\"[#{Chimp.get_job_uuid}] Running executable\"",
  "task",
  "=",
  "self",
  ".",
  "object",
  ".",
  "run_executable",
  "(",
  "script_href",
  "+",
  "params",
  ")",
  "return",
  "task",
  "end"
] | 
	In order to run the task, we need to call run_executable on ourselves | 
	[
  "In",
  "order",
  "to",
  "run",
  "the",
  "task",
  "we",
  "need",
  "to",
  "call",
  "run_executable",
  "on",
  "ourselves"
] | 
	290d3e01f7bf4b505722a080cb0abbb0314222f8 | 
	https://github.com/rightscale/right_chimp/blob/290d3e01f7bf4b505722a080cb0abbb0314222f8/lib/right_chimp/resources/server.rb#L63-L77 | 
| 148 | 
	rberger/phaserunner | 
	lib/phaserunner/main.rb | 
	Phaserunner.Cli.main | 
	def main
      program_desc 'Read values from the Grin PhaseRunner Controller primarily for logging'
      version Phaserunner::VERSION
      subcommand_option_handling :normal
      arguments :strict
      sort_help :manually
      desc 'Serial (USB) device'
      default_value '/dev/ttyUSB0'
      arg 'tty'
      flag [:t, :tty]
      desc 'Serial port baudrate'
      default_value 115200
      arg 'baudrate'
      flag [:b, :baudrate]
      desc 'Modbus slave ID'
      default_value 1
      arg 'slave_id'
      flag [:s, :slave_id]
      desc 'Path to json file that contains Grin Modbus Dictionary'
      default_value Modbus.default_file_path
      arg 'dictionary_file'
      flag [:d, :dictionary_file]
      desc 'Loop the command n times'
      default_value :forever
      arg 'loop_count', :optional
      flag [:l, :loop_count]
      desc 'Do not output to stdout'
      switch [:q, :quiet]
      desc 'Read a single or multiple adjacent registers from and address'
      arg_name 'register_address'
      command :read_register do |read_register|
        read_register.desc 'Number of registers to read starting at the Arg Address'
        read_register.default_value 1
        read_register.flag [:c, :count]
        read_register.arg 'address'
        read_register.action do |global_options, options, args|
          address = args[0].to_i
          count = args[1].to_i
          node = dict[address]
          puts modbus.range_address_header(address, count).join(",") unless quiet
          (0..loop_count).each do |i|
            puts modbus.read_raw_range(address, count).join(",") unless quiet
          end
        end
      end
      desc 'Logs interesting Phaserunner registers to stdout and file'
      long_desc %q(Logs interesting Phaserunner registers to stdout and a CSV file. File name in the form: phaserunner.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.csv)
      command :log do |log|
        log.action do |global_options, options, args|
          filename = "phaserunner.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.csv"
          output_fd = File.open(filename, 'w')
          header = modbus.bulk_log_header
          # Generate and output header line
          hdr = %Q(Timestamp,#{header.join(",")})
          puts hdr unless quiet
          output_fd.puts hdr
          (0..loop_count).each do |i| 
            data = modbus.bulk_log_data
            str = %Q(#{Time.now.utc.round(10).iso8601(6)},#{data.join(",")})
            puts str unless quiet
            output_fd.puts str
            sleep 0.2
          end
        end
      end
      pre do |global, command, options, args|
        # Pre logic here
        # Return true to proceed; false to abort and not call the
        # chosen command
        # Use skips_pre before a command to skip this block
        # on that command only
        @quiet = global[:quiet]
        # Handle that loop_count can be :forever or an Integer
        @loop_count = if global[:loop_count] == :forever
                        Float::INFINITY
                      else
                        global[:loop_count].to_i
                      end
        @modbus = Modbus.new(global)
        @dict = @modbus.dict
      end
      post do |global,command,options,args|
        # Post logic here
        # Use skips_post before a command to skip this
        # block on that command only
      end
      on_error do |exception|
        # Error logic here
        # return false to skip default error handling
        true
      end
      exit run(ARGV)
    end | 
	ruby | 
	def main
      program_desc 'Read values from the Grin PhaseRunner Controller primarily for logging'
      version Phaserunner::VERSION
      subcommand_option_handling :normal
      arguments :strict
      sort_help :manually
      desc 'Serial (USB) device'
      default_value '/dev/ttyUSB0'
      arg 'tty'
      flag [:t, :tty]
      desc 'Serial port baudrate'
      default_value 115200
      arg 'baudrate'
      flag [:b, :baudrate]
      desc 'Modbus slave ID'
      default_value 1
      arg 'slave_id'
      flag [:s, :slave_id]
      desc 'Path to json file that contains Grin Modbus Dictionary'
      default_value Modbus.default_file_path
      arg 'dictionary_file'
      flag [:d, :dictionary_file]
      desc 'Loop the command n times'
      default_value :forever
      arg 'loop_count', :optional
      flag [:l, :loop_count]
      desc 'Do not output to stdout'
      switch [:q, :quiet]
      desc 'Read a single or multiple adjacent registers from and address'
      arg_name 'register_address'
      command :read_register do |read_register|
        read_register.desc 'Number of registers to read starting at the Arg Address'
        read_register.default_value 1
        read_register.flag [:c, :count]
        read_register.arg 'address'
        read_register.action do |global_options, options, args|
          address = args[0].to_i
          count = args[1].to_i
          node = dict[address]
          puts modbus.range_address_header(address, count).join(",") unless quiet
          (0..loop_count).each do |i|
            puts modbus.read_raw_range(address, count).join(",") unless quiet
          end
        end
      end
      desc 'Logs interesting Phaserunner registers to stdout and file'
      long_desc %q(Logs interesting Phaserunner registers to stdout and a CSV file. File name in the form: phaserunner.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.csv)
      command :log do |log|
        log.action do |global_options, options, args|
          filename = "phaserunner.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.csv"
          output_fd = File.open(filename, 'w')
          header = modbus.bulk_log_header
          # Generate and output header line
          hdr = %Q(Timestamp,#{header.join(",")})
          puts hdr unless quiet
          output_fd.puts hdr
          (0..loop_count).each do |i| 
            data = modbus.bulk_log_data
            str = %Q(#{Time.now.utc.round(10).iso8601(6)},#{data.join(",")})
            puts str unless quiet
            output_fd.puts str
            sleep 0.2
          end
        end
      end
      pre do |global, command, options, args|
        # Pre logic here
        # Return true to proceed; false to abort and not call the
        # chosen command
        # Use skips_pre before a command to skip this block
        # on that command only
        @quiet = global[:quiet]
        # Handle that loop_count can be :forever or an Integer
        @loop_count = if global[:loop_count] == :forever
                        Float::INFINITY
                      else
                        global[:loop_count].to_i
                      end
        @modbus = Modbus.new(global)
        @dict = @modbus.dict
      end
      post do |global,command,options,args|
        # Post logic here
        # Use skips_post before a command to skip this
        # block on that command only
      end
      on_error do |exception|
        # Error logic here
        # return false to skip default error handling
        true
      end
      exit run(ARGV)
    end | 
	[
  "def",
  "main",
  "program_desc",
  "'Read values from the Grin PhaseRunner Controller primarily for logging'",
  "version",
  "Phaserunner",
  "::",
  "VERSION",
  "subcommand_option_handling",
  ":normal",
  "arguments",
  ":strict",
  "sort_help",
  ":manually",
  "desc",
  "'Serial (USB) device'",
  "default_value",
  "'/dev/ttyUSB0'",
  "arg",
  "'tty'",
  "flag",
  "[",
  ":t",
  ",",
  ":tty",
  "]",
  "desc",
  "'Serial port baudrate'",
  "default_value",
  "115200",
  "arg",
  "'baudrate'",
  "flag",
  "[",
  ":b",
  ",",
  ":baudrate",
  "]",
  "desc",
  "'Modbus slave ID'",
  "default_value",
  "1",
  "arg",
  "'slave_id'",
  "flag",
  "[",
  ":s",
  ",",
  ":slave_id",
  "]",
  "desc",
  "'Path to json file that contains Grin Modbus Dictionary'",
  "default_value",
  "Modbus",
  ".",
  "default_file_path",
  "arg",
  "'dictionary_file'",
  "flag",
  "[",
  ":d",
  ",",
  ":dictionary_file",
  "]",
  "desc",
  "'Loop the command n times'",
  "default_value",
  ":forever",
  "arg",
  "'loop_count'",
  ",",
  ":optional",
  "flag",
  "[",
  ":l",
  ",",
  ":loop_count",
  "]",
  "desc",
  "'Do not output to stdout'",
  "switch",
  "[",
  ":q",
  ",",
  ":quiet",
  "]",
  "desc",
  "'Read a single or multiple adjacent registers from and address'",
  "arg_name",
  "'register_address'",
  "command",
  ":read_register",
  "do",
  "|",
  "read_register",
  "|",
  "read_register",
  ".",
  "desc",
  "'Number of registers to read starting at the Arg Address'",
  "read_register",
  ".",
  "default_value",
  "1",
  "read_register",
  ".",
  "flag",
  "[",
  ":c",
  ",",
  ":count",
  "]",
  "read_register",
  ".",
  "arg",
  "'address'",
  "read_register",
  ".",
  "action",
  "do",
  "|",
  "global_options",
  ",",
  "options",
  ",",
  "args",
  "|",
  "address",
  "=",
  "args",
  "[",
  "0",
  "]",
  ".",
  "to_i",
  "count",
  "=",
  "args",
  "[",
  "1",
  "]",
  ".",
  "to_i",
  "node",
  "=",
  "dict",
  "[",
  "address",
  "]",
  "puts",
  "modbus",
  ".",
  "range_address_header",
  "(",
  "address",
  ",",
  "count",
  ")",
  ".",
  "join",
  "(",
  "\",\"",
  ")",
  "unless",
  "quiet",
  "(",
  "0",
  "..",
  "loop_count",
  ")",
  ".",
  "each",
  "do",
  "|",
  "i",
  "|",
  "puts",
  "modbus",
  ".",
  "read_raw_range",
  "(",
  "address",
  ",",
  "count",
  ")",
  ".",
  "join",
  "(",
  "\",\"",
  ")",
  "unless",
  "quiet",
  "end",
  "end",
  "end",
  "desc",
  "'Logs interesting Phaserunner registers to stdout and file'",
  "long_desc",
  "%q(Logs interesting Phaserunner registers to stdout and a CSV file. File name in the form: phaserunner.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.csv)",
  "command",
  ":log",
  "do",
  "|",
  "log",
  "|",
  "log",
  ".",
  "action",
  "do",
  "|",
  "global_options",
  ",",
  "options",
  ",",
  "args",
  "|",
  "filename",
  "=",
  "\"phaserunner.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.csv\"",
  "output_fd",
  "=",
  "File",
  ".",
  "open",
  "(",
  "filename",
  ",",
  "'w'",
  ")",
  "header",
  "=",
  "modbus",
  ".",
  "bulk_log_header",
  "# Generate and output header line",
  "hdr",
  "=",
  "%Q(Timestamp,#{header.join(\",\")})",
  "puts",
  "hdr",
  "unless",
  "quiet",
  "output_fd",
  ".",
  "puts",
  "hdr",
  "(",
  "0",
  "..",
  "loop_count",
  ")",
  ".",
  "each",
  "do",
  "|",
  "i",
  "|",
  "data",
  "=",
  "modbus",
  ".",
  "bulk_log_data",
  "str",
  "=",
  "%Q(#{Time.now.utc.round(10).iso8601(6)},#{data.join(\",\")})",
  "puts",
  "str",
  "unless",
  "quiet",
  "output_fd",
  ".",
  "puts",
  "str",
  "sleep",
  "0.2",
  "end",
  "end",
  "end",
  "pre",
  "do",
  "|",
  "global",
  ",",
  "command",
  ",",
  "options",
  ",",
  "args",
  "|",
  "# Pre logic here",
  "# Return true to proceed; false to abort and not call the",
  "# chosen command",
  "# Use skips_pre before a command to skip this block",
  "# on that command only",
  "@quiet",
  "=",
  "global",
  "[",
  ":quiet",
  "]",
  "# Handle that loop_count can be :forever or an Integer",
  "@loop_count",
  "=",
  "if",
  "global",
  "[",
  ":loop_count",
  "]",
  "==",
  ":forever",
  "Float",
  "::",
  "INFINITY",
  "else",
  "global",
  "[",
  ":loop_count",
  "]",
  ".",
  "to_i",
  "end",
  "@modbus",
  "=",
  "Modbus",
  ".",
  "new",
  "(",
  "global",
  ")",
  "@dict",
  "=",
  "@modbus",
  ".",
  "dict",
  "end",
  "post",
  "do",
  "|",
  "global",
  ",",
  "command",
  ",",
  "options",
  ",",
  "args",
  "|",
  "# Post logic here",
  "# Use skips_post before a command to skip this",
  "# block on that command only",
  "end",
  "on_error",
  "do",
  "|",
  "exception",
  "|",
  "# Error logic here",
  "# return false to skip default error handling",
  "true",
  "end",
  "exit",
  "run",
  "(",
  "ARGV",
  ")",
  "end"
] | 
	Does all the CLI work | 
	[
  "Does",
  "all",
  "the",
  "CLI",
  "work"
] | 
	bc1d7c94381c1a3547f5badd581c2f40eefdd807 | 
	https://github.com/rberger/phaserunner/blob/bc1d7c94381c1a3547f5badd581c2f40eefdd807/lib/phaserunner/main.rb#L22-L131 | 
| 149 | 
	angelim/rails_redshift_replicator | 
	lib/rails_redshift_replicator/deleter.rb | 
	RailsRedshiftReplicator.Deleter.handle_delete_propagation | 
	def handle_delete_propagation
      if replicable.tracking_deleted && has_deleted_ids?
        RailsRedshiftReplicator.logger.info propagation_message(:propagating_deletes)
        delete_on_target ? purge_deleted : RailsRedshiftReplicator.logger.error(propagation_message(:delete_propagation_error))
      end
    end | 
	ruby | 
	def handle_delete_propagation
      if replicable.tracking_deleted && has_deleted_ids?
        RailsRedshiftReplicator.logger.info propagation_message(:propagating_deletes)
        delete_on_target ? purge_deleted : RailsRedshiftReplicator.logger.error(propagation_message(:delete_propagation_error))
      end
    end | 
	[
  "def",
  "handle_delete_propagation",
  "if",
  "replicable",
  ".",
  "tracking_deleted",
  "&&",
  "has_deleted_ids?",
  "RailsRedshiftReplicator",
  ".",
  "logger",
  ".",
  "info",
  "propagation_message",
  "(",
  ":propagating_deletes",
  ")",
  "delete_on_target",
  "?",
  "purge_deleted",
  ":",
  "RailsRedshiftReplicator",
  ".",
  "logger",
  ".",
  "error",
  "(",
  "propagation_message",
  "(",
  ":delete_propagation_error",
  ")",
  ")",
  "end",
  "end"
] | 
	Deletes records flagged for deletion on target and then delete the queue from source | 
	[
  "Deletes",
  "records",
  "flagged",
  "for",
  "deletion",
  "on",
  "target",
  "and",
  "then",
  "delete",
  "the",
  "queue",
  "from",
  "source"
] | 
	823f6da36f43a39f340a3ca7eb159df58a86766d | 
	https://github.com/angelim/rails_redshift_replicator/blob/823f6da36f43a39f340a3ca7eb159df58a86766d/lib/rails_redshift_replicator/deleter.rb#L20-L25 | 
| 150 | 
	rayyanqcri/rayyan-scrapers | 
	lib/rayyan-scrapers/nih_fulltext_scraper.rb | 
	RayyanScrapers.NihFulltextScraper.process_list_page | 
	def process_list_page(page)
      @logger.info("Processing list page with URL: #{page.uri}")
      #page.save_as "html/result-list.html"
      new_items_found = nil
      items = page.links #[0..50]   # TODO REMOVE [], getting sample only
      items_len = items.length - 1
      @total = @total + items_len
  #    pline "Found #{items_len} items in page", true
      items.each do |anchor|
        next if anchor.text == '../'
        new_items_found = false if new_items_found.nil? 
      
        pid = anchor.text.split('.').first
        link = "#{page.uri}#{anchor.href}"
        
        @logger.info "Got result with id #{pid}"
        
  #      pline "  Item #{@curr_property} of #{@total}..."
        # get detailed info
        begin
          article = Article.find_by_url link
          if article.nil?
            new_items_found = true
            article = process_fulltext_detail_page(@agent.get(link), pid)
            yield article, true
          else
            yield article, false
          end
        rescue => exception
          @logger.error "Error processing #{link}:"
          @logger.error exception
          @logger.error exception.backtrace.join("\n")
        end
        @curr_property = @curr_property + 1
      end
      new_items_found
    end | 
	ruby | 
	def process_list_page(page)
      @logger.info("Processing list page with URL: #{page.uri}")
      #page.save_as "html/result-list.html"
      new_items_found = nil
      items = page.links #[0..50]   # TODO REMOVE [], getting sample only
      items_len = items.length - 1
      @total = @total + items_len
  #    pline "Found #{items_len} items in page", true
      items.each do |anchor|
        next if anchor.text == '../'
        new_items_found = false if new_items_found.nil? 
      
        pid = anchor.text.split('.').first
        link = "#{page.uri}#{anchor.href}"
        
        @logger.info "Got result with id #{pid}"
        
  #      pline "  Item #{@curr_property} of #{@total}..."
        # get detailed info
        begin
          article = Article.find_by_url link
          if article.nil?
            new_items_found = true
            article = process_fulltext_detail_page(@agent.get(link), pid)
            yield article, true
          else
            yield article, false
          end
        rescue => exception
          @logger.error "Error processing #{link}:"
          @logger.error exception
          @logger.error exception.backtrace.join("\n")
        end
        @curr_property = @curr_property + 1
      end
      new_items_found
    end | 
	[
  "def",
  "process_list_page",
  "(",
  "page",
  ")",
  "@logger",
  ".",
  "info",
  "(",
  "\"Processing list page with URL: #{page.uri}\"",
  ")",
  "#page.save_as \"html/result-list.html\"",
  "new_items_found",
  "=",
  "nil",
  "items",
  "=",
  "page",
  ".",
  "links",
  "#[0..50]   # TODO REMOVE [], getting sample only",
  "items_len",
  "=",
  "items",
  ".",
  "length",
  "-",
  "1",
  "@total",
  "=",
  "@total",
  "+",
  "items_len",
  "#    pline \"Found #{items_len} items in page\", true",
  "items",
  ".",
  "each",
  "do",
  "|",
  "anchor",
  "|",
  "next",
  "if",
  "anchor",
  ".",
  "text",
  "==",
  "'../'",
  "new_items_found",
  "=",
  "false",
  "if",
  "new_items_found",
  ".",
  "nil?",
  "pid",
  "=",
  "anchor",
  ".",
  "text",
  ".",
  "split",
  "(",
  "'.'",
  ")",
  ".",
  "first",
  "link",
  "=",
  "\"#{page.uri}#{anchor.href}\"",
  "@logger",
  ".",
  "info",
  "\"Got result with id #{pid}\"",
  "#      pline \"  Item #{@curr_property} of #{@total}...\"",
  "# get detailed info",
  "begin",
  "article",
  "=",
  "Article",
  ".",
  "find_by_url",
  "link",
  "if",
  "article",
  ".",
  "nil?",
  "new_items_found",
  "=",
  "true",
  "article",
  "=",
  "process_fulltext_detail_page",
  "(",
  "@agent",
  ".",
  "get",
  "(",
  "link",
  ")",
  ",",
  "pid",
  ")",
  "yield",
  "article",
  ",",
  "true",
  "else",
  "yield",
  "article",
  ",",
  "false",
  "end",
  "rescue",
  "=>",
  "exception",
  "@logger",
  ".",
  "error",
  "\"Error processing #{link}:\"",
  "@logger",
  ".",
  "error",
  "exception",
  "@logger",
  ".",
  "error",
  "exception",
  ".",
  "backtrace",
  ".",
  "join",
  "(",
  "\"\\n\"",
  ")",
  "end",
  "@curr_property",
  "=",
  "@curr_property",
  "+",
  "1",
  "end",
  "new_items_found",
  "end"
] | 
	NOTUSED by islam | 
	[
  "NOTUSED",
  "by",
  "islam"
] | 
	63d8b02987790ca08c06121775f95c49ed52c1b4 | 
	https://github.com/rayyanqcri/rayyan-scrapers/blob/63d8b02987790ca08c06121775f95c49ed52c1b4/lib/rayyan-scrapers/nih_fulltext_scraper.rb#L54-L94 | 
| 151 | 
	emn178/sms_carrier | 
	lib/sms_carrier/log_subscriber.rb | 
	SmsCarrier.LogSubscriber.deliver | 
	def deliver(event)
      info do
        recipients = Array(event.payload[:to]).join(', ')
        "\nSent SMS to #{recipients} (#{event.duration.round(1)}ms)"
      end
      debug { event.payload[:sms] }
    end | 
	ruby | 
	def deliver(event)
      info do
        recipients = Array(event.payload[:to]).join(', ')
        "\nSent SMS to #{recipients} (#{event.duration.round(1)}ms)"
      end
      debug { event.payload[:sms] }
    end | 
	[
  "def",
  "deliver",
  "(",
  "event",
  ")",
  "info",
  "do",
  "recipients",
  "=",
  "Array",
  "(",
  "event",
  ".",
  "payload",
  "[",
  ":to",
  "]",
  ")",
  ".",
  "join",
  "(",
  "', '",
  ")",
  "\"\\nSent SMS to #{recipients} (#{event.duration.round(1)}ms)\"",
  "end",
  "debug",
  "{",
  "event",
  ".",
  "payload",
  "[",
  ":sms",
  "]",
  "}",
  "end"
] | 
	An SMS was delivered. | 
	[
  "An",
  "SMS",
  "was",
  "delivered",
  "."
] | 
	6aa97b46d8fa6e92db67a8cf5c81076d5ae1f9ad | 
	https://github.com/emn178/sms_carrier/blob/6aa97b46d8fa6e92db67a8cf5c81076d5ae1f9ad/lib/sms_carrier/log_subscriber.rb#L8-L15 | 
| 152 | 
	activenetwork/actv | 
	lib/actv/base.rb | 
	ACTV.Base.to_hash | 
	def to_hash
      hash = {}
      hash["attrs"] = @attrs
      self.instance_variables.keep_if { |key| key != :@attrs }.each do |var|
        val = self.instance_variable_get(var)
        hash["attrs"][var.to_s.delete("@").to_sym] = val.to_hash if val.is_a? ACTV::Base
      end
      hash["attrs"]
    end | 
	ruby | 
	def to_hash
      hash = {}
      hash["attrs"] = @attrs
      self.instance_variables.keep_if { |key| key != :@attrs }.each do |var|
        val = self.instance_variable_get(var)
        hash["attrs"][var.to_s.delete("@").to_sym] = val.to_hash if val.is_a? ACTV::Base
      end
      hash["attrs"]
    end | 
	[
  "def",
  "to_hash",
  "hash",
  "=",
  "{",
  "}",
  "hash",
  "[",
  "\"attrs\"",
  "]",
  "=",
  "@attrs",
  "self",
  ".",
  "instance_variables",
  ".",
  "keep_if",
  "{",
  "|",
  "key",
  "|",
  "key",
  "!=",
  ":@attrs",
  "}",
  ".",
  "each",
  "do",
  "|",
  "var",
  "|",
  "val",
  "=",
  "self",
  ".",
  "instance_variable_get",
  "(",
  "var",
  ")",
  "hash",
  "[",
  "\"attrs\"",
  "]",
  "[",
  "var",
  ".",
  "to_s",
  ".",
  "delete",
  "(",
  "\"@\"",
  ")",
  ".",
  "to_sym",
  "]",
  "=",
  "val",
  ".",
  "to_hash",
  "if",
  "val",
  ".",
  "is_a?",
  "ACTV",
  "::",
  "Base",
  "end",
  "hash",
  "[",
  "\"attrs\"",
  "]",
  "end"
] | 
	Creation of object hash when sending request to soap | 
	[
  "Creation",
  "of",
  "object",
  "hash",
  "when",
  "sending",
  "request",
  "to",
  "soap"
] | 
	861222f5eccf81628221c71af8b8681789171402 | 
	https://github.com/activenetwork/actv/blob/861222f5eccf81628221c71af8b8681789171402/lib/actv/base.rb#L125-L135 | 
| 153 | 
	praxis/attributor | 
	lib/attributor/attribute_resolver.rb | 
	Attributor.AttributeResolver.check | 
	def check(path_prefix, key_path, predicate = nil)
      value = query(key_path, path_prefix)
      # we have a value, any value, which is good enough given no predicate
      return true if !value.nil? && predicate.nil?
      case predicate
      when ::String, ::Regexp, ::Integer, ::Float, ::DateTime, true, false
        return predicate === value
      when ::Proc
        # Cannot use === here as above due to different behavior in Ruby 1.8
        return predicate.call(value)
      when nil
        return !value.nil?
      else
        raise AttributorException, "predicate not supported: #{predicate.inspect}"
      end
    end | 
	ruby | 
	def check(path_prefix, key_path, predicate = nil)
      value = query(key_path, path_prefix)
      # we have a value, any value, which is good enough given no predicate
      return true if !value.nil? && predicate.nil?
      case predicate
      when ::String, ::Regexp, ::Integer, ::Float, ::DateTime, true, false
        return predicate === value
      when ::Proc
        # Cannot use === here as above due to different behavior in Ruby 1.8
        return predicate.call(value)
      when nil
        return !value.nil?
      else
        raise AttributorException, "predicate not supported: #{predicate.inspect}"
      end
    end | 
	[
  "def",
  "check",
  "(",
  "path_prefix",
  ",",
  "key_path",
  ",",
  "predicate",
  "=",
  "nil",
  ")",
  "value",
  "=",
  "query",
  "(",
  "key_path",
  ",",
  "path_prefix",
  ")",
  "# we have a value, any value, which is good enough given no predicate",
  "return",
  "true",
  "if",
  "!",
  "value",
  ".",
  "nil?",
  "&&",
  "predicate",
  ".",
  "nil?",
  "case",
  "predicate",
  "when",
  "::",
  "String",
  ",",
  "::",
  "Regexp",
  ",",
  "::",
  "Integer",
  ",",
  "::",
  "Float",
  ",",
  "::",
  "DateTime",
  ",",
  "true",
  ",",
  "false",
  "return",
  "predicate",
  "===",
  "value",
  "when",
  "::",
  "Proc",
  "# Cannot use === here as above due to different behavior in Ruby 1.8",
  "return",
  "predicate",
  ".",
  "call",
  "(",
  "value",
  ")",
  "when",
  "nil",
  "return",
  "!",
  "value",
  ".",
  "nil?",
  "else",
  "raise",
  "AttributorException",
  ",",
  "\"predicate not supported: #{predicate.inspect}\"",
  "end",
  "end"
] | 
	Checks that the the condition is met. This means the attribute identified
 by path_prefix and key_path satisfies the optional predicate, which when
 nil simply checks for existence.
 @param path_prefix [String]
 @param key_path [String]
 @param predicate [String|Regexp|Proc|NilClass]
 @returns [Boolean] True if :required_if condition is met, false otherwise
 @raise [AttributorException] When an unsupported predicate is passed | 
	[
  "Checks",
  "that",
  "the",
  "the",
  "condition",
  "is",
  "met",
  ".",
  "This",
  "means",
  "the",
  "attribute",
  "identified",
  "by",
  "path_prefix",
  "and",
  "key_path",
  "satisfies",
  "the",
  "optional",
  "predicate",
  "which",
  "when",
  "nil",
  "simply",
  "checks",
  "for",
  "existence",
  "."
] | 
	faebaa0176086e1421cefc54a352d13a5b08d985 | 
	https://github.com/praxis/attributor/blob/faebaa0176086e1421cefc54a352d13a5b08d985/lib/attributor/attribute_resolver.rb#L82-L99 | 
| 154 | 
	praxis/attributor | 
	lib/attributor/attribute.rb | 
	Attributor.Attribute.describe | 
	def describe(shallow = true, example: nil)
      description = {}
      # Clone the common options
      TOP_LEVEL_OPTIONS.each do |option_name|
        description[option_name] = options[option_name] if options.key? option_name
      end
      # Make sure this option definition is not mistaken for the real generated example
      if (ex_def = description.delete(:example))
        description[:example_definition] = ex_def
      end
      special_options = options.keys - TOP_LEVEL_OPTIONS - INTERNAL_OPTIONS
      description[:options] = {} unless special_options.empty?
      special_options.each do |opt_name|
        description[:options][opt_name] = options[opt_name]
      end
      # Change the reference option to the actual class name.
      if (reference = options[:reference])
        description[:options][:reference] = reference.name
      end
      description[:type] = type.describe(shallow, example: example)
      # Move over any example from the type, into the attribute itself
      if (ex = description[:type].delete(:example))
        description[:example] = dump(ex)
      end
      description
    end | 
	ruby | 
	def describe(shallow = true, example: nil)
      description = {}
      # Clone the common options
      TOP_LEVEL_OPTIONS.each do |option_name|
        description[option_name] = options[option_name] if options.key? option_name
      end
      # Make sure this option definition is not mistaken for the real generated example
      if (ex_def = description.delete(:example))
        description[:example_definition] = ex_def
      end
      special_options = options.keys - TOP_LEVEL_OPTIONS - INTERNAL_OPTIONS
      description[:options] = {} unless special_options.empty?
      special_options.each do |opt_name|
        description[:options][opt_name] = options[opt_name]
      end
      # Change the reference option to the actual class name.
      if (reference = options[:reference])
        description[:options][:reference] = reference.name
      end
      description[:type] = type.describe(shallow, example: example)
      # Move over any example from the type, into the attribute itself
      if (ex = description[:type].delete(:example))
        description[:example] = dump(ex)
      end
      description
    end | 
	[
  "def",
  "describe",
  "(",
  "shallow",
  "=",
  "true",
  ",",
  "example",
  ":",
  "nil",
  ")",
  "description",
  "=",
  "{",
  "}",
  "# Clone the common options",
  "TOP_LEVEL_OPTIONS",
  ".",
  "each",
  "do",
  "|",
  "option_name",
  "|",
  "description",
  "[",
  "option_name",
  "]",
  "=",
  "options",
  "[",
  "option_name",
  "]",
  "if",
  "options",
  ".",
  "key?",
  "option_name",
  "end",
  "# Make sure this option definition is not mistaken for the real generated example",
  "if",
  "(",
  "ex_def",
  "=",
  "description",
  ".",
  "delete",
  "(",
  ":example",
  ")",
  ")",
  "description",
  "[",
  ":example_definition",
  "]",
  "=",
  "ex_def",
  "end",
  "special_options",
  "=",
  "options",
  ".",
  "keys",
  "-",
  "TOP_LEVEL_OPTIONS",
  "-",
  "INTERNAL_OPTIONS",
  "description",
  "[",
  ":options",
  "]",
  "=",
  "{",
  "}",
  "unless",
  "special_options",
  ".",
  "empty?",
  "special_options",
  ".",
  "each",
  "do",
  "|",
  "opt_name",
  "|",
  "description",
  "[",
  ":options",
  "]",
  "[",
  "opt_name",
  "]",
  "=",
  "options",
  "[",
  "opt_name",
  "]",
  "end",
  "# Change the reference option to the actual class name.",
  "if",
  "(",
  "reference",
  "=",
  "options",
  "[",
  ":reference",
  "]",
  ")",
  "description",
  "[",
  ":options",
  "]",
  "[",
  ":reference",
  "]",
  "=",
  "reference",
  ".",
  "name",
  "end",
  "description",
  "[",
  ":type",
  "]",
  "=",
  "type",
  ".",
  "describe",
  "(",
  "shallow",
  ",",
  "example",
  ":",
  "example",
  ")",
  "# Move over any example from the type, into the attribute itself",
  "if",
  "(",
  "ex",
  "=",
  "description",
  "[",
  ":type",
  "]",
  ".",
  "delete",
  "(",
  ":example",
  ")",
  ")",
  "description",
  "[",
  ":example",
  "]",
  "=",
  "dump",
  "(",
  "ex",
  ")",
  "end",
  "description",
  "end"
] | 
	Options we don't want to expose when describing attributes | 
	[
  "Options",
  "we",
  "don",
  "t",
  "want",
  "to",
  "expose",
  "when",
  "describing",
  "attributes"
] | 
	faebaa0176086e1421cefc54a352d13a5b08d985 | 
	https://github.com/praxis/attributor/blob/faebaa0176086e1421cefc54a352d13a5b08d985/lib/attributor/attribute.rb#L97-L126 | 
| 155 | 
	praxis/attributor | 
	lib/attributor/attribute.rb | 
	Attributor.Attribute.validate | 
	def validate(object, context = Attributor::DEFAULT_ROOT_CONTEXT)
      raise "INVALID CONTEXT!! #{context}" unless context
      # Validate any requirements, absolute or conditional, and return.
      if object.nil? # == Attributor::UNSET
        # With no value, we can only validate whether that is acceptable or not and return.
        # Beyond that, no further validation should be done.
        return validate_missing_value(context)
      end
      # TODO: support validation for other types of conditional dependencies based on values of other attributes
      errors = validate_type(object, context)
      # End validation if we don't even have the proper type to begin with
      return errors if errors.any?
      if options[:values] && !options[:values].include?(object)
        errors << "Attribute #{Attributor.humanize_context(context)}: #{Attributor.errorize_value(object)} is not within the allowed values=#{options[:values].inspect} "
      end
      errors + type.validate(object, context, self)
    end | 
	ruby | 
	def validate(object, context = Attributor::DEFAULT_ROOT_CONTEXT)
      raise "INVALID CONTEXT!! #{context}" unless context
      # Validate any requirements, absolute or conditional, and return.
      if object.nil? # == Attributor::UNSET
        # With no value, we can only validate whether that is acceptable or not and return.
        # Beyond that, no further validation should be done.
        return validate_missing_value(context)
      end
      # TODO: support validation for other types of conditional dependencies based on values of other attributes
      errors = validate_type(object, context)
      # End validation if we don't even have the proper type to begin with
      return errors if errors.any?
      if options[:values] && !options[:values].include?(object)
        errors << "Attribute #{Attributor.humanize_context(context)}: #{Attributor.errorize_value(object)} is not within the allowed values=#{options[:values].inspect} "
      end
      errors + type.validate(object, context, self)
    end | 
	[
  "def",
  "validate",
  "(",
  "object",
  ",",
  "context",
  "=",
  "Attributor",
  "::",
  "DEFAULT_ROOT_CONTEXT",
  ")",
  "raise",
  "\"INVALID CONTEXT!! #{context}\"",
  "unless",
  "context",
  "# Validate any requirements, absolute or conditional, and return.",
  "if",
  "object",
  ".",
  "nil?",
  "# == Attributor::UNSET",
  "# With no value, we can only validate whether that is acceptable or not and return.",
  "# Beyond that, no further validation should be done.",
  "return",
  "validate_missing_value",
  "(",
  "context",
  ")",
  "end",
  "# TODO: support validation for other types of conditional dependencies based on values of other attributes",
  "errors",
  "=",
  "validate_type",
  "(",
  "object",
  ",",
  "context",
  ")",
  "# End validation if we don't even have the proper type to begin with",
  "return",
  "errors",
  "if",
  "errors",
  ".",
  "any?",
  "if",
  "options",
  "[",
  ":values",
  "]",
  "&&",
  "!",
  "options",
  "[",
  ":values",
  "]",
  ".",
  "include?",
  "(",
  "object",
  ")",
  "errors",
  "<<",
  "\"Attribute #{Attributor.humanize_context(context)}: #{Attributor.errorize_value(object)} is not within the allowed values=#{options[:values].inspect} \"",
  "end",
  "errors",
  "+",
  "type",
  ".",
  "validate",
  "(",
  "object",
  ",",
  "context",
  ",",
  "self",
  ")",
  "end"
] | 
	Validates stuff and checks dependencies | 
	[
  "Validates",
  "stuff",
  "and",
  "checks",
  "dependencies"
] | 
	faebaa0176086e1421cefc54a352d13a5b08d985 | 
	https://github.com/praxis/attributor/blob/faebaa0176086e1421cefc54a352d13a5b08d985/lib/attributor/attribute.rb#L180-L202 | 
| 156 | 
	cldwalker/boson-more | 
	lib/boson/pipes.rb | 
	Boson.Pipes.sort_pipe | 
	def sort_pipe(object, sort)
      sort_lambda = lambda {}
      if object[0].is_a?(Hash)
        if sort.to_s[/^\d+$/]
          sort = sort.to_i
        elsif object[0].keys.all? {|e| e.is_a?(Symbol) }
          sort = sort.to_sym
        end
        sort_lambda = untouched_sort?(object.map {|e| e[sort] }) ? lambda {|e| e[sort] } : lambda {|e| e[sort].to_s }
      else
        sort_lambda = untouched_sort?(object.map {|e| e.send(sort) }) ? lambda {|e| e.send(sort) || ''} :
          lambda {|e| e.send(sort).to_s }
      end
      object.sort_by &sort_lambda
    rescue NoMethodError, ArgumentError
      $stderr.puts "Sort failed with nonexistant method '#{sort}'"
    end | 
	ruby | 
	def sort_pipe(object, sort)
      sort_lambda = lambda {}
      if object[0].is_a?(Hash)
        if sort.to_s[/^\d+$/]
          sort = sort.to_i
        elsif object[0].keys.all? {|e| e.is_a?(Symbol) }
          sort = sort.to_sym
        end
        sort_lambda = untouched_sort?(object.map {|e| e[sort] }) ? lambda {|e| e[sort] } : lambda {|e| e[sort].to_s }
      else
        sort_lambda = untouched_sort?(object.map {|e| e.send(sort) }) ? lambda {|e| e.send(sort) || ''} :
          lambda {|e| e.send(sort).to_s }
      end
      object.sort_by &sort_lambda
    rescue NoMethodError, ArgumentError
      $stderr.puts "Sort failed with nonexistant method '#{sort}'"
    end | 
	[
  "def",
  "sort_pipe",
  "(",
  "object",
  ",",
  "sort",
  ")",
  "sort_lambda",
  "=",
  "lambda",
  "{",
  "}",
  "if",
  "object",
  "[",
  "0",
  "]",
  ".",
  "is_a?",
  "(",
  "Hash",
  ")",
  "if",
  "sort",
  ".",
  "to_s",
  "[",
  "/",
  "\\d",
  "/",
  "]",
  "sort",
  "=",
  "sort",
  ".",
  "to_i",
  "elsif",
  "object",
  "[",
  "0",
  "]",
  ".",
  "keys",
  ".",
  "all?",
  "{",
  "|",
  "e",
  "|",
  "e",
  ".",
  "is_a?",
  "(",
  "Symbol",
  ")",
  "}",
  "sort",
  "=",
  "sort",
  ".",
  "to_sym",
  "end",
  "sort_lambda",
  "=",
  "untouched_sort?",
  "(",
  "object",
  ".",
  "map",
  "{",
  "|",
  "e",
  "|",
  "e",
  "[",
  "sort",
  "]",
  "}",
  ")",
  "?",
  "lambda",
  "{",
  "|",
  "e",
  "|",
  "e",
  "[",
  "sort",
  "]",
  "}",
  ":",
  "lambda",
  "{",
  "|",
  "e",
  "|",
  "e",
  "[",
  "sort",
  "]",
  ".",
  "to_s",
  "}",
  "else",
  "sort_lambda",
  "=",
  "untouched_sort?",
  "(",
  "object",
  ".",
  "map",
  "{",
  "|",
  "e",
  "|",
  "e",
  ".",
  "send",
  "(",
  "sort",
  ")",
  "}",
  ")",
  "?",
  "lambda",
  "{",
  "|",
  "e",
  "|",
  "e",
  ".",
  "send",
  "(",
  "sort",
  ")",
  "||",
  "''",
  "}",
  ":",
  "lambda",
  "{",
  "|",
  "e",
  "|",
  "e",
  ".",
  "send",
  "(",
  "sort",
  ")",
  ".",
  "to_s",
  "}",
  "end",
  "object",
  ".",
  "sort_by",
  "sort_lambda",
  "rescue",
  "NoMethodError",
  ",",
  "ArgumentError",
  "$stderr",
  ".",
  "puts",
  "\"Sort failed with nonexistant method '#{sort}'\"",
  "end"
] | 
	Sorts an array of objects or hashes using a sort field. Sort is reversed with reverse_sort set to true. | 
	[
  "Sorts",
  "an",
  "array",
  "of",
  "objects",
  "or",
  "hashes",
  "using",
  "a",
  "sort",
  "field",
  ".",
  "Sort",
  "is",
  "reversed",
  "with",
  "reverse_sort",
  "set",
  "to",
  "true",
  "."
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/pipes.rb#L43-L59 | 
| 157 | 
	cldwalker/boson-more | 
	lib/boson/pipes.rb | 
	Boson.Pipes.pipes_pipe | 
	def pipes_pipe(obj, arr)
      arr.inject(obj) {|acc,e| Boson.full_invoke(e, [acc]) }
    end | 
	ruby | 
	def pipes_pipe(obj, arr)
      arr.inject(obj) {|acc,e| Boson.full_invoke(e, [acc]) }
    end | 
	[
  "def",
  "pipes_pipe",
  "(",
  "obj",
  ",",
  "arr",
  ")",
  "arr",
  ".",
  "inject",
  "(",
  "obj",
  ")",
  "{",
  "|",
  "acc",
  ",",
  "e",
  "|",
  "Boson",
  ".",
  "full_invoke",
  "(",
  "e",
  ",",
  "[",
  "acc",
  "]",
  ")",
  "}",
  "end"
] | 
	Pipes output of multiple commands recursively, given initial object | 
	[
  "Pipes",
  "output",
  "of",
  "multiple",
  "commands",
  "recursively",
  "given",
  "initial",
  "object"
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/pipes.rb#L71-L73 | 
| 158 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line.rb | 
	MiniReadline.Readline.readline | 
	def readline(options = {})
      suppress_warnings
      initialize_parms(options)
      MiniTerm.raw { @edit.edit_process }
    ensure
      restore_warnings
      puts
    end | 
	ruby | 
	def readline(options = {})
      suppress_warnings
      initialize_parms(options)
      MiniTerm.raw { @edit.edit_process }
    ensure
      restore_warnings
      puts
    end | 
	[
  "def",
  "readline",
  "(",
  "options",
  "=",
  "{",
  "}",
  ")",
  "suppress_warnings",
  "initialize_parms",
  "(",
  "options",
  ")",
  "MiniTerm",
  ".",
  "raw",
  "{",
  "@edit",
  ".",
  "edit_process",
  "}",
  "ensure",
  "restore_warnings",
  "puts",
  "end"
] | 
	Read a line from the console with edit and history. | 
	[
  "Read",
  "a",
  "line",
  "from",
  "the",
  "console",
  "with",
  "edit",
  "and",
  "history",
  "."
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line.rb#L34-L41 | 
| 159 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line.rb | 
	MiniReadline.Readline.set_options | 
	def set_options(options)
      @options = MiniReadline::BASE_OPTIONS
                   .merge(instance_options)
                   .merge(options)
      @options[:window_width] = MiniTerm.width - 1
      set_prompt(@options[:prompt])
      verify_mask(@options[:secret_mask])
    end | 
	ruby | 
	def set_options(options)
      @options = MiniReadline::BASE_OPTIONS
                   .merge(instance_options)
                   .merge(options)
      @options[:window_width] = MiniTerm.width - 1
      set_prompt(@options[:prompt])
      verify_mask(@options[:secret_mask])
    end | 
	[
  "def",
  "set_options",
  "(",
  "options",
  ")",
  "@options",
  "=",
  "MiniReadline",
  "::",
  "BASE_OPTIONS",
  ".",
  "merge",
  "(",
  "instance_options",
  ")",
  ".",
  "merge",
  "(",
  "options",
  ")",
  "@options",
  "[",
  ":window_width",
  "]",
  "=",
  "MiniTerm",
  ".",
  "width",
  "-",
  "1",
  "set_prompt",
  "(",
  "@options",
  "[",
  ":prompt",
  "]",
  ")",
  "verify_mask",
  "(",
  "@options",
  "[",
  ":secret_mask",
  "]",
  ")",
  "end"
] | 
	Set up the options | 
	[
  "Set",
  "up",
  "the",
  "options"
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line.rb#L55-L63 | 
| 160 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line.rb | 
	MiniReadline.Readline.set_prompt | 
	def set_prompt(prompt)
      @options[:base_prompt]   = Prompt.new(prompt)
      @options[:scroll_prompt] = Prompt.new(@options[:alt_prompt] || prompt)
      verify_prompt(@options[:base_prompt])
      verify_prompt(@options[:scroll_prompt])
    end | 
	ruby | 
	def set_prompt(prompt)
      @options[:base_prompt]   = Prompt.new(prompt)
      @options[:scroll_prompt] = Prompt.new(@options[:alt_prompt] || prompt)
      verify_prompt(@options[:base_prompt])
      verify_prompt(@options[:scroll_prompt])
    end | 
	[
  "def",
  "set_prompt",
  "(",
  "prompt",
  ")",
  "@options",
  "[",
  ":base_prompt",
  "]",
  "=",
  "Prompt",
  ".",
  "new",
  "(",
  "prompt",
  ")",
  "@options",
  "[",
  ":scroll_prompt",
  "]",
  "=",
  "Prompt",
  ".",
  "new",
  "(",
  "@options",
  "[",
  ":alt_prompt",
  "]",
  "||",
  "prompt",
  ")",
  "verify_prompt",
  "(",
  "@options",
  "[",
  ":base_prompt",
  "]",
  ")",
  "verify_prompt",
  "(",
  "@options",
  "[",
  ":scroll_prompt",
  "]",
  ")",
  "end"
] | 
	Set up the prompt. | 
	[
  "Set",
  "up",
  "the",
  "prompt",
  "."
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line.rb#L66-L72 | 
| 161 | 
	jomalley2112/hot_date_rails | 
	app/helpers/form_helper.rb | 
	FormHelper.ActionView::Helpers::FormTagHelper.hd_picker_tag | 
	def hd_picker_tag(field_name, value=nil, cls="datepicker", opts={}, locale_format=nil)
	  	draw_ext_input_tag(field_name, value, cls, locale_format, opts)
	  end | 
	ruby | 
	def hd_picker_tag(field_name, value=nil, cls="datepicker", opts={}, locale_format=nil)
	  	draw_ext_input_tag(field_name, value, cls, locale_format, opts)
	  end | 
	[
  "def",
  "hd_picker_tag",
  "(",
  "field_name",
  ",",
  "value",
  "=",
  "nil",
  ",",
  "cls",
  "=",
  "\"datepicker\"",
  ",",
  "opts",
  "=",
  "{",
  "}",
  ",",
  "locale_format",
  "=",
  "nil",
  ")",
  "draw_ext_input_tag",
  "(",
  "field_name",
  ",",
  "value",
  ",",
  "cls",
  ",",
  "locale_format",
  ",",
  "opts",
  ")",
  "end"
] | 
	for when there's no rails form object and you really just need inputs | 
	[
  "for",
  "when",
  "there",
  "s",
  "no",
  "rails",
  "form",
  "object",
  "and",
  "you",
  "really",
  "just",
  "need",
  "inputs"
] | 
	4580d2c2823ba472afca3d38f21b2f8acff954f2 | 
	https://github.com/jomalley2112/hot_date_rails/blob/4580d2c2823ba472afca3d38f21b2f8acff954f2/app/helpers/form_helper.rb#L5-L7 | 
| 162 | 
	ejlangev/citibike | 
	lib/citibike/api.rb | 
	Citibike.Api.distance_from | 
	def distance_from(lat, long)
      dLat = self.degrees_to_radians(lat - self.latitude)
      dLon = self.degrees_to_radians(long - self.longitude)
      lat1 = self.degrees_to_radians(lat)
      lat2 = self.degrees_to_radians(self.latitude)
      a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
          Math.sin(dLon / 2) * Math.sin(dLon / 2) *
          Math.cos(lat1) * Math.cos(lat2)
      c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
      EARTH_RADIUS * c
    end | 
	ruby | 
	def distance_from(lat, long)
      dLat = self.degrees_to_radians(lat - self.latitude)
      dLon = self.degrees_to_radians(long - self.longitude)
      lat1 = self.degrees_to_radians(lat)
      lat2 = self.degrees_to_radians(self.latitude)
      a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
          Math.sin(dLon / 2) * Math.sin(dLon / 2) *
          Math.cos(lat1) * Math.cos(lat2)
      c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
      EARTH_RADIUS * c
    end | 
	[
  "def",
  "distance_from",
  "(",
  "lat",
  ",",
  "long",
  ")",
  "dLat",
  "=",
  "self",
  ".",
  "degrees_to_radians",
  "(",
  "lat",
  "-",
  "self",
  ".",
  "latitude",
  ")",
  "dLon",
  "=",
  "self",
  ".",
  "degrees_to_radians",
  "(",
  "long",
  "-",
  "self",
  ".",
  "longitude",
  ")",
  "lat1",
  "=",
  "self",
  ".",
  "degrees_to_radians",
  "(",
  "lat",
  ")",
  "lat2",
  "=",
  "self",
  ".",
  "degrees_to_radians",
  "(",
  "self",
  ".",
  "latitude",
  ")",
  "a",
  "=",
  "Math",
  ".",
  "sin",
  "(",
  "dLat",
  "/",
  "2",
  ")",
  "*",
  "Math",
  ".",
  "sin",
  "(",
  "dLat",
  "/",
  "2",
  ")",
  "+",
  "Math",
  ".",
  "sin",
  "(",
  "dLon",
  "/",
  "2",
  ")",
  "*",
  "Math",
  ".",
  "sin",
  "(",
  "dLon",
  "/",
  "2",
  ")",
  "*",
  "Math",
  ".",
  "cos",
  "(",
  "lat1",
  ")",
  "*",
  "Math",
  ".",
  "cos",
  "(",
  "lat2",
  ")",
  "c",
  "=",
  "2",
  "*",
  "Math",
  ".",
  "atan2",
  "(",
  "Math",
  ".",
  "sqrt",
  "(",
  "a",
  ")",
  ",",
  "Math",
  ".",
  "sqrt",
  "(",
  "1",
  "-",
  "a",
  ")",
  ")",
  "EARTH_RADIUS",
  "*",
  "c",
  "end"
] | 
	Returns the distance this object is from the given
 latitude and longitude.  Distance is as the crow flies.
 @param  lat [Float] [A latitude position]
 @param  long [Float] [A longitude position]
 @return [Float] [Distance from the input postion in miles] | 
	[
  "Returns",
  "the",
  "distance",
  "this",
  "object",
  "is",
  "from",
  "the",
  "given",
  "latitude",
  "and",
  "longitude",
  ".",
  "Distance",
  "is",
  "as",
  "the",
  "crow",
  "flies",
  "."
] | 
	40ae300dacb299468985fa9c2fdf5dba7a235c93 | 
	https://github.com/ejlangev/citibike/blob/40ae300dacb299468985fa9c2fdf5dba7a235c93/lib/citibike/api.rb#L44-L58 | 
| 163 | 
	ejlangev/citibike | 
	lib/citibike/api.rb | 
	Citibike.Api.method_missing | 
	def method_missing(sym, *args, &block)
      if self.internal_object.key?(sym.to_s)
        return self.internal_object[sym.to_s]
      end
      super
    end | 
	ruby | 
	def method_missing(sym, *args, &block)
      if self.internal_object.key?(sym.to_s)
        return self.internal_object[sym.to_s]
      end
      super
    end | 
	[
  "def",
  "method_missing",
  "(",
  "sym",
  ",",
  "*",
  "args",
  ",",
  "&",
  "block",
  ")",
  "if",
  "self",
  ".",
  "internal_object",
  ".",
  "key?",
  "(",
  "sym",
  ".",
  "to_s",
  ")",
  "return",
  "self",
  ".",
  "internal_object",
  "[",
  "sym",
  ".",
  "to_s",
  "]",
  "end",
  "super",
  "end"
] | 
	Allow hash keys to be used as methods | 
	[
  "Allow",
  "hash",
  "keys",
  "to",
  "be",
  "used",
  "as",
  "methods"
] | 
	40ae300dacb299468985fa9c2fdf5dba7a235c93 | 
	https://github.com/ejlangev/citibike/blob/40ae300dacb299468985fa9c2fdf5dba7a235c93/lib/citibike/api.rb#L66-L72 | 
| 164 | 
	3scale/xcflushd | 
	lib/xcflushd/storage.rb | 
	Xcflushd.Storage.reports_to_flush | 
	def reports_to_flush
      # The Redis rename command overwrites the key with the new name if it
      # exists. This means that if the rename operation fails in a flush cycle,
      # and succeeds in a next one, the data that the key had in the first
      # flush cycle will be lost.
      # For that reason, every time we need to rename a key, we will use a
      # unique suffix. This way, when the rename operation fails, the key
      # will not be overwritten later, and we will be able to recover its
      # content.
      suffix = suffix_for_unique_naming
      report_keys = report_keys_to_flush(suffix)
      if report_keys.empty?
        logger.warn "No reports available to flush"
        report_keys
      else
        reports(report_keys, suffix)
      end
    end | 
	ruby | 
	def reports_to_flush
      # The Redis rename command overwrites the key with the new name if it
      # exists. This means that if the rename operation fails in a flush cycle,
      # and succeeds in a next one, the data that the key had in the first
      # flush cycle will be lost.
      # For that reason, every time we need to rename a key, we will use a
      # unique suffix. This way, when the rename operation fails, the key
      # will not be overwritten later, and we will be able to recover its
      # content.
      suffix = suffix_for_unique_naming
      report_keys = report_keys_to_flush(suffix)
      if report_keys.empty?
        logger.warn "No reports available to flush"
        report_keys
      else
        reports(report_keys, suffix)
      end
    end | 
	[
  "def",
  "reports_to_flush",
  "# The Redis rename command overwrites the key with the new name if it",
  "# exists. This means that if the rename operation fails in a flush cycle,",
  "# and succeeds in a next one, the data that the key had in the first",
  "# flush cycle will be lost.",
  "# For that reason, every time we need to rename a key, we will use a",
  "# unique suffix. This way, when the rename operation fails, the key",
  "# will not be overwritten later, and we will be able to recover its",
  "# content.",
  "suffix",
  "=",
  "suffix_for_unique_naming",
  "report_keys",
  "=",
  "report_keys_to_flush",
  "(",
  "suffix",
  ")",
  "if",
  "report_keys",
  ".",
  "empty?",
  "logger",
  ".",
  "warn",
  "\"No reports available to flush\"",
  "report_keys",
  "else",
  "reports",
  "(",
  "report_keys",
  ",",
  "suffix",
  ")",
  "end",
  "end"
] | 
	This performs a cleanup of the reports to be flushed.
 We can decide later whether it is better to leave this responsibility
 to the caller of the method.
 Returns an array of hashes where each of them has a service_id,
 credentials, and a usage. The usage is another hash where the keys are
 the metrics and the values are guaranteed to respond to to_i and to_s. | 
	[
  "This",
  "performs",
  "a",
  "cleanup",
  "of",
  "the",
  "reports",
  "to",
  "be",
  "flushed",
  ".",
  "We",
  "can",
  "decide",
  "later",
  "whether",
  "it",
  "is",
  "better",
  "to",
  "leave",
  "this",
  "responsibility",
  "to",
  "the",
  "caller",
  "of",
  "the",
  "method",
  "."
] | 
	ca29b7674c3cd952a2a50c0604a99f04662bf27d | 
	https://github.com/3scale/xcflushd/blob/ca29b7674c3cd952a2a50c0604a99f04662bf27d/lib/xcflushd/storage.rb#L53-L71 | 
| 165 | 
	pdobb/object_inspector | 
	lib/object_inspector/scope.rb | 
	ObjectInspector.Scope.join_name | 
	def join_name(parts,
                  separator: ObjectInspector.configuration.name_separator)
      the_parts = Array(parts).tap(&:compact!)
      the_parts.join(separator) if the_parts.any?
    end | 
	ruby | 
	def join_name(parts,
                  separator: ObjectInspector.configuration.name_separator)
      the_parts = Array(parts).tap(&:compact!)
      the_parts.join(separator) if the_parts.any?
    end | 
	[
  "def",
  "join_name",
  "(",
  "parts",
  ",",
  "separator",
  ":",
  "ObjectInspector",
  ".",
  "configuration",
  ".",
  "name_separator",
  ")",
  "the_parts",
  "=",
  "Array",
  "(",
  "parts",
  ")",
  ".",
  "tap",
  "(",
  ":compact!",
  ")",
  "the_parts",
  ".",
  "join",
  "(",
  "separator",
  ")",
  "if",
  "the_parts",
  ".",
  "any?",
  "end"
] | 
	Join the passed-in name parts with the passed in separator.
 @param parts [Array<#to_s>]
 @param separator [#to_s] (ObjectInspector.configuration.flags_separator) | 
	[
  "Join",
  "the",
  "passed",
  "-",
  "in",
  "name",
  "parts",
  "with",
  "the",
  "passed",
  "in",
  "separator",
  "."
] | 
	ce89add5055b195e3a024f3cc98c8fe5cc1d4d94 | 
	https://github.com/pdobb/object_inspector/blob/ce89add5055b195e3a024f3cc98c8fe5cc1d4d94/lib/object_inspector/scope.rb#L28-L32 | 
| 166 | 
	pdobb/object_inspector | 
	lib/object_inspector/scope.rb | 
	ObjectInspector.Scope.join_flags | 
	def join_flags(flags,
                   separator: ObjectInspector.configuration.flags_separator)
      the_flags = Array(flags).tap(&:compact!)
      the_flags.join(separator) if the_flags.any?
    end | 
	ruby | 
	def join_flags(flags,
                   separator: ObjectInspector.configuration.flags_separator)
      the_flags = Array(flags).tap(&:compact!)
      the_flags.join(separator) if the_flags.any?
    end | 
	[
  "def",
  "join_flags",
  "(",
  "flags",
  ",",
  "separator",
  ":",
  "ObjectInspector",
  ".",
  "configuration",
  ".",
  "flags_separator",
  ")",
  "the_flags",
  "=",
  "Array",
  "(",
  "flags",
  ")",
  ".",
  "tap",
  "(",
  ":compact!",
  ")",
  "the_flags",
  ".",
  "join",
  "(",
  "separator",
  ")",
  "if",
  "the_flags",
  ".",
  "any?",
  "end"
] | 
	Join the passed-in flags with the passed in separator.
 @param flags [Array<#to_s>]
 @param separator [#to_s] (ObjectInspector.configuration.flags_separator) | 
	[
  "Join",
  "the",
  "passed",
  "-",
  "in",
  "flags",
  "with",
  "the",
  "passed",
  "in",
  "separator",
  "."
] | 
	ce89add5055b195e3a024f3cc98c8fe5cc1d4d94 | 
	https://github.com/pdobb/object_inspector/blob/ce89add5055b195e3a024f3cc98c8fe5cc1d4d94/lib/object_inspector/scope.rb#L38-L42 | 
| 167 | 
	pdobb/object_inspector | 
	lib/object_inspector/scope.rb | 
	ObjectInspector.Scope.join_issues | 
	def join_issues(issues,
                    separator: ObjectInspector.configuration.issues_separator)
      the_issues = Array(issues).tap(&:compact!)
      the_issues.join(separator) if the_issues.any?
    end | 
	ruby | 
	def join_issues(issues,
                    separator: ObjectInspector.configuration.issues_separator)
      the_issues = Array(issues).tap(&:compact!)
      the_issues.join(separator) if the_issues.any?
    end | 
	[
  "def",
  "join_issues",
  "(",
  "issues",
  ",",
  "separator",
  ":",
  "ObjectInspector",
  ".",
  "configuration",
  ".",
  "issues_separator",
  ")",
  "the_issues",
  "=",
  "Array",
  "(",
  "issues",
  ")",
  ".",
  "tap",
  "(",
  ":compact!",
  ")",
  "the_issues",
  ".",
  "join",
  "(",
  "separator",
  ")",
  "if",
  "the_issues",
  ".",
  "any?",
  "end"
] | 
	Join the passed-in issues with the passed in separator.
 @param issues [Array<#to_s>]
 @param separator [#to_s] (ObjectInspector.configuration.issues_separator) | 
	[
  "Join",
  "the",
  "passed",
  "-",
  "in",
  "issues",
  "with",
  "the",
  "passed",
  "in",
  "separator",
  "."
] | 
	ce89add5055b195e3a024f3cc98c8fe5cc1d4d94 | 
	https://github.com/pdobb/object_inspector/blob/ce89add5055b195e3a024f3cc98c8fe5cc1d4d94/lib/object_inspector/scope.rb#L48-L52 | 
| 168 | 
	pdobb/object_inspector | 
	lib/object_inspector/scope.rb | 
	ObjectInspector.Scope.join_info | 
	def join_info(items,
                  separator: ObjectInspector.configuration.info_separator)
      the_items = Array(items).tap(&:compact!)
      the_items.join(separator) if the_items.any?
    end | 
	ruby | 
	def join_info(items,
                  separator: ObjectInspector.configuration.info_separator)
      the_items = Array(items).tap(&:compact!)
      the_items.join(separator) if the_items.any?
    end | 
	[
  "def",
  "join_info",
  "(",
  "items",
  ",",
  "separator",
  ":",
  "ObjectInspector",
  ".",
  "configuration",
  ".",
  "info_separator",
  ")",
  "the_items",
  "=",
  "Array",
  "(",
  "items",
  ")",
  ".",
  "tap",
  "(",
  ":compact!",
  ")",
  "the_items",
  ".",
  "join",
  "(",
  "separator",
  ")",
  "if",
  "the_items",
  ".",
  "any?",
  "end"
] | 
	Join the passed-in items with the passed in separator.
 @param items [Array<#to_s>]
 @param separator [#to_s] (ObjectInspector.configuration.info_separator) | 
	[
  "Join",
  "the",
  "passed",
  "-",
  "in",
  "items",
  "with",
  "the",
  "passed",
  "in",
  "separator",
  "."
] | 
	ce89add5055b195e3a024f3cc98c8fe5cc1d4d94 | 
	https://github.com/pdobb/object_inspector/blob/ce89add5055b195e3a024f3cc98c8fe5cc1d4d94/lib/object_inspector/scope.rb#L58-L62 | 
| 169 | 
	alexandre025/cdx | 
	lib/friendly_id/json_translate.rb | 
	FriendlyId.JsonTranslate.execute_with_locale | 
	def execute_with_locale(locale = ::I18n.locale, &block)
      actual_locale = ::I18n.locale
      ::I18n.locale = locale
      block.call
      ::I18n.locale = actual_locale
    end | 
	ruby | 
	def execute_with_locale(locale = ::I18n.locale, &block)
      actual_locale = ::I18n.locale
      ::I18n.locale = locale
      block.call
      ::I18n.locale = actual_locale
    end | 
	[
  "def",
  "execute_with_locale",
  "(",
  "locale",
  "=",
  "::",
  "I18n",
  ".",
  "locale",
  ",",
  "&",
  "block",
  ")",
  "actual_locale",
  "=",
  "::",
  "I18n",
  ".",
  "locale",
  "::",
  "I18n",
  ".",
  "locale",
  "=",
  "locale",
  "block",
  ".",
  "call",
  "::",
  "I18n",
  ".",
  "locale",
  "=",
  "actual_locale",
  "end"
] | 
	Auxiliar function to execute a block with other locale set | 
	[
  "Auxiliar",
  "function",
  "to",
  "execute",
  "a",
  "block",
  "with",
  "other",
  "locale",
  "set"
] | 
	a689edac06736978956a3d7b952eadab62c8691b | 
	https://github.com/alexandre025/cdx/blob/a689edac06736978956a3d7b952eadab62c8691b/lib/friendly_id/json_translate.rb#L66-L73 | 
| 170 | 
	brightbox/brightbox-cli | 
	lib/brightbox-cli/database_server.rb | 
	Brightbox.DatabaseServer.maintenance_window | 
	def maintenance_window
      return nil if maintenance_weekday.nil?
      weekday = Date::DAYNAMES[maintenance_weekday]
      sprintf("%s %02d:00 UTC", weekday, maintenance_hour)
    end | 
	ruby | 
	def maintenance_window
      return nil if maintenance_weekday.nil?
      weekday = Date::DAYNAMES[maintenance_weekday]
      sprintf("%s %02d:00 UTC", weekday, maintenance_hour)
    end | 
	[
  "def",
  "maintenance_window",
  "return",
  "nil",
  "if",
  "maintenance_weekday",
  ".",
  "nil?",
  "weekday",
  "=",
  "Date",
  "::",
  "DAYNAMES",
  "[",
  "maintenance_weekday",
  "]",
  "sprintf",
  "(",
  "\"%s %02d:00 UTC\"",
  ",",
  "weekday",
  ",",
  "maintenance_hour",
  ")",
  "end"
] | 
	A more humanised version of the maintenance window | 
	[
  "A",
  "more",
  "humanised",
  "version",
  "of",
  "the",
  "maintenance",
  "window"
] | 
	aba751383197e0484f75c504420ca0f355a57dc1 | 
	https://github.com/brightbox/brightbox-cli/blob/aba751383197e0484f75c504420ca0f355a57dc1/lib/brightbox-cli/database_server.rb#L100-L104 | 
| 171 | 
	sferik/mtgox | 
	lib/mtgox/client.rb | 
	MtGox.Client.ticker | 
	def ticker
      ticker = get('/api/1/BTCUSD/ticker')
      Ticker.instance.buy         = value_currency ticker['buy']
      Ticker.instance.high        = value_currency ticker['high']
      Ticker.instance.price       = value_currency ticker['last_all']
      Ticker.instance.low         = value_currency ticker['low']
      Ticker.instance.sell        = value_currency ticker['sell']
      Ticker.instance.volume      = value_bitcoin ticker['vol']
      Ticker.instance.vwap        = value_currency ticker['vwap']
      Ticker.instance.avg         = value_currency ticker['avg']
      Ticker.instance.last_local  = value_currency ticker['last_local']
      Ticker.instance
    end | 
	ruby | 
	def ticker
      ticker = get('/api/1/BTCUSD/ticker')
      Ticker.instance.buy         = value_currency ticker['buy']
      Ticker.instance.high        = value_currency ticker['high']
      Ticker.instance.price       = value_currency ticker['last_all']
      Ticker.instance.low         = value_currency ticker['low']
      Ticker.instance.sell        = value_currency ticker['sell']
      Ticker.instance.volume      = value_bitcoin ticker['vol']
      Ticker.instance.vwap        = value_currency ticker['vwap']
      Ticker.instance.avg         = value_currency ticker['avg']
      Ticker.instance.last_local  = value_currency ticker['last_local']
      Ticker.instance
    end | 
	[
  "def",
  "ticker",
  "ticker",
  "=",
  "get",
  "(",
  "'/api/1/BTCUSD/ticker'",
  ")",
  "Ticker",
  ".",
  "instance",
  ".",
  "buy",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'buy'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "high",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'high'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "price",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'last_all'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "low",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'low'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "sell",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'sell'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "volume",
  "=",
  "value_bitcoin",
  "ticker",
  "[",
  "'vol'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "vwap",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'vwap'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "avg",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'avg'",
  "]",
  "Ticker",
  ".",
  "instance",
  ".",
  "last_local",
  "=",
  "value_currency",
  "ticker",
  "[",
  "'last_local'",
  "]",
  "Ticker",
  ".",
  "instance",
  "end"
] | 
	Fetch the latest ticker data
 @authenticated false
 @return [MtGox::Ticker]
 @example
   MtGox.ticker | 
	[
  "Fetch",
  "the",
  "latest",
  "ticker",
  "data"
] | 
	031308d64fabbcdb0a745a866818fa9235830c51 | 
	https://github.com/sferik/mtgox/blob/031308d64fabbcdb0a745a866818fa9235830c51/lib/mtgox/client.rb#L55-L67 | 
| 172 | 
	sferik/mtgox | 
	lib/mtgox/client.rb | 
	MtGox.Client.offers | 
	def offers
      offers = get('/api/1/BTCUSD/depth/fetch')
      asks = offers['asks'].sort_by { |ask| ask['price_int'].to_i }.collect { |ask| Ask.new(self, ask) }
      bids = offers['bids'].sort_by { |bid| -bid['price_int'].to_i }.collect { |bid| Bid.new(self, bid) }
      {:asks => asks, :bids => bids}
    end | 
	ruby | 
	def offers
      offers = get('/api/1/BTCUSD/depth/fetch')
      asks = offers['asks'].sort_by { |ask| ask['price_int'].to_i }.collect { |ask| Ask.new(self, ask) }
      bids = offers['bids'].sort_by { |bid| -bid['price_int'].to_i }.collect { |bid| Bid.new(self, bid) }
      {:asks => asks, :bids => bids}
    end | 
	[
  "def",
  "offers",
  "offers",
  "=",
  "get",
  "(",
  "'/api/1/BTCUSD/depth/fetch'",
  ")",
  "asks",
  "=",
  "offers",
  "[",
  "'asks'",
  "]",
  ".",
  "sort_by",
  "{",
  "|",
  "ask",
  "|",
  "ask",
  "[",
  "'price_int'",
  "]",
  ".",
  "to_i",
  "}",
  ".",
  "collect",
  "{",
  "|",
  "ask",
  "|",
  "Ask",
  ".",
  "new",
  "(",
  "self",
  ",",
  "ask",
  ")",
  "}",
  "bids",
  "=",
  "offers",
  "[",
  "'bids'",
  "]",
  ".",
  "sort_by",
  "{",
  "|",
  "bid",
  "|",
  "-",
  "bid",
  "[",
  "'price_int'",
  "]",
  ".",
  "to_i",
  "}",
  ".",
  "collect",
  "{",
  "|",
  "bid",
  "|",
  "Bid",
  ".",
  "new",
  "(",
  "self",
  ",",
  "bid",
  ")",
  "}",
  "{",
  ":asks",
  "=>",
  "asks",
  ",",
  ":bids",
  "=>",
  "bids",
  "}",
  "end"
] | 
	Fetch both bids and asks in one call, for network efficiency
 @authenticated false
 @return [Hash] with keys :asks and :bids, which contain arrays as described in {MtGox::Client#asks} and {MtGox::Clients#bids}
 @example
   MtGox.offers | 
	[
  "Fetch",
  "both",
  "bids",
  "and",
  "asks",
  "in",
  "one",
  "call",
  "for",
  "network",
  "efficiency"
] | 
	031308d64fabbcdb0a745a866818fa9235830c51 | 
	https://github.com/sferik/mtgox/blob/031308d64fabbcdb0a745a866818fa9235830c51/lib/mtgox/client.rb#L88-L93 | 
| 173 | 
	sferik/mtgox | 
	lib/mtgox/client.rb | 
	MtGox.Client.trades | 
	def trades(opts = {})
      get('/api/1/BTCUSD/trades/fetch', opts).
        sort_by { |trade| trade['date'] }.collect do |trade|
        Trade.new(trade)
      end
    end | 
	ruby | 
	def trades(opts = {})
      get('/api/1/BTCUSD/trades/fetch', opts).
        sort_by { |trade| trade['date'] }.collect do |trade|
        Trade.new(trade)
      end
    end | 
	[
  "def",
  "trades",
  "(",
  "opts",
  "=",
  "{",
  "}",
  ")",
  "get",
  "(",
  "'/api/1/BTCUSD/trades/fetch'",
  ",",
  "opts",
  ")",
  ".",
  "sort_by",
  "{",
  "|",
  "trade",
  "|",
  "trade",
  "[",
  "'date'",
  "]",
  "}",
  ".",
  "collect",
  "do",
  "|",
  "trade",
  "|",
  "Trade",
  ".",
  "new",
  "(",
  "trade",
  ")",
  "end",
  "end"
] | 
	Fetch recent trades
 @authenticated false
 @return [Array<MtGox::Trade>] an array of trades, sorted in chronological order
 @example
   MtGox.trades
   MtGox.trades :since => 12341234 | 
	[
  "Fetch",
  "recent",
  "trades"
] | 
	031308d64fabbcdb0a745a866818fa9235830c51 | 
	https://github.com/sferik/mtgox/blob/031308d64fabbcdb0a745a866818fa9235830c51/lib/mtgox/client.rb#L142-L147 | 
| 174 | 
	sferik/mtgox | 
	lib/mtgox/client.rb | 
	MtGox.Client.order! | 
	def order!(type, amount, price)
      order = {:type => order_type(type), :amount_int => intify(amount, :btc)}
      order[:price_int] = intify(price, :usd) if price != :market
      post('/api/1/BTCUSD/order/add', order)
    end | 
	ruby | 
	def order!(type, amount, price)
      order = {:type => order_type(type), :amount_int => intify(amount, :btc)}
      order[:price_int] = intify(price, :usd) if price != :market
      post('/api/1/BTCUSD/order/add', order)
    end | 
	[
  "def",
  "order!",
  "(",
  "type",
  ",",
  "amount",
  ",",
  "price",
  ")",
  "order",
  "=",
  "{",
  ":type",
  "=>",
  "order_type",
  "(",
  "type",
  ")",
  ",",
  ":amount_int",
  "=>",
  "intify",
  "(",
  "amount",
  ",",
  ":btc",
  ")",
  "}",
  "order",
  "[",
  ":price_int",
  "]",
  "=",
  "intify",
  "(",
  "price",
  ",",
  ":usd",
  ")",
  "if",
  "price",
  "!=",
  ":market",
  "post",
  "(",
  "'/api/1/BTCUSD/order/add'",
  ",",
  "order",
  ")",
  "end"
] | 
	Create a new order
 @authenticated true
 @param type [String] the type of order to create, either "buy" or "sell"
 @param amount [Numberic] the number of bitcoins to buy/sell
 @param price [Numeric or Symbol] the bid/ask price in USD, or :market if placing a market order
 @return [String] order ID for the order, can be inspected using order_result
 @example
   # Sell one bitcoin for $123
   MtGox.add_order! :sell, 1.0, 123.0 | 
	[
  "Create",
  "a",
  "new",
  "order"
] | 
	031308d64fabbcdb0a745a866818fa9235830c51 | 
	https://github.com/sferik/mtgox/blob/031308d64fabbcdb0a745a866818fa9235830c51/lib/mtgox/client.rb#L235-L239 | 
| 175 | 
	sferik/mtgox | 
	lib/mtgox/client.rb | 
	MtGox.Client.withdraw! | 
	def withdraw!(amount, address)
      if amount >= 1000
        fail(FilthyRichError.new("#withdraw! take bitcoin amount as parameter (you are trying to withdraw #{amount} BTC"))
      else
        post('/api/1/generic/bitcoin/send_simple', :amount_int => intify(amount, :btc), :address => address)['trx']
      end
    end | 
	ruby | 
	def withdraw!(amount, address)
      if amount >= 1000
        fail(FilthyRichError.new("#withdraw! take bitcoin amount as parameter (you are trying to withdraw #{amount} BTC"))
      else
        post('/api/1/generic/bitcoin/send_simple', :amount_int => intify(amount, :btc), :address => address)['trx']
      end
    end | 
	[
  "def",
  "withdraw!",
  "(",
  "amount",
  ",",
  "address",
  ")",
  "if",
  "amount",
  ">=",
  "1000",
  "fail",
  "(",
  "FilthyRichError",
  ".",
  "new",
  "(",
  "\"#withdraw! take bitcoin amount as parameter (you are trying to withdraw #{amount} BTC\"",
  ")",
  ")",
  "else",
  "post",
  "(",
  "'/api/1/generic/bitcoin/send_simple'",
  ",",
  ":amount_int",
  "=>",
  "intify",
  "(",
  "amount",
  ",",
  ":btc",
  ")",
  ",",
  ":address",
  "=>",
  "address",
  ")",
  "[",
  "'trx'",
  "]",
  "end",
  "end"
] | 
	Transfer bitcoins from your Mt. Gox account into another account
 @authenticated true
 @param amount [Numeric] the number of bitcoins to withdraw
 @param address [String] the bitcoin address to send to
 @return [String] Completed Transaction ID
 @example
   # Withdraw 1 BTC from your account
   MtGox.withdraw! 1.0, '1KxSo9bGBfPVFEtWNLpnUK1bfLNNT4q31L' | 
	[
  "Transfer",
  "bitcoins",
  "from",
  "your",
  "Mt",
  ".",
  "Gox",
  "account",
  "into",
  "another",
  "account"
] | 
	031308d64fabbcdb0a745a866818fa9235830c51 | 
	https://github.com/sferik/mtgox/blob/031308d64fabbcdb0a745a866818fa9235830c51/lib/mtgox/client.rb#L284-L290 | 
| 176 | 
	cldwalker/boson-more | 
	lib/boson/pipe.rb | 
	Boson.Pipe.scientist_process | 
	def scientist_process(object, global_opt, env={})
      @env = env
      [:query, :sort, :reverse_sort].each {|e| global_opt.delete(e) } unless object.is_a?(Array)
      process_pipes(object, global_opt)
    end | 
	ruby | 
	def scientist_process(object, global_opt, env={})
      @env = env
      [:query, :sort, :reverse_sort].each {|e| global_opt.delete(e) } unless object.is_a?(Array)
      process_pipes(object, global_opt)
    end | 
	[
  "def",
  "scientist_process",
  "(",
  "object",
  ",",
  "global_opt",
  ",",
  "env",
  "=",
  "{",
  "}",
  ")",
  "@env",
  "=",
  "env",
  "[",
  ":query",
  ",",
  ":sort",
  ",",
  ":reverse_sort",
  "]",
  ".",
  "each",
  "{",
  "|",
  "e",
  "|",
  "global_opt",
  ".",
  "delete",
  "(",
  "e",
  ")",
  "}",
  "unless",
  "object",
  ".",
  "is_a?",
  "(",
  "Array",
  ")",
  "process_pipes",
  "(",
  "object",
  ",",
  "global_opt",
  ")",
  "end"
] | 
	Process pipes for Scientist | 
	[
  "Process",
  "pipes",
  "for",
  "Scientist"
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/pipe.rb#L77-L81 | 
| 177 | 
	cldwalker/boson-more | 
	lib/boson/pipe.rb | 
	Boson.Pipe.process_pipes | 
	def process_pipes(obj, options)
      internal_pipes(options).each {|pipe|
        obj = Pipes.send("#{pipe}_pipe", obj, options[pipe]) if options[pipe]
      }
      process_user_pipes(obj, options)
    end | 
	ruby | 
	def process_pipes(obj, options)
      internal_pipes(options).each {|pipe|
        obj = Pipes.send("#{pipe}_pipe", obj, options[pipe]) if options[pipe]
      }
      process_user_pipes(obj, options)
    end | 
	[
  "def",
  "process_pipes",
  "(",
  "obj",
  ",",
  "options",
  ")",
  "internal_pipes",
  "(",
  "options",
  ")",
  ".",
  "each",
  "{",
  "|",
  "pipe",
  "|",
  "obj",
  "=",
  "Pipes",
  ".",
  "send",
  "(",
  "\"#{pipe}_pipe\"",
  ",",
  "obj",
  ",",
  "options",
  "[",
  "pipe",
  "]",
  ")",
  "if",
  "options",
  "[",
  "pipe",
  "]",
  "}",
  "process_user_pipes",
  "(",
  "obj",
  ",",
  "options",
  ")",
  "end"
] | 
	Main method which processes all pipe commands, both default and user-defined ones. | 
	[
  "Main",
  "method",
  "which",
  "processes",
  "all",
  "pipe",
  "commands",
  "both",
  "default",
  "and",
  "user",
  "-",
  "defined",
  "ones",
  "."
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/pipe.rb#L84-L89 | 
| 178 | 
	cldwalker/boson-more | 
	lib/boson/pipe.rb | 
	Boson.Pipe.process_user_pipes | 
	def process_user_pipes(result, global_opt)
      pipes_to_process(global_opt).each {|e|
        args = [pipe(e)[:pipe], result]
        args << global_opt[e] unless pipe(e)[:type] == :boolean
        args << get_env(e, global_opt) if pipe(e)[:env]
        pipe_result = Boson.invoke(*args)
        result = pipe_result if pipe(e)[:filter]
      }
      result
    end | 
	ruby | 
	def process_user_pipes(result, global_opt)
      pipes_to_process(global_opt).each {|e|
        args = [pipe(e)[:pipe], result]
        args << global_opt[e] unless pipe(e)[:type] == :boolean
        args << get_env(e, global_opt) if pipe(e)[:env]
        pipe_result = Boson.invoke(*args)
        result = pipe_result if pipe(e)[:filter]
      }
      result
    end | 
	[
  "def",
  "process_user_pipes",
  "(",
  "result",
  ",",
  "global_opt",
  ")",
  "pipes_to_process",
  "(",
  "global_opt",
  ")",
  ".",
  "each",
  "{",
  "|",
  "e",
  "|",
  "args",
  "=",
  "[",
  "pipe",
  "(",
  "e",
  ")",
  "[",
  ":pipe",
  "]",
  ",",
  "result",
  "]",
  "args",
  "<<",
  "global_opt",
  "[",
  "e",
  "]",
  "unless",
  "pipe",
  "(",
  "e",
  ")",
  "[",
  ":type",
  "]",
  "==",
  ":boolean",
  "args",
  "<<",
  "get_env",
  "(",
  "e",
  ",",
  "global_opt",
  ")",
  "if",
  "pipe",
  "(",
  "e",
  ")",
  "[",
  ":env",
  "]",
  "pipe_result",
  "=",
  "Boson",
  ".",
  "invoke",
  "(",
  "args",
  ")",
  "result",
  "=",
  "pipe_result",
  "if",
  "pipe",
  "(",
  "e",
  ")",
  "[",
  ":filter",
  "]",
  "}",
  "result",
  "end"
] | 
	global_opt can come from Hirb callback or Scientist | 
	[
  "global_opt",
  "can",
  "come",
  "from",
  "Hirb",
  "callback",
  "or",
  "Scientist"
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/pipe.rb#L117-L126 | 
| 179 | 
	svoop/aixm | 
	lib/aixm/document.rb | 
	AIXM.Document.errors | 
	def errors
      xsd = Nokogiri::XML::Schema(File.open(AIXM.schema(:xsd)))
      xsd.validate(Nokogiri::XML(to_xml)).reject do |error|
        AIXM.config.ignored_errors && error.message.match?(AIXM.config.ignored_errors)
      end
    end | 
	ruby | 
	def errors
      xsd = Nokogiri::XML::Schema(File.open(AIXM.schema(:xsd)))
      xsd.validate(Nokogiri::XML(to_xml)).reject do |error|
        AIXM.config.ignored_errors && error.message.match?(AIXM.config.ignored_errors)
      end
    end | 
	[
  "def",
  "errors",
  "xsd",
  "=",
  "Nokogiri",
  "::",
  "XML",
  "::",
  "Schema",
  "(",
  "File",
  ".",
  "open",
  "(",
  "AIXM",
  ".",
  "schema",
  "(",
  ":xsd",
  ")",
  ")",
  ")",
  "xsd",
  ".",
  "validate",
  "(",
  "Nokogiri",
  "::",
  "XML",
  "(",
  "to_xml",
  ")",
  ")",
  ".",
  "reject",
  "do",
  "|",
  "error",
  "|",
  "AIXM",
  ".",
  "config",
  ".",
  "ignored_errors",
  "&&",
  "error",
  ".",
  "message",
  ".",
  "match?",
  "(",
  "AIXM",
  ".",
  "config",
  ".",
  "ignored_errors",
  ")",
  "end",
  "end"
] | 
	Validate the generated AIXM or OFMX atainst it's XSD and return the
 errors found.
 @return [Array<String>] validation errors | 
	[
  "Validate",
  "the",
  "generated",
  "AIXM",
  "or",
  "OFMX",
  "atainst",
  "it",
  "s",
  "XSD",
  "and",
  "return",
  "the",
  "errors",
  "found",
  "."
] | 
	4541e6543d4b6fcd023ef3cd2768946a29ec0b9e | 
	https://github.com/svoop/aixm/blob/4541e6543d4b6fcd023ef3cd2768946a29ec0b9e/lib/aixm/document.rb#L74-L79 | 
| 180 | 
	cldwalker/boson-more | 
	lib/boson/namespacer.rb | 
	Boson.Namespacer.full_invoke | 
	def full_invoke(cmd, args) #:nodoc:
      command, subcommand = cmd.include?(NAMESPACE) ? cmd.split(NAMESPACE, 2) : [cmd, nil]
      dispatcher = subcommand ? Boson.invoke(command) : Boson.main_object
      dispatcher.send(subcommand || command, *args)
    end | 
	ruby | 
	def full_invoke(cmd, args) #:nodoc:
      command, subcommand = cmd.include?(NAMESPACE) ? cmd.split(NAMESPACE, 2) : [cmd, nil]
      dispatcher = subcommand ? Boson.invoke(command) : Boson.main_object
      dispatcher.send(subcommand || command, *args)
    end | 
	[
  "def",
  "full_invoke",
  "(",
  "cmd",
  ",",
  "args",
  ")",
  "#:nodoc:",
  "command",
  ",",
  "subcommand",
  "=",
  "cmd",
  ".",
  "include?",
  "(",
  "NAMESPACE",
  ")",
  "?",
  "cmd",
  ".",
  "split",
  "(",
  "NAMESPACE",
  ",",
  "2",
  ")",
  ":",
  "[",
  "cmd",
  ",",
  "nil",
  "]",
  "dispatcher",
  "=",
  "subcommand",
  "?",
  "Boson",
  ".",
  "invoke",
  "(",
  "command",
  ")",
  ":",
  "Boson",
  ".",
  "main_object",
  "dispatcher",
  ".",
  "send",
  "(",
  "subcommand",
  "||",
  "command",
  ",",
  "args",
  ")",
  "end"
] | 
	Invoke command string even with namespaces | 
	[
  "Invoke",
  "command",
  "string",
  "even",
  "with",
  "namespaces"
] | 
	f928ebc18d8641e038891f78896ae7251b97415c | 
	https://github.com/cldwalker/boson-more/blob/f928ebc18d8641e038891f78896ae7251b97415c/lib/boson/namespacer.rb#L13-L17 | 
| 181 | 
	soffes/unmarkdown | 
	lib/unmarkdown/parser.rb | 
	Unmarkdown.Parser.parse_nodes | 
	def parse_nodes(nodes)
      output = ''
      # Short-circuit if it's empty
      return output if !nodes || nodes.empty?
      # Loop through nodes
      nodes.each do |node|
        case node.name
        when 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
          level = node.name.match(/\Ah(\d)\Z/)[1].to_i
          if @options[:underline_headers] && level < 3
            content = parse_content(node)
            output << content + "\n"
            character = level == 1 ? '=' : '-'
            content.length.times { output << character}
          else
            hashes = ''
            level.times { hashes << '#' }
            output << "#{hashes} #{parse_content(node)}"
          end
        when 'blockquote'
          parse_content(node).split("\n").each do |line|
            output << "> #{line}\n"
          end
        when 'ul', 'ol'
          output << "\n\n" if @list.count > 0
          if unordered = node.name == 'ul'
            @list << :unordered
          else
            @list << :ordered
            @list_position << 0
          end
          output << parse_nodes(node.children)
          @list.pop
          @list_position.pop unless unordered
        when 'li'
          (@list.count - 1).times { output << '    ' }
          if @list.last == :unordered
            output << "* #{parse_content(node)}"
          else
            num = (@list_position[@list_position.count - 1] += 1)
            output << "#{num}. #{parse_content(node)}"
          end
        when 'pre'
          content = parse_content(node)
          if @options[:fenced_code_blocks]
            output << "```\n#{content}\n```"
          else
            content.split("\n").each do |line|
              output << "    #{line}\n"
            end
          end
        when 'hr'
          output << "---\n\n"
        when 'a'
          output << "[#{parse_content(node)}](#{node['href']}#{build_title(node)})"
        when 'i', 'em'
          output << "*#{parse_content(node)}*"
        when 'b', 'strong'
          output << "**#{parse_content(node)}**"
        when 'u'
          output << "_#{parse_content(node)}_"
        when 'mark'
          output << "==#{parse_content(node)}=="
        when 'code'
          output << "`#{parse_content(node)}`"
        when 'img'
          output << "![#{node['alt']}](#{node['src']}#{build_title(node)})"
        when 'text'
          content = parse_content(node)
          # Optionally look for links
          content.gsub!(AUTOLINK_URL_REGEX, '<\1>') if @options[:autolink]
          content.gsub!(AUTOLINK_EMAIL_REGEX, '<\1>') if @options[:autolink]
          output << content
        when 'script'
          next unless @options[:allow_scripts]
          output << node.to_html
        else
          # If it's an supported node or a node that just contains text, just get
          # its content
          output << parse_content(node)
        end
        output << "\n\n" if BLOCK_ELEMENT_NAMES.include?(node.name)
      end
      output
    end | 
	ruby | 
	def parse_nodes(nodes)
      output = ''
      # Short-circuit if it's empty
      return output if !nodes || nodes.empty?
      # Loop through nodes
      nodes.each do |node|
        case node.name
        when 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
          level = node.name.match(/\Ah(\d)\Z/)[1].to_i
          if @options[:underline_headers] && level < 3
            content = parse_content(node)
            output << content + "\n"
            character = level == 1 ? '=' : '-'
            content.length.times { output << character}
          else
            hashes = ''
            level.times { hashes << '#' }
            output << "#{hashes} #{parse_content(node)}"
          end
        when 'blockquote'
          parse_content(node).split("\n").each do |line|
            output << "> #{line}\n"
          end
        when 'ul', 'ol'
          output << "\n\n" if @list.count > 0
          if unordered = node.name == 'ul'
            @list << :unordered
          else
            @list << :ordered
            @list_position << 0
          end
          output << parse_nodes(node.children)
          @list.pop
          @list_position.pop unless unordered
        when 'li'
          (@list.count - 1).times { output << '    ' }
          if @list.last == :unordered
            output << "* #{parse_content(node)}"
          else
            num = (@list_position[@list_position.count - 1] += 1)
            output << "#{num}. #{parse_content(node)}"
          end
        when 'pre'
          content = parse_content(node)
          if @options[:fenced_code_blocks]
            output << "```\n#{content}\n```"
          else
            content.split("\n").each do |line|
              output << "    #{line}\n"
            end
          end
        when 'hr'
          output << "---\n\n"
        when 'a'
          output << "[#{parse_content(node)}](#{node['href']}#{build_title(node)})"
        when 'i', 'em'
          output << "*#{parse_content(node)}*"
        when 'b', 'strong'
          output << "**#{parse_content(node)}**"
        when 'u'
          output << "_#{parse_content(node)}_"
        when 'mark'
          output << "==#{parse_content(node)}=="
        when 'code'
          output << "`#{parse_content(node)}`"
        when 'img'
          output << "![#{node['alt']}](#{node['src']}#{build_title(node)})"
        when 'text'
          content = parse_content(node)
          # Optionally look for links
          content.gsub!(AUTOLINK_URL_REGEX, '<\1>') if @options[:autolink]
          content.gsub!(AUTOLINK_EMAIL_REGEX, '<\1>') if @options[:autolink]
          output << content
        when 'script'
          next unless @options[:allow_scripts]
          output << node.to_html
        else
          # If it's an supported node or a node that just contains text, just get
          # its content
          output << parse_content(node)
        end
        output << "\n\n" if BLOCK_ELEMENT_NAMES.include?(node.name)
      end
      output
    end | 
	[
  "def",
  "parse_nodes",
  "(",
  "nodes",
  ")",
  "output",
  "=",
  "''",
  "# Short-circuit if it's empty",
  "return",
  "output",
  "if",
  "!",
  "nodes",
  "||",
  "nodes",
  ".",
  "empty?",
  "# Loop through nodes",
  "nodes",
  ".",
  "each",
  "do",
  "|",
  "node",
  "|",
  "case",
  "node",
  ".",
  "name",
  "when",
  "'h1'",
  ",",
  "'h2'",
  ",",
  "'h3'",
  ",",
  "'h4'",
  ",",
  "'h5'",
  ",",
  "'h6'",
  "level",
  "=",
  "node",
  ".",
  "name",
  ".",
  "match",
  "(",
  "/",
  "\\A",
  "\\d",
  "\\Z",
  "/",
  ")",
  "[",
  "1",
  "]",
  ".",
  "to_i",
  "if",
  "@options",
  "[",
  ":underline_headers",
  "]",
  "&&",
  "level",
  "<",
  "3",
  "content",
  "=",
  "parse_content",
  "(",
  "node",
  ")",
  "output",
  "<<",
  "content",
  "+",
  "\"\\n\"",
  "character",
  "=",
  "level",
  "==",
  "1",
  "?",
  "'='",
  ":",
  "'-'",
  "content",
  ".",
  "length",
  ".",
  "times",
  "{",
  "output",
  "<<",
  "character",
  "}",
  "else",
  "hashes",
  "=",
  "''",
  "level",
  ".",
  "times",
  "{",
  "hashes",
  "<<",
  "'#'",
  "}",
  "output",
  "<<",
  "\"#{hashes} #{parse_content(node)}\"",
  "end",
  "when",
  "'blockquote'",
  "parse_content",
  "(",
  "node",
  ")",
  ".",
  "split",
  "(",
  "\"\\n\"",
  ")",
  ".",
  "each",
  "do",
  "|",
  "line",
  "|",
  "output",
  "<<",
  "\"> #{line}\\n\"",
  "end",
  "when",
  "'ul'",
  ",",
  "'ol'",
  "output",
  "<<",
  "\"\\n\\n\"",
  "if",
  "@list",
  ".",
  "count",
  ">",
  "0",
  "if",
  "unordered",
  "=",
  "node",
  ".",
  "name",
  "==",
  "'ul'",
  "@list",
  "<<",
  ":unordered",
  "else",
  "@list",
  "<<",
  ":ordered",
  "@list_position",
  "<<",
  "0",
  "end",
  "output",
  "<<",
  "parse_nodes",
  "(",
  "node",
  ".",
  "children",
  ")",
  "@list",
  ".",
  "pop",
  "@list_position",
  ".",
  "pop",
  "unless",
  "unordered",
  "when",
  "'li'",
  "(",
  "@list",
  ".",
  "count",
  "-",
  "1",
  ")",
  ".",
  "times",
  "{",
  "output",
  "<<",
  "'    '",
  "}",
  "if",
  "@list",
  ".",
  "last",
  "==",
  ":unordered",
  "output",
  "<<",
  "\"* #{parse_content(node)}\"",
  "else",
  "num",
  "=",
  "(",
  "@list_position",
  "[",
  "@list_position",
  ".",
  "count",
  "-",
  "1",
  "]",
  "+=",
  "1",
  ")",
  "output",
  "<<",
  "\"#{num}. #{parse_content(node)}\"",
  "end",
  "when",
  "'pre'",
  "content",
  "=",
  "parse_content",
  "(",
  "node",
  ")",
  "if",
  "@options",
  "[",
  ":fenced_code_blocks",
  "]",
  "output",
  "<<",
  "\"```\\n#{content}\\n```\"",
  "else",
  "content",
  ".",
  "split",
  "(",
  "\"\\n\"",
  ")",
  ".",
  "each",
  "do",
  "|",
  "line",
  "|",
  "output",
  "<<",
  "\"    #{line}\\n\"",
  "end",
  "end",
  "when",
  "'hr'",
  "output",
  "<<",
  "\"---\\n\\n\"",
  "when",
  "'a'",
  "output",
  "<<",
  "\"[#{parse_content(node)}](#{node['href']}#{build_title(node)})\"",
  "when",
  "'i'",
  ",",
  "'em'",
  "output",
  "<<",
  "\"*#{parse_content(node)}*\"",
  "when",
  "'b'",
  ",",
  "'strong'",
  "output",
  "<<",
  "\"**#{parse_content(node)}**\"",
  "when",
  "'u'",
  "output",
  "<<",
  "\"_#{parse_content(node)}_\"",
  "when",
  "'mark'",
  "output",
  "<<",
  "\"==#{parse_content(node)}==\"",
  "when",
  "'code'",
  "output",
  "<<",
  "\"`#{parse_content(node)}`\"",
  "when",
  "'img'",
  "output",
  "<<",
  "\"![#{node['alt']}](#{node['src']}#{build_title(node)})\"",
  "when",
  "'text'",
  "content",
  "=",
  "parse_content",
  "(",
  "node",
  ")",
  "# Optionally look for links",
  "content",
  ".",
  "gsub!",
  "(",
  "AUTOLINK_URL_REGEX",
  ",",
  "'<\\1>'",
  ")",
  "if",
  "@options",
  "[",
  ":autolink",
  "]",
  "content",
  ".",
  "gsub!",
  "(",
  "AUTOLINK_EMAIL_REGEX",
  ",",
  "'<\\1>'",
  ")",
  "if",
  "@options",
  "[",
  ":autolink",
  "]",
  "output",
  "<<",
  "content",
  "when",
  "'script'",
  "next",
  "unless",
  "@options",
  "[",
  ":allow_scripts",
  "]",
  "output",
  "<<",
  "node",
  ".",
  "to_html",
  "else",
  "# If it's an supported node or a node that just contains text, just get",
  "# its content",
  "output",
  "<<",
  "parse_content",
  "(",
  "node",
  ")",
  "end",
  "output",
  "<<",
  "\"\\n\\n\"",
  "if",
  "BLOCK_ELEMENT_NAMES",
  ".",
  "include?",
  "(",
  "node",
  ".",
  "name",
  ")",
  "end",
  "output",
  "end"
] | 
	Parse the children of a node | 
	[
  "Parse",
  "the",
  "children",
  "of",
  "a",
  "node"
] | 
	5dac78bc785918e36568b23b087cccb90e288b53 | 
	https://github.com/soffes/unmarkdown/blob/5dac78bc785918e36568b23b087cccb90e288b53/lib/unmarkdown/parser.rb#L36-L130 | 
| 182 | 
	soffes/unmarkdown | 
	lib/unmarkdown/parser.rb | 
	Unmarkdown.Parser.parse_content | 
	def parse_content(node)
      content = if node.children.empty?
        node.content
      else
        parse_nodes(node.children)
      end
    end | 
	ruby | 
	def parse_content(node)
      content = if node.children.empty?
        node.content
      else
        parse_nodes(node.children)
      end
    end | 
	[
  "def",
  "parse_content",
  "(",
  "node",
  ")",
  "content",
  "=",
  "if",
  "node",
  ".",
  "children",
  ".",
  "empty?",
  "node",
  ".",
  "content",
  "else",
  "parse_nodes",
  "(",
  "node",
  ".",
  "children",
  ")",
  "end",
  "end"
] | 
	Get the content from a node | 
	[
  "Get",
  "the",
  "content",
  "from",
  "a",
  "node"
] | 
	5dac78bc785918e36568b23b087cccb90e288b53 | 
	https://github.com/soffes/unmarkdown/blob/5dac78bc785918e36568b23b087cccb90e288b53/lib/unmarkdown/parser.rb#L133-L139 | 
| 183 | 
	svoop/aixm | 
	lib/aixm/a.rb | 
	AIXM.A.invert | 
	def invert
      build(precision: precision, deg: (deg + 180) % 360, suffix: SUFFIX_INVERSIONS.fetch(suffix, suffix))
    end | 
	ruby | 
	def invert
      build(precision: precision, deg: (deg + 180) % 360, suffix: SUFFIX_INVERSIONS.fetch(suffix, suffix))
    end | 
	[
  "def",
  "invert",
  "build",
  "(",
  "precision",
  ":",
  "precision",
  ",",
  "deg",
  ":",
  "(",
  "deg",
  "+",
  "180",
  ")",
  "%",
  "360",
  ",",
  "suffix",
  ":",
  "SUFFIX_INVERSIONS",
  ".",
  "fetch",
  "(",
  "suffix",
  ",",
  "suffix",
  ")",
  ")",
  "end"
] | 
	Invert an angle by 180 degrees
 @example
   AIXM.a(120).invert     # => AIXM.a(300)
   AIXM.a("34L").invert   # => AIXM.a("16R")
   AIXM.a("33X").invert   # => AIXM.a("33X")
 @return [AIXM::A] inverted angle | 
	[
  "Invert",
  "an",
  "angle",
  "by",
  "180",
  "degrees"
] | 
	4541e6543d4b6fcd023ef3cd2768946a29ec0b9e | 
	https://github.com/svoop/aixm/blob/4541e6543d4b6fcd023ef3cd2768946a29ec0b9e/lib/aixm/a.rb#L90-L92 | 
| 184 | 
	3scale/xcflushd | 
	lib/xcflushd/flusher.rb | 
	Xcflushd.Flusher.async_authorization_tasks | 
	def async_authorization_tasks(reports)
      # Each call to authorizer.authorizations might need to contact 3scale
      # several times. The number of calls equals 1 + number of reported
      # metrics without limits.
      # This is probably good enough for now, but in the future we might want
      # to make sure that we perform concurrent calls to 3scale instead of
      # authorizer.authorizations.
      reports.map do |report|
        task = Concurrent::Future.new(executor: thread_pool) do
          authorizer.authorizations(report[:service_id],
                                    report[:credentials],
                                    report[:usage].keys)
        end
        [report, task]
      end.to_h
    end | 
	ruby | 
	def async_authorization_tasks(reports)
      # Each call to authorizer.authorizations might need to contact 3scale
      # several times. The number of calls equals 1 + number of reported
      # metrics without limits.
      # This is probably good enough for now, but in the future we might want
      # to make sure that we perform concurrent calls to 3scale instead of
      # authorizer.authorizations.
      reports.map do |report|
        task = Concurrent::Future.new(executor: thread_pool) do
          authorizer.authorizations(report[:service_id],
                                    report[:credentials],
                                    report[:usage].keys)
        end
        [report, task]
      end.to_h
    end | 
	[
  "def",
  "async_authorization_tasks",
  "(",
  "reports",
  ")",
  "# Each call to authorizer.authorizations might need to contact 3scale",
  "# several times. The number of calls equals 1 + number of reported",
  "# metrics without limits.",
  "# This is probably good enough for now, but in the future we might want",
  "# to make sure that we perform concurrent calls to 3scale instead of",
  "# authorizer.authorizations.",
  "reports",
  ".",
  "map",
  "do",
  "|",
  "report",
  "|",
  "task",
  "=",
  "Concurrent",
  "::",
  "Future",
  ".",
  "new",
  "(",
  "executor",
  ":",
  "thread_pool",
  ")",
  "do",
  "authorizer",
  ".",
  "authorizations",
  "(",
  "report",
  "[",
  ":service_id",
  "]",
  ",",
  "report",
  "[",
  ":credentials",
  "]",
  ",",
  "report",
  "[",
  ":usage",
  "]",
  ".",
  "keys",
  ")",
  "end",
  "[",
  "report",
  ",",
  "task",
  "]",
  "end",
  ".",
  "to_h",
  "end"
] | 
	Returns a Hash. The keys are the reports and the values their associated
 async authorization tasks. | 
	[
  "Returns",
  "a",
  "Hash",
  ".",
  "The",
  "keys",
  "are",
  "the",
  "reports",
  "and",
  "the",
  "values",
  "their",
  "associated",
  "async",
  "authorization",
  "tasks",
  "."
] | 
	ca29b7674c3cd952a2a50c0604a99f04662bf27d | 
	https://github.com/3scale/xcflushd/blob/ca29b7674c3cd952a2a50c0604a99f04662bf27d/lib/xcflushd/flusher.rb#L129-L144 | 
| 185 | 
	leandog/gametel | 
	lib/gametel/navigation.rb | 
	Gametel.Navigation.on | 
	def on(cls, &block)
      @current_screen = @current_page = cls.new
      waiting_for  = "#{cls} to be active"
      wait_until(10, waiting_for) { @current_screen.active? } if @current_screen.respond_to?(:active?)
      block.call @current_screen if block
      @current_screen
    end | 
	ruby | 
	def on(cls, &block)
      @current_screen = @current_page = cls.new
      waiting_for  = "#{cls} to be active"
      wait_until(10, waiting_for) { @current_screen.active? } if @current_screen.respond_to?(:active?)
      block.call @current_screen if block
      @current_screen
    end | 
	[
  "def",
  "on",
  "(",
  "cls",
  ",",
  "&",
  "block",
  ")",
  "@current_screen",
  "=",
  "@current_page",
  "=",
  "cls",
  ".",
  "new",
  "waiting_for",
  "=",
  "\"#{cls} to be active\"",
  "wait_until",
  "(",
  "10",
  ",",
  "waiting_for",
  ")",
  "{",
  "@current_screen",
  ".",
  "active?",
  "}",
  "if",
  "@current_screen",
  ".",
  "respond_to?",
  "(",
  ":active?",
  ")",
  "block",
  ".",
  "call",
  "@current_screen",
  "if",
  "block",
  "@current_screen",
  "end"
] | 
	create a new screen given a class name | 
	[
  "create",
  "a",
  "new",
  "screen",
  "given",
  "a",
  "class",
  "name"
] | 
	fc9468da9a443b5e6ac553b3e445333a0eabfc18 | 
	https://github.com/leandog/gametel/blob/fc9468da9a443b5e6ac553b3e445333a0eabfc18/lib/gametel/navigation.rb#L15-L21 | 
| 186 | 
	kaspermeyer/prawndown | 
	lib/prawndown.rb | 
	Prawndown.Interface.markdown | 
	def markdown(string, options = {})
      text Prawndown::Parser.new(string).to_prawn, options.merge(inline_format: true)
    end | 
	ruby | 
	def markdown(string, options = {})
      text Prawndown::Parser.new(string).to_prawn, options.merge(inline_format: true)
    end | 
	[
  "def",
  "markdown",
  "(",
  "string",
  ",",
  "options",
  "=",
  "{",
  "}",
  ")",
  "text",
  "Prawndown",
  "::",
  "Parser",
  ".",
  "new",
  "(",
  "string",
  ")",
  ".",
  "to_prawn",
  ",",
  "options",
  ".",
  "merge",
  "(",
  "inline_format",
  ":",
  "true",
  ")",
  "end"
] | 
	Renders Markdown in the current document
 It supports header 1-6, bold text, italic text, strikethrough and links
 It supports the same options as +Prawn::Document#text+
   Prawn::Document.generate('markdown.pdf') do
     markdown '# Welcome to Prawndown!'
     markdown '**Important:** We _hope_ you enjoy your stay!'
   end | 
	[
  "Renders",
  "Markdown",
  "in",
  "the",
  "current",
  "document"
] | 
	9d9f86f0a2c799a1dedd32a214427d06e1cf3488 | 
	https://github.com/kaspermeyer/prawndown/blob/9d9f86f0a2c799a1dedd32a214427d06e1cf3488/lib/prawndown.rb#L17-L19 | 
| 187 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line/edit.rb | 
	MiniReadline.Edit.edit_loop | 
	def edit_loop
      while @working
        @edit_window.sync_window(edit_buffer, edit_posn)
        @edit_window.sync_cursor(edit_posn)
        process_keystroke(MiniTerm.get_mapped_char)
      end
      edit_buffer
    end | 
	ruby | 
	def edit_loop
      while @working
        @edit_window.sync_window(edit_buffer, edit_posn)
        @edit_window.sync_cursor(edit_posn)
        process_keystroke(MiniTerm.get_mapped_char)
      end
      edit_buffer
    end | 
	[
  "def",
  "edit_loop",
  "while",
  "@working",
  "@edit_window",
  ".",
  "sync_window",
  "(",
  "edit_buffer",
  ",",
  "edit_posn",
  ")",
  "@edit_window",
  ".",
  "sync_cursor",
  "(",
  "edit_posn",
  ")",
  "process_keystroke",
  "(",
  "MiniTerm",
  ".",
  "get_mapped_char",
  ")",
  "end",
  "edit_buffer",
  "end"
] | 
	The line editor processing loop. | 
	[
  "The",
  "line",
  "editor",
  "processing",
  "loop",
  "."
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line/edit.rb#L68-L76 | 
| 188 | 
	PeterCamilleri/mini_readline | 
	lib/mini_readline/read_line/edit/word_right.rb | 
	MiniReadline.Edit.word_right | 
	def word_right(_keyboard_args)
      if @edit_posn < length
        right = @edit_buffer[(@edit_posn+1)..-1]
        @edit_posn = (posn = right.index(/\s\S/)) ? @edit_posn+posn+2 : length
      else
        MiniTerm.beep
      end
    end | 
	ruby | 
	def word_right(_keyboard_args)
      if @edit_posn < length
        right = @edit_buffer[(@edit_posn+1)..-1]
        @edit_posn = (posn = right.index(/\s\S/)) ? @edit_posn+posn+2 : length
      else
        MiniTerm.beep
      end
    end | 
	[
  "def",
  "word_right",
  "(",
  "_keyboard_args",
  ")",
  "if",
  "@edit_posn",
  "<",
  "length",
  "right",
  "=",
  "@edit_buffer",
  "[",
  "(",
  "@edit_posn",
  "+",
  "1",
  ")",
  "..",
  "-",
  "1",
  "]",
  "@edit_posn",
  "=",
  "(",
  "posn",
  "=",
  "right",
  ".",
  "index",
  "(",
  "/",
  "\\s",
  "\\S",
  "/",
  ")",
  ")",
  "?",
  "@edit_posn",
  "+",
  "posn",
  "+",
  "2",
  ":",
  "length",
  "else",
  "MiniTerm",
  ".",
  "beep",
  "end",
  "end"
] | 
	A little more to the right please! | 
	[
  "A",
  "little",
  "more",
  "to",
  "the",
  "right",
  "please!"
] | 
	45175ee01653a184b8ba04b2e8691dce5b26a1b5 | 
	https://github.com/PeterCamilleri/mini_readline/blob/45175ee01653a184b8ba04b2e8691dce5b26a1b5/lib/mini_readline/read_line/edit/word_right.rb#L10-L17 | 
| 189 | 
	phusion/union_station_hooks_core | 
	lib/union_station_hooks_core/request_reporter/view_rendering.rb | 
	UnionStationHooks.RequestReporter.log_view_rendering | 
	def log_view_rendering(options)
      return do_nothing_on_null(:log_view_rendering) if null?
      Utils.require_key(options, :name)
      Utils.require_key(options, :begin_time)
      Utils.require_key(options, :end_time)
      @transaction.log_activity(next_view_rendering_name,
        options[:begin_time], options[:end_time],
        options[:name], options[:has_error])
    end | 
	ruby | 
	def log_view_rendering(options)
      return do_nothing_on_null(:log_view_rendering) if null?
      Utils.require_key(options, :name)
      Utils.require_key(options, :begin_time)
      Utils.require_key(options, :end_time)
      @transaction.log_activity(next_view_rendering_name,
        options[:begin_time], options[:end_time],
        options[:name], options[:has_error])
    end | 
	[
  "def",
  "log_view_rendering",
  "(",
  "options",
  ")",
  "return",
  "do_nothing_on_null",
  "(",
  ":log_view_rendering",
  ")",
  "if",
  "null?",
  "Utils",
  ".",
  "require_key",
  "(",
  "options",
  ",",
  ":name",
  ")",
  "Utils",
  ".",
  "require_key",
  "(",
  "options",
  ",",
  ":begin_time",
  ")",
  "Utils",
  ".",
  "require_key",
  "(",
  "options",
  ",",
  ":end_time",
  ")",
  "@transaction",
  ".",
  "log_activity",
  "(",
  "next_view_rendering_name",
  ",",
  "options",
  "[",
  ":begin_time",
  "]",
  ",",
  "options",
  "[",
  ":end_time",
  "]",
  ",",
  "options",
  "[",
  ":name",
  "]",
  ",",
  "options",
  "[",
  ":has_error",
  "]",
  ")",
  "end"
] | 
	Logs timing information about the rendering of a single view, template or
 partial.
 Unlike {#log_view_rendering_block}, this form does not expect a block.
 However, you are expected to pass timing information to the options
 hash.
 The `union_station_hooks_rails` gem automatically calls
 {#log_view_rendering_block} for you if your application is a Rails app.
 It will call this on every view or partial rendering.
 @option options [String] :name Name of the view, template or partial
   that is being rendered.
 @option options [TimePoint or Time] :begin_time The time at which this
   view rendering begun. See {UnionStationHooks.now} to learn more.
 @option options [TimePoint or Time] :end_time The time at which this view
   rendering ended. See {UnionStationHooks.now} to learn more.
 @option options [Boolean] :has_error (optional) Whether an uncaught
   exception occurred during the view rendering. Default: false. | 
	[
  "Logs",
  "timing",
  "information",
  "about",
  "the",
  "rendering",
  "of",
  "a",
  "single",
  "view",
  "template",
  "or",
  "partial",
  "."
] | 
	e4b1797736a9b72a348db8e6d4ceebb62b30d478 | 
	https://github.com/phusion/union_station_hooks_core/blob/e4b1797736a9b72a348db8e6d4ceebb62b30d478/lib/union_station_hooks_core/request_reporter/view_rendering.rb#L72-L81 | 
| 190 | 
	pdobb/version_compare | 
	lib/version_compare/conversions.rb | 
	VersionCompare.Conversions.ComparableVersion | 
	def ComparableVersion(value)
      case value
      when String,
           Integer,
           Float,
           ->(val) { val.respond_to?(:to_ary) }
        ComparableVersion.new(value)
      when ->(val) { val.respond_to?(:to_comparable_version) }
        value.to_comparable_version
      else
        raise TypeError, "Cannot convert #{value.inspect} to ComparableVersion"
      end
    end | 
	ruby | 
	def ComparableVersion(value)
      case value
      when String,
           Integer,
           Float,
           ->(val) { val.respond_to?(:to_ary) }
        ComparableVersion.new(value)
      when ->(val) { val.respond_to?(:to_comparable_version) }
        value.to_comparable_version
      else
        raise TypeError, "Cannot convert #{value.inspect} to ComparableVersion"
      end
    end | 
	[
  "def",
  "ComparableVersion",
  "(",
  "value",
  ")",
  "case",
  "value",
  "when",
  "String",
  ",",
  "Integer",
  ",",
  "Float",
  ",",
  "->",
  "(",
  "val",
  ")",
  "{",
  "val",
  ".",
  "respond_to?",
  "(",
  ":to_ary",
  ")",
  "}",
  "ComparableVersion",
  ".",
  "new",
  "(",
  "value",
  ")",
  "when",
  "->",
  "(",
  "val",
  ")",
  "{",
  "val",
  ".",
  "respond_to?",
  "(",
  ":to_comparable_version",
  ")",
  "}",
  "value",
  ".",
  "to_comparable_version",
  "else",
  "raise",
  "TypeError",
  ",",
  "\"Cannot convert #{value.inspect} to ComparableVersion\"",
  "end",
  "end"
] | 
	Strict conversion method for creating a `ComparableVersion` object out of
 anything that can be interpreted is a ComparableVersion.
 @param [Object] value the object to be converted
 @example
   ComparableVersion(1)
   # => #<ComparableVersion @major=1, @minor=nil, @tiny=nil, @patch=nil>
   ComparableVersion(1.2)
   # => #<ComparableVersion @major=1, @minor=2, @tiny=nil, @patch=nil>
   ComparableVersion("1.2.3")
   # => #<ComparableVersion @major=1, @minor=2, @tiny=3, @patch=nil>
   ComparableVersion(["1", "2", "3", "4"])
   # => #<ComparableVersion @major=1, @minor=2, @tiny=3, @patch=4> | 
	[
  "Strict",
  "conversion",
  "method",
  "for",
  "creating",
  "a",
  "ComparableVersion",
  "object",
  "out",
  "of",
  "anything",
  "that",
  "can",
  "be",
  "interpreted",
  "is",
  "a",
  "ComparableVersion",
  "."
] | 
	3da53adbd2cf639c3bb248bb87f33c4bea83d704 | 
	https://github.com/pdobb/version_compare/blob/3da53adbd2cf639c3bb248bb87f33c4bea83d704/lib/version_compare/conversions.rb#L25-L37 | 
| 191 | 
	epuber-io/epuber | 
	lib/epuber/compiler.rb | 
	Epuber.Compiler.archive | 
	def archive(path = nil, configuration_suffix: nil)
      path ||= epub_name(configuration_suffix)
      epub_path = File.expand_path(path)
      Dir.chdir(@file_resolver.destination_path) do
        new_paths = @file_resolver.package_files.map(&:pkg_destination_path)
        if ::File.exists?(epub_path)
          Zip::File.open(epub_path, true) do |zip_file|
            old_paths = zip_file.instance_eval { @entry_set.entries.map(&:name) }
            diff = old_paths - new_paths
            diff.each do |file_to_remove|
              puts "DEBUG: removing file from result EPUB: #{file_to_remove}" if compilation_context.verbose?
              zip_file.remove(file_to_remove)
            end
          end
        end
        run_command(%(zip -q0X "#{epub_path}" mimetype))
        run_command(%(zip -qXr9D "#{epub_path}" "#{new_paths.join('" "')}" --exclude \\*.DS_Store))
      end
      path
    end | 
	ruby | 
	def archive(path = nil, configuration_suffix: nil)
      path ||= epub_name(configuration_suffix)
      epub_path = File.expand_path(path)
      Dir.chdir(@file_resolver.destination_path) do
        new_paths = @file_resolver.package_files.map(&:pkg_destination_path)
        if ::File.exists?(epub_path)
          Zip::File.open(epub_path, true) do |zip_file|
            old_paths = zip_file.instance_eval { @entry_set.entries.map(&:name) }
            diff = old_paths - new_paths
            diff.each do |file_to_remove|
              puts "DEBUG: removing file from result EPUB: #{file_to_remove}" if compilation_context.verbose?
              zip_file.remove(file_to_remove)
            end
          end
        end
        run_command(%(zip -q0X "#{epub_path}" mimetype))
        run_command(%(zip -qXr9D "#{epub_path}" "#{new_paths.join('" "')}" --exclude \\*.DS_Store))
      end
      path
    end | 
	[
  "def",
  "archive",
  "(",
  "path",
  "=",
  "nil",
  ",",
  "configuration_suffix",
  ":",
  "nil",
  ")",
  "path",
  "||=",
  "epub_name",
  "(",
  "configuration_suffix",
  ")",
  "epub_path",
  "=",
  "File",
  ".",
  "expand_path",
  "(",
  "path",
  ")",
  "Dir",
  ".",
  "chdir",
  "(",
  "@file_resolver",
  ".",
  "destination_path",
  ")",
  "do",
  "new_paths",
  "=",
  "@file_resolver",
  ".",
  "package_files",
  ".",
  "map",
  "(",
  ":pkg_destination_path",
  ")",
  "if",
  "::",
  "File",
  ".",
  "exists?",
  "(",
  "epub_path",
  ")",
  "Zip",
  "::",
  "File",
  ".",
  "open",
  "(",
  "epub_path",
  ",",
  "true",
  ")",
  "do",
  "|",
  "zip_file",
  "|",
  "old_paths",
  "=",
  "zip_file",
  ".",
  "instance_eval",
  "{",
  "@entry_set",
  ".",
  "entries",
  ".",
  "map",
  "(",
  ":name",
  ")",
  "}",
  "diff",
  "=",
  "old_paths",
  "-",
  "new_paths",
  "diff",
  ".",
  "each",
  "do",
  "|",
  "file_to_remove",
  "|",
  "puts",
  "\"DEBUG: removing file from result EPUB: #{file_to_remove}\"",
  "if",
  "compilation_context",
  ".",
  "verbose?",
  "zip_file",
  ".",
  "remove",
  "(",
  "file_to_remove",
  ")",
  "end",
  "end",
  "end",
  "run_command",
  "(",
  "%(zip -q0X \"#{epub_path}\" mimetype)",
  ")",
  "run_command",
  "(",
  "%(zip -qXr9D \"#{epub_path}\" \"#{new_paths.join('\" \"')}\" --exclude \\\\*.DS_Store)",
  ")",
  "end",
  "path",
  "end"
] | 
	Archives current target files to epub
 @param path [String] path to created archive
 @return [String] path | 
	[
  "Archives",
  "current",
  "target",
  "files",
  "to",
  "epub"
] | 
	4d736deb3f18c034fc93fcb95cfb9bf03b63c252 | 
	https://github.com/epuber-io/epuber/blob/4d736deb3f18c034fc93fcb95cfb9bf03b63c252/lib/epuber/compiler.rb#L112-L136 | 
| 192 | 
	epuber-io/epuber | 
	lib/epuber/compiler.rb | 
	Epuber.Compiler.epub_name | 
	def epub_name(configuration_suffix = nil)
      epub_name = if [email protected]_base_name.nil?
                    @book.output_base_name
                  elsif @book.from_file?
                    ::File.basename(@book.file_path, ::File.extname(@book.file_path))
                  else
                    @book.title
                  end
      epub_name += @book.build_version.to_s unless @book.build_version.nil?
      epub_name += "-#{@target.name}" if @target != @book.default_target
      epub_name += "-#{configuration_suffix}" unless configuration_suffix.nil?
      epub_name + '.epub'
    end | 
	ruby | 
	def epub_name(configuration_suffix = nil)
      epub_name = if [email protected]_base_name.nil?
                    @book.output_base_name
                  elsif @book.from_file?
                    ::File.basename(@book.file_path, ::File.extname(@book.file_path))
                  else
                    @book.title
                  end
      epub_name += @book.build_version.to_s unless @book.build_version.nil?
      epub_name += "-#{@target.name}" if @target != @book.default_target
      epub_name += "-#{configuration_suffix}" unless configuration_suffix.nil?
      epub_name + '.epub'
    end | 
	[
  "def",
  "epub_name",
  "(",
  "configuration_suffix",
  "=",
  "nil",
  ")",
  "epub_name",
  "=",
  "if",
  "!",
  "@book",
  ".",
  "output_base_name",
  ".",
  "nil?",
  "@book",
  ".",
  "output_base_name",
  "elsif",
  "@book",
  ".",
  "from_file?",
  "::",
  "File",
  ".",
  "basename",
  "(",
  "@book",
  ".",
  "file_path",
  ",",
  "::",
  "File",
  ".",
  "extname",
  "(",
  "@book",
  ".",
  "file_path",
  ")",
  ")",
  "else",
  "@book",
  ".",
  "title",
  "end",
  "epub_name",
  "+=",
  "@book",
  ".",
  "build_version",
  ".",
  "to_s",
  "unless",
  "@book",
  ".",
  "build_version",
  ".",
  "nil?",
  "epub_name",
  "+=",
  "\"-#{@target.name}\"",
  "if",
  "@target",
  "!=",
  "@book",
  ".",
  "default_target",
  "epub_name",
  "+=",
  "\"-#{configuration_suffix}\"",
  "unless",
  "configuration_suffix",
  ".",
  "nil?",
  "epub_name",
  "+",
  "'.epub'",
  "end"
] | 
	Creates name of epub file for current book and current target
 @return [String] name of result epub file | 
	[
  "Creates",
  "name",
  "of",
  "epub",
  "file",
  "for",
  "current",
  "book",
  "and",
  "current",
  "target"
] | 
	4d736deb3f18c034fc93fcb95cfb9bf03b63c252 | 
	https://github.com/epuber-io/epuber/blob/4d736deb3f18c034fc93fcb95cfb9bf03b63c252/lib/epuber/compiler.rb#L142-L155 | 
| 193 | 
	JonnieCache/tinyci | 
	lib/tinyci/scheduler.rb | 
	TinyCI.Scheduler.run_all_commits | 
	def run_all_commits
      commits = get_commits
      
      until commits.empty? do
        commits.each {|c| run_commit(c)}
        
        commits = get_commits
      end
    end | 
	ruby | 
	def run_all_commits
      commits = get_commits
      
      until commits.empty? do
        commits.each {|c| run_commit(c)}
        
        commits = get_commits
      end
    end | 
	[
  "def",
  "run_all_commits",
  "commits",
  "=",
  "get_commits",
  "until",
  "commits",
  ".",
  "empty?",
  "do",
  "commits",
  ".",
  "each",
  "{",
  "|",
  "c",
  "|",
  "run_commit",
  "(",
  "c",
  ")",
  "}",
  "commits",
  "=",
  "get_commits",
  "end",
  "end"
] | 
	Repeatedly gets the list of eligable commits and runs TinyCI against them until there are no more remaining | 
	[
  "Repeatedly",
  "gets",
  "the",
  "list",
  "of",
  "eligable",
  "commits",
  "and",
  "runs",
  "TinyCI",
  "against",
  "them",
  "until",
  "there",
  "are",
  "no",
  "more",
  "remaining"
] | 
	6dc23fc201f3527718afd814223eee0238ef8b06 | 
	https://github.com/JonnieCache/tinyci/blob/6dc23fc201f3527718afd814223eee0238ef8b06/lib/tinyci/scheduler.rb#L96-L104 | 
| 194 | 
	appoxy/simple_record | 
	lib/simple_record/results_array.rb | 
	SimpleRecord.ResultsArray.as_json | 
	def as_json(options = nil) #:nodoc:
            # use encoder as a proxy to call as_json on all elements, to protect from circular references
            encoder = options && options[:encoder] || ActiveSupport::JSON::Encoding::Encoder.new(options)
            map { |v| encoder.as_json(v) }
        end | 
	ruby | 
	def as_json(options = nil) #:nodoc:
            # use encoder as a proxy to call as_json on all elements, to protect from circular references
            encoder = options && options[:encoder] || ActiveSupport::JSON::Encoding::Encoder.new(options)
            map { |v| encoder.as_json(v) }
        end | 
	[
  "def",
  "as_json",
  "(",
  "options",
  "=",
  "nil",
  ")",
  "#:nodoc:",
  "# use encoder as a proxy to call as_json on all elements, to protect from circular references",
  "encoder",
  "=",
  "options",
  "&&",
  "options",
  "[",
  ":encoder",
  "]",
  "||",
  "ActiveSupport",
  "::",
  "JSON",
  "::",
  "Encoding",
  "::",
  "Encoder",
  ".",
  "new",
  "(",
  "options",
  ")",
  "map",
  "{",
  "|",
  "v",
  "|",
  "encoder",
  ".",
  "as_json",
  "(",
  "v",
  ")",
  "}",
  "end"
] | 
	A couple json serialization methods copied from active_support | 
	[
  "A",
  "couple",
  "json",
  "serialization",
  "methods",
  "copied",
  "from",
  "active_support"
] | 
	0252a022a938f368d6853ab1ae31f77f80b9f044 | 
	https://github.com/appoxy/simple_record/blob/0252a022a938f368d6853ab1ae31f77f80b9f044/lib/simple_record/results_array.rb#L219-L223 | 
| 195 | 
	talis/blueprint_rb | 
	lib/blueprint_ruby_client/api/assets_api.rb | 
	BlueprintClient.AssetsApi.add_asset_to_node | 
	def add_asset_to_node(namespace, type, id, asset_type, asset_id, opts = {})
      data, _status_code, _headers = add_asset_to_node_with_http_info(namespace, type, id, asset_type, asset_id, opts)
      return data
    end | 
	ruby | 
	def add_asset_to_node(namespace, type, id, asset_type, asset_id, opts = {})
      data, _status_code, _headers = add_asset_to_node_with_http_info(namespace, type, id, asset_type, asset_id, opts)
      return data
    end | 
	[
  "def",
  "add_asset_to_node",
  "(",
  "namespace",
  ",",
  "type",
  ",",
  "id",
  ",",
  "asset_type",
  ",",
  "asset_id",
  ",",
  "opts",
  "=",
  "{",
  "}",
  ")",
  "data",
  ",",
  "_status_code",
  ",",
  "_headers",
  "=",
  "add_asset_to_node_with_http_info",
  "(",
  "namespace",
  ",",
  "type",
  ",",
  "id",
  ",",
  "asset_type",
  ",",
  "asset_id",
  ",",
  "opts",
  ")",
  "return",
  "data",
  "end"
] | 
	Add an asset to the node.  Body must be empty.  Will upsert the asset if it doesn't exist
 @param namespace identifier namespacing the blueprint. It must start with a letter or underscore and can only be followed by letters, numbers and underscores.
 @param type subtype of Node, e.g. 'modules', 'departments', etc.
 @param id id identifying a domain model
 @param asset_type subtype of Asset, e.g. 'textbooks', 'digitisations', etc.
 @param asset_id id of an asset
 @param [Hash] opts the optional parameters
 @return [AssetBody] | 
	[
  "Add",
  "an",
  "asset",
  "to",
  "the",
  "node",
  ".",
  "Body",
  "must",
  "be",
  "empty",
  ".",
  "Will",
  "upsert",
  "the",
  "asset",
  "if",
  "it",
  "doesn",
  "t",
  "exist"
] | 
	0ded0734161d288ba2d81485b3d3ec82a4063e1e | 
	https://github.com/talis/blueprint_rb/blob/0ded0734161d288ba2d81485b3d3ec82a4063e1e/lib/blueprint_ruby_client/api/assets_api.rb#L32-L35 | 
| 196 | 
	talis/blueprint_rb | 
	lib/blueprint_ruby_client/api/assets_api.rb | 
	BlueprintClient.AssetsApi.delete_asset | 
	def delete_asset(namespace, asset_id, asset_type, opts = {})
      delete_asset_with_http_info(namespace, asset_id, asset_type, opts)
      return nil
    end | 
	ruby | 
	def delete_asset(namespace, asset_id, asset_type, opts = {})
      delete_asset_with_http_info(namespace, asset_id, asset_type, opts)
      return nil
    end | 
	[
  "def",
  "delete_asset",
  "(",
  "namespace",
  ",",
  "asset_id",
  ",",
  "asset_type",
  ",",
  "opts",
  "=",
  "{",
  "}",
  ")",
  "delete_asset_with_http_info",
  "(",
  "namespace",
  ",",
  "asset_id",
  ",",
  "asset_type",
  ",",
  "opts",
  ")",
  "return",
  "nil",
  "end"
] | 
	Delete an Asset
 @param namespace identifier namespacing the blueprint. It must start with a letter or underscore and can only be followed by letters, numbers and underscores.
 @param asset_id id of an asset
 @param asset_type subtype of Asset, e.g. 'textbooks', 'digitisations', etc.
 @param [Hash] opts the optional parameters
 @return [nil] | 
	[
  "Delete",
  "an",
  "Asset"
] | 
	0ded0734161d288ba2d81485b3d3ec82a4063e1e | 
	https://github.com/talis/blueprint_rb/blob/0ded0734161d288ba2d81485b3d3ec82a4063e1e/lib/blueprint_ruby_client/api/assets_api.rb#L135-L138 | 
| 197 | 
	talis/blueprint_rb | 
	lib/blueprint_ruby_client/api/assets_api.rb | 
	BlueprintClient.AssetsApi.get_asset | 
	def get_asset(namespace, asset_type, asset_id, opts = {})
      data, _status_code, _headers = get_asset_with_http_info(namespace, asset_type, asset_id, opts)
      return data
    end | 
	ruby | 
	def get_asset(namespace, asset_type, asset_id, opts = {})
      data, _status_code, _headers = get_asset_with_http_info(namespace, asset_type, asset_id, opts)
      return data
    end | 
	[
  "def",
  "get_asset",
  "(",
  "namespace",
  ",",
  "asset_type",
  ",",
  "asset_id",
  ",",
  "opts",
  "=",
  "{",
  "}",
  ")",
  "data",
  ",",
  "_status_code",
  ",",
  "_headers",
  "=",
  "get_asset_with_http_info",
  "(",
  "namespace",
  ",",
  "asset_type",
  ",",
  "asset_id",
  ",",
  "opts",
  ")",
  "return",
  "data",
  "end"
] | 
	Get details of a given asset
 @param namespace identifier namespacing the blueprint. It must start with a letter or underscore and can only be followed by letters, numbers and underscores.
 @param asset_type subtype of Asset, e.g. 'textbooks', 'digitisations', etc.
 @param asset_id id of an asset
 @param [Hash] opts the optional parameters
 @return [AssetBody] | 
	[
  "Get",
  "details",
  "of",
  "a",
  "given",
  "asset"
] | 
	0ded0734161d288ba2d81485b3d3ec82a4063e1e | 
	https://github.com/talis/blueprint_rb/blob/0ded0734161d288ba2d81485b3d3ec82a4063e1e/lib/blueprint_ruby_client/api/assets_api.rb#L283-L286 | 
| 198 | 
	talis/blueprint_rb | 
	lib/blueprint_ruby_client/api/assets_api.rb | 
	BlueprintClient.AssetsApi.get_assets_in_node | 
	def get_assets_in_node(namespace, type, id, opts = {})
      data, _status_code, _headers = get_assets_in_node_with_http_info(namespace, type, id, opts)
      return data
    end | 
	ruby | 
	def get_assets_in_node(namespace, type, id, opts = {})
      data, _status_code, _headers = get_assets_in_node_with_http_info(namespace, type, id, opts)
      return data
    end | 
	[
  "def",
  "get_assets_in_node",
  "(",
  "namespace",
  ",",
  "type",
  ",",
  "id",
  ",",
  "opts",
  "=",
  "{",
  "}",
  ")",
  "data",
  ",",
  "_status_code",
  ",",
  "_headers",
  "=",
  "get_assets_in_node_with_http_info",
  "(",
  "namespace",
  ",",
  "type",
  ",",
  "id",
  ",",
  "opts",
  ")",
  "return",
  "data",
  "end"
] | 
	Get for assets in the relevant node
 @param namespace identifier namespacing the blueprint. It must start with a letter or underscore and can only be followed by letters, numbers and underscores.
 @param type subtype of Node, e.g. 'modules', 'departments', etc.
 @param id id identifying a domain model
 @param [Hash] opts the optional parameters
 @option opts [Array<String>] :filter_asset_type type of asset to return. This filters the results by asset type, but returns all the assets associated with the result.
 @option opts [Float] :offset index to start result set from
 @option opts [Float] :limit number of records to return
 @return [AssetResultSet] | 
	[
  "Get",
  "for",
  "assets",
  "in",
  "the",
  "relevant",
  "node"
] | 
	0ded0734161d288ba2d81485b3d3ec82a4063e1e | 
	https://github.com/talis/blueprint_rb/blob/0ded0734161d288ba2d81485b3d3ec82a4063e1e/lib/blueprint_ruby_client/api/assets_api.rb#L371-L374 | 
| 199 | 
	talis/blueprint_rb | 
	lib/blueprint_ruby_client/api/assets_api.rb | 
	BlueprintClient.AssetsApi.remove_asset_from_node | 
	def remove_asset_from_node(namespace, type, id, asset_type, asset_id, opts = {})
      remove_asset_from_node_with_http_info(namespace, type, id, asset_type, asset_id, opts)
      return nil
    end | 
	ruby | 
	def remove_asset_from_node(namespace, type, id, asset_type, asset_id, opts = {})
      remove_asset_from_node_with_http_info(namespace, type, id, asset_type, asset_id, opts)
      return nil
    end | 
	[
  "def",
  "remove_asset_from_node",
  "(",
  "namespace",
  ",",
  "type",
  ",",
  "id",
  ",",
  "asset_type",
  ",",
  "asset_id",
  ",",
  "opts",
  "=",
  "{",
  "}",
  ")",
  "remove_asset_from_node_with_http_info",
  "(",
  "namespace",
  ",",
  "type",
  ",",
  "id",
  ",",
  "asset_type",
  ",",
  "asset_id",
  ",",
  "opts",
  ")",
  "return",
  "nil",
  "end"
] | 
	Remove an asset from the relevant node
 @param namespace identifier namespacing the blueprint. It must start with a letter or underscore and can only be followed by letters, numbers and underscores.
 @param type subtype of Node, e.g. 'modules', 'departments', etc.
 @param id id identifying a domain model
 @param asset_type subtype of Asset, e.g. 'textbooks', 'digitisations', etc.
 @param asset_id id of an asset
 @param [Hash] opts the optional parameters
 @return [nil] | 
	[
  "Remove",
  "an",
  "asset",
  "from",
  "the",
  "relevant",
  "node"
] | 
	0ded0734161d288ba2d81485b3d3ec82a4063e1e | 
	https://github.com/talis/blueprint_rb/blob/0ded0734161d288ba2d81485b3d3ec82a4063e1e/lib/blueprint_ruby_client/api/assets_api.rb#L482-L485 | 
			Subsets and Splits
				
	
				
			
				
No community queries yet
The top public SQL queries from the community will appear here once available.