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
18,500
sosedoff/goodreads
lib/goodreads/client/groups.rb
Goodreads.Groups.group
def group(group_id) data = request("/group/show", id: group_id) Hashie::Mash.new(data["group"]) end
ruby
def group(group_id) data = request("/group/show", id: group_id) Hashie::Mash.new(data["group"]) end
[ "def", "group", "(", "group_id", ")", "data", "=", "request", "(", "\"/group/show\"", ",", "id", ":", "group_id", ")", "Hashie", "::", "Mash", ".", "new", "(", "data", "[", "\"group\"", "]", ")", "end" ]
Get group details
[ "Get", "group", "details" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/groups.rb#L4-L7
18,501
sosedoff/goodreads
lib/goodreads/client/groups.rb
Goodreads.Groups.group_list
def group_list(user_id, sort = "my_activity") data = request("/group/list", id: user_id, sort: sort) Hashie::Mash.new(data["groups"]["list"]) end
ruby
def group_list(user_id, sort = "my_activity") data = request("/group/list", id: user_id, sort: sort) Hashie::Mash.new(data["groups"]["list"]) end
[ "def", "group_list", "(", "user_id", ",", "sort", "=", "\"my_activity\"", ")", "data", "=", "request", "(", "\"/group/list\"", ",", "id", ":", "user_id", ",", "sort", ":", "sort", ")", "Hashie", "::", "Mash", ".", "new", "(", "data", "[", "\"groups\"", ...
Get list of groups a given user is a member of
[ "Get", "list", "of", "groups", "a", "given", "user", "is", "a", "member", "of" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/groups.rb#L10-L13
18,502
sosedoff/goodreads
lib/goodreads/client/users.rb
Goodreads.Users.user
def user(id) data = request("/user/show", id: id) Hashie::Mash.new(data["user"]) end
ruby
def user(id) data = request("/user/show", id: id) Hashie::Mash.new(data["user"]) end
[ "def", "user", "(", "id", ")", "data", "=", "request", "(", "\"/user/show\"", ",", "id", ":", "id", ")", "Hashie", "::", "Mash", ".", "new", "(", "data", "[", "\"user\"", "]", ")", "end" ]
Get user details
[ "Get", "user", "details" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/users.rb#L5-L8
18,503
sosedoff/goodreads
lib/goodreads/client/friends.rb
Goodreads.Friends.friends
def friends(user_id, options={}) data = oauth_request("/friend/user/#{user_id}", options) Hashie::Mash.new(data["friends"]) end
ruby
def friends(user_id, options={}) data = oauth_request("/friend/user/#{user_id}", options) Hashie::Mash.new(data["friends"]) end
[ "def", "friends", "(", "user_id", ",", "options", "=", "{", "}", ")", "data", "=", "oauth_request", "(", "\"/friend/user/#{user_id}\"", ",", "options", ")", "Hashie", "::", "Mash", ".", "new", "(", "data", "[", "\"friends\"", "]", ")", "end" ]
Get the specified user's friends user_id - integer or string
[ "Get", "the", "specified", "user", "s", "friends" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/friends.rb#L7-L10
18,504
sosedoff/goodreads
lib/goodreads/client/reviews.rb
Goodreads.Reviews.recent_reviews
def recent_reviews(params = {}) skip_cropped = params.delete(:skip_cropped) || false data = request("/review/recent_reviews", params) return unless data["reviews"] && data["reviews"].key?("review") reviews = data["reviews"]["review"].map { |r| Hashie::Mash.new(r) } reviews = reviews.select...
ruby
def recent_reviews(params = {}) skip_cropped = params.delete(:skip_cropped) || false data = request("/review/recent_reviews", params) return unless data["reviews"] && data["reviews"].key?("review") reviews = data["reviews"]["review"].map { |r| Hashie::Mash.new(r) } reviews = reviews.select...
[ "def", "recent_reviews", "(", "params", "=", "{", "}", ")", "skip_cropped", "=", "params", ".", "delete", "(", ":skip_cropped", ")", "||", "false", "data", "=", "request", "(", "\"/review/recent_reviews\"", ",", "params", ")", "return", "unless", "data", "["...
Recent reviews from all members. params[:skip_cropped] - Select only non-cropped reviews
[ "Recent", "reviews", "from", "all", "members", "." ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/reviews.rb#L7-L14
18,505
sosedoff/goodreads
lib/goodreads/client/reviews.rb
Goodreads.Reviews.review
def review(id) data = request("/review/show", id: id) Hashie::Mash.new(data["review"]) end
ruby
def review(id) data = request("/review/show", id: id) Hashie::Mash.new(data["review"]) end
[ "def", "review", "(", "id", ")", "data", "=", "request", "(", "\"/review/show\"", ",", "id", ":", "id", ")", "Hashie", "::", "Mash", ".", "new", "(", "data", "[", "\"review\"", "]", ")", "end" ]
Get review details
[ "Get", "review", "details" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/reviews.rb#L18-L21
18,506
sosedoff/goodreads
lib/goodreads/client/reviews.rb
Goodreads.Reviews.reviews
def reviews(params = {}) data = request("/review/list", params.merge(v: "2")) reviews = data["reviews"]["review"] if reviews.present? reviews.map { |review| Hashie::Mash.new(review) } else [] end end
ruby
def reviews(params = {}) data = request("/review/list", params.merge(v: "2")) reviews = data["reviews"]["review"] if reviews.present? reviews.map { |review| Hashie::Mash.new(review) } else [] end end
[ "def", "reviews", "(", "params", "=", "{", "}", ")", "data", "=", "request", "(", "\"/review/list\"", ",", "params", ".", "merge", "(", "v", ":", "\"2\"", ")", ")", "reviews", "=", "data", "[", "\"reviews\"", "]", "[", "\"review\"", "]", "if", "revie...
Get list of reviews
[ "Get", "list", "of", "reviews" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/reviews.rb#L25-L33
18,507
sosedoff/goodreads
lib/goodreads/client/reviews.rb
Goodreads.Reviews.user_review
def user_review(user_id, book_id, params = {}) data = request('/review/show_by_user_and_book.xml', params.merge(v: "2", user_id: user_id, book_id: book_id)) Hashie::Mash.new(data["review"]) end
ruby
def user_review(user_id, book_id, params = {}) data = request('/review/show_by_user_and_book.xml', params.merge(v: "2", user_id: user_id, book_id: book_id)) Hashie::Mash.new(data["review"]) end
[ "def", "user_review", "(", "user_id", ",", "book_id", ",", "params", "=", "{", "}", ")", "data", "=", "request", "(", "'/review/show_by_user_and_book.xml'", ",", "params", ".", "merge", "(", "v", ":", "\"2\"", ",", "user_id", ":", "user_id", ",", "book_id"...
Get a user's review for a given book
[ "Get", "a", "user", "s", "review", "for", "a", "given", "book" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/reviews.rb#L36-L39
18,508
sosedoff/goodreads
lib/goodreads/client/reviews.rb
Goodreads.Reviews.create_review
def create_review(book_id, params = {}) params = params.merge(book_id: book_id, v: "2") params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time) params[:'review[review]'] = params.delete(:review) if params[:review] params[:'review[rating]'] = params.delete(:rati...
ruby
def create_review(book_id, params = {}) params = params.merge(book_id: book_id, v: "2") params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time) params[:'review[review]'] = params.delete(:review) if params[:review] params[:'review[rating]'] = params.delete(:rati...
[ "def", "create_review", "(", "book_id", ",", "params", "=", "{", "}", ")", "params", "=", "params", ".", "merge", "(", "book_id", ":", "book_id", ",", "v", ":", "\"2\"", ")", "params", "[", ":read_at", "]", "=", "params", "[", ":read_at", "]", ".", ...
Add review for a book Params can include :review, :rating, and :shelf review: text of the review (optional) rating: rating (0-5) (optional, default is 0 (no rating)) shelf: Name of shelf to add book to (optional, must exist, see: shelves.list) Note that Goodreads API documentation says that this endpoint accept...
[ "Add", "review", "for", "a", "book" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/reviews.rb#L51-L63
18,509
sosedoff/goodreads
lib/goodreads/client/reviews.rb
Goodreads.Reviews.edit_review
def edit_review(review_id, params = {}) params = params.merge(v: "2") params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time) params[:'review[review]'] = params.delete(:review) if params[:review] params[:'review[rating]'] = params.delete(:rating) if params[:rat...
ruby
def edit_review(review_id, params = {}) params = params.merge(v: "2") params[:read_at] = params[:read_at].strftime('%Y-%m-%d') if params[:read_at].is_a?(Time) params[:'review[review]'] = params.delete(:review) if params[:review] params[:'review[rating]'] = params.delete(:rating) if params[:rat...
[ "def", "edit_review", "(", "review_id", ",", "params", "=", "{", "}", ")", "params", "=", "params", ".", "merge", "(", "v", ":", "\"2\"", ")", "params", "[", ":read_at", "]", "=", "params", "[", ":read_at", "]", ".", "strftime", "(", "'%Y-%m-%d'", ")...
Edit review for a book Params can include :review, :rating, :read_at and :shelf, and :finished review: text of the review (optional) rating: rating (0-5) (optional, default is 0 (no rating)) shelf: Name of shelf to add book to (optional, must exist, see: shelves.list) read_at: Time object or String in YYYY-MM-DD...
[ "Edit", "review", "for", "a", "book" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/reviews.rb#L75-L89
18,510
sosedoff/goodreads
lib/goodreads/client/books.rb
Goodreads.Books.search_books
def search_books(query, params = {}) params[:q] = query.to_s.strip data = request("/search/index", params) Hashie::Mash.new(data["search"]) end
ruby
def search_books(query, params = {}) params[:q] = query.to_s.strip data = request("/search/index", params) Hashie::Mash.new(data["search"]) end
[ "def", "search_books", "(", "query", ",", "params", "=", "{", "}", ")", "params", "[", ":q", "]", "=", "query", ".", "to_s", ".", "strip", "data", "=", "request", "(", "\"/search/index\"", ",", "params", ")", "Hashie", "::", "Mash", ".", "new", "(", ...
Search for books query - Text to match against book title, author, and ISBN fields. options - Optional search parameters options[:page] - Which page to returns (default: 1) options[:field] - Search field. One of: title, author, or genre (default is all)
[ "Search", "for", "books" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/books.rb#L11-L15
18,511
sosedoff/goodreads
lib/goodreads/client/authors.rb
Goodreads.Authors.author
def author(id, params = {}) params[:id] = id data = request("/author/show", params) Hashie::Mash.new(data["author"]) end
ruby
def author(id, params = {}) params[:id] = id data = request("/author/show", params) Hashie::Mash.new(data["author"]) end
[ "def", "author", "(", "id", ",", "params", "=", "{", "}", ")", "params", "[", ":id", "]", "=", "id", "data", "=", "request", "(", "\"/author/show\"", ",", "params", ")", "Hashie", "::", "Mash", ".", "new", "(", "data", "[", "\"author\"", "]", ")", ...
Get author details
[ "Get", "author", "details" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/authors.rb#L5-L9
18,512
sosedoff/goodreads
lib/goodreads/client/authors.rb
Goodreads.Authors.author_by_name
def author_by_name(name, params = {}) params[:id] = name name_encoded = URI.encode(name) data = request("/api/author_url/#{name_encoded}", params) Hashie::Mash.new(data["author"]) end
ruby
def author_by_name(name, params = {}) params[:id] = name name_encoded = URI.encode(name) data = request("/api/author_url/#{name_encoded}", params) Hashie::Mash.new(data["author"]) end
[ "def", "author_by_name", "(", "name", ",", "params", "=", "{", "}", ")", "params", "[", ":id", "]", "=", "name", "name_encoded", "=", "URI", ".", "encode", "(", "name", ")", "data", "=", "request", "(", "\"/api/author_url/#{name_encoded}\"", ",", "params",...
Search for an author by name
[ "Search", "for", "an", "author", "by", "name" ]
aa571069ab07190c93b8a8aff77e1da2c79ab694
https://github.com/sosedoff/goodreads/blob/aa571069ab07190c93b8a8aff77e1da2c79ab694/lib/goodreads/client/authors.rb#L13-L18
18,513
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.insert
def insert(prev, protocol, options={}) klass = check_protocol(protocol) nxt = prev.body header = klass.new(options.merge!(packet: self)) add_header header, previous_header: prev idx = headers.index(prev) + 1 headers[idx, 0] = header header[:body] = nxt self end
ruby
def insert(prev, protocol, options={}) klass = check_protocol(protocol) nxt = prev.body header = klass.new(options.merge!(packet: self)) add_header header, previous_header: prev idx = headers.index(prev) + 1 headers[idx, 0] = header header[:body] = nxt self end
[ "def", "insert", "(", "prev", ",", "protocol", ",", "options", "=", "{", "}", ")", "klass", "=", "check_protocol", "(", "protocol", ")", "nxt", "=", "prev", ".", "body", "header", "=", "klass", ".", "new", "(", "options", ".", "merge!", "(", "packet"...
Insert a header in packet @param [Header] prev header after which insert new one @param [String] protocol protocol to insert @param [Hash] options protocol specific options @return [self] @raise [ArgumentError] unknown protocol
[ "Insert", "a", "header", "in", "packet" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L150-L160
18,514
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.encapsulate
def encapsulate(other, parsing: false) other.headers.each_with_index do |h, i| add_header h, parsing: (i > 0) || parsing end end
ruby
def encapsulate(other, parsing: false) other.headers.each_with_index do |h, i| add_header h, parsing: (i > 0) || parsing end end
[ "def", "encapsulate", "(", "other", ",", "parsing", ":", "false", ")", "other", ".", "headers", ".", "each_with_index", "do", "|", "h", ",", "i", "|", "add_header", "h", ",", "parsing", ":", "(", "i", ">", "0", ")", "||", "parsing", "end", "end" ]
Encapulate another packet in +self+ @param [Packet] other @param [Boolean] parsing set to +true+ to not update last current header field from binding with first other's one. Use only when current header field has its value set accordingly. @return [self] +self+ with new headers from +other+ @since 1.1.0
[ "Encapulate", "another", "packet", "in", "+", "self", "+" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L255-L259
18,515
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.decapsulate
def decapsulate(*hdrs) hdrs.each do |hdr| idx = headers.index(hdr) raise FormatError, 'header not in packet!' if idx.nil? prev_hdr = idx > 0 ? headers[idx - 1] : nil next_hdr = (idx + 1) < headers.size ? headers[idx + 1] : nil headers.delete_at(idx) add_header(next...
ruby
def decapsulate(*hdrs) hdrs.each do |hdr| idx = headers.index(hdr) raise FormatError, 'header not in packet!' if idx.nil? prev_hdr = idx > 0 ? headers[idx - 1] : nil next_hdr = (idx + 1) < headers.size ? headers[idx + 1] : nil headers.delete_at(idx) add_header(next...
[ "def", "decapsulate", "(", "*", "hdrs", ")", "hdrs", ".", "each", "do", "|", "hdr", "|", "idx", "=", "headers", ".", "index", "(", "hdr", ")", "raise", "FormatError", ",", "'header not in packet!'", "if", "idx", ".", "nil?", "prev_hdr", "=", "idx", ">"...
Remove headers from +self+ @param [Array<Header>] hdrs @return [self] +self+ with some headers removed @raise [FormatError] any headers not in +self+ @raise [FormatError] removed headers result in an unknown binding @since 1.1.0
[ "Remove", "headers", "from", "+", "self", "+" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L267-L279
18,516
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.parse
def parse(binary_str, first_header: nil) headers.clear if first_header.nil? # No decoding forced for first header. Have to guess it! first_header = guess_first_header(binary_str) if first_header.nil? raise ParseError, 'cannot identify first header in string' end ...
ruby
def parse(binary_str, first_header: nil) headers.clear if first_header.nil? # No decoding forced for first header. Have to guess it! first_header = guess_first_header(binary_str) if first_header.nil? raise ParseError, 'cannot identify first header in string' end ...
[ "def", "parse", "(", "binary_str", ",", "first_header", ":", "nil", ")", "headers", ".", "clear", "if", "first_header", ".", "nil?", "# No decoding forced for first header. Have to guess it!", "first_header", "=", "guess_first_header", "(", "binary_str", ")", "if", "f...
Parse a binary string and populate Packet from it. @param [String] binary_str @param [String,nil] first_header First protocol header. +nil+ means discover it! @return [Packet] self @raise [ArgumentError] +first_header+ is an unknown header
[ "Parse", "a", "binary", "string", "and", "populate", "Packet", "from", "it", "." ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L286-L303
18,517
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.inspect
def inspect str = Inspect.dashed_line(self.class) headers.each do |header| str << header.inspect end str << Inspect.inspect_body(body) end
ruby
def inspect str = Inspect.dashed_line(self.class) headers.each do |header| str << header.inspect end str << Inspect.inspect_body(body) end
[ "def", "inspect", "str", "=", "Inspect", ".", "dashed_line", "(", "self", ".", "class", ")", "headers", ".", "each", "do", "|", "header", "|", "str", "<<", "header", ".", "inspect", "end", "str", "<<", "Inspect", ".", "inspect_body", "(", "body", ")", ...
Get packet as a pretty formatted string. @return [String]
[ "Get", "packet", "as", "a", "pretty", "formatted", "string", "." ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L307-L313
18,518
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.check_protocol
def check_protocol(protocol) klass = Header.get_header_class_by_name(protocol) raise ArgumentError, "unknown #{protocol} protocol" if klass.nil? klass end
ruby
def check_protocol(protocol) klass = Header.get_header_class_by_name(protocol) raise ArgumentError, "unknown #{protocol} protocol" if klass.nil? klass end
[ "def", "check_protocol", "(", "protocol", ")", "klass", "=", "Header", ".", "get_header_class_by_name", "(", "protocol", ")", "raise", "ArgumentError", ",", "\"unknown #{protocol} protocol\"", "if", "klass", ".", "nil?", "klass", "end" ]
check if protocol is known @param [String] protocol @raise [ArgumentError] unknown protocol
[ "check", "if", "protocol", "is", "known" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L403-L408
18,519
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.add_header
def add_header(header, previous_header: nil, parsing: false) prev_header = previous_header || last_header if prev_header bindings = prev_header.class.known_headers[header.class] bindings = prev_header.class.known_headers[header.class.superclass] if bindings.nil? if bindings.nil? ...
ruby
def add_header(header, previous_header: nil, parsing: false) prev_header = previous_header || last_header if prev_header bindings = prev_header.class.known_headers[header.class] bindings = prev_header.class.known_headers[header.class.superclass] if bindings.nil? if bindings.nil? ...
[ "def", "add_header", "(", "header", ",", "previous_header", ":", "nil", ",", "parsing", ":", "false", ")", "prev_header", "=", "previous_header", "||", "last_header", "if", "prev_header", "bindings", "=", "prev_header", ".", "class", ".", "known_headers", "[", ...
Add a header to packet @param [Header::Base] header @param [Header::Base] previous_header @param [Boolean] parsing @return [void]
[ "Add", "a", "header", "to", "packet" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L415-L437
18,520
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.guess_first_header
def guess_first_header(binary_str) first_header = nil Header.all.each do |hklass| hdr = hklass.new(packet: self) # #read may return another object (more specific class) hdr = hdr.read(binary_str) # First header is found when, for one known header, # * +#parse?+ is tru...
ruby
def guess_first_header(binary_str) first_header = nil Header.all.each do |hklass| hdr = hklass.new(packet: self) # #read may return another object (more specific class) hdr = hdr.read(binary_str) # First header is found when, for one known header, # * +#parse?+ is tru...
[ "def", "guess_first_header", "(", "binary_str", ")", "first_header", "=", "nil", "Header", ".", "all", ".", "each", "do", "|", "hklass", "|", "hdr", "=", "hklass", ".", "new", "(", "packet", ":", "self", ")", "# #read may return another object (more specific cla...
Try to guess header from +binary_str+ @param [String] binary_str @return [String] header/protocol name
[ "Try", "to", "guess", "header", "from", "+", "binary_str", "+" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L450-L465
18,521
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.decode_bottom_up
def decode_bottom_up loop do last_known_hdr = last_header break if !last_known_hdr.respond_to?(:body) || last_known_hdr.body.empty? nh = search_upper_header(last_known_hdr) break if nh.nil? nheader = nh.new(packet: self) nheader = nheader.read(last_known_hdr.body)...
ruby
def decode_bottom_up loop do last_known_hdr = last_header break if !last_known_hdr.respond_to?(:body) || last_known_hdr.body.empty? nh = search_upper_header(last_known_hdr) break if nh.nil? nheader = nh.new(packet: self) nheader = nheader.read(last_known_hdr.body)...
[ "def", "decode_bottom_up", "loop", "do", "last_known_hdr", "=", "last_header", "break", "if", "!", "last_known_hdr", ".", "respond_to?", "(", ":body", ")", "||", "last_known_hdr", ".", "body", ".", "empty?", "nh", "=", "search_upper_header", "(", "last_known_hdr",...
Decode packet bottom up @return [void]
[ "Decode", "packet", "bottom", "up" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L469-L484
18,522
sdaubert/packetgen
lib/packetgen/packet.rb
PacketGen.Packet.search_upper_header
def search_upper_header(hdr) hdr.class.known_headers.each do |nh, bindings| return nh if bindings.check?(hdr) end nil end
ruby
def search_upper_header(hdr) hdr.class.known_headers.each do |nh, bindings| return nh if bindings.check?(hdr) end nil end
[ "def", "search_upper_header", "(", "hdr", ")", "hdr", ".", "class", ".", "known_headers", ".", "each", "do", "|", "nh", ",", "bindings", "|", "return", "nh", "if", "bindings", ".", "check?", "(", "hdr", ")", "end", "nil", "end" ]
Search a upper header for +hdr+ @param [Header::Base] hdr @return [void] @yieldparam [Header::Base] found upper header
[ "Search", "a", "upper", "header", "for", "+", "hdr", "+" ]
fd093a638d5b5dfe0440fa90fc75b5647f560be3
https://github.com/sdaubert/packetgen/blob/fd093a638d5b5dfe0440fa90fc75b5647f560be3/lib/packetgen/packet.rb#L490-L496
18,523
madzhuga/rails_workflow
app/models/rails_workflow/process_template.rb
RailsWorkflow.ProcessTemplate.dependent_operations
def dependent_operations(operation) operations.select do |top| top.dependencies.select do |dp| dp['id'] == operation.template.id && dp['statuses'].include?(operation.status) end.present? end end
ruby
def dependent_operations(operation) operations.select do |top| top.dependencies.select do |dp| dp['id'] == operation.template.id && dp['statuses'].include?(operation.status) end.present? end end
[ "def", "dependent_operations", "(", "operation", ")", "operations", ".", "select", "do", "|", "top", "|", "top", ".", "dependencies", ".", "select", "do", "|", "dp", "|", "dp", "[", "'id'", "]", "==", "operation", ".", "template", ".", "id", "&&", "dp"...
here we calculate template operations that depends on given process operation status and template id
[ "here", "we", "calculate", "template", "operations", "that", "depends", "on", "given", "process", "operation", "status", "and", "template", "id" ]
881ccbc4efd58b48a5125f3850ecccfc84490f94
https://github.com/madzhuga/rails_workflow/blob/881ccbc4efd58b48a5125f3850ecccfc84490f94/app/models/rails_workflow/process_template.rb#L32-L39
18,524
madzhuga/rails_workflow
lib/rails_workflow/error_builder.rb
RailsWorkflow.ErrorBuilder.target
def target @target ||= begin parent = context[:parent] if parent.is_a? RailsWorkflow::Operation parent.becomes(RailsWorkflow::Operation) elsif parent.is_a? RailsWorkflow::Process parent.becomes(RailsWorkflow::Process) end end end
ruby
def target @target ||= begin parent = context[:parent] if parent.is_a? RailsWorkflow::Operation parent.becomes(RailsWorkflow::Operation) elsif parent.is_a? RailsWorkflow::Process parent.becomes(RailsWorkflow::Process) end end end
[ "def", "target", "@target", "||=", "begin", "parent", "=", "context", "[", ":parent", "]", "if", "parent", ".", "is_a?", "RailsWorkflow", "::", "Operation", "parent", ".", "becomes", "(", "RailsWorkflow", "::", "Operation", ")", "elsif", "parent", ".", "is_a...
Changing custom process or operation classes to default classes. If we store error with a custom class and somebody will delete or rename this class - we will not be able to load error.
[ "Changing", "custom", "process", "or", "operation", "classes", "to", "default", "classes", ".", "If", "we", "store", "error", "with", "a", "custom", "class", "and", "somebody", "will", "delete", "or", "rename", "this", "class", "-", "we", "will", "not", "b...
881ccbc4efd58b48a5125f3850ecccfc84490f94
https://github.com/madzhuga/rails_workflow/blob/881ccbc4efd58b48a5125f3850ecccfc84490f94/lib/rails_workflow/error_builder.rb#L38-L47
18,525
buruzaemon/natto
lib/natto/struct.rb
Natto.MeCabStruct.method_missing
def method_missing(attr_name) member_sym = attr_name.id2name.to_sym self[member_sym] rescue ArgumentError # `member_sym` field doesn't exist. raise(NoMethodError.new("undefined method '#{attr_name}' for #{self}")) end
ruby
def method_missing(attr_name) member_sym = attr_name.id2name.to_sym self[member_sym] rescue ArgumentError # `member_sym` field doesn't exist. raise(NoMethodError.new("undefined method '#{attr_name}' for #{self}")) end
[ "def", "method_missing", "(", "attr_name", ")", "member_sym", "=", "attr_name", ".", "id2name", ".", "to_sym", "self", "[", "member_sym", "]", "rescue", "ArgumentError", "# `member_sym` field doesn't exist.", "raise", "(", "NoMethodError", ".", "new", "(", "\"undefi...
Provides accessor methods for the members of the MeCab struct. @param attr_name [String] attribute name @return member values for the MeCab struct @raise [NoMethodError] if `attr_name` is not a member of this MeCab struct
[ "Provides", "accessor", "methods", "for", "the", "members", "of", "the", "MeCab", "struct", "." ]
7801f1294dcda534b707024182a1b5743d0e41e8
https://github.com/buruzaemon/natto/blob/7801f1294dcda534b707024182a1b5743d0e41e8/lib/natto/struct.rb#L16-L21
18,526
buruzaemon/natto
lib/natto/natto.rb
Natto.MeCab.parse
def parse(text, constraints={}) if text.nil? raise ArgumentError.new 'Text to parse cannot be nil' elsif constraints[:boundary_constraints] if !(constraints[:boundary_constraints].is_a?(Regexp) || constraints[:boundary_constraints].is_a?(String)) raise ArgumentError.ne...
ruby
def parse(text, constraints={}) if text.nil? raise ArgumentError.new 'Text to parse cannot be nil' elsif constraints[:boundary_constraints] if !(constraints[:boundary_constraints].is_a?(Regexp) || constraints[:boundary_constraints].is_a?(String)) raise ArgumentError.ne...
[ "def", "parse", "(", "text", ",", "constraints", "=", "{", "}", ")", "if", "text", ".", "nil?", "raise", "ArgumentError", ".", "new", "'Text to parse cannot be nil'", "elsif", "constraints", "[", ":boundary_constraints", "]", "if", "!", "(", "constraints", "["...
Initializes the wrapped Tagger instance with the given `options`. Options supported are: - :rcfile -- resource file - :dicdir -- system dicdir - :userdic -- user dictionary - :lattice_level -- lattice information level (DEPRECATED) - :output_format_type -- output format type (wakati, chasen, yomi, etc.) -...
[ "Initializes", "the", "wrapped", "Tagger", "instance", "with", "the", "given", "options", "." ]
7801f1294dcda534b707024182a1b5743d0e41e8
https://github.com/buruzaemon/natto/blob/7801f1294dcda534b707024182a1b5743d0e41e8/lib/natto/natto.rb#L466-L485
18,527
flapjack/flapjack
lib/flapjack/utility.rb
Flapjack.Utility.truncate
def truncate(str, length, options = {}) text = str.dup options[:omission] ||= "..." length_with_room_for_omission = length - options[:omission].length stop = options[:separator] ? (text.rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission) : length...
ruby
def truncate(str, length, options = {}) text = str.dup options[:omission] ||= "..." length_with_room_for_omission = length - options[:omission].length stop = options[:separator] ? (text.rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission) : length...
[ "def", "truncate", "(", "str", ",", "length", ",", "options", "=", "{", "}", ")", "text", "=", "str", ".", "dup", "options", "[", ":omission", "]", "||=", "\"...\"", "length_with_room_for_omission", "=", "length", "-", "options", "[", ":omission", "]", "...
copied from ActiveSupport
[ "copied", "from", "ActiveSupport" ]
1f27caebf5a632510effb82cc72d62ddce4b9275
https://github.com/flapjack/flapjack/blob/1f27caebf5a632510effb82cc72d62ddce4b9275/lib/flapjack/utility.rb#L79-L88
18,528
flapjack/flapjack
lib/flapjack/notifier.rb
Flapjack.Notifier.process_notification
def process_notification(notification) Flapjack.logger.debug { "Processing notification: #{notification.inspect}" } check = notification.check check_name = check.name # TODO check whether time should come from something stored in the notification alerts = alerts_for(notification, ...
ruby
def process_notification(notification) Flapjack.logger.debug { "Processing notification: #{notification.inspect}" } check = notification.check check_name = check.name # TODO check whether time should come from something stored in the notification alerts = alerts_for(notification, ...
[ "def", "process_notification", "(", "notification", ")", "Flapjack", ".", "logger", ".", "debug", "{", "\"Processing notification: #{notification.inspect}\"", "}", "check", "=", "notification", ".", "check", "check_name", "=", "check", ".", "name", "# TODO check whether...
takes an event for which messages should be generated, works out the type of notification, updates the notification history in redis, generates the notifications
[ "takes", "an", "event", "for", "which", "messages", "should", "be", "generated", "works", "out", "the", "type", "of", "notification", "updates", "the", "notification", "history", "in", "redis", "generates", "the", "notifications" ]
1f27caebf5a632510effb82cc72d62ddce4b9275
https://github.com/flapjack/flapjack/blob/1f27caebf5a632510effb82cc72d62ddce4b9275/lib/flapjack/notifier.rb#L69-L99
18,529
flapjack/flapjack
lib/flapjack/coordinator.rb
Flapjack.Coordinator.setup_signals
def setup_signals Kernel.trap('INT') { Thread.new { @shutdown.call(Signal.list['INT']) }.join } Kernel.trap('TERM') { Thread.new { @shutdown.call(Signal.list['TERM']) }.join } unless RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin/i Kernel.trap('HUP') { Thread.new { @reload.call }.j...
ruby
def setup_signals Kernel.trap('INT') { Thread.new { @shutdown.call(Signal.list['INT']) }.join } Kernel.trap('TERM') { Thread.new { @shutdown.call(Signal.list['TERM']) }.join } unless RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin/i Kernel.trap('HUP') { Thread.new { @reload.call }.j...
[ "def", "setup_signals", "Kernel", ".", "trap", "(", "'INT'", ")", "{", "Thread", ".", "new", "{", "@shutdown", ".", "call", "(", "Signal", ".", "list", "[", "'INT'", "]", ")", "}", ".", "join", "}", "Kernel", ".", "trap", "(", "'TERM'", ")", "{", ...
the global nature of this seems at odds with it calling stop within a single coordinator instance. Coordinator is essentially a singleton anyway...
[ "the", "global", "nature", "of", "this", "seems", "at", "odds", "with", "it", "calling", "stop", "within", "a", "single", "coordinator", "instance", ".", "Coordinator", "is", "essentially", "a", "singleton", "anyway", "..." ]
1f27caebf5a632510effb82cc72d62ddce4b9275
https://github.com/flapjack/flapjack/blob/1f27caebf5a632510effb82cc72d62ddce4b9275/lib/flapjack/coordinator.rb#L114-L120
18,530
khipu/khipu-api-ruby-client
lib/khipu-api-client/models/base_object.rb
Khipu.BaseObject.build_from_hash
def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v...
ruby
def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v...
[ "def", "build_from_hash", "(", "attributes", ")", "return", "nil", "unless", "attributes", ".", "is_a?", "(", "Hash", ")", "self", ".", "class", ".", "swagger_types", ".", "each_pair", "do", "|", "key", ",", "type", "|", "if", "type", "=~", "/", "/i", ...
build the object from hash
[ "build", "the", "object", "from", "hash" ]
865af9e81c3b6e3b69205bbe7161806981a015e8
https://github.com/khipu/khipu-api-ruby-client/blob/865af9e81c3b6e3b69205bbe7161806981a015e8/lib/khipu-api-client/models/base_object.rb#L8-L25
18,531
khipu/khipu-api-ruby-client
lib/khipu-api-client/models/base_object.rb
Khipu.BaseObject.to_hash
def to_hash hash = {} attributes = self.class.attribute_map.sort_by {|key,value| key} attributes.each { |attr, param| value = self.send(attr) next if value.nil? if value.is_a?(Array) hash[param] = value.compact.map{ |v| _to_hash(v) } else hash[param]...
ruby
def to_hash hash = {} attributes = self.class.attribute_map.sort_by {|key,value| key} attributes.each { |attr, param| value = self.send(attr) next if value.nil? if value.is_a?(Array) hash[param] = value.compact.map{ |v| _to_hash(v) } else hash[param]...
[ "def", "to_hash", "hash", "=", "{", "}", "attributes", "=", "self", ".", "class", ".", "attribute_map", ".", "sort_by", "{", "|", "key", ",", "value", "|", "key", "}", "attributes", ".", "each", "{", "|", "attr", ",", "param", "|", "value", "=", "s...
return the object in the form of hash
[ "return", "the", "object", "in", "the", "form", "of", "hash" ]
865af9e81c3b6e3b69205bbe7161806981a015e8
https://github.com/khipu/khipu-api-ruby-client/blob/865af9e81c3b6e3b69205bbe7161806981a015e8/lib/khipu-api-client/models/base_object.rb#L61-L74
18,532
interagent/heroics
lib/heroics/cli.rb
Heroics.CLI.run
def run(*parameters) name = parameters.shift if name.nil? || name == 'help' if command_name = parameters.first command = @commands[command_name] command.usage else usage end else command = @commands[name] if command.nil? @...
ruby
def run(*parameters) name = parameters.shift if name.nil? || name == 'help' if command_name = parameters.first command = @commands[command_name] command.usage else usage end else command = @commands[name] if command.nil? @...
[ "def", "run", "(", "*", "parameters", ")", "name", "=", "parameters", ".", "shift", "if", "name", ".", "nil?", "||", "name", "==", "'help'", "if", "command_name", "=", "parameters", ".", "first", "command", "=", "@commands", "[", "command_name", "]", "co...
Instantiate a CLI for an API described by a JSON schema. @param name [String] The name of the CLI. @param schema [Schema] The JSON schema describing the API. @param client [Client] A client generated from the JSON schema. @param output [IO] The stream to write to. Run a command. @param parameters [Array] The pa...
[ "Instantiate", "a", "CLI", "for", "an", "API", "described", "by", "a", "JSON", "schema", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/cli.rb#L21-L38
18,533
interagent/heroics
lib/heroics/command.rb
Heroics.Command.run
def run(*parameters) resource_name = @link_schema.resource_name name = @link_schema.name result = @client.send(resource_name).send(name, *parameters) result = result.to_a if result.instance_of?(Enumerator) if result && !result.instance_of?(String) result = MultiJson.dump(result, pr...
ruby
def run(*parameters) resource_name = @link_schema.resource_name name = @link_schema.name result = @client.send(resource_name).send(name, *parameters) result = result.to_a if result.instance_of?(Enumerator) if result && !result.instance_of?(String) result = MultiJson.dump(result, pr...
[ "def", "run", "(", "*", "parameters", ")", "resource_name", "=", "@link_schema", ".", "resource_name", "name", "=", "@link_schema", ".", "name", "result", "=", "@client", ".", "send", "(", "resource_name", ")", ".", "send", "(", "name", ",", "parameters", ...
Run the command and write the results to the output stream. @param parameters [Array] The parameters to pass when making a request to run the command.
[ "Run", "the", "command", "and", "write", "the", "results", "to", "the", "output", "stream", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/command.rb#L57-L66
18,534
interagent/heroics
lib/heroics/link.rb
Heroics.Link.run
def run(*parameters) path, body = @link_schema.format_path(parameters) path = "#{@path_prefix}#{path}" unless @path_prefix == '/' headers = @default_headers if body case @link_schema.method when :put, :post, :patch headers = headers.merge({'Content-Type' => @link_schema...
ruby
def run(*parameters) path, body = @link_schema.format_path(parameters) path = "#{@path_prefix}#{path}" unless @path_prefix == '/' headers = @default_headers if body case @link_schema.method when :put, :post, :patch headers = headers.merge({'Content-Type' => @link_schema...
[ "def", "run", "(", "*", "parameters", ")", "path", ",", "body", "=", "@link_schema", ".", "format_path", "(", "parameters", ")", "path", "=", "\"#{@path_prefix}#{path}\"", "unless", "@path_prefix", "==", "'/'", "headers", "=", "@default_headers", "if", "body", ...
Instantiate a link. @param url [String] The URL to use when making requests. Include the username and password to use with HTTP basic auth. @param link_schema [LinkSchema] The schema for this link. @param options [Hash] Configuration for the link. Possible keys include: - default_headers: Optionally, a s...
[ "Instantiate", "a", "link", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/link.rb#L46-L100
18,535
interagent/heroics
lib/heroics/link.rb
Heroics.Link.unpack_url
def unpack_url(url) root_url = [] path_prefix = '' parts = URI.split(url) root_url << "#{parts[0]}://" root_url << "#{parts[1]}@" unless parts[1].nil? root_url << "#{parts[2]}" root_url << ":#{parts[3]}" unless parts[3].nil? path_prefix = parts[5] return root_url.jo...
ruby
def unpack_url(url) root_url = [] path_prefix = '' parts = URI.split(url) root_url << "#{parts[0]}://" root_url << "#{parts[1]}@" unless parts[1].nil? root_url << "#{parts[2]}" root_url << ":#{parts[3]}" unless parts[3].nil? path_prefix = parts[5] return root_url.jo...
[ "def", "unpack_url", "(", "url", ")", "root_url", "=", "[", "]", "path_prefix", "=", "''", "parts", "=", "URI", ".", "split", "(", "url", ")", "root_url", "<<", "\"#{parts[0]}://\"", "root_url", "<<", "\"#{parts[1]}@\"", "unless", "parts", "[", "1", "]", ...
Unpack the URL and split it into a root URL and a path prefix, if one exists. @param url [String] The complete base URL to use when making requests. @return [String,String] A (root URL, path) prefix pair.
[ "Unpack", "the", "URL", "and", "split", "it", "into", "a", "root", "URL", "and", "a", "path", "prefix", "if", "one", "exists", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/link.rb#L134-L144
18,536
interagent/heroics
lib/heroics/client.rb
Heroics.Client.method_missing
def method_missing(name) name = name.to_s resource = @resources[name] if resource.nil? # Find the name using the same ruby_name replacement semantics as when # we set up the @resources hash name = Heroics.ruby_name(name) resource = @resources[name] if resource.n...
ruby
def method_missing(name) name = name.to_s resource = @resources[name] if resource.nil? # Find the name using the same ruby_name replacement semantics as when # we set up the @resources hash name = Heroics.ruby_name(name) resource = @resources[name] if resource.n...
[ "def", "method_missing", "(", "name", ")", "name", "=", "name", ".", "to_s", "resource", "=", "@resources", "[", "name", "]", "if", "resource", ".", "nil?", "# Find the name using the same ruby_name replacement semantics as when", "# we set up the @resources hash", "name"...
Instantiate an HTTP client. @param resources [Hash<String,Resource>] A hash that maps method names to resources. @param url [String] The URL used by this client. Find a resource. @param name [String] The name of the resource to find. @raise [NoMethodError] Raised if the name doesn't match a known resource. @...
[ "Instantiate", "an", "HTTP", "client", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/client.rb#L21-L34
18,537
interagent/heroics
lib/heroics/resource.rb
Heroics.Resource.method_missing
def method_missing(name, *parameters) link = @links[name.to_s] if link.nil? address = "<#{self.class.name}:0x00#{(self.object_id << 1).to_s(16)}>" raise NoMethodError.new("undefined method `#{name}' for ##{address}") end link.run(*parameters) end
ruby
def method_missing(name, *parameters) link = @links[name.to_s] if link.nil? address = "<#{self.class.name}:0x00#{(self.object_id << 1).to_s(16)}>" raise NoMethodError.new("undefined method `#{name}' for ##{address}") end link.run(*parameters) end
[ "def", "method_missing", "(", "name", ",", "*", "parameters", ")", "link", "=", "@links", "[", "name", ".", "to_s", "]", "if", "link", ".", "nil?", "address", "=", "\"<#{self.class.name}:0x00#{(self.object_id << 1).to_s(16)}>\"", "raise", "NoMethodError", ".", "ne...
Find a link and invoke it. @param name [String] The name of the method to invoke. @param parameters [Array] The arguments to pass to the method. This should always be a `Hash` mapping parameter names to values. @raise [NoMethodError] Raised if the name doesn't match a known link. @return [String,Array,Hash] Th...
[ "Find", "a", "link", "and", "invoke", "it", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/resource.rb#L22-L29
18,538
interagent/heroics
lib/heroics/schema.rb
Heroics.Schema.resource
def resource(name) if @schema['definitions'].has_key?(name) ResourceSchema.new(@schema, name) else raise SchemaError.new("Unknown resource '#{name}'.") end end
ruby
def resource(name) if @schema['definitions'].has_key?(name) ResourceSchema.new(@schema, name) else raise SchemaError.new("Unknown resource '#{name}'.") end end
[ "def", "resource", "(", "name", ")", "if", "@schema", "[", "'definitions'", "]", ".", "has_key?", "(", "name", ")", "ResourceSchema", ".", "new", "(", "@schema", ",", "name", ")", "else", "raise", "SchemaError", ".", "new", "(", "\"Unknown resource '#{name}'...
Get a schema for a named resource. @param name [String] The name of the resource. @raise [SchemaError] Raised if an unknown resource name is provided.
[ "Get", "a", "schema", "for", "a", "named", "resource", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L27-L33
18,539
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.example_body
def example_body if body_schema = link_schema['schema'] definitions = @schema['definitions'][@resource_name]['definitions'] Hash[body_schema['properties'].keys.map do |property| # FIXME This is wrong! -jkakar if definitions.has_key?(property) example = definitions[p...
ruby
def example_body if body_schema = link_schema['schema'] definitions = @schema['definitions'][@resource_name]['definitions'] Hash[body_schema['properties'].keys.map do |property| # FIXME This is wrong! -jkakar if definitions.has_key?(property) example = definitions[p...
[ "def", "example_body", "if", "body_schema", "=", "link_schema", "[", "'schema'", "]", "definitions", "=", "@schema", "[", "'definitions'", "]", "[", "@resource_name", "]", "[", "'definitions'", "]", "Hash", "[", "body_schema", "[", "'properties'", "]", ".", "k...
Get an example request body. @return [Hash] A sample request body.
[ "Get", "an", "example", "request", "body", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L181-L194
18,540
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.format_path
def format_path(parameters) path = link_schema['href'] parameter_size = path.scan(PARAMETER_REGEX).size too_few_parameters = parameter_size > parameters.size # FIXME We should use the schema to detect when a request body is # permitted and do the calculation correctly here. -jkakar t...
ruby
def format_path(parameters) path = link_schema['href'] parameter_size = path.scan(PARAMETER_REGEX).size too_few_parameters = parameter_size > parameters.size # FIXME We should use the schema to detect when a request body is # permitted and do the calculation correctly here. -jkakar t...
[ "def", "format_path", "(", "parameters", ")", "path", "=", "link_schema", "[", "'href'", "]", "parameter_size", "=", "path", ".", "scan", "(", "PARAMETER_REGEX", ")", ".", "size", "too_few_parameters", "=", "parameter_size", ">", "parameters", ".", "size", "# ...
Inject parameters into the link href and return the body, if it exists. @param parameters [Array] The list of parameters to inject into the path. @raise [ArgumentError] Raised if either too many or too few parameters were provided. @return [String,Object] A path and request body pair. The body value is ni...
[ "Inject", "parameters", "into", "the", "link", "href", "and", "return", "the", "body", "if", "it", "exists", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L204-L221
18,541
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.resolve_parameters
def resolve_parameters(parameters) properties = @schema['definitions'][@resource_name]['properties'] return [''] if properties.nil? definitions = Hash[properties.each_pair.map do |key, value| [value['$ref'], key] end] parameters.map do |paramet...
ruby
def resolve_parameters(parameters) properties = @schema['definitions'][@resource_name]['properties'] return [''] if properties.nil? definitions = Hash[properties.each_pair.map do |key, value| [value['$ref'], key] end] parameters.map do |paramet...
[ "def", "resolve_parameters", "(", "parameters", ")", "properties", "=", "@schema", "[", "'definitions'", "]", "[", "@resource_name", "]", "[", "'properties'", "]", "return", "[", "''", "]", "if", "properties", ".", "nil?", "definitions", "=", "Hash", "[", "p...
Get the names of the parameters this link expects. @param parameters [Array] The names of the parameter definitions to convert to parameter names. @return [Array<String>] The parameters.
[ "Get", "the", "names", "of", "the", "parameters", "this", "link", "expects", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L240-L265
18,542
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.resolve_parameter_details
def resolve_parameter_details(parameters) parameters.map do |parameter| # URI decode parameters and strip the leading '{(' and trailing ')}'. parameter = URI.unescape(parameter[2..-3]) # Split the path into components and discard the leading '#' that # represents the root of the s...
ruby
def resolve_parameter_details(parameters) parameters.map do |parameter| # URI decode parameters and strip the leading '{(' and trailing ')}'. parameter = URI.unescape(parameter[2..-3]) # Split the path into components and discard the leading '#' that # represents the root of the s...
[ "def", "resolve_parameter_details", "(", "parameters", ")", "parameters", ".", "map", "do", "|", "parameter", "|", "# URI decode parameters and strip the leading '{(' and trailing ')}'.", "parameter", "=", "URI", ".", "unescape", "(", "parameter", "[", "2", "..", "-", ...
Get the parameters this link expects. @param parameters [Array] The names of the parameter definitions to convert to parameter names. @return [Array<Parameter|ParameterChoice>] A list of parameter instances that represent parameters to be injected into the link URL.
[ "Get", "the", "parameters", "this", "link", "expects", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L273-L295
18,543
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.unpack_multiple_parameters
def unpack_multiple_parameters(parameters) parameters.map do |info| parameter = info['$ref'] path = parameter.split('/')[1..-1] info = lookup_parameter(path, @schema) resource_name = path.size > 2 ? path[1].gsub('-', '_') : nil name = path[-1] Parameter.new(resource...
ruby
def unpack_multiple_parameters(parameters) parameters.map do |info| parameter = info['$ref'] path = parameter.split('/')[1..-1] info = lookup_parameter(path, @schema) resource_name = path.size > 2 ? path[1].gsub('-', '_') : nil name = path[-1] Parameter.new(resource...
[ "def", "unpack_multiple_parameters", "(", "parameters", ")", "parameters", ".", "map", "do", "|", "info", "|", "parameter", "=", "info", "[", "'$ref'", "]", "path", "=", "parameter", ".", "split", "(", "'/'", ")", "[", "1", "..", "-", "1", "]", "info",...
Unpack an 'anyOf' or 'oneOf' multi-parameter blob. @param parameters [Array<Hash>] An array of hashes containing '$ref' keys and definition values. @return [Array<Parameter>] An array of parameters extracted from the blob.
[ "Unpack", "an", "anyOf", "or", "oneOf", "multi", "-", "parameter", "blob", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L303-L312
18,544
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.lookup_parameter
def lookup_parameter(path, schema) key = path[0] remaining = path[1..-1] if remaining.empty? return schema[key] else lookup_parameter(remaining, schema[key]) end end
ruby
def lookup_parameter(path, schema) key = path[0] remaining = path[1..-1] if remaining.empty? return schema[key] else lookup_parameter(remaining, schema[key]) end end
[ "def", "lookup_parameter", "(", "path", ",", "schema", ")", "key", "=", "path", "[", "0", "]", "remaining", "=", "path", "[", "1", "..", "-", "1", "]", "if", "remaining", ".", "empty?", "return", "schema", "[", "key", "]", "else", "lookup_parameter", ...
Recursively walk the object hierarchy in the schema to resolve a given path. This is used to find property information related to definitions in link hrefs. @param path [Array<String>] An array of paths to walk, such as ['definitions', 'resource', 'definitions', 'property']. @param schema [Hash] The schema to ...
[ "Recursively", "walk", "the", "object", "hierarchy", "in", "the", "schema", "to", "resolve", "a", "given", "path", ".", "This", "is", "used", "to", "find", "property", "information", "related", "to", "definitions", "in", "link", "hrefs", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L321-L329
18,545
interagent/heroics
lib/heroics/schema.rb
Heroics.LinkSchema.format_parameter
def format_parameter(parameter) formatted_parameter = parameter.instance_of?(Time) ? iso_format(parameter) : parameter.to_s WEBrick::HTTPUtils.escape formatted_parameter end
ruby
def format_parameter(parameter) formatted_parameter = parameter.instance_of?(Time) ? iso_format(parameter) : parameter.to_s WEBrick::HTTPUtils.escape formatted_parameter end
[ "def", "format_parameter", "(", "parameter", ")", "formatted_parameter", "=", "parameter", ".", "instance_of?", "(", "Time", ")", "?", "iso_format", "(", "parameter", ")", ":", "parameter", ".", "to_s", "WEBrick", "::", "HTTPUtils", ".", "escape", "formatted_par...
Convert a path parameter to a format suitable for use in a path. @param [Fixnum,String,TrueClass,FalseClass,Time] The parameter to format. @return [String] The formatted parameter.
[ "Convert", "a", "path", "parameter", "to", "a", "format", "suitable", "for", "use", "in", "a", "path", "." ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/schema.rb#L335-L338
18,546
interagent/heroics
lib/heroics/client_generator.rb
Heroics.GeneratorLink.method_signature
def method_signature @parameters.map { |info| info.name == 'body' ? "body = {}" : Heroics.ruby_name(info.name) }.join(', ') end
ruby
def method_signature @parameters.map { |info| info.name == 'body' ? "body = {}" : Heroics.ruby_name(info.name) }.join(', ') end
[ "def", "method_signature", "@parameters", ".", "map", "{", "|", "info", "|", "info", ".", "name", "==", "'body'", "?", "\"body = {}\"", ":", "Heroics", ".", "ruby_name", "(", "info", ".", "name", ")", "}", ".", "join", "(", "', '", ")", "end" ]
list of parameters for method signature, body is optional
[ "list", "of", "parameters", "for", "method", "signature", "body", "is", "optional" ]
373f6defeade22fd9d09b89ec3f8a39ba9f29df1
https://github.com/interagent/heroics/blob/373f6defeade22fd9d09b89ec3f8a39ba9f29df1/lib/heroics/client_generator.rb#L77-L79
18,547
ddfreyne/cri
lib/cri/command_dsl.rb
Cri.CommandDSL.option
def option(short, long, desc, argument: :forbidden, multiple: false, hidden: false, default: nil, transform: nil, &block) @command.option_definitions << Cri::OptionDefinition.new( short: short&.to_s, long: lo...
ruby
def option(short, long, desc, argument: :forbidden, multiple: false, hidden: false, default: nil, transform: nil, &block) @command.option_definitions << Cri::OptionDefinition.new( short: short&.to_s, long: lo...
[ "def", "option", "(", "short", ",", "long", ",", "desc", ",", "argument", ":", ":forbidden", ",", "multiple", ":", "false", ",", "hidden", ":", "false", ",", "default", ":", "nil", ",", "transform", ":", "nil", ",", "&", "block", ")", "@command", "."...
Adds a new option to the command. If a block is given, it will be executed when the option is successfully parsed. @param [String, Symbol, nil] short The short option name @param [String, Symbol, nil] long The long option name @param [String] desc The option description @option params [:forbidden, :required, :...
[ "Adds", "a", "new", "option", "to", "the", "command", ".", "If", "a", "block", "is", "given", "it", "will", "be", "executed", "when", "the", "option", "is", "successfully", "parsed", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command_dsl.rb#L155-L173
18,548
ddfreyne/cri
lib/cri/command_dsl.rb
Cri.CommandDSL.param
def param(name, transform: nil) if @command.explicitly_no_params? raise AlreadySpecifiedAsNoParams.new(name, @command) end @command.parameter_definitions << Cri::ParamDefinition.new( name: name, transform: transform, ) end
ruby
def param(name, transform: nil) if @command.explicitly_no_params? raise AlreadySpecifiedAsNoParams.new(name, @command) end @command.parameter_definitions << Cri::ParamDefinition.new( name: name, transform: transform, ) end
[ "def", "param", "(", "name", ",", "transform", ":", "nil", ")", "if", "@command", ".", "explicitly_no_params?", "raise", "AlreadySpecifiedAsNoParams", ".", "new", "(", "name", ",", "@command", ")", "end", "@command", ".", "parameter_definitions", "<<", "Cri", ...
Defines a new parameter for the command. @param [Symbol] name The name of the parameter
[ "Defines", "a", "new", "parameter", "for", "the", "command", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command_dsl.rb#L179-L188
18,549
ddfreyne/cri
lib/cri/command_dsl.rb
Cri.CommandDSL.required
def required(short, long, desc, params = {}, &block) params = params.merge(argument: :required) option(short, long, desc, params, &block) end
ruby
def required(short, long, desc, params = {}, &block) params = params.merge(argument: :required) option(short, long, desc, params, &block) end
[ "def", "required", "(", "short", ",", "long", ",", "desc", ",", "params", "=", "{", "}", ",", "&", "block", ")", "params", "=", "params", ".", "merge", "(", "argument", ":", ":required", ")", "option", "(", "short", ",", "long", ",", "desc", ",", ...
Adds a new option with a required argument to the command. If a block is given, it will be executed when the option is successfully parsed. @param [String, Symbol, nil] short The short option name @param [String, Symbol, nil] long The long option name @param [String] desc The option description @option params ...
[ "Adds", "a", "new", "option", "with", "a", "required", "argument", "to", "the", "command", ".", "If", "a", "block", "is", "given", "it", "will", "be", "executed", "when", "the", "option", "is", "successfully", "parsed", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command_dsl.rb#L218-L221
18,550
ddfreyne/cri
lib/cri/parser.rb
Cri.Parser.run
def run @running = true while running? # Get next item e = @unprocessed_arguments_and_options.shift break if e.nil? if e == '--' handle_dashdash(e) elsif e =~ /^--./ && !@no_more_options handle_dashdash_option(e) elsif e =~ /^-./ && !@no_...
ruby
def run @running = true while running? # Get next item e = @unprocessed_arguments_and_options.shift break if e.nil? if e == '--' handle_dashdash(e) elsif e =~ /^--./ && !@no_more_options handle_dashdash_option(e) elsif e =~ /^-./ && !@no_...
[ "def", "run", "@running", "=", "true", "while", "running?", "# Get next item", "e", "=", "@unprocessed_arguments_and_options", ".", "shift", "break", "if", "e", ".", "nil?", "if", "e", "==", "'--'", "handle_dashdash", "(", "e", ")", "elsif", "e", "=~", "/", ...
Parses the command-line arguments into options and arguments. During parsing, two errors can be raised: @raise IllegalOptionError if an unrecognised option was encountered, i.e. an option that is not present in the list of option definitions @raise OptionRequiresAnArgumentError if an option was found that did ...
[ "Parses", "the", "command", "-", "line", "arguments", "into", "options", "and", "arguments", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/parser.rb#L102-L126
18,551
ddfreyne/cri
lib/cri/string_formatter.rb
Cri.StringFormatter.wrap_and_indent
def wrap_and_indent(str, width, indentation, first_line_already_indented = false) indented_width = width - indentation indent = ' ' * indentation # Split into paragraphs paragraphs = to_paragraphs(str) # Wrap and indent each paragraph text = paragraphs.map do |paragraph| # I...
ruby
def wrap_and_indent(str, width, indentation, first_line_already_indented = false) indented_width = width - indentation indent = ' ' * indentation # Split into paragraphs paragraphs = to_paragraphs(str) # Wrap and indent each paragraph text = paragraphs.map do |paragraph| # I...
[ "def", "wrap_and_indent", "(", "str", ",", "width", ",", "indentation", ",", "first_line_already_indented", "=", "false", ")", "indented_width", "=", "width", "-", "indentation", "indent", "=", "' '", "*", "indentation", "# Split into paragraphs", "paragraphs", "=",...
Word-wraps and indents the string. @param [String] str The string to format @param [Number] width The maximal width of each line. This also includes indentation, i.e. the actual maximal width of the text is `width`-`indentation`. @param [Number] indentation The number of spaces to indent each line. @param...
[ "Word", "-", "wraps", "and", "indents", "the", "string", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/string_formatter.rb#L43-L77
18,552
ddfreyne/cri
lib/cri/help_renderer.rb
Cri.HelpRenderer.render
def render text = +'' append_summary(text) append_usage(text) append_description(text) append_subcommands(text) append_options(text) text end
ruby
def render text = +'' append_summary(text) append_usage(text) append_description(text) append_subcommands(text) append_options(text) text end
[ "def", "render", "text", "=", "+", "''", "append_summary", "(", "text", ")", "append_usage", "(", "text", ")", "append_description", "(", "text", ")", "append_subcommands", "(", "text", ")", "append_options", "(", "text", ")", "text", "end" ]
Creates a new help renderer for the given command. @param [Cri::Command] cmd The command to generate the help for @option params [Boolean] :verbose true if the help output should be verbose, false otherwise. @return [String] The help text for this command
[ "Creates", "a", "new", "help", "renderer", "for", "the", "given", "command", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/help_renderer.rb#L29-L39
18,553
ddfreyne/cri
lib/cri/command.rb
Cri.Command.modify
def modify(&block) dsl = Cri::CommandDSL.new(self) if [-1, 0].include? block.arity dsl.instance_eval(&block) else yield(dsl) end self end
ruby
def modify(&block) dsl = Cri::CommandDSL.new(self) if [-1, 0].include? block.arity dsl.instance_eval(&block) else yield(dsl) end self end
[ "def", "modify", "(", "&", "block", ")", "dsl", "=", "Cri", "::", "CommandDSL", ".", "new", "(", "self", ")", "if", "[", "-", "1", ",", "0", "]", ".", "include?", "block", ".", "arity", "dsl", ".", "instance_eval", "(", "block", ")", "else", "yie...
Modifies the command using the DSL. If the block has one parameter, the block will be executed in the same context with the command DSL as its parameter. If the block has no parameters, the block will be executed in the context of the DSL. @return [Cri::Command] The command itself
[ "Modifies", "the", "command", "using", "the", "DSL", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command.rb#L185-L193
18,554
ddfreyne/cri
lib/cri/command.rb
Cri.Command.define_command
def define_command(name = nil, &block) # Execute DSL dsl = Cri::CommandDSL.new dsl.name name unless name.nil? if [-1, 0].include? block.arity dsl.instance_eval(&block) else yield(dsl) end # Create command cmd = dsl.command add_command(cmd) cmd...
ruby
def define_command(name = nil, &block) # Execute DSL dsl = Cri::CommandDSL.new dsl.name name unless name.nil? if [-1, 0].include? block.arity dsl.instance_eval(&block) else yield(dsl) end # Create command cmd = dsl.command add_command(cmd) cmd...
[ "def", "define_command", "(", "name", "=", "nil", ",", "&", "block", ")", "# Execute DSL", "dsl", "=", "Cri", "::", "CommandDSL", ".", "new", "dsl", ".", "name", "name", "unless", "name", ".", "nil?", "if", "[", "-", "1", ",", "0", "]", ".", "inclu...
Defines a new subcommand for the current command using the DSL. @param [String, nil] name The name of the subcommand, or nil if no name should be set (yet) @return [Cri::Command] The subcommand
[ "Defines", "a", "new", "subcommand", "for", "the", "current", "command", "using", "the", "DSL", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command.rb#L220-L234
18,555
ddfreyne/cri
lib/cri/command.rb
Cri.Command.commands_named
def commands_named(name) # Find by exact name or alias @commands.each do |cmd| found = cmd.name == name || cmd.aliases.include?(name) return [cmd] if found end # Find by approximation @commands.select do |cmd| cmd.name[0, name.length] == name end end
ruby
def commands_named(name) # Find by exact name or alias @commands.each do |cmd| found = cmd.name == name || cmd.aliases.include?(name) return [cmd] if found end # Find by approximation @commands.select do |cmd| cmd.name[0, name.length] == name end end
[ "def", "commands_named", "(", "name", ")", "# Find by exact name or alias", "@commands", ".", "each", "do", "|", "cmd", "|", "found", "=", "cmd", ".", "name", "==", "name", "||", "cmd", ".", "aliases", ".", "include?", "(", "name", ")", "return", "[", "c...
Returns the commands that could be referred to with the given name. If the result contains more than one command, the name is ambiguous. @param [String] name The full, partial or aliases name of the command @return [Array<Cri::Command>] A list of commands matching the given name
[ "Returns", "the", "commands", "that", "could", "be", "referred", "to", "with", "the", "given", "name", ".", "If", "the", "result", "contains", "more", "than", "one", "command", "the", "name", "is", "ambiguous", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command.rb#L242-L253
18,556
ddfreyne/cri
lib/cri/command.rb
Cri.Command.run
def run(opts_and_args, parent_opts = {}, hard_exit: true) # Parse up to command name stuff = partition(opts_and_args) opts_before_subcmd, subcmd_name, opts_and_args_after_subcmd = *stuff if subcommands.empty? || (subcmd_name.nil? && !block.nil?) run_this(opts_and_args, parent_opts) ...
ruby
def run(opts_and_args, parent_opts = {}, hard_exit: true) # Parse up to command name stuff = partition(opts_and_args) opts_before_subcmd, subcmd_name, opts_and_args_after_subcmd = *stuff if subcommands.empty? || (subcmd_name.nil? && !block.nil?) run_this(opts_and_args, parent_opts) ...
[ "def", "run", "(", "opts_and_args", ",", "parent_opts", "=", "{", "}", ",", "hard_exit", ":", "true", ")", "# Parse up to command name", "stuff", "=", "partition", "(", "opts_and_args", ")", "opts_before_subcmd", ",", "subcmd_name", ",", "opts_and_args_after_subcmd"...
Runs the command with the given command-line arguments, possibly invoking subcommands and passing on the options and arguments. @param [Array<String>] opts_and_args A list of unparsed arguments @param [Hash] parent_opts A hash of options already handled by the supercommand @return [void]
[ "Runs", "the", "command", "with", "the", "given", "command", "-", "line", "arguments", "possibly", "invoking", "subcommands", "and", "passing", "on", "the", "options", "and", "arguments", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command.rb#L290-L318
18,557
ddfreyne/cri
lib/cri/command.rb
Cri.Command.run_this
def run_this(opts_and_args, parent_opts = {}) if all_opts_as_args? args = opts_and_args global_opts = parent_opts else # Parse parser = Cri::Parser.new( opts_and_args, global_option_definitions, parameter_definitions, explicitly_no_para...
ruby
def run_this(opts_and_args, parent_opts = {}) if all_opts_as_args? args = opts_and_args global_opts = parent_opts else # Parse parser = Cri::Parser.new( opts_and_args, global_option_definitions, parameter_definitions, explicitly_no_para...
[ "def", "run_this", "(", "opts_and_args", ",", "parent_opts", "=", "{", "}", ")", "if", "all_opts_as_args?", "args", "=", "opts_and_args", "global_opts", "=", "parent_opts", "else", "# Parse", "parser", "=", "Cri", "::", "Parser", ".", "new", "(", "opts_and_arg...
Runs the actual command with the given command-line arguments, not invoking any subcommands. If the command does not have an execution block, an error ir raised. @param [Array<String>] opts_and_args A list of unparsed arguments @param [Hash] parent_opts A hash of options already handled by the supercommand @...
[ "Runs", "the", "actual", "command", "with", "the", "given", "command", "-", "line", "arguments", "not", "invoking", "any", "subcommands", ".", "If", "the", "command", "does", "not", "have", "an", "execution", "block", "an", "error", "ir", "raised", "." ]
4e4abafb352be093b63e0773e1d1d8869fc2ace9
https://github.com/ddfreyne/cri/blob/4e4abafb352be093b63e0773e1d1d8869fc2ace9/lib/cri/command.rb#L333-L360
18,558
nwops/puppet-debugger
lib/puppet-debugger/support.rb
PuppetDebugger.Support.parse_error
def parse_error(error) case error when SocketError PuppetDebugger::Exception::ConnectError.new(message: "Unknown host: #{Puppet[:server]}") when Net::HTTPError PuppetDebugger::Exception::AuthError.new(message: error.message) when Errno::ECONNREFUSED PuppetDebugger::Except...
ruby
def parse_error(error) case error when SocketError PuppetDebugger::Exception::ConnectError.new(message: "Unknown host: #{Puppet[:server]}") when Net::HTTPError PuppetDebugger::Exception::AuthError.new(message: error.message) when Errno::ECONNREFUSED PuppetDebugger::Except...
[ "def", "parse_error", "(", "error", ")", "case", "error", "when", "SocketError", "PuppetDebugger", "::", "Exception", "::", "ConnectError", ".", "new", "(", "message", ":", "\"Unknown host: #{Puppet[:server]}\"", ")", "when", "Net", "::", "HTTPError", "PuppetDebugge...
parses the error type into a more useful error message defined in errors.rb returns new error object or the original if error cannot be parsed
[ "parses", "the", "error", "type", "into", "a", "more", "useful", "error", "message", "defined", "in", "errors", ".", "rb", "returns", "new", "error", "object", "or", "the", "original", "if", "error", "cannot", "be", "parsed" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/support.rb#L24-L45
18,559
nwops/puppet-debugger
lib/puppet-debugger/support.rb
PuppetDebugger.Support.puppet_repl_lib_dir
def puppet_repl_lib_dir File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib')) end
ruby
def puppet_repl_lib_dir File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib')) end
[ "def", "puppet_repl_lib_dir", "File", ".", "expand_path", "(", "File", ".", "join", "(", "File", ".", "dirname", "(", "File", ".", "dirname", "(", "File", ".", "dirname", "(", "__FILE__", ")", ")", ")", ",", "'lib'", ")", ")", "end" ]
this is the lib directory of this gem in order to load any puppet functions from this gem we need to add the lib path of this gem
[ "this", "is", "the", "lib", "directory", "of", "this", "gem", "in", "order", "to", "load", "any", "puppet", "functions", "from", "this", "gem", "we", "need", "to", "add", "the", "lib", "path", "of", "this", "gem" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/support.rb#L54-L56
18,560
nwops/puppet-debugger
lib/puppet-debugger/support.rb
PuppetDebugger.Support.do_initialize
def do_initialize Puppet.initialize_settings Puppet[:parser] = 'future' # this is required in order to work with puppet 3.8 Puppet[:trusted_node_data] = true rescue ArgumentError => e rescue Puppet::DevError => e # do nothing otherwise calling init twice raises an error end
ruby
def do_initialize Puppet.initialize_settings Puppet[:parser] = 'future' # this is required in order to work with puppet 3.8 Puppet[:trusted_node_data] = true rescue ArgumentError => e rescue Puppet::DevError => e # do nothing otherwise calling init twice raises an error end
[ "def", "do_initialize", "Puppet", ".", "initialize_settings", "Puppet", "[", ":parser", "]", "=", "'future'", "# this is required in order to work with puppet 3.8", "Puppet", "[", ":trusted_node_data", "]", "=", "true", "rescue", "ArgumentError", "=>", "e", "rescue", "P...
this is required in order to load things only when we need them
[ "this", "is", "required", "in", "order", "to", "load", "things", "only", "when", "we", "need", "them" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/support.rb#L87-L94
18,561
nwops/puppet-debugger
lib/puppet-debugger/cli.rb
PuppetDebugger.Cli.key_words
def key_words # because dollar signs don't work we can't display a $ sign in the keyword # list so its not explicitly clear what the keyword variables = scope.to_hash.keys # prepend a :: to topscope variables scoped_vars = variables.map { |k, _v| scope.compiler.topscope.exist?(k) ? "$::#{k...
ruby
def key_words # because dollar signs don't work we can't display a $ sign in the keyword # list so its not explicitly clear what the keyword variables = scope.to_hash.keys # prepend a :: to topscope variables scoped_vars = variables.map { |k, _v| scope.compiler.topscope.exist?(k) ? "$::#{k...
[ "def", "key_words", "# because dollar signs don't work we can't display a $ sign in the keyword", "# list so its not explicitly clear what the keyword", "variables", "=", "scope", ".", "to_hash", ".", "keys", "# prepend a :: to topscope variables", "scoped_vars", "=", "variables", ".",...
returns a cached list of key words
[ "returns", "a", "cached", "list", "of", "key", "words" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/cli.rb#L66-L76
18,562
nwops/puppet-debugger
lib/puppet-debugger/cli.rb
PuppetDebugger.Cli.to_resource_declaration
def to_resource_declaration(type) if type.respond_to?(:type_name) && type.respond_to?(:title) title = type.title type_name = type.type_name elsif type_result = /(\w+)\['?(\w+)'?\]/.match(type.to_s) # not all types have a type_name and title so we # output to a string and pars...
ruby
def to_resource_declaration(type) if type.respond_to?(:type_name) && type.respond_to?(:title) title = type.title type_name = type.type_name elsif type_result = /(\w+)\['?(\w+)'?\]/.match(type.to_s) # not all types have a type_name and title so we # output to a string and pars...
[ "def", "to_resource_declaration", "(", "type", ")", "if", "type", ".", "respond_to?", "(", ":type_name", ")", "&&", "type", ".", "respond_to?", "(", ":title", ")", "title", "=", "type", ".", "title", "type_name", "=", "type", ".", "type_name", "elsif", "ty...
looks up the type in the catalog by using the type and title and returns the resource in ral format
[ "looks", "up", "the", "type", "in", "the", "catalog", "by", "using", "the", "type", "and", "title", "and", "returns", "the", "resource", "in", "ral", "format" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/cli.rb#L80-L95
18,563
nwops/puppet-debugger
lib/puppet-debugger/cli.rb
PuppetDebugger.Cli.expand_resource_type
def expand_resource_type(types) output = [types].flatten.map do |t| if t.class.to_s =~ /Puppet::Pops::Types/ to_resource_declaration(t) else t end end output end
ruby
def expand_resource_type(types) output = [types].flatten.map do |t| if t.class.to_s =~ /Puppet::Pops::Types/ to_resource_declaration(t) else t end end output end
[ "def", "expand_resource_type", "(", "types", ")", "output", "=", "[", "types", "]", ".", "flatten", ".", "map", "do", "|", "t", "|", "if", "t", ".", "class", ".", "to_s", "=~", "/", "/", "to_resource_declaration", "(", "t", ")", "else", "t", "end", ...
returns a formatted array
[ "returns", "a", "formatted", "array" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/cli.rb#L98-L107
18,564
nwops/puppet-debugger
lib/puppet-debugger/cli.rb
PuppetDebugger.Cli.handle_input
def handle_input(input) raise ArgumentError unless input.instance_of?(String) begin output = '' case input.strip when PuppetDebugger::InputResponders::Commands.command_list_regex args = input.split(' ') command = args.shift plugin = PuppetDebugger::Input...
ruby
def handle_input(input) raise ArgumentError unless input.instance_of?(String) begin output = '' case input.strip when PuppetDebugger::InputResponders::Commands.command_list_regex args = input.split(' ') command = args.shift plugin = PuppetDebugger::Input...
[ "def", "handle_input", "(", "input", ")", "raise", "ArgumentError", "unless", "input", ".", "instance_of?", "(", "String", ")", "begin", "output", "=", "''", "case", "input", ".", "strip", "when", "PuppetDebugger", "::", "InputResponders", "::", "Commands", "....
this method handles all input and expects a string of text.
[ "this", "method", "handles", "all", "input", "and", "expects", "a", "string", "of", "text", "." ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/cli.rb#L126-L171
18,565
nwops/puppet-debugger
lib/puppet-debugger/cli.rb
PuppetDebugger.Cli.read_loop
def read_loop line_number = 1 full_buffer = '' while buf = Readline.readline("#{line_number}:#{extra_prompt}>> ", true) begin full_buffer += buf # unless this is puppet code, otherwise skip repl keywords unless PuppetDebugger::InputResponders::Commands.command_lis...
ruby
def read_loop line_number = 1 full_buffer = '' while buf = Readline.readline("#{line_number}:#{extra_prompt}>> ", true) begin full_buffer += buf # unless this is puppet code, otherwise skip repl keywords unless PuppetDebugger::InputResponders::Commands.command_lis...
[ "def", "read_loop", "line_number", "=", "1", "full_buffer", "=", "''", "while", "buf", "=", "Readline", ".", "readline", "(", "\"#{line_number}:#{extra_prompt}>> \"", ",", "true", ")", "begin", "full_buffer", "+=", "buf", "# unless this is puppet code, otherwise skip re...
reads input from stdin, since readline requires a tty we cannot read from other sources as readline requires a file object we parse the string after each input to determine if the input is a multiline_input entry. If it is multiline we run through the loop again and concatenate the input
[ "reads", "input", "from", "stdin", "since", "readline", "requires", "a", "tty", "we", "cannot", "read", "from", "other", "sources", "as", "readline", "requires", "a", "file", "object", "we", "parse", "the", "string", "after", "each", "input", "to", "determin...
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/cli.rb#L204-L227
18,566
ruby-oembed/ruby-oembed
lib/oembed/http_helper.rb
OEmbed.HttpHelper.http_get
def http_get(uri, options = {}) found = false remaining_redirects = options[:max_redirects] ? options[:max_redirects].to_i : 4 until found http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.rea...
ruby
def http_get(uri, options = {}) found = false remaining_redirects = options[:max_redirects] ? options[:max_redirects].to_i : 4 until found http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.rea...
[ "def", "http_get", "(", "uri", ",", "options", "=", "{", "}", ")", "found", "=", "false", "remaining_redirects", "=", "options", "[", ":max_redirects", "]", "?", "options", "[", ":max_redirects", "]", ".", "to_i", ":", "4", "until", "found", "http", "=",...
Given a URI, make an HTTP request The options Hash recognizes the following keys: :timeout:: specifies the timeout (in seconds) for the http request. :max_redirects:: the number of times this request will follow 3XX redirects before throwing an error. Default: 4
[ "Given", "a", "URI", "make", "an", "HTTP", "request" ]
cd3f3531e3b0d1d0dec833af6f2b5142fc35be0f
https://github.com/ruby-oembed/ruby-oembed/blob/cd3f3531e3b0d1d0dec833af6f2b5142fc35be0f/lib/oembed/http_helper.rb#L13-L63
18,567
nwops/puppet-debugger
lib/awesome_print/ext/awesome_puppet.rb
AwesomePrint.Puppet.cast_with_puppet_resource
def cast_with_puppet_resource(object, type) cast = cast_without_puppet_resource(object, type) # check the object to see if it has an acestor (< ) of the specified type if defined?(::Puppet::Type) && (object.class < ::Puppet::Type) cast = :puppet_type elsif defined?(::Puppet::Pops::Types)...
ruby
def cast_with_puppet_resource(object, type) cast = cast_without_puppet_resource(object, type) # check the object to see if it has an acestor (< ) of the specified type if defined?(::Puppet::Type) && (object.class < ::Puppet::Type) cast = :puppet_type elsif defined?(::Puppet::Pops::Types)...
[ "def", "cast_with_puppet_resource", "(", "object", ",", "type", ")", "cast", "=", "cast_without_puppet_resource", "(", "object", ",", "type", ")", "# check the object to see if it has an acestor (< ) of the specified type", "if", "defined?", "(", "::", "Puppet", "::", "Ty...
this tells ap how to cast our object so we can be specific about printing different puppet objects
[ "this", "tells", "ap", "how", "to", "cast", "our", "object", "so", "we", "can", "be", "specific", "about", "printing", "different", "puppet", "objects" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/awesome_print/ext/awesome_puppet.rb#L26-L39
18,568
nwops/puppet-debugger
lib/puppet-debugger/hooks.rb
PuppetDebugger.Hooks.initialize_copy
def initialize_copy(orig) hooks_dup = @hooks.dup @hooks.each do |k, v| hooks_dup[k] = v.dup end @hooks = hooks_dup end
ruby
def initialize_copy(orig) hooks_dup = @hooks.dup @hooks.each do |k, v| hooks_dup[k] = v.dup end @hooks = hooks_dup end
[ "def", "initialize_copy", "(", "orig", ")", "hooks_dup", "=", "@hooks", ".", "dup", "@hooks", ".", "each", "do", "|", "k", ",", "v", "|", "hooks_dup", "[", "k", "]", "=", "v", ".", "dup", "end", "@hooks", "=", "hooks_dup", "end" ]
Ensure that duplicates have their @hooks object.
[ "Ensure", "that", "duplicates", "have", "their" ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/hooks.rb#L21-L28
18,569
nwops/puppet-debugger
lib/puppet-debugger/hooks.rb
PuppetDebugger.Hooks.add_hook
def add_hook(event_name, hook_name, callable=nil, &block) event_name = event_name.to_s # do not allow duplicates, but allow multiple `nil` hooks # (anonymous hooks) if hook_exists?(event_name, hook_name) && !hook_name.nil? raise ArgumentError, "Hook with name '#{hook_name}' already defi...
ruby
def add_hook(event_name, hook_name, callable=nil, &block) event_name = event_name.to_s # do not allow duplicates, but allow multiple `nil` hooks # (anonymous hooks) if hook_exists?(event_name, hook_name) && !hook_name.nil? raise ArgumentError, "Hook with name '#{hook_name}' already defi...
[ "def", "add_hook", "(", "event_name", ",", "hook_name", ",", "callable", "=", "nil", ",", "&", "block", ")", "event_name", "=", "event_name", ".", "to_s", "# do not allow duplicates, but allow multiple `nil` hooks", "# (anonymous hooks)", "if", "hook_exists?", "(", "e...
Add a new hook to be executed for the `event_name` event. @param [Symbol] event_name The name of the event. @param [Symbol] hook_name The name of the hook. @param [#call] callable The callable. @yield The block to use as the callable (if no `callable` provided). @return [PuppetDebugger::Hooks] The receiver.
[ "Add", "a", "new", "hook", "to", "be", "executed", "for", "the", "event_name", "event", "." ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/hooks.rb#L71-L94
18,570
nwops/puppet-debugger
lib/puppet-debugger/hooks.rb
PuppetDebugger.Hooks.exec_hook
def exec_hook(event_name, *args, &block) @hooks[event_name.to_s].map do |hook_name, callable| begin callable.call(*args, &block) rescue PuppetDebugger::Exception::Error, ::RuntimeError => e errors << e e end end.last end
ruby
def exec_hook(event_name, *args, &block) @hooks[event_name.to_s].map do |hook_name, callable| begin callable.call(*args, &block) rescue PuppetDebugger::Exception::Error, ::RuntimeError => e errors << e e end end.last end
[ "def", "exec_hook", "(", "event_name", ",", "*", "args", ",", "&", "block", ")", "@hooks", "[", "event_name", ".", "to_s", "]", ".", "map", "do", "|", "hook_name", ",", "callable", "|", "begin", "callable", ".", "call", "(", "args", ",", "block", ")"...
Execute the list of hooks for the `event_name` event. @param [Symbol] event_name The name of the event. @param [Array] args The arguments to pass to each hook function. @return [Object] The return value of the last executed hook.
[ "Execute", "the", "list", "of", "hooks", "for", "the", "event_name", "event", "." ]
ee9705ceec08dd1330c8bff6fb6bb55982496305
https://github.com/nwops/puppet-debugger/blob/ee9705ceec08dd1330c8bff6fb6bb55982496305/lib/puppet-debugger/hooks.rb#L100-L109
18,571
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.task_status
def task_status(task_id) current_path = "/api/v1/wip/task/#{task_id}/status" res = @conn.get(current_path) raise InvalidDataError, "No wip task returned for task id #{task_id}" if res['wip_task'].nil? raise InvalidDataError, "No task status returned for task id #{task_id}" if res['wip_task']['st...
ruby
def task_status(task_id) current_path = "/api/v1/wip/task/#{task_id}/status" res = @conn.get(current_path) raise InvalidDataError, "No wip task returned for task id #{task_id}" if res['wip_task'].nil? raise InvalidDataError, "No task status returned for task id #{task_id}" if res['wip_task']['st...
[ "def", "task_status", "(", "task_id", ")", "current_path", "=", "\"/api/v1/wip/task/#{task_id}/status\"", "res", "=", "@conn", ".", "get", "(", "current_path", ")", "raise", "InvalidDataError", ",", "\"No wip task returned for task id #{task_id}\"", "if", "res", "[", "'...
Get the status of a wip task by id. @param [Integer] task_id @return [Hash{"wip_task" => {"id" => Integer, "status" => Integer}, "time" => timestamp}]
[ "Get", "the", "status", "of", "a", "wip", "task", "by", "id", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L81-L88
18,572
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.find_task_ids
def find_task_ids(limit = nil, page = nil, group = nil, klass = nil, status = nil) res = find_tasks limit: limit, page: page, group: group, klass: klass, status: status task_ids = [] i = 0 res.each do |task| task_ids[i] = task['id'] i += 1 end task_ids end
ruby
def find_task_ids(limit = nil, page = nil, group = nil, klass = nil, status = nil) res = find_tasks limit: limit, page: page, group: group, klass: klass, status: status task_ids = [] i = 0 res.each do |task| task_ids[i] = task['id'] i += 1 end task_ids end
[ "def", "find_task_ids", "(", "limit", "=", "nil", ",", "page", "=", "nil", ",", "group", "=", "nil", ",", "klass", "=", "nil", ",", "status", "=", "nil", ")", "res", "=", "find_tasks", "limit", ":", "limit", ",", "page", ":", "page", ",", "group", ...
Find a set of task ids. @param [Integer] limit max amount of results to return per request @param [Integer] page page of request @param [String] group task group @param [String] klass task class @param [Integer] status Integerish the status of the task see SFRest::Task::STATUS_* @return [Array[Integer]]
[ "Find", "a", "set", "of", "task", "ids", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L148-L157
18,573
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.find_tasks
def find_tasks(datum = nil) current_path = '/api/v1/tasks' pb = SFRest::Pathbuilder.new @conn.get URI.parse(pb.build_url_query(current_path, datum)).to_s end
ruby
def find_tasks(datum = nil) current_path = '/api/v1/tasks' pb = SFRest::Pathbuilder.new @conn.get URI.parse(pb.build_url_query(current_path, datum)).to_s end
[ "def", "find_tasks", "(", "datum", "=", "nil", ")", "current_path", "=", "'/api/v1/tasks'", "pb", "=", "SFRest", "::", "Pathbuilder", ".", "new", "@conn", ".", "get", "URI", ".", "parse", "(", "pb", ".", "build_url_query", "(", "current_path", ",", "datum"...
Find a set of tasks. @param [Hash] datum Hash of filters @option datum [Integer] :limit max amount of results to return per request @option datum [Integer] :page page of request @option datum [String] :group task group @option datum [String] :class task class @option datum [Integer] :status Integerish the status ...
[ "Find", "a", "set", "of", "tasks", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L167-L171
18,574
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.globally_paused?
def globally_paused? paused = false current_path = '/api/v1/variables?name=wip_pause_global' begin res = @conn.get(current_path) paused = res['wip_pause_global'] rescue SFRest::SFError => error paused = false if error.message =~ /Variable not found/ end paused...
ruby
def globally_paused? paused = false current_path = '/api/v1/variables?name=wip_pause_global' begin res = @conn.get(current_path) paused = res['wip_pause_global'] rescue SFRest::SFError => error paused = false if error.message =~ /Variable not found/ end paused...
[ "def", "globally_paused?", "paused", "=", "false", "current_path", "=", "'/api/v1/variables?name=wip_pause_global'", "begin", "res", "=", "@conn", ".", "get", "(", "current_path", ")", "paused", "=", "res", "[", "'wip_pause_global'", "]", "rescue", "SFRest", "::", ...
Gets the value of a vairable @TODO: this is missnamed becasue it does not check the global paused variable @return [Boolean]
[ "Gets", "the", "value", "of", "a", "vairable" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L217-L227
18,575
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.pause_task
def pause_task(task_id, level = 'family') current_path = '/api/v1/pause/' << task_id.to_s payload = { 'paused' => true, 'level' => level }.to_json @conn.post(current_path, payload) end
ruby
def pause_task(task_id, level = 'family') current_path = '/api/v1/pause/' << task_id.to_s payload = { 'paused' => true, 'level' => level }.to_json @conn.post(current_path, payload) end
[ "def", "pause_task", "(", "task_id", ",", "level", "=", "'family'", ")", "current_path", "=", "'/api/v1/pause/'", "<<", "task_id", ".", "to_s", "payload", "=", "{", "'paused'", "=>", "true", ",", "'level'", "=>", "level", "}", ".", "to_json", "@conn", ".",...
Pauses a specific task identified by its task id. This can pause either the task and it's children or just the task @param [Integer] task_id @param [String] level family|task
[ "Pauses", "a", "specific", "task", "identified", "by", "its", "task", "id", ".", "This", "can", "pause", "either", "the", "task", "and", "it", "s", "children", "or", "just", "the", "task" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L233-L237
18,576
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.resume_task
def resume_task(task_id, level = 'family') current_path = '/api/v1/pause/' << task_id.to_s payload = { 'paused' => false, 'level' => level }.to_json @conn.post(current_path, payload) end
ruby
def resume_task(task_id, level = 'family') current_path = '/api/v1/pause/' << task_id.to_s payload = { 'paused' => false, 'level' => level }.to_json @conn.post(current_path, payload) end
[ "def", "resume_task", "(", "task_id", ",", "level", "=", "'family'", ")", "current_path", "=", "'/api/v1/pause/'", "<<", "task_id", ".", "to_s", "payload", "=", "{", "'paused'", "=>", "false", ",", "'level'", "=>", "level", "}", ".", "to_json", "@conn", "....
Resumes a specific task identified by its task id. This can resume either the task and it's children or just the task @param [Integer] task_id @param [String] level family|task
[ "Resumes", "a", "specific", "task", "identified", "by", "its", "task", "id", ".", "This", "can", "resume", "either", "the", "task", "and", "it", "s", "children", "or", "just", "the", "task" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L243-L247
18,577
acquia/sf-sdk-ruby
lib/sfrest/task.rb
SFRest.Task.wait_until_state
def wait_until_state(task_id, state, max_nap) blink_time = 5 # wake up and scan nap_start = Time.now state_method = method("task_#{state}?".to_sym) loop do break if state_method.call(task_id) raise TaskNotDoneError, "Task: #{task_id} has taken too long to complete!" if Time.new >...
ruby
def wait_until_state(task_id, state, max_nap) blink_time = 5 # wake up and scan nap_start = Time.now state_method = method("task_#{state}?".to_sym) loop do break if state_method.call(task_id) raise TaskNotDoneError, "Task: #{task_id} has taken too long to complete!" if Time.new >...
[ "def", "wait_until_state", "(", "task_id", ",", "state", ",", "max_nap", ")", "blink_time", "=", "5", "# wake up and scan", "nap_start", "=", "Time", ".", "now", "state_method", "=", "method", "(", "\"task_#{state}?\"", ".", "to_sym", ")", "loop", "do", "break...
Blocks until a task reaches a specific status @param [Integer] task_id @param [String] state state to reach @param [Integer] max_nap seconds to try before giving up
[ "Blocks", "until", "a", "task", "reaches", "a", "specific", "status" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L293-L304
18,578
acquia/sf-sdk-ruby
lib/sfrest/collection.rb
SFRest.Collection.collection_list
def collection_list page = 1 not_done = true count = 0 while not_done current_path = '/api/v1/collections?page=' << page.to_s res = @conn.get(current_path) if res['collections'] == [] not_done = false elsif !res['message'].nil? return { 'messag...
ruby
def collection_list page = 1 not_done = true count = 0 while not_done current_path = '/api/v1/collections?page=' << page.to_s res = @conn.get(current_path) if res['collections'] == [] not_done = false elsif !res['message'].nil? return { 'messag...
[ "def", "collection_list", "page", "=", "1", "not_done", "=", "true", "count", "=", "0", "while", "not_done", "current_path", "=", "'/api/v1/collections?page='", "<<", "page", ".", "to_s", "res", "=", "@conn", ".", "get", "(", "current_path", ")", "if", "res"...
Gets the complete list of collections Makes multiple requests to the factory to get all the collections on the factory @return [Hash{'count' => Integer, 'sites' => Hash}]
[ "Gets", "the", "complete", "list", "of", "collections", "Makes", "multiple", "requests", "to", "the", "factory", "to", "get", "all", "the", "collections", "on", "the", "factory" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/collection.rb#L59-L81
18,579
acquia/sf-sdk-ruby
lib/sfrest/collection.rb
SFRest.Collection.create
def create(name, sites, groups, internal_domain_prefix = nil) sites = Array(sites) groups = Array(groups) current_path = '/api/v1/collections' payload = { 'name' => name, 'site_ids' => sites, 'group_ids' => groups, 'internal_domain_prefix' => internal_domain_prefix }.to_json ...
ruby
def create(name, sites, groups, internal_domain_prefix = nil) sites = Array(sites) groups = Array(groups) current_path = '/api/v1/collections' payload = { 'name' => name, 'site_ids' => sites, 'group_ids' => groups, 'internal_domain_prefix' => internal_domain_prefix }.to_json ...
[ "def", "create", "(", "name", ",", "sites", ",", "groups", ",", "internal_domain_prefix", "=", "nil", ")", "sites", "=", "Array", "(", "sites", ")", "groups", "=", "Array", "(", "groups", ")", "current_path", "=", "'/api/v1/collections'", "payload", "=", "...
create a site collection @param [String] name site collection name @param [int|Array] sites nid or array of site nids. First nid is primary @param [int|Array] groups gid or array of group ids. @param [String] internal_domain_prefix optional the prefix for the internal domain default...
[ "create", "a", "site", "collection" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/collection.rb#L92-L99
18,580
acquia/sf-sdk-ruby
lib/sfrest/collection.rb
SFRest.Collection.set_primary_site
def set_primary_site(id, site) payload = { 'site_id' => site }.to_json current_path = "/api/v1/collections/#{id}/set-primary" @conn.post(current_path, payload) end
ruby
def set_primary_site(id, site) payload = { 'site_id' => site }.to_json current_path = "/api/v1/collections/#{id}/set-primary" @conn.post(current_path, payload) end
[ "def", "set_primary_site", "(", "id", ",", "site", ")", "payload", "=", "{", "'site_id'", "=>", "site", "}", ".", "to_json", "current_path", "=", "\"/api/v1/collections/#{id}/set-primary\"", "@conn", ".", "post", "(", "current_path", ",", "payload", ")", "end" ]
sets a site to be a primary site in a site collection @param [int] id of the collection where the primary site is being changed @param [int] site nid to become the primary site @return [Hash{ "id" => Integer, "name" => String, "time" => "2016-10-28T09:25:26+00:00", "pr...
[ "sets", "a", "site", "to", "be", "a", "primary", "site", "in", "a", "site", "collection" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/collection.rb#L154-L158
18,581
acquia/sf-sdk-ruby
lib/sfrest/update.rb
SFRest.Update.modify_status
def modify_status(site_creation, site_duplication, domain_management, bulk_operations) current_path = '/api/v1/status' payload = { 'site_creation' => site_creation, 'site_duplication' => site_duplication, 'domain_management' => domain_management, 'bulk_o...
ruby
def modify_status(site_creation, site_duplication, domain_management, bulk_operations) current_path = '/api/v1/status' payload = { 'site_creation' => site_creation, 'site_duplication' => site_duplication, 'domain_management' => domain_management, 'bulk_o...
[ "def", "modify_status", "(", "site_creation", ",", "site_duplication", ",", "domain_management", ",", "bulk_operations", ")", "current_path", "=", "'/api/v1/status'", "payload", "=", "{", "'site_creation'", "=>", "site_creation", ",", "'site_duplication'", "=>", "site_d...
Modifies the status information.
[ "Modifies", "the", "status", "information", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/update.rb#L16-L23
18,582
acquia/sf-sdk-ruby
lib/sfrest/update.rb
SFRest.Update.start_update
def start_update(ref) if update_version == 'v2' raise InvalidApiVersion, 'There is more than one codebase use sfrest.update.update directly.' end update_data = { scope: 'sites', sites_type: 'code, db', sites_ref: ref } update(update_data) end
ruby
def start_update(ref) if update_version == 'v2' raise InvalidApiVersion, 'There is more than one codebase use sfrest.update.update directly.' end update_data = { scope: 'sites', sites_type: 'code, db', sites_ref: ref } update(update_data) end
[ "def", "start_update", "(", "ref", ")", "if", "update_version", "==", "'v2'", "raise", "InvalidApiVersion", ",", "'There is more than one codebase use sfrest.update.update directly.'", "end", "update_data", "=", "{", "scope", ":", "'sites'", ",", "sites_type", ":", "'co...
Starts an update.
[ "Starts", "an", "update", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/update.rb#L32-L39
18,583
acquia/sf-sdk-ruby
lib/sfrest/group.rb
SFRest.Group.group_list
def group_list page = 1 not_done = true count = 0 while not_done current_path = '/api/v1/groups?page=' << page.to_s res = @conn.get(current_path) if res['groups'] == [] not_done = false elsif !res['message'].nil? return { 'message' => res['mess...
ruby
def group_list page = 1 not_done = true count = 0 while not_done current_path = '/api/v1/groups?page=' << page.to_s res = @conn.get(current_path) if res['groups'] == [] not_done = false elsif !res['message'].nil? return { 'message' => res['mess...
[ "def", "group_list", "page", "=", "1", "not_done", "=", "true", "count", "=", "0", "while", "not_done", "current_path", "=", "'/api/v1/groups?page='", "<<", "page", ".", "to_s", "res", "=", "@conn", ".", "get", "(", "current_path", ")", "if", "res", "[", ...
Gets a list of all site groups. @return [Hash] all the groups on the factory plus a count {'count' => count, 'groups' => Hash } this will iterate through the group pages
[ "Gets", "a", "list", "of", "all", "site", "groups", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/group.rb#L30-L52
18,584
acquia/sf-sdk-ruby
lib/sfrest/user.rb
SFRest.User.get_user_id
def get_user_id(username) pglimit = 100 res = @conn.get('/api/v1/users&limit=' + pglimit.to_s) usercount = res['count'].to_i id = user_data_from_results(res, username, 'uid') return id if id pages = (usercount / pglimit) + 1 2.upto(pages) do |i| res = @conn.get('/api/v...
ruby
def get_user_id(username) pglimit = 100 res = @conn.get('/api/v1/users&limit=' + pglimit.to_s) usercount = res['count'].to_i id = user_data_from_results(res, username, 'uid') return id if id pages = (usercount / pglimit) + 1 2.upto(pages) do |i| res = @conn.get('/api/v...
[ "def", "get_user_id", "(", "username", ")", "pglimit", "=", "100", "res", "=", "@conn", ".", "get", "(", "'/api/v1/users&limit='", "+", "pglimit", ".", "to_s", ")", "usercount", "=", "res", "[", "'count'", "]", ".", "to_i", "id", "=", "user_data_from_resul...
gets the site ID for the site named sitename will page through all the sites available searching for the site @param [String] username drupal username (not email) @return [Integer] the uid of the drupal user
[ "gets", "the", "site", "ID", "for", "the", "site", "named", "sitename", "will", "page", "through", "all", "the", "sites", "available", "searching", "for", "the", "site" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/user.rb#L40-L54
18,585
acquia/sf-sdk-ruby
lib/sfrest/user.rb
SFRest.User.user_data_from_results
def user_data_from_results(res, username, key) users = res['users'] users.each do |user| return user[key] if user['name'] == username end nil end
ruby
def user_data_from_results(res, username, key) users = res['users'] users.each do |user| return user[key] if user['name'] == username end nil end
[ "def", "user_data_from_results", "(", "res", ",", "username", ",", "key", ")", "users", "=", "res", "[", "'users'", "]", "users", ".", "each", "do", "|", "user", "|", "return", "user", "[", "key", "]", "if", "user", "[", "'name'", "]", "==", "usernam...
Extract the user data for 'key' based on the user result object @param [Hash] res result from a request to /users @param [String] username @param [String] key one of the user data returned (uid, mail, tfa_status...) @return [Object] Integer, String, Array, Hash depending on the user data
[ "Extract", "the", "user", "data", "for", "key", "based", "on", "the", "user", "result", "object" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/user.rb#L61-L67
18,586
acquia/sf-sdk-ruby
lib/sfrest/user.rb
SFRest.User.create_user
def create_user(name, email, datum = nil) current_path = '/api/v1/users' payload = { name: name, mail: email } payload.merge!(datum) unless datum.nil? @conn.post(current_path, payload.to_json) end
ruby
def create_user(name, email, datum = nil) current_path = '/api/v1/users' payload = { name: name, mail: email } payload.merge!(datum) unless datum.nil? @conn.post(current_path, payload.to_json) end
[ "def", "create_user", "(", "name", ",", "email", ",", "datum", "=", "nil", ")", "current_path", "=", "'/api/v1/users'", "payload", "=", "{", "name", ":", "name", ",", "mail", ":", "email", "}", "payload", ".", "merge!", "(", "datum", ")", "unless", "da...
Creates a user. @param [String] name @param [String] email @param [Hash] datum hash with elements :pass => string, :status => 0|1, :roles => Array
[ "Creates", "a", "user", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/user.rb#L82-L87
18,587
acquia/sf-sdk-ruby
lib/sfrest/stage.rb
SFRest.Stage.staging_versions
def staging_versions possible_versions = [1, 2] @versions ||= [] possible_versions.each do |version| begin @conn.get "/api/v#{version}/stage" @versions.push version rescue SFRest::InvalidResponse nil end end @versions end
ruby
def staging_versions possible_versions = [1, 2] @versions ||= [] possible_versions.each do |version| begin @conn.get "/api/v#{version}/stage" @versions.push version rescue SFRest::InvalidResponse nil end end @versions end
[ "def", "staging_versions", "possible_versions", "=", "[", "1", ",", "2", "]", "@versions", "||=", "[", "]", "possible_versions", ".", "each", "do", "|", "version", "|", "begin", "@conn", ".", "get", "\"/api/v#{version}/stage\"", "@versions", ".", "push", "vers...
determine what version are available for staging @return [Array] Array of available api endpoints
[ "determine", "what", "version", "are", "available", "for", "staging" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/stage.rb#L57-L69
18,588
acquia/sf-sdk-ruby
lib/sfrest/connection.rb
SFRest.Connection.put
def put(uri, payload) headers = { 'Content-Type' => 'application/json' } res = Excon.put(@base_url + uri.to_s, headers: headers, user: username, password: password, ssl_verify_peer: false, body: pay...
ruby
def put(uri, payload) headers = { 'Content-Type' => 'application/json' } res = Excon.put(@base_url + uri.to_s, headers: headers, user: username, password: password, ssl_verify_peer: false, body: pay...
[ "def", "put", "(", "uri", ",", "payload", ")", "headers", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "res", "=", "Excon", ".", "put", "(", "@base_url", "+", "uri", ".", "to_s", ",", "headers", ":", "headers", ",", "user", ":", "userna...
http request via put @param [string] uri @return [Object] ruby representation of the json response if the reponse body does not parse, raises a SFRest::InvalidResponse
[ "http", "request", "via", "put" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/connection.rb#L67-L76
18,589
acquia/sf-sdk-ruby
lib/sfrest/connection.rb
SFRest.Connection.delete
def delete(uri) headers = { 'Content-Type' => 'application/json' } res = Excon.delete(@base_url + uri.to_s, headers: headers, user: username, password: password, ssl_verify_peer: false) api_response res...
ruby
def delete(uri) headers = { 'Content-Type' => 'application/json' } res = Excon.delete(@base_url + uri.to_s, headers: headers, user: username, password: password, ssl_verify_peer: false) api_response res...
[ "def", "delete", "(", "uri", ")", "headers", "=", "{", "'Content-Type'", "=>", "'application/json'", "}", "res", "=", "Excon", ".", "delete", "(", "@base_url", "+", "uri", ".", "to_s", ",", "headers", ":", "headers", ",", "user", ":", "username", ",", ...
http request via delete @param [string] uri @return [Object] ruby representation of the json response if the reponse body does not parse, raises a SFRest::InvalidResponse
[ "http", "request", "via", "delete" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/connection.rb#L83-L91
18,590
acquia/sf-sdk-ruby
lib/sfrest/connection.rb
SFRest.Connection.api_response
def api_response(res, return_status = false) data = access_check JSON(res.body), res.status return_status ? [res.status, data] : data rescue JSON::ParserError message = "Invalid data, status #{res.status}, body: #{res.body}" raise SFRest::InvalidResponse, message end
ruby
def api_response(res, return_status = false) data = access_check JSON(res.body), res.status return_status ? [res.status, data] : data rescue JSON::ParserError message = "Invalid data, status #{res.status}, body: #{res.body}" raise SFRest::InvalidResponse, message end
[ "def", "api_response", "(", "res", ",", "return_status", "=", "false", ")", "data", "=", "access_check", "JSON", "(", "res", ".", "body", ")", ",", "res", ".", "status", "return_status", "?", "[", "res", ".", "status", ",", "data", "]", ":", "data", ...
Confirm that the result looks adequate @param [Excon::Response] res @param [Boolean] return_status If true returns the integer status with the reponse @return [Array|Object] if return_status then [int, Object] else Object
[ "Confirm", "that", "the", "result", "looks", "adequate" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/connection.rb#L99-L105
18,591
acquia/sf-sdk-ruby
lib/sfrest/pathbuilder.rb
SFRest.Pathbuilder.build_url_query
def build_url_query(current_path, datum = nil) unless datum.nil? current_path += '?' current_path += URI.encode_www_form datum end current_path end
ruby
def build_url_query(current_path, datum = nil) unless datum.nil? current_path += '?' current_path += URI.encode_www_form datum end current_path end
[ "def", "build_url_query", "(", "current_path", ",", "datum", "=", "nil", ")", "unless", "datum", ".", "nil?", "current_path", "+=", "'?'", "current_path", "+=", "URI", ".", "encode_www_form", "datum", "end", "current_path", "end" ]
build a get query @param [String] current_path the uri like /api/v1/foo @param [Hash] datum k,v hash of get query param and value
[ "build", "a", "get", "query" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/pathbuilder.rb#L9-L15
18,592
acquia/sf-sdk-ruby
lib/sfrest/variable.rb
SFRest.Variable.set_variable
def set_variable(name, value) current_path = '/api/v1/variables' payload = { 'name' => name, 'value' => value }.to_json @conn.put(current_path, payload) end
ruby
def set_variable(name, value) current_path = '/api/v1/variables' payload = { 'name' => name, 'value' => value }.to_json @conn.put(current_path, payload) end
[ "def", "set_variable", "(", "name", ",", "value", ")", "current_path", "=", "'/api/v1/variables'", "payload", "=", "{", "'name'", "=>", "name", ",", "'value'", "=>", "value", "}", ".", "to_json", "@conn", ".", "put", "(", "current_path", ",", "payload", ")...
Sets the key and value of a variable.
[ "Sets", "the", "key", "and", "value", "of", "a", "variable", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/variable.rb#L22-L26
18,593
acquia/sf-sdk-ruby
lib/sfrest/site.rb
SFRest.Site.site_list
def site_list(show_incomplete = true) page = 1 not_done = true count = 0 sites = [] while not_done current_path = '/api/v1/sites?page=' << page.to_s current_path <<= '&show_incomplete=true' if show_incomplete res = @conn.get(current_path) if res['sites'] == ...
ruby
def site_list(show_incomplete = true) page = 1 not_done = true count = 0 sites = [] while not_done current_path = '/api/v1/sites?page=' << page.to_s current_path <<= '&show_incomplete=true' if show_incomplete res = @conn.get(current_path) if res['sites'] == ...
[ "def", "site_list", "(", "show_incomplete", "=", "true", ")", "page", "=", "1", "not_done", "=", "true", "count", "=", "0", "sites", "=", "[", "]", "while", "not_done", "current_path", "=", "'/api/v1/sites?page='", "<<", "page", ".", "to_s", "current_path", ...
Gets the complete list of sites Makes multiple requests to the factory to get all the sites on the factory @param [Boolean] show_incomplete whether to include incomplete sites in the list. The default differs from UI/SF to maintain backward compatibility. @return [Hash{'count' => Integer, 'sites' => Hash}]
[ "Gets", "the", "complete", "list", "of", "sites", "Makes", "multiple", "requests", "to", "the", "factory", "to", "get", "all", "the", "sites", "on", "the", "factory" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/site.rb#L61-L85
18,594
acquia/sf-sdk-ruby
lib/sfrest/site.rb
SFRest.Site.create_site
def create_site(sitename, group_id, install_profile = nil, codebase = nil) current_path = '/api/v1/sites' payload = { 'site_name' => sitename, 'group_ids' => [group_id], 'install_profile' => install_profile, 'codebase' => codebase }.to_json @conn.post(current_path, payload) end
ruby
def create_site(sitename, group_id, install_profile = nil, codebase = nil) current_path = '/api/v1/sites' payload = { 'site_name' => sitename, 'group_ids' => [group_id], 'install_profile' => install_profile, 'codebase' => codebase }.to_json @conn.post(current_path, payload) end
[ "def", "create_site", "(", "sitename", ",", "group_id", ",", "install_profile", "=", "nil", ",", "codebase", "=", "nil", ")", "current_path", "=", "'/api/v1/sites'", "payload", "=", "{", "'site_name'", "=>", "sitename", ",", "'group_ids'", "=>", "[", "group_id...
Creates a site. @param [String] sitename The name of the site to create. @param [Integer] group_id The Id of the group the site is to be a member of. @param [String] install_profile The install profile to use when creating the site. @param [Integer] codebase The codebase index to use in installs.
[ "Creates", "a", "site", "." ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/site.rb#L92-L97
18,595
acquia/sf-sdk-ruby
lib/sfrest/role.rb
SFRest.Role.get_role_id
def get_role_id(rolename) pglimit = 100 res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s) rolecount = res['count'].to_i id = role_data_from_results(res, rolename) return id if id pages = (rolecount / pglimit) + 1 2.upto(pages) do |i| res = @conn.get('/api/v1/roles...
ruby
def get_role_id(rolename) pglimit = 100 res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s) rolecount = res['count'].to_i id = role_data_from_results(res, rolename) return id if id pages = (rolecount / pglimit) + 1 2.upto(pages) do |i| res = @conn.get('/api/v1/roles...
[ "def", "get_role_id", "(", "rolename", ")", "pglimit", "=", "100", "res", "=", "@conn", ".", "get", "(", "'/api/v1/roles&limit='", "+", "pglimit", ".", "to_s", ")", "rolecount", "=", "res", "[", "'count'", "]", ".", "to_i", "id", "=", "role_data_from_resul...
gets the role ID for the role named rolename will page through all the roles available searching for the site @param [String] rolename the name of the role to find @return [Integer] the id of rolename this will iterate through the roles pages
[ "gets", "the", "role", "ID", "for", "the", "role", "named", "rolename", "will", "page", "through", "all", "the", "roles", "available", "searching", "for", "the", "site" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/role.rb#L43-L57
18,596
acquia/sf-sdk-ruby
lib/sfrest/role.rb
SFRest.Role.role_data_from_results
def role_data_from_results(res, rolename) roles = res['roles'] roles.each do |role| return role[0].to_i if role[1] == rolename end nil end
ruby
def role_data_from_results(res, rolename) roles = res['roles'] roles.each do |role| return role[0].to_i if role[1] == rolename end nil end
[ "def", "role_data_from_results", "(", "res", ",", "rolename", ")", "roles", "=", "res", "[", "'roles'", "]", "roles", ".", "each", "do", "|", "role", "|", "return", "role", "[", "0", "]", ".", "to_i", "if", "role", "[", "1", "]", "==", "rolename", ...
Extract the role data for rolename based on the role result object @param [Hash] res result from a request to /roles @param [String] rolename @return [Object] Integer, String, Array, Hash depending on the user data
[ "Extract", "the", "role", "data", "for", "rolename", "based", "on", "the", "role", "result", "object" ]
c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8
https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/role.rb#L63-L69
18,597
damjack/spree_banner
app/models/spree/banner_box.rb
Spree.BannerBox.duplicate
def duplicate enhance_settings p = self.dup p.category = 'COPY OF ' + category p.created_at = p.updated_at = nil p.url = url p.attachment = attachment # allow site to do some customization p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra) p.save! ...
ruby
def duplicate enhance_settings p = self.dup p.category = 'COPY OF ' + category p.created_at = p.updated_at = nil p.url = url p.attachment = attachment # allow site to do some customization p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra) p.save! ...
[ "def", "duplicate", "enhance_settings", "p", "=", "self", ".", "dup", "p", ".", "category", "=", "'COPY OF '", "+", "category", "p", ".", "created_at", "=", "p", ".", "updated_at", "=", "nil", "p", ".", "url", "=", "url", "p", ".", "attachment", "=", ...
for adding banner_boxes which are closely related to existing ones define "duplicate_extra" for site-specific actions, eg for additional fields
[ "for", "adding", "banner_boxes", "which", "are", "closely", "related", "to", "existing", "ones", "define", "duplicate_extra", "for", "site", "-", "specific", "actions", "eg", "for", "additional", "fields" ]
b14044b13e1242b8e4f4ef2623f9056d4e83f081
https://github.com/damjack/spree_banner/blob/b14044b13e1242b8e4f4ef2623f9056d4e83f081/app/models/spree/banner_box.rb#L38-L50
18,598
learn-co/learn-co
lib/learn/options_sanitizer.rb
Learn.OptionsSanitizer.handle_missing_or_unknown_args
def handle_missing_or_unknown_args if first_arg_not_a_flag_or_file? exit_with_unknown_command elsif has_output_flag? || has_format_flag? check_for_output_file if has_output_flag? check_for_format_type if has_format_flag? elsif only_has_flag_arguments? add_test_command ...
ruby
def handle_missing_or_unknown_args if first_arg_not_a_flag_or_file? exit_with_unknown_command elsif has_output_flag? || has_format_flag? check_for_output_file if has_output_flag? check_for_format_type if has_format_flag? elsif only_has_flag_arguments? add_test_command ...
[ "def", "handle_missing_or_unknown_args", "if", "first_arg_not_a_flag_or_file?", "exit_with_unknown_command", "elsif", "has_output_flag?", "||", "has_format_flag?", "check_for_output_file", "if", "has_output_flag?", "check_for_format_type", "if", "has_format_flag?", "elsif", "only_has...
Arg manipulation methods
[ "Arg", "manipulation", "methods" ]
9a63701fc9efda53e2162b15f62405dfe2e2e105
https://github.com/learn-co/learn-co/blob/9a63701fc9efda53e2162b15f62405dfe2e2e105/lib/learn/options_sanitizer.rb#L69-L80
18,599
mongoid/origin
lib/origin/selectable.rb
Origin.Selectable.between
def between(criterion = nil) selection(criterion) do |selector, field, value| selector.store( field, { "$gte" => value.min, "$lte" => value.max } ) end end
ruby
def between(criterion = nil) selection(criterion) do |selector, field, value| selector.store( field, { "$gte" => value.min, "$lte" => value.max } ) end end
[ "def", "between", "(", "criterion", "=", "nil", ")", "selection", "(", "criterion", ")", "do", "|", "selector", ",", "field", ",", "value", "|", "selector", ".", "store", "(", "field", ",", "{", "\"$gte\"", "=>", "value", ".", "min", ",", "\"$lte\"", ...
Add the range selection. @example Match on results within a single range. selectable.between(field: 1..2) @example Match on results between multiple ranges. selectable.between(field: 1..2, other: 5..7) @param [ Hash ] criterion Multiple key/range pairs. @return [ Selectable ] The cloned selectable. @sin...
[ "Add", "the", "range", "selection", "." ]
b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63
https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selectable.rb#L77-L84