id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
19,800
benedikt/mongoid-tree
lib/mongoid/tree.rb
Mongoid.Tree.rearrange
def rearrange if self.parent_id self.parent_ids = parent.parent_ids + [self.parent_id] else self.parent_ids = [] end self.depth = parent_ids.size rearrange_children! if self.parent_ids_changed? end
ruby
def rearrange if self.parent_id self.parent_ids = parent.parent_ids + [self.parent_id] else self.parent_ids = [] end self.depth = parent_ids.size rearrange_children! if self.parent_ids_changed? end
[ "def", "rearrange", "if", "self", ".", "parent_id", "self", ".", "parent_ids", "=", "parent", ".", "parent_ids", "+", "[", "self", ".", "parent_id", "]", "else", "self", ".", "parent_ids", "=", "[", "]", "end", "self", ".", "depth", "=", "parent_ids", ".", "size", "rearrange_children!", "if", "self", ".", "parent_ids_changed?", "end" ]
Updates the parent_ids and marks the children for rearrangement when the parent_ids changed @private @return [undefined]
[ "Updates", "the", "parent_ids", "and", "marks", "the", "children", "for", "rearrangement", "when", "the", "parent_ids", "changed" ]
0970a945a16a1539511f6dd2017e78f1ba54d4bd
https://github.com/benedikt/mongoid-tree/blob/0970a945a16a1539511f6dd2017e78f1ba54d4bd/lib/mongoid/tree.rb#L433-L443
19,801
intercom/cocoapods-mangle
lib/cocoapods_mangle/config.rb
CocoapodsMangle.Config.needs_update?
def needs_update? return true unless File.exist?(@context.xcconfig_path) xcconfig_hash = Xcodeproj::Config.new(File.new(@context.xcconfig_path)).to_hash needs_update = xcconfig_hash[MANGLED_SPECS_CHECKSUM_XCCONFIG_KEY] != @context.specs_checksum Pod::UI.message '- Mangling config already up to date' unless needs_update needs_update end
ruby
def needs_update? return true unless File.exist?(@context.xcconfig_path) xcconfig_hash = Xcodeproj::Config.new(File.new(@context.xcconfig_path)).to_hash needs_update = xcconfig_hash[MANGLED_SPECS_CHECKSUM_XCCONFIG_KEY] != @context.specs_checksum Pod::UI.message '- Mangling config already up to date' unless needs_update needs_update end
[ "def", "needs_update?", "return", "true", "unless", "File", ".", "exist?", "(", "@context", ".", "xcconfig_path", ")", "xcconfig_hash", "=", "Xcodeproj", "::", "Config", ".", "new", "(", "File", ".", "new", "(", "@context", ".", "xcconfig_path", ")", ")", ".", "to_hash", "needs_update", "=", "xcconfig_hash", "[", "MANGLED_SPECS_CHECKSUM_XCCONFIG_KEY", "]", "!=", "@context", ".", "specs_checksum", "Pod", "::", "UI", ".", "message", "'- Mangling config already up to date'", "unless", "needs_update", "needs_update", "end" ]
Does the mangling xcconfig need to be updated? @return [Truthy] Does the xcconfig need to be updated?
[ "Does", "the", "mangling", "xcconfig", "need", "to", "be", "updated?" ]
aaec3e68b578eb61185aa0895568a9316c24a05c
https://github.com/intercom/cocoapods-mangle/blob/aaec3e68b578eb61185aa0895568a9316c24a05c/lib/cocoapods_mangle/config.rb#L42-L48
19,802
intercom/cocoapods-mangle
lib/cocoapods_mangle/config.rb
CocoapodsMangle.Config.update_pod_xcconfigs_for_mangling!
def update_pod_xcconfigs_for_mangling! Pod::UI.message '- Updating Pod xcconfig files' do @context.pod_xcconfig_paths.each do |pod_xcconfig_path| Pod::UI.message "- Updating '#{File.basename(pod_xcconfig_path)}'" update_pod_xcconfig_for_mangling!(pod_xcconfig_path) end end end
ruby
def update_pod_xcconfigs_for_mangling! Pod::UI.message '- Updating Pod xcconfig files' do @context.pod_xcconfig_paths.each do |pod_xcconfig_path| Pod::UI.message "- Updating '#{File.basename(pod_xcconfig_path)}'" update_pod_xcconfig_for_mangling!(pod_xcconfig_path) end end end
[ "def", "update_pod_xcconfigs_for_mangling!", "Pod", "::", "UI", ".", "message", "'- Updating Pod xcconfig files'", "do", "@context", ".", "pod_xcconfig_paths", ".", "each", "do", "|", "pod_xcconfig_path", "|", "Pod", "::", "UI", ".", "message", "\"- Updating '#{File.basename(pod_xcconfig_path)}'\"", "update_pod_xcconfig_for_mangling!", "(", "pod_xcconfig_path", ")", "end", "end", "end" ]
Update all pod xcconfigs to use the mangling defines
[ "Update", "all", "pod", "xcconfigs", "to", "use", "the", "mangling", "defines" ]
aaec3e68b578eb61185aa0895568a9316c24a05c
https://github.com/intercom/cocoapods-mangle/blob/aaec3e68b578eb61185aa0895568a9316c24a05c/lib/cocoapods_mangle/config.rb#L51-L58
19,803
intercom/cocoapods-mangle
lib/cocoapods_mangle/config.rb
CocoapodsMangle.Config.update_pod_xcconfig_for_mangling!
def update_pod_xcconfig_for_mangling!(pod_xcconfig_path) mangle_xcconfig_include = "#include \"#{@context.xcconfig_path}\"\n" gcc_preprocessor_defs = File.readlines(pod_xcconfig_path).select { |line| line =~ /GCC_PREPROCESSOR_DEFINITIONS/ }.first gcc_preprocessor_defs.strip! xcconfig_contents = File.read(pod_xcconfig_path) # import the mangling config new_xcconfig_contents = mangle_xcconfig_include + xcconfig_contents # update GCC_PREPROCESSOR_DEFINITIONS to include mangling new_xcconfig_contents.sub!(gcc_preprocessor_defs, gcc_preprocessor_defs + " $(#{MANGLING_DEFINES_XCCONFIG_KEY})") File.open(pod_xcconfig_path, 'w') { |pod_xcconfig| pod_xcconfig.write(new_xcconfig_contents) } end
ruby
def update_pod_xcconfig_for_mangling!(pod_xcconfig_path) mangle_xcconfig_include = "#include \"#{@context.xcconfig_path}\"\n" gcc_preprocessor_defs = File.readlines(pod_xcconfig_path).select { |line| line =~ /GCC_PREPROCESSOR_DEFINITIONS/ }.first gcc_preprocessor_defs.strip! xcconfig_contents = File.read(pod_xcconfig_path) # import the mangling config new_xcconfig_contents = mangle_xcconfig_include + xcconfig_contents # update GCC_PREPROCESSOR_DEFINITIONS to include mangling new_xcconfig_contents.sub!(gcc_preprocessor_defs, gcc_preprocessor_defs + " $(#{MANGLING_DEFINES_XCCONFIG_KEY})") File.open(pod_xcconfig_path, 'w') { |pod_xcconfig| pod_xcconfig.write(new_xcconfig_contents) } end
[ "def", "update_pod_xcconfig_for_mangling!", "(", "pod_xcconfig_path", ")", "mangle_xcconfig_include", "=", "\"#include \\\"#{@context.xcconfig_path}\\\"\\n\"", "gcc_preprocessor_defs", "=", "File", ".", "readlines", "(", "pod_xcconfig_path", ")", ".", "select", "{", "|", "line", "|", "line", "=~", "/", "/", "}", ".", "first", "gcc_preprocessor_defs", ".", "strip!", "xcconfig_contents", "=", "File", ".", "read", "(", "pod_xcconfig_path", ")", "# import the mangling config", "new_xcconfig_contents", "=", "mangle_xcconfig_include", "+", "xcconfig_contents", "# update GCC_PREPROCESSOR_DEFINITIONS to include mangling", "new_xcconfig_contents", ".", "sub!", "(", "gcc_preprocessor_defs", ",", "gcc_preprocessor_defs", "+", "\" $(#{MANGLING_DEFINES_XCCONFIG_KEY})\"", ")", "File", ".", "open", "(", "pod_xcconfig_path", ",", "'w'", ")", "{", "|", "pod_xcconfig", "|", "pod_xcconfig", ".", "write", "(", "new_xcconfig_contents", ")", "}", "end" ]
Update a mangling config to use the mangling defines @param [String] pod_xcconfig_path Path to the pod xcconfig to update
[ "Update", "a", "mangling", "config", "to", "use", "the", "mangling", "defines" ]
aaec3e68b578eb61185aa0895568a9316c24a05c
https://github.com/intercom/cocoapods-mangle/blob/aaec3e68b578eb61185aa0895568a9316c24a05c/lib/cocoapods_mangle/config.rb#L63-L75
19,804
HipByte/motion-cocoapods
lib/motion/project/cocoapods.rb
Motion::Project.CocoaPods.configure_project
def configure_project if (xcconfig = self.pods_xcconfig_hash) && ldflags = xcconfig['OTHER_LDFLAGS'] @config.resources_dirs << resources_dir.to_s frameworks = installed_frameworks[:pre_built] if frameworks @config.embedded_frameworks += frameworks @config.embedded_frameworks.uniq! end if @use_frameworks configure_project_frameworks else configure_project_static_libraries end end end
ruby
def configure_project if (xcconfig = self.pods_xcconfig_hash) && ldflags = xcconfig['OTHER_LDFLAGS'] @config.resources_dirs << resources_dir.to_s frameworks = installed_frameworks[:pre_built] if frameworks @config.embedded_frameworks += frameworks @config.embedded_frameworks.uniq! end if @use_frameworks configure_project_frameworks else configure_project_static_libraries end end end
[ "def", "configure_project", "if", "(", "xcconfig", "=", "self", ".", "pods_xcconfig_hash", ")", "&&", "ldflags", "=", "xcconfig", "[", "'OTHER_LDFLAGS'", "]", "@config", ".", "resources_dirs", "<<", "resources_dir", ".", "to_s", "frameworks", "=", "installed_frameworks", "[", ":pre_built", "]", "if", "frameworks", "@config", ".", "embedded_frameworks", "+=", "frameworks", "@config", ".", "embedded_frameworks", ".", "uniq!", "end", "if", "@use_frameworks", "configure_project_frameworks", "else", "configure_project_static_libraries", "end", "end", "end" ]
Adds the Pods project to the RubyMotion config as a vendored project and
[ "Adds", "the", "Pods", "project", "to", "the", "RubyMotion", "config", "as", "a", "vendored", "project", "and" ]
005ffa50fdbe6074c7933e689d709e1a609f2a8a
https://github.com/HipByte/motion-cocoapods/blob/005ffa50fdbe6074c7933e689d709e1a609f2a8a/lib/motion/project/cocoapods.rb#L111-L127
19,805
HipByte/motion-cocoapods
lib/motion/project/cocoapods.rb
Motion::Project.CocoaPods.install!
def install!(update) FileUtils.rm_rf(resources_dir) pods_installer.update = update pods_installer.installation_options.integrate_targets = false pods_installer.install! install_resources copy_cocoapods_env_and_prefix_headers end
ruby
def install!(update) FileUtils.rm_rf(resources_dir) pods_installer.update = update pods_installer.installation_options.integrate_targets = false pods_installer.install! install_resources copy_cocoapods_env_and_prefix_headers end
[ "def", "install!", "(", "update", ")", "FileUtils", ".", "rm_rf", "(", "resources_dir", ")", "pods_installer", ".", "update", "=", "update", "pods_installer", ".", "installation_options", ".", "integrate_targets", "=", "false", "pods_installer", ".", "install!", "install_resources", "copy_cocoapods_env_and_prefix_headers", "end" ]
Performs a CocoaPods Installation. For now we only support one Pods target, this will have to be expanded once we work on more spec support. Let RubyMotion re-generate the BridgeSupport file whenever the list of installed pods changes.
[ "Performs", "a", "CocoaPods", "Installation", "." ]
005ffa50fdbe6074c7933e689d709e1a609f2a8a
https://github.com/HipByte/motion-cocoapods/blob/005ffa50fdbe6074c7933e689d709e1a609f2a8a/lib/motion/project/cocoapods.rb#L236-L244
19,806
HipByte/motion-cocoapods
lib/motion/project/cocoapods.rb
Motion::Project.CocoaPods.resources
def resources resources = [] script = Pathname.new(@config.project_dir) + SUPPORT_FILES + "Pods-#{TARGET_NAME}-resources.sh" return resources unless File.exist?(script) File.open(script) { |f| f.each_line do |line| if matched = line.match(/install_resource\s+(.*)/) path = (matched[1].strip)[1..-2] if path.start_with?('${PODS_ROOT}') path = path.sub('${PODS_ROOT}/', '') end if path.include?("$PODS_CONFIGURATION_BUILD_DIR") path = File.join(".build", File.basename(path)) end unless File.extname(path) == '.framework' resources << Pathname.new(@config.project_dir) + PODS_ROOT + path end end end } resources.uniq end
ruby
def resources resources = [] script = Pathname.new(@config.project_dir) + SUPPORT_FILES + "Pods-#{TARGET_NAME}-resources.sh" return resources unless File.exist?(script) File.open(script) { |f| f.each_line do |line| if matched = line.match(/install_resource\s+(.*)/) path = (matched[1].strip)[1..-2] if path.start_with?('${PODS_ROOT}') path = path.sub('${PODS_ROOT}/', '') end if path.include?("$PODS_CONFIGURATION_BUILD_DIR") path = File.join(".build", File.basename(path)) end unless File.extname(path) == '.framework' resources << Pathname.new(@config.project_dir) + PODS_ROOT + path end end end } resources.uniq end
[ "def", "resources", "resources", "=", "[", "]", "script", "=", "Pathname", ".", "new", "(", "@config", ".", "project_dir", ")", "+", "SUPPORT_FILES", "+", "\"Pods-#{TARGET_NAME}-resources.sh\"", "return", "resources", "unless", "File", ".", "exist?", "(", "script", ")", "File", ".", "open", "(", "script", ")", "{", "|", "f", "|", "f", ".", "each_line", "do", "|", "line", "|", "if", "matched", "=", "line", ".", "match", "(", "/", "\\s", "/", ")", "path", "=", "(", "matched", "[", "1", "]", ".", "strip", ")", "[", "1", "..", "-", "2", "]", "if", "path", ".", "start_with?", "(", "'${PODS_ROOT}'", ")", "path", "=", "path", ".", "sub", "(", "'${PODS_ROOT}/'", ",", "''", ")", "end", "if", "path", ".", "include?", "(", "\"$PODS_CONFIGURATION_BUILD_DIR\"", ")", "path", "=", "File", ".", "join", "(", "\".build\"", ",", "File", ".", "basename", "(", "path", ")", ")", "end", "unless", "File", ".", "extname", "(", "path", ")", "==", "'.framework'", "resources", "<<", "Pathname", ".", "new", "(", "@config", ".", "project_dir", ")", "+", "PODS_ROOT", "+", "path", "end", "end", "end", "}", "resources", ".", "uniq", "end" ]
Do not copy `.framework` bundles, these should be handled through RM's `embedded_frameworks` config attribute.
[ "Do", "not", "copy", ".", "framework", "bundles", "these", "should", "be", "handled", "through", "RM", "s", "embedded_frameworks", "config", "attribute", "." ]
005ffa50fdbe6074c7933e689d709e1a609f2a8a
https://github.com/HipByte/motion-cocoapods/blob/005ffa50fdbe6074c7933e689d709e1a609f2a8a/lib/motion/project/cocoapods.rb#L500-L521
19,807
michaeledgar/laser
lib/laser/support/acts_as_struct.rb
Laser.ActsAsStruct.acts_as_struct
def acts_as_struct(*members) include Comparable extend InheritedAttributes class_inheritable_array :current_members unless respond_to?(:current_members) self.current_members ||= [] self.current_members.concat members all_members = self.current_members # Only add new members attr_accessor *members # NOT backwards compatible with a Struct's initializer. If you # try to initialize the first argument to a Hash and don't provide # other arguments, you trigger the hash extraction initializer instead # of the positional initializer. That's a bad idea. define_method :initialize do |*args| if args.size == 1 && Hash === args.first initialize_hash(args.first) else if args.size > all_members.size raise ArgumentError.new("#{self.class} has #{all_members.size} members " + "- you provided #{args.size}") end initialize_positional(args) end end # Initializes by treating the input as key-value assignments. define_method :initialize_hash do |hash| hash.each { |k, v| send("#{k}=", v) } end private :initialize_hash # Initialize by treating the input as positional arguments that # line up with the struct members provided to acts_as_struct. define_method :initialize_positional do |args| args.each_with_index do |value, idx| key = all_members[idx] send("#{key}=", value) end end private :initialize_positional # Helper methods for keys/values. define_method(:keys_and_values) { keys.zip(values) } define_method(:values) { keys.map { |member| send member } } define_method(:keys) { all_members } define_method(:each) { |&blk| keys_and_values.each { |k, v| blk.call([k, v]) } } define_method(:'<=>') do |other| each do |key, value| res = (value <=> other.send(key)) if res != 0 return res end end 0 end end
ruby
def acts_as_struct(*members) include Comparable extend InheritedAttributes class_inheritable_array :current_members unless respond_to?(:current_members) self.current_members ||= [] self.current_members.concat members all_members = self.current_members # Only add new members attr_accessor *members # NOT backwards compatible with a Struct's initializer. If you # try to initialize the first argument to a Hash and don't provide # other arguments, you trigger the hash extraction initializer instead # of the positional initializer. That's a bad idea. define_method :initialize do |*args| if args.size == 1 && Hash === args.first initialize_hash(args.first) else if args.size > all_members.size raise ArgumentError.new("#{self.class} has #{all_members.size} members " + "- you provided #{args.size}") end initialize_positional(args) end end # Initializes by treating the input as key-value assignments. define_method :initialize_hash do |hash| hash.each { |k, v| send("#{k}=", v) } end private :initialize_hash # Initialize by treating the input as positional arguments that # line up with the struct members provided to acts_as_struct. define_method :initialize_positional do |args| args.each_with_index do |value, idx| key = all_members[idx] send("#{key}=", value) end end private :initialize_positional # Helper methods for keys/values. define_method(:keys_and_values) { keys.zip(values) } define_method(:values) { keys.map { |member| send member } } define_method(:keys) { all_members } define_method(:each) { |&blk| keys_and_values.each { |k, v| blk.call([k, v]) } } define_method(:'<=>') do |other| each do |key, value| res = (value <=> other.send(key)) if res != 0 return res end end 0 end end
[ "def", "acts_as_struct", "(", "*", "members", ")", "include", "Comparable", "extend", "InheritedAttributes", "class_inheritable_array", ":current_members", "unless", "respond_to?", "(", ":current_members", ")", "self", ".", "current_members", "||=", "[", "]", "self", ".", "current_members", ".", "concat", "members", "all_members", "=", "self", ".", "current_members", "# Only add new members", "attr_accessor", "members", "# NOT backwards compatible with a Struct's initializer. If you", "# try to initialize the first argument to a Hash and don't provide", "# other arguments, you trigger the hash extraction initializer instead", "# of the positional initializer. That's a bad idea.", "define_method", ":initialize", "do", "|", "*", "args", "|", "if", "args", ".", "size", "==", "1", "&&", "Hash", "===", "args", ".", "first", "initialize_hash", "(", "args", ".", "first", ")", "else", "if", "args", ".", "size", ">", "all_members", ".", "size", "raise", "ArgumentError", ".", "new", "(", "\"#{self.class} has #{all_members.size} members \"", "+", "\"- you provided #{args.size}\"", ")", "end", "initialize_positional", "(", "args", ")", "end", "end", "# Initializes by treating the input as key-value assignments.", "define_method", ":initialize_hash", "do", "|", "hash", "|", "hash", ".", "each", "{", "|", "k", ",", "v", "|", "send", "(", "\"#{k}=\"", ",", "v", ")", "}", "end", "private", ":initialize_hash", "# Initialize by treating the input as positional arguments that", "# line up with the struct members provided to acts_as_struct.", "define_method", ":initialize_positional", "do", "|", "args", "|", "args", ".", "each_with_index", "do", "|", "value", ",", "idx", "|", "key", "=", "all_members", "[", "idx", "]", "send", "(", "\"#{key}=\"", ",", "value", ")", "end", "end", "private", ":initialize_positional", "# Helper methods for keys/values.", "define_method", "(", ":keys_and_values", ")", "{", "keys", ".", "zip", "(", "values", ")", "}", "define_method", "(", ":values", ")", "{", "keys", ".", "map", "{", "|", "member", "|", "send", "member", "}", "}", "define_method", "(", ":keys", ")", "{", "all_members", "}", "define_method", "(", ":each", ")", "{", "|", "&", "blk", "|", "keys_and_values", ".", "each", "{", "|", "k", ",", "v", "|", "blk", ".", "call", "(", "[", "k", ",", "v", "]", ")", "}", "}", "define_method", "(", ":'", "'", ")", "do", "|", "other", "|", "each", "do", "|", "key", ",", "value", "|", "res", "=", "(", "value", "<=>", "other", ".", "send", "(", "key", ")", ")", "if", "res", "!=", "0", "return", "res", "end", "end", "0", "end", "end" ]
Mixes in struct behavior to the current class.
[ "Mixes", "in", "struct", "behavior", "to", "the", "current", "class", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/support/acts_as_struct.rb#L8-L64
19,808
michaeledgar/laser
lib/laser/third_party/rgl/mutable.rb
RGL.MutableGraph.cycles
def cycles g = self.clone self.inject([]) do |acc, v| acc = acc.concat(g.cycles_with_vertex(v)) g.remove_vertex(v); acc end end
ruby
def cycles g = self.clone self.inject([]) do |acc, v| acc = acc.concat(g.cycles_with_vertex(v)) g.remove_vertex(v); acc end end
[ "def", "cycles", "g", "=", "self", ".", "clone", "self", ".", "inject", "(", "[", "]", ")", "do", "|", "acc", ",", "v", "|", "acc", "=", "acc", ".", "concat", "(", "g", ".", "cycles_with_vertex", "(", "v", ")", ")", "g", ".", "remove_vertex", "(", "v", ")", ";", "acc", "end", "end" ]
Returns an array of all minimum cycles in a graph This is not an efficient implementation O(n^4) and could be done using Minimum Spanning Trees. Hint. Hint.
[ "Returns", "an", "array", "of", "all", "minimum", "cycles", "in", "a", "graph" ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/mutable.rb#L108-L114
19,809
michaeledgar/laser
lib/laser/analysis/sexp_analysis.rb
Laser.Analysis.parse
def parse(body = self.body) return PARSING_CACHE[body] if PARSING_CACHE[body] pairs = Analysis.analyze_inputs([[file, body]]) PARSING_CACHE[body] = pairs[0][1] end
ruby
def parse(body = self.body) return PARSING_CACHE[body] if PARSING_CACHE[body] pairs = Analysis.analyze_inputs([[file, body]]) PARSING_CACHE[body] = pairs[0][1] end
[ "def", "parse", "(", "body", "=", "self", ".", "body", ")", "return", "PARSING_CACHE", "[", "body", "]", "if", "PARSING_CACHE", "[", "body", "]", "pairs", "=", "Analysis", ".", "analyze_inputs", "(", "[", "[", "file", ",", "body", "]", "]", ")", "PARSING_CACHE", "[", "body", "]", "=", "pairs", "[", "0", "]", "[", "1", "]", "end" ]
Parses the given text. @param [String] body (self.body) The text to parse @return [Sexp, NilClass] the sexp representing the input text.
[ "Parses", "the", "given", "text", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/analysis/sexp_analysis.rb#L19-L23
19,810
michaeledgar/laser
lib/laser/analysis/sexp_analysis.rb
Laser.Analysis.find_sexps
def find_sexps(type, tree = self.parse(self.body)) result = tree[0] == type ? [tree] : [] tree.each do |node| result.concat find_sexps(type, node) if node.is_a?(Array) end result end
ruby
def find_sexps(type, tree = self.parse(self.body)) result = tree[0] == type ? [tree] : [] tree.each do |node| result.concat find_sexps(type, node) if node.is_a?(Array) end result end
[ "def", "find_sexps", "(", "type", ",", "tree", "=", "self", ".", "parse", "(", "self", ".", "body", ")", ")", "result", "=", "tree", "[", "0", "]", "==", "type", "?", "[", "tree", "]", ":", "[", "]", "tree", ".", "each", "do", "|", "node", "|", "result", ".", "concat", "find_sexps", "(", "type", ",", "node", ")", "if", "node", ".", "is_a?", "(", "Array", ")", "end", "result", "end" ]
Finds all sexps of the given type in the given Sexp tree. @param [Symbol] type the type of sexp to search for @param [Sexp] tree (self.parse(self.body)) The tree to search in. Leave blank to search the entire body. @return [Array<Sexp>] all sexps in the input tree (or whole body) that are of the given type.
[ "Finds", "all", "sexps", "of", "the", "given", "type", "in", "the", "given", "Sexp", "tree", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/analysis/sexp_analysis.rb#L32-L38
19,811
michaeledgar/laser
lib/laser/third_party/rgl/connected_components.rb
RGL.Graph.strongly_connected_components
def strongly_connected_components raise NotDirectedError, "strong_components only works for directed graphs." unless directed? vis = TarjanSccVisitor.new(self) depth_first_search(vis) { |v| } vis end
ruby
def strongly_connected_components raise NotDirectedError, "strong_components only works for directed graphs." unless directed? vis = TarjanSccVisitor.new(self) depth_first_search(vis) { |v| } vis end
[ "def", "strongly_connected_components", "raise", "NotDirectedError", ",", "\"strong_components only works for directed graphs.\"", "unless", "directed?", "vis", "=", "TarjanSccVisitor", ".", "new", "(", "self", ")", "depth_first_search", "(", "vis", ")", "{", "|", "v", "|", "}", "vis", "end" ]
class TarjanSccVisitor This is Tarjan's algorithm for strongly connected components, from his paper "Depth first search and linear graph algorithms". It calculates the components in a single application of DFS. We implement the algorithm with the help of the DFSVisitor TarjanSccVisitor. === Definition A _strongly connected component_ of a directed graph G=(V,E) is a maximal set of vertices U which is in V, such that for every pair of vertices u and v in U, we have both a path from u to v and a path from v to u. That is to say, u and v are reachable from each other. @Article{Tarjan:1972:DFS, author = "R. E. Tarjan", key = "Tarjan", title = "Depth First Search and Linear Graph Algorithms", journal = "SIAM Journal on Computing", volume = "1", number = "2", pages = "146--160", month = jun, year = "1972", CODEN = "SMJCAT", ISSN = "0097-5397 (print), 1095-7111 (electronic)", bibdate = "Thu Jan 23 09:56:44 1997", bibsource = "Parallel/Multi.bib, Misc/Reverse.eng.bib", } The output of the algorithm is recorded in a TarjanSccVisitor _vis_. vis.comp_map will contain numbers giving the component ID assigned to each vertex. The number of components is vis.num_comp.
[ "class", "TarjanSccVisitor", "This", "is", "Tarjan", "s", "algorithm", "for", "strongly", "connected", "components", "from", "his", "paper", "Depth", "first", "search", "and", "linear", "graph", "algorithms", ".", "It", "calculates", "the", "components", "in", "a", "single", "application", "of", "DFS", ".", "We", "implement", "the", "algorithm", "with", "the", "help", "of", "the", "DFSVisitor", "TarjanSccVisitor", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/connected_components.rb#L129-L135
19,812
michaeledgar/laser
lib/laser/third_party/rgl/base.rb
RGL.Graph.each_edge
def each_edge (&block) if directed? each_vertex { |u| each_adjacent(u) { |v| yield u,v } } else each_edge_aux(&block) # concrete graphs should to this better end end
ruby
def each_edge (&block) if directed? each_vertex { |u| each_adjacent(u) { |v| yield u,v } } else each_edge_aux(&block) # concrete graphs should to this better end end
[ "def", "each_edge", "(", "&", "block", ")", "if", "directed?", "each_vertex", "{", "|", "u", "|", "each_adjacent", "(", "u", ")", "{", "|", "v", "|", "yield", "u", ",", "v", "}", "}", "else", "each_edge_aux", "(", "block", ")", "# concrete graphs should to this better", "end", "end" ]
The each_edge iterator should provide efficient access to all edges of the graph. Its defines the EdgeListGraph concept. This method must _not_ be defined by concrete graph classes, because it can be implemented using each_vertex and each_adjacent. However for undirected graph the function is inefficient because we must not yield (v,u) if we already visited edge (u,v).
[ "The", "each_edge", "iterator", "should", "provide", "efficient", "access", "to", "all", "edges", "of", "the", "graph", ".", "Its", "defines", "the", "EdgeListGraph", "concept", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/base.rb#L123-L131
19,813
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.handle_global_options
def handle_global_options(settings) if settings[:"line-length"] @using << Laser.LineLengthWarning(settings[:"line-length"]) end if (only_name = settings[:only]) @fix = @using = Warning.concrete_warnings.select do |w| classname = w.name && w.name.split('::').last (classname && only_name.index(classname)) || (w.short_name && only_name.index(w.short_name)) end end if settings[:profile] require 'benchmark' require 'profile' SETTINGS[:profile] = true end if settings[:include] Laser::SETTINGS[:load_path] = settings[:include].reverse end ARGV.replace(['(stdin)']) if settings[:stdin] end
ruby
def handle_global_options(settings) if settings[:"line-length"] @using << Laser.LineLengthWarning(settings[:"line-length"]) end if (only_name = settings[:only]) @fix = @using = Warning.concrete_warnings.select do |w| classname = w.name && w.name.split('::').last (classname && only_name.index(classname)) || (w.short_name && only_name.index(w.short_name)) end end if settings[:profile] require 'benchmark' require 'profile' SETTINGS[:profile] = true end if settings[:include] Laser::SETTINGS[:load_path] = settings[:include].reverse end ARGV.replace(['(stdin)']) if settings[:stdin] end
[ "def", "handle_global_options", "(", "settings", ")", "if", "settings", "[", ":\"", "\"", "]", "@using", "<<", "Laser", ".", "LineLengthWarning", "(", "settings", "[", ":\"", "\"", "]", ")", "end", "if", "(", "only_name", "=", "settings", "[", ":only", "]", ")", "@fix", "=", "@using", "=", "Warning", ".", "concrete_warnings", ".", "select", "do", "|", "w", "|", "classname", "=", "w", ".", "name", "&&", "w", ".", "name", ".", "split", "(", "'::'", ")", ".", "last", "(", "classname", "&&", "only_name", ".", "index", "(", "classname", ")", ")", "||", "(", "w", ".", "short_name", "&&", "only_name", ".", "index", "(", "w", ".", "short_name", ")", ")", "end", "end", "if", "settings", "[", ":profile", "]", "require", "'benchmark'", "require", "'profile'", "SETTINGS", "[", ":profile", "]", "=", "true", "end", "if", "settings", "[", ":include", "]", "Laser", "::", "SETTINGS", "[", ":load_path", "]", "=", "settings", "[", ":include", "]", ".", "reverse", "end", "ARGV", ".", "replace", "(", "[", "'(stdin)'", "]", ")", "if", "settings", "[", ":stdin", "]", "end" ]
Processes the global options, which includes picking which warnings to run against the source code. The settings provided determine what modifies the runner's settings. @param [Hash] settings the settings from the command-line to process. @option settings :only (String) a list of warning names or short names that will be the only warnings run. The names should be whitespace-delimited. @option settings :"line-length" (Integer) a maximum line length to generate a warning for. A common choice is 80/83.
[ "Processes", "the", "global", "options", "which", "includes", "picking", "which", "warnings", "to", "run", "against", "the", "source", "code", ".", "The", "settings", "provided", "determine", "what", "modifies", "the", "runner", "s", "settings", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L42-L61
19,814
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.get_settings
def get_settings warning_opts = get_warning_options Trollop::options do banner 'LASER: Lexically- and Semantically-Enriched Ruby' opt :fix, 'Should errors be fixed in-line?', short: '-f' opt :display, 'Should errors be displayed?', short: '-b', default: true opt :'report-fixed', 'Should fixed errors be reported anyway?', short: '-r' opt :'line-length', 'Warn at the given line length', short: '-l', type: :int opt :only, 'Only consider the given warning (by short or full name)', short: '-O', type: :string opt :stdin, 'Read Ruby code from standard input', short: '-s' opt :'list-modules', 'Print the discovered, loaded modules' opt :profile, 'Run the profiler during execution' opt :include, 'specify $LOAD_PATH directory (may be used more than once)', short: '-I', multi: true opt :S, 'look for scripts using PATH environment variable', short: '-S' warning_opts.each { |warning| opt(*warning) } end end
ruby
def get_settings warning_opts = get_warning_options Trollop::options do banner 'LASER: Lexically- and Semantically-Enriched Ruby' opt :fix, 'Should errors be fixed in-line?', short: '-f' opt :display, 'Should errors be displayed?', short: '-b', default: true opt :'report-fixed', 'Should fixed errors be reported anyway?', short: '-r' opt :'line-length', 'Warn at the given line length', short: '-l', type: :int opt :only, 'Only consider the given warning (by short or full name)', short: '-O', type: :string opt :stdin, 'Read Ruby code from standard input', short: '-s' opt :'list-modules', 'Print the discovered, loaded modules' opt :profile, 'Run the profiler during execution' opt :include, 'specify $LOAD_PATH directory (may be used more than once)', short: '-I', multi: true opt :S, 'look for scripts using PATH environment variable', short: '-S' warning_opts.each { |warning| opt(*warning) } end end
[ "def", "get_settings", "warning_opts", "=", "get_warning_options", "Trollop", "::", "options", "do", "banner", "'LASER: Lexically- and Semantically-Enriched Ruby'", "opt", ":fix", ",", "'Should errors be fixed in-line?'", ",", "short", ":", "'-f'", "opt", ":display", ",", "'Should errors be displayed?'", ",", "short", ":", "'-b'", ",", "default", ":", "true", "opt", ":'", "'", ",", "'Should fixed errors be reported anyway?'", ",", "short", ":", "'-r'", "opt", ":'", "'", ",", "'Warn at the given line length'", ",", "short", ":", "'-l'", ",", "type", ":", ":int", "opt", ":only", ",", "'Only consider the given warning (by short or full name)'", ",", "short", ":", "'-O'", ",", "type", ":", ":string", "opt", ":stdin", ",", "'Read Ruby code from standard input'", ",", "short", ":", "'-s'", "opt", ":'", "'", ",", "'Print the discovered, loaded modules'", "opt", ":profile", ",", "'Run the profiler during execution'", "opt", ":include", ",", "'specify $LOAD_PATH directory (may be used more than once)'", ",", "short", ":", "'-I'", ",", "multi", ":", "true", "opt", ":S", ",", "'look for scripts using PATH environment variable'", ",", "short", ":", "'-S'", "warning_opts", ".", "each", "{", "|", "warning", "|", "opt", "(", "warning", ")", "}", "end", "end" ]
Parses the command-line options using Trollop @return [Hash{Symbol => Object}] the settings entered by the user
[ "Parses", "the", "command", "-", "line", "options", "using", "Trollop" ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L66-L82
19,815
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.get_warning_options
def get_warning_options all_options = Warning.all_warnings.inject({}) do |result, warning| options = warning.options options = [options] if options.any? && !options[0].is_a?(Array) options.each do |option| result[option.first] = option end result end all_options.values end
ruby
def get_warning_options all_options = Warning.all_warnings.inject({}) do |result, warning| options = warning.options options = [options] if options.any? && !options[0].is_a?(Array) options.each do |option| result[option.first] = option end result end all_options.values end
[ "def", "get_warning_options", "all_options", "=", "Warning", ".", "all_warnings", ".", "inject", "(", "{", "}", ")", "do", "|", "result", ",", "warning", "|", "options", "=", "warning", ".", "options", "options", "=", "[", "options", "]", "if", "options", ".", "any?", "&&", "!", "options", "[", "0", "]", ".", "is_a?", "(", "Array", ")", "options", ".", "each", "do", "|", "option", "|", "result", "[", "option", ".", "first", "]", "=", "option", "end", "result", "end", "all_options", ".", "values", "end" ]
Gets all the options from the warning plugins and collects them with overriding rules. The later the declaration is run, the higher the priority the option has.
[ "Gets", "all", "the", "options", "from", "the", "warning", "plugins", "and", "collects", "them", "with", "overriding", "rules", ".", "The", "later", "the", "declaration", "is", "run", "the", "higher", "the", "priority", "the", "option", "has", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L87-L97
19,816
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.print_modules
def print_modules Analysis::LaserModule.all_modules.map do |mod| result = [] result << if Analysis::LaserClass === mod && mod.superclass then "#{mod.path} < #{mod.superclass.path}" else mod.name end result end.sort.flatten.each { |name| puts name } end
ruby
def print_modules Analysis::LaserModule.all_modules.map do |mod| result = [] result << if Analysis::LaserClass === mod && mod.superclass then "#{mod.path} < #{mod.superclass.path}" else mod.name end result end.sort.flatten.each { |name| puts name } end
[ "def", "print_modules", "Analysis", "::", "LaserModule", ".", "all_modules", ".", "map", "do", "|", "mod", "|", "result", "=", "[", "]", "result", "<<", "if", "Analysis", "::", "LaserClass", "===", "mod", "&&", "mod", ".", "superclass", "then", "\"#{mod.path} < #{mod.superclass.path}\"", "else", "mod", ".", "name", "end", "result", "end", ".", "sort", ".", "flatten", ".", "each", "{", "|", "name", "|", "puts", "name", "}", "end" ]
Prints the known modules after analysis.
[ "Prints", "the", "known", "modules", "after", "analysis", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L100-L109
19,817
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.convert_warning_list
def convert_warning_list(list) list.map do |list| case list when :all then Warning.all_warnings when :whitespace [ExtraBlankLinesWarning, ExtraWhitespaceWarning, OperatorSpacing, MisalignedUnindentationWarning] else list end end.flatten end
ruby
def convert_warning_list(list) list.map do |list| case list when :all then Warning.all_warnings when :whitespace [ExtraBlankLinesWarning, ExtraWhitespaceWarning, OperatorSpacing, MisalignedUnindentationWarning] else list end end.flatten end
[ "def", "convert_warning_list", "(", "list", ")", "list", ".", "map", "do", "|", "list", "|", "case", "list", "when", ":all", "then", "Warning", ".", "all_warnings", "when", ":whitespace", "[", "ExtraBlankLinesWarning", ",", "ExtraWhitespaceWarning", ",", "OperatorSpacing", ",", "MisalignedUnindentationWarning", "]", "else", "list", "end", "end", ".", "flatten", "end" ]
Converts a list of warnings and symbol shortcuts for warnings to just a list of warnings.
[ "Converts", "a", "list", "of", "warnings", "and", "symbol", "shortcuts", "for", "warnings", "to", "just", "a", "list", "of", "warnings", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L120-L130
19,818
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.collect_warnings
def collect_warnings(files, scanner) full_list = files.map do |file| data = file == '(stdin)' ? STDIN.read : File.read(file) if scanner.settings[:fix] scanner.settings[:output_file] = scanner.settings[:stdin] ? STDOUT : File.open(file, 'w') end results = scanner.scan(data, file) if scanner.settings[:fix] && !scanner.settings[:stdin] scanner.settings[:output_file].close end results end full_list.flatten end
ruby
def collect_warnings(files, scanner) full_list = files.map do |file| data = file == '(stdin)' ? STDIN.read : File.read(file) if scanner.settings[:fix] scanner.settings[:output_file] = scanner.settings[:stdin] ? STDOUT : File.open(file, 'w') end results = scanner.scan(data, file) if scanner.settings[:fix] && !scanner.settings[:stdin] scanner.settings[:output_file].close end results end full_list.flatten end
[ "def", "collect_warnings", "(", "files", ",", "scanner", ")", "full_list", "=", "files", ".", "map", "do", "|", "file", "|", "data", "=", "file", "==", "'(stdin)'", "?", "STDIN", ".", "read", ":", "File", ".", "read", "(", "file", ")", "if", "scanner", ".", "settings", "[", ":fix", "]", "scanner", ".", "settings", "[", ":output_file", "]", "=", "scanner", ".", "settings", "[", ":stdin", "]", "?", "STDOUT", ":", "File", ".", "open", "(", "file", ",", "'w'", ")", "end", "results", "=", "scanner", ".", "scan", "(", "data", ",", "file", ")", "if", "scanner", ".", "settings", "[", ":fix", "]", "&&", "!", "scanner", ".", "settings", "[", ":stdin", "]", "scanner", ".", "settings", "[", ":output_file", "]", ".", "close", "end", "results", "end", "full_list", ".", "flatten", "end" ]
Collects warnings from all the provided files by running them through the scanner. @param [Array<String>] files the files to scan. If (stdin) is in the array, then data will be read from STDIN until EOF is reached. @param [Scanner] scanner the scanner that will look for warnings in the source text. @return [Array<Warning>] a set of warnings, ordered by file.
[ "Collects", "warnings", "from", "all", "the", "provided", "files", "by", "running", "them", "through", "the", "scanner", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L160-L173
19,819
michaeledgar/laser
lib/laser/runner.rb
Laser.Runner.display_warnings
def display_warnings(warnings, settings) num_fixable = warnings.select { |warn| warn.fixable? }.size num_total = warnings.size results = "#{num_total} warnings found. #{num_fixable} are fixable." puts results puts '=' * results.size warnings.each do |warning| puts "#{warning.file}:#{warning.line_number} #{warning.name} " + "(#{warning.severity}) - #{warning.desc}" end end
ruby
def display_warnings(warnings, settings) num_fixable = warnings.select { |warn| warn.fixable? }.size num_total = warnings.size results = "#{num_total} warnings found. #{num_fixable} are fixable." puts results puts '=' * results.size warnings.each do |warning| puts "#{warning.file}:#{warning.line_number} #{warning.name} " + "(#{warning.severity}) - #{warning.desc}" end end
[ "def", "display_warnings", "(", "warnings", ",", "settings", ")", "num_fixable", "=", "warnings", ".", "select", "{", "|", "warn", "|", "warn", ".", "fixable?", "}", ".", "size", "num_total", "=", "warnings", ".", "size", "results", "=", "\"#{num_total} warnings found. #{num_fixable} are fixable.\"", "puts", "results", "puts", "'='", "*", "results", ".", "size", "warnings", ".", "each", "do", "|", "warning", "|", "puts", "\"#{warning.file}:#{warning.line_number} #{warning.name} \"", "+", "\"(#{warning.severity}) - #{warning.desc}\"", "end", "end" ]
Displays warnings using user-provided settings. @param [Array<Warning>] warnings the warnings generated by the input files, ordered by file @param [Hash{Symbol => Object}] settings the user-set display settings
[ "Displays", "warnings", "using", "user", "-", "provided", "settings", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/runner.rb#L180-L192
19,820
michaeledgar/laser
lib/laser/third_party/rgl/traversal.rb
RGL.GraphVisitor.attach_distance_map
def attach_distance_map (map = Hash.new(0)) @dist_map = map class << self def handle_tree_edge (u, v) super @dist_map[v] = @dist_map[u] + 1 end # Answer the distance to the start vertex. def distance_to_root (v) @dist_map[v] end end # class end
ruby
def attach_distance_map (map = Hash.new(0)) @dist_map = map class << self def handle_tree_edge (u, v) super @dist_map[v] = @dist_map[u] + 1 end # Answer the distance to the start vertex. def distance_to_root (v) @dist_map[v] end end # class end
[ "def", "attach_distance_map", "(", "map", "=", "Hash", ".", "new", "(", "0", ")", ")", "@dist_map", "=", "map", "class", "<<", "self", "def", "handle_tree_edge", "(", "u", ",", "v", ")", "super", "@dist_map", "[", "v", "]", "=", "@dist_map", "[", "u", "]", "+", "1", "end", "# Answer the distance to the start vertex.", "def", "distance_to_root", "(", "v", ")", "@dist_map", "[", "v", "]", "end", "end", "# class", "end" ]
Attach a map to the visitor which records the distance of a visited vertex to the start vertex. This is similar to BGLs distance_recorder[http://www.boost.org/libs/graph/doc/distance_recorder.html]. After the distance_map is attached, the visitor has a new method distance_to_root, which answers the distance to the start vertex.
[ "Attach", "a", "map", "to", "the", "visitor", "which", "records", "the", "distance", "of", "a", "visited", "vertex", "to", "the", "start", "vertex", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/traversal.rb#L99-L116
19,821
michaeledgar/laser
lib/laser/third_party/rgl/traversal.rb
RGL.Graph.bfs_search_tree_from
def bfs_search_tree_from (v) require 'laser/third_party/rgl/adjacency' bfs = bfs_iterator(v) tree = DirectedAdjacencyGraph.new bfs.set_tree_edge_event_handler { |from, to| tree.add_edge(from, to) } bfs.set_to_end # does the search tree end
ruby
def bfs_search_tree_from (v) require 'laser/third_party/rgl/adjacency' bfs = bfs_iterator(v) tree = DirectedAdjacencyGraph.new bfs.set_tree_edge_event_handler { |from, to| tree.add_edge(from, to) } bfs.set_to_end # does the search tree end
[ "def", "bfs_search_tree_from", "(", "v", ")", "require", "'laser/third_party/rgl/adjacency'", "bfs", "=", "bfs_iterator", "(", "v", ")", "tree", "=", "DirectedAdjacencyGraph", ".", "new", "bfs", ".", "set_tree_edge_event_handler", "{", "|", "from", ",", "to", "|", "tree", ".", "add_edge", "(", "from", ",", "to", ")", "}", "bfs", ".", "set_to_end", "# does the search", "tree", "end" ]
Returns a DirectedAdjacencyGraph, which represents a BFS search tree starting at _v_. This method uses the tree_edge_event of BFSIterator to record all tree edges of the search tree in the result.
[ "Returns", "a", "DirectedAdjacencyGraph", "which", "represents", "a", "BFS", "search", "tree", "starting", "at", "_v_", ".", "This", "method", "uses", "the", "tree_edge_event", "of", "BFSIterator", "to", "record", "all", "tree", "edges", "of", "the", "search", "tree", "in", "the", "result", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/traversal.rb#L237-L246
19,822
michaeledgar/laser
lib/laser/third_party/rgl/traversal.rb
RGL.Graph.depth_first_search
def depth_first_search (vis = DFSVisitor.new(self), &b) each_vertex do |u| unless vis.finished_vertex?(u) vis.handle_start_vertex(u) depth_first_visit(u, vis, &b) end end end
ruby
def depth_first_search (vis = DFSVisitor.new(self), &b) each_vertex do |u| unless vis.finished_vertex?(u) vis.handle_start_vertex(u) depth_first_visit(u, vis, &b) end end end
[ "def", "depth_first_search", "(", "vis", "=", "DFSVisitor", ".", "new", "(", "self", ")", ",", "&", "b", ")", "each_vertex", "do", "|", "u", "|", "unless", "vis", ".", "finished_vertex?", "(", "u", ")", "vis", ".", "handle_start_vertex", "(", "u", ")", "depth_first_visit", "(", "u", ",", "vis", ",", "b", ")", "end", "end", "end" ]
Do a recursive DFS search on the whole graph. If a block is passed, it is called on each _finish_vertex_ event. See strongly_connected_components for an example usage.
[ "Do", "a", "recursive", "DFS", "search", "on", "the", "whole", "graph", ".", "If", "a", "block", "is", "passed", "it", "is", "called", "on", "each", "_finish_vertex_", "event", ".", "See", "strongly_connected_components", "for", "an", "example", "usage", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/traversal.rb#L299-L306
19,823
michaeledgar/laser
lib/laser/third_party/rgl/traversal.rb
RGL.Graph.depth_first_visit
def depth_first_visit (u, vis = DFSVisitor.new(self), &b) vis.color_map[u] = :GRAY vis.handle_examine_vertex(u) each_adjacent(u) { |v| vis.handle_examine_edge(u, v) if vis.follow_edge?(u, v) # (u,v) is a tree edge vis.handle_tree_edge(u, v) # also discovers v vis.color_map[v] = :GRAY # color of v was :WHITE depth_first_visit(v, vis, &b) else # (u,v) is a non tree edge if vis.color_map[v] == :GRAY vis.handle_back_edge(u, v) # (u,v) has gray target else vis.handle_forward_edge(u, v) # (u,v) is a cross or forward edge end end } vis.color_map[u] = :BLACK vis.handle_finish_vertex(u) # finish vertex b.call(u) end
ruby
def depth_first_visit (u, vis = DFSVisitor.new(self), &b) vis.color_map[u] = :GRAY vis.handle_examine_vertex(u) each_adjacent(u) { |v| vis.handle_examine_edge(u, v) if vis.follow_edge?(u, v) # (u,v) is a tree edge vis.handle_tree_edge(u, v) # also discovers v vis.color_map[v] = :GRAY # color of v was :WHITE depth_first_visit(v, vis, &b) else # (u,v) is a non tree edge if vis.color_map[v] == :GRAY vis.handle_back_edge(u, v) # (u,v) has gray target else vis.handle_forward_edge(u, v) # (u,v) is a cross or forward edge end end } vis.color_map[u] = :BLACK vis.handle_finish_vertex(u) # finish vertex b.call(u) end
[ "def", "depth_first_visit", "(", "u", ",", "vis", "=", "DFSVisitor", ".", "new", "(", "self", ")", ",", "&", "b", ")", "vis", ".", "color_map", "[", "u", "]", "=", ":GRAY", "vis", ".", "handle_examine_vertex", "(", "u", ")", "each_adjacent", "(", "u", ")", "{", "|", "v", "|", "vis", ".", "handle_examine_edge", "(", "u", ",", "v", ")", "if", "vis", ".", "follow_edge?", "(", "u", ",", "v", ")", "# (u,v) is a tree edge", "vis", ".", "handle_tree_edge", "(", "u", ",", "v", ")", "# also discovers v", "vis", ".", "color_map", "[", "v", "]", "=", ":GRAY", "# color of v was :WHITE", "depth_first_visit", "(", "v", ",", "vis", ",", "b", ")", "else", "# (u,v) is a non tree edge", "if", "vis", ".", "color_map", "[", "v", "]", "==", ":GRAY", "vis", ".", "handle_back_edge", "(", "u", ",", "v", ")", "# (u,v) has gray target", "else", "vis", ".", "handle_forward_edge", "(", "u", ",", "v", ")", "# (u,v) is a cross or forward edge ", "end", "end", "}", "vis", ".", "color_map", "[", "u", "]", "=", ":BLACK", "vis", ".", "handle_finish_vertex", "(", "u", ")", "# finish vertex", "b", ".", "call", "(", "u", ")", "end" ]
Start a depth first search at vertex _u_. The block _b_ is called on each finish_vertex event.
[ "Start", "a", "depth", "first", "search", "at", "vertex", "_u_", ".", "The", "block", "_b_", "is", "called", "on", "each", "finish_vertex", "event", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/traversal.rb#L311-L331
19,824
michaeledgar/laser
lib/laser/scanner.rb
Laser.Scanner.scan
def scan(text, filename='(none)') warnings = scan_for_file_warnings(text, filename) text = filter_fixable(warnings).inject(text) do |text, warning| warning.fix(text) end with_fixing_piped_to_output do text.split(/\n/).each_with_index do |line, number| warnings.concat process_line(line, number + 1, filename) end end warnings += unused_method_warnings warnings end
ruby
def scan(text, filename='(none)') warnings = scan_for_file_warnings(text, filename) text = filter_fixable(warnings).inject(text) do |text, warning| warning.fix(text) end with_fixing_piped_to_output do text.split(/\n/).each_with_index do |line, number| warnings.concat process_line(line, number + 1, filename) end end warnings += unused_method_warnings warnings end
[ "def", "scan", "(", "text", ",", "filename", "=", "'(none)'", ")", "warnings", "=", "scan_for_file_warnings", "(", "text", ",", "filename", ")", "text", "=", "filter_fixable", "(", "warnings", ")", ".", "inject", "(", "text", ")", "do", "|", "text", ",", "warning", "|", "warning", ".", "fix", "(", "text", ")", "end", "with_fixing_piped_to_output", "do", "text", ".", "split", "(", "/", "\\n", "/", ")", ".", "each_with_index", "do", "|", "line", ",", "number", "|", "warnings", ".", "concat", "process_line", "(", "line", ",", "number", "+", "1", ",", "filename", ")", "end", "end", "warnings", "+=", "unused_method_warnings", "warnings", "end" ]
Scans the text for warnings. @param [String] text the input ruby file to scan @return [Array[Laser::Warnings]] the warnings generated by the code. If the code is clean, an empty array is returned.
[ "Scans", "the", "text", "for", "warnings", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/scanner.rb#L45-L57
19,825
michaeledgar/laser
lib/laser/scanner.rb
Laser.Scanner.process_line
def process_line(line, line_number, filename) warnings = all_warnings_for_line(line, line_number, filename) fix_input(warnings, line, line_number, filename) if @settings[:fix] warnings end
ruby
def process_line(line, line_number, filename) warnings = all_warnings_for_line(line, line_number, filename) fix_input(warnings, line, line_number, filename) if @settings[:fix] warnings end
[ "def", "process_line", "(", "line", ",", "line_number", ",", "filename", ")", "warnings", "=", "all_warnings_for_line", "(", "line", ",", "line_number", ",", "filename", ")", "fix_input", "(", "warnings", ",", "line", ",", "line_number", ",", "filename", ")", "if", "@settings", "[", ":fix", "]", "warnings", "end" ]
Finds all matching warnings, and if the user wishes, fix a subset of them.
[ "Finds", "all", "matching", "warnings", "and", "if", "the", "user", "wishes", "fix", "a", "subset", "of", "them", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/scanner.rb#L68-L72
19,826
michaeledgar/laser
lib/laser/scanner.rb
Laser.Scanner.fix_input
def fix_input(warnings, line, line_number, filename) fixable_warnings = filter_fixable warnings if fixable_warnings.size == 1 self.settings[:output_lines] << fixable_warnings.first.fix rescue line elsif fixable_warnings.size > 1 new_text = fixable_warnings.first.fix rescue line process_line(new_text, line_number, filename) else self.settings[:output_lines] << line end end
ruby
def fix_input(warnings, line, line_number, filename) fixable_warnings = filter_fixable warnings if fixable_warnings.size == 1 self.settings[:output_lines] << fixable_warnings.first.fix rescue line elsif fixable_warnings.size > 1 new_text = fixable_warnings.first.fix rescue line process_line(new_text, line_number, filename) else self.settings[:output_lines] << line end end
[ "def", "fix_input", "(", "warnings", ",", "line", ",", "line_number", ",", "filename", ")", "fixable_warnings", "=", "filter_fixable", "warnings", "if", "fixable_warnings", ".", "size", "==", "1", "self", ".", "settings", "[", ":output_lines", "]", "<<", "fixable_warnings", ".", "first", ".", "fix", "rescue", "line", "elsif", "fixable_warnings", ".", "size", ">", "1", "new_text", "=", "fixable_warnings", ".", "first", ".", "fix", "rescue", "line", "process_line", "(", "new_text", ",", "line_number", ",", "filename", ")", "else", "self", ".", "settings", "[", ":output_lines", "]", "<<", "line", "end", "end" ]
Tries to fix the given line with a set of matching warnings for that line. May recurse if there are multiple warnings on the same line.
[ "Tries", "to", "fix", "the", "given", "line", "with", "a", "set", "of", "matching", "warnings", "for", "that", "line", ".", "May", "recurse", "if", "there", "are", "multiple", "warnings", "on", "the", "same", "line", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/scanner.rb#L76-L86
19,827
michaeledgar/laser
lib/laser/scanner.rb
Laser.Scanner.all_warnings_for_line
def all_warnings_for_line(line, line_number, filename) new_warnings = check_for_indent_warnings!(line, filename) new_warnings.concat scan_for_line_warnings(line, filename) new_warnings.each {|warning| warning.line_number = line_number} end
ruby
def all_warnings_for_line(line, line_number, filename) new_warnings = check_for_indent_warnings!(line, filename) new_warnings.concat scan_for_line_warnings(line, filename) new_warnings.each {|warning| warning.line_number = line_number} end
[ "def", "all_warnings_for_line", "(", "line", ",", "line_number", ",", "filename", ")", "new_warnings", "=", "check_for_indent_warnings!", "(", "line", ",", "filename", ")", "new_warnings", ".", "concat", "scan_for_line_warnings", "(", "line", ",", "filename", ")", "new_warnings", ".", "each", "{", "|", "warning", "|", "warning", ".", "line_number", "=", "line_number", "}", "end" ]
Returns all warnings that match the line
[ "Returns", "all", "warnings", "that", "match", "the", "line" ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/scanner.rb#L89-L93
19,828
michaeledgar/laser
lib/laser/scanner.rb
Laser.Scanner.check_for_indent_warnings!
def check_for_indent_warnings!(line, filename) return [] if line == "" indent_size = get_indent_size line if indent_size > current_indent self.indent_stack.push indent_size elsif indent_size < current_indent previous = self.indent_stack.pop if indent_size != current_indent && using.include?(MisalignedUnindentationWarning) warnings_to_check = [MisalignedUnindentationWarning.new(filename, line, current_indent)] return filtered_warnings_from_line(line, warnings_to_check) end end [] end
ruby
def check_for_indent_warnings!(line, filename) return [] if line == "" indent_size = get_indent_size line if indent_size > current_indent self.indent_stack.push indent_size elsif indent_size < current_indent previous = self.indent_stack.pop if indent_size != current_indent && using.include?(MisalignedUnindentationWarning) warnings_to_check = [MisalignedUnindentationWarning.new(filename, line, current_indent)] return filtered_warnings_from_line(line, warnings_to_check) end end [] end
[ "def", "check_for_indent_warnings!", "(", "line", ",", "filename", ")", "return", "[", "]", "if", "line", "==", "\"\"", "indent_size", "=", "get_indent_size", "line", "if", "indent_size", ">", "current_indent", "self", ".", "indent_stack", ".", "push", "indent_size", "elsif", "indent_size", "<", "current_indent", "previous", "=", "self", ".", "indent_stack", ".", "pop", "if", "indent_size", "!=", "current_indent", "&&", "using", ".", "include?", "(", "MisalignedUnindentationWarning", ")", "warnings_to_check", "=", "[", "MisalignedUnindentationWarning", ".", "new", "(", "filename", ",", "line", ",", "current_indent", ")", "]", "return", "filtered_warnings_from_line", "(", "line", ",", "warnings_to_check", ")", "end", "end", "[", "]", "end" ]
Checks for new warnings based on indentation.
[ "Checks", "for", "new", "warnings", "based", "on", "indentation", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/scanner.rb#L101-L115
19,829
michaeledgar/laser
lib/laser/scanner.rb
Laser.Scanner.scan_for_line_warnings
def scan_for_line_warnings(line, filename) warnings = scan_for_warnings(using & LineWarning.all_warnings, line, filename) filtered_warnings_from_line(line, warnings) end
ruby
def scan_for_line_warnings(line, filename) warnings = scan_for_warnings(using & LineWarning.all_warnings, line, filename) filtered_warnings_from_line(line, warnings) end
[ "def", "scan_for_line_warnings", "(", "line", ",", "filename", ")", "warnings", "=", "scan_for_warnings", "(", "using", "&", "LineWarning", ".", "all_warnings", ",", "line", ",", "filename", ")", "filtered_warnings_from_line", "(", "line", ",", "warnings", ")", "end" ]
Goes through all line warning subclasses and checks if we got some new warnings for a given line
[ "Goes", "through", "all", "line", "warning", "subclasses", "and", "checks", "if", "we", "got", "some", "new", "warnings", "for", "a", "given", "line" ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/scanner.rb#L147-L150
19,830
michaeledgar/laser
lib/laser/analysis/lexical_analysis.rb
Laser.LexicalAnalysis.lex
def lex(body = self.body, token_class = Token) return [] if body =~ /^#.*encoding.*/ Ripper.lex(body).map {|token| token_class.new(token) } end
ruby
def lex(body = self.body, token_class = Token) return [] if body =~ /^#.*encoding.*/ Ripper.lex(body).map {|token| token_class.new(token) } end
[ "def", "lex", "(", "body", "=", "self", ".", "body", ",", "token_class", "=", "Token", ")", "return", "[", "]", "if", "body", "=~", "/", "/", "Ripper", ".", "lex", "(", "body", ")", ".", "map", "{", "|", "token", "|", "token_class", ".", "new", "(", "token", ")", "}", "end" ]
Lexes the given text. @param [String] body (self.body) The text to lex @return [Array<Array<Integer, Integer>, Symbol, String>] A set of tokens in Ripper's result format. Each token is an array of the form: [[1, token_position], token_type, token_text]. I'm not exactly clear on why the 1 is always there. At any rate - the result is an array of those tokens.
[ "Lexes", "the", "given", "text", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/analysis/lexical_analysis.rb#L31-L34
19,831
michaeledgar/laser
lib/laser/analysis/lexical_analysis.rb
Laser.LexicalAnalysis.find_token
def find_token(*args) body, list = _extract_token_search_args(args) # grr match comment with encoding in it lexed = lex(body) lexed.find.with_index do |tok, idx| is_token = list.include?(tok.type) is_not_symbol = idx == 0 || lexed[idx-1].type != :on_symbeg is_token && is_not_symbol end end
ruby
def find_token(*args) body, list = _extract_token_search_args(args) # grr match comment with encoding in it lexed = lex(body) lexed.find.with_index do |tok, idx| is_token = list.include?(tok.type) is_not_symbol = idx == 0 || lexed[idx-1].type != :on_symbeg is_token && is_not_symbol end end
[ "def", "find_token", "(", "*", "args", ")", "body", ",", "list", "=", "_extract_token_search_args", "(", "args", ")", "# grr match comment with encoding in it", "lexed", "=", "lex", "(", "body", ")", "lexed", ".", "find", ".", "with_index", "do", "|", "tok", ",", "idx", "|", "is_token", "=", "list", ".", "include?", "(", "tok", ".", "type", ")", "is_not_symbol", "=", "idx", "==", "0", "||", "lexed", "[", "idx", "-", "1", "]", ".", "type", "!=", ":on_symbeg", "is_token", "&&", "is_not_symbol", "end", "end" ]
Finds the first instance of a set of tokens in the body. If no text is given to scan, then the full content is scanned. @param [String] body (self.body) The first parameter is optional: the text to search. This defaults to the full text. @param [Symbol] token The rest of the arguments are tokens to search for. Any number of tokens may be specified. @return [Array] the token in the form returned by Ripper. See #lex.
[ "Finds", "the", "first", "instance", "of", "a", "set", "of", "tokens", "in", "the", "body", ".", "If", "no", "text", "is", "given", "to", "scan", "then", "the", "full", "content", "is", "scanned", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/analysis/lexical_analysis.rb#L114-L123
19,832
michaeledgar/laser
lib/laser/analysis/lexical_analysis.rb
Laser.LexicalAnalysis.split_on_keyword
def split_on_keyword(*args) body, keywords = _extract_token_search_args(args) token = find_keyword(body, *keywords) return _split_body_with_raw_token(body, token) end
ruby
def split_on_keyword(*args) body, keywords = _extract_token_search_args(args) token = find_keyword(body, *keywords) return _split_body_with_raw_token(body, token) end
[ "def", "split_on_keyword", "(", "*", "args", ")", "body", ",", "keywords", "=", "_extract_token_search_args", "(", "args", ")", "token", "=", "find_keyword", "(", "body", ",", "keywords", ")", "return", "_split_body_with_raw_token", "(", "body", ",", "token", ")", "end" ]
Splits the body into two halfs based on the first appearance of a keyword. @example split_on_keyword('x = 5 unless y == 2', :unless) # => ['x = 5 ', 'unless y == 2'] @param [String] body (self.body) The first parameter is optional: the text to search. This defaults to the full text. @param [Symbol] token The rest of the arguments are keywords to search for. Any number of keywords may be specified. @return [Array<String, String>] The body split by the keyword.
[ "Splits", "the", "body", "into", "two", "halfs", "based", "on", "the", "first", "appearance", "of", "a", "keyword", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/analysis/lexical_analysis.rb#L135-L139
19,833
michaeledgar/laser
lib/laser/analysis/lexical_analysis.rb
Laser.LexicalAnalysis.split_on_token
def split_on_token(*args) body, tokens = _extract_token_search_args(args) token = find_token(body, *tokens) return _split_body_with_raw_token(body, token) end
ruby
def split_on_token(*args) body, tokens = _extract_token_search_args(args) token = find_token(body, *tokens) return _split_body_with_raw_token(body, token) end
[ "def", "split_on_token", "(", "*", "args", ")", "body", ",", "tokens", "=", "_extract_token_search_args", "(", "args", ")", "token", "=", "find_token", "(", "body", ",", "tokens", ")", "return", "_split_body_with_raw_token", "(", "body", ",", "token", ")", "end" ]
Splits the body into two halfs based on the first appearance of a token. @example split_on_token('x = 5 unless y == 2', :on_kw) # => ['x = 5 ', 'unless y == 2'] @param [String] body (self.body) The first parameter is optional: the text to search. This defaults to the full text. @param [Symbol] token The rest of the arguments are tokens to search for. Any number of tokens may be specified. @return [Array<String, String>] The body split by the token.
[ "Splits", "the", "body", "into", "two", "halfs", "based", "on", "the", "first", "appearance", "of", "a", "token", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/analysis/lexical_analysis.rb#L151-L155
19,834
michaeledgar/laser
lib/laser/third_party/rgl/adjacency.rb
RGL.Graph.to_adjacency
def to_adjacency result = (directed? ? DirectedAdjacencyGraph : AdjacencyGraph).new each_vertex { |v| result.add_vertex(v) } each_edge { |u,v| result.add_edge(u, v) } result end
ruby
def to_adjacency result = (directed? ? DirectedAdjacencyGraph : AdjacencyGraph).new each_vertex { |v| result.add_vertex(v) } each_edge { |u,v| result.add_edge(u, v) } result end
[ "def", "to_adjacency", "result", "=", "(", "directed?", "?", "DirectedAdjacencyGraph", ":", "AdjacencyGraph", ")", ".", "new", "each_vertex", "{", "|", "v", "|", "result", ".", "add_vertex", "(", "v", ")", "}", "each_edge", "{", "|", "u", ",", "v", "|", "result", ".", "add_edge", "(", "u", ",", "v", ")", "}", "result", "end" ]
Convert a general graph to an AdjacencyGraph. If the graph is directed, returns a DirectedAdjacencyGraph; otherwise, returns an AdjacencyGraph.
[ "Convert", "a", "general", "graph", "to", "an", "AdjacencyGraph", ".", "If", "the", "graph", "is", "directed", "returns", "a", "DirectedAdjacencyGraph", ";", "otherwise", "returns", "an", "AdjacencyGraph", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/adjacency.rb#L189-L194
19,835
michaeledgar/laser
lib/laser/third_party/rgl/adjacency.rb
RGL.DirectedAdjacencyGraph.initialize_copy
def initialize_copy(orig) @vertex_dict = orig.instance_eval{@vertex_dict}.dup @vertex_dict.keys.each do |v| @vertex_dict[v] = @vertex_dict[v].dup end @predecessor_dict = orig.instance_eval{@predecessor_dict}.dup @predecessor_dict.keys.each do |v| @predecessor_dict[v] = @predecessor_dict[v].dup end end
ruby
def initialize_copy(orig) @vertex_dict = orig.instance_eval{@vertex_dict}.dup @vertex_dict.keys.each do |v| @vertex_dict[v] = @vertex_dict[v].dup end @predecessor_dict = orig.instance_eval{@predecessor_dict}.dup @predecessor_dict.keys.each do |v| @predecessor_dict[v] = @predecessor_dict[v].dup end end
[ "def", "initialize_copy", "(", "orig", ")", "@vertex_dict", "=", "orig", ".", "instance_eval", "{", "@vertex_dict", "}", ".", "dup", "@vertex_dict", ".", "keys", ".", "each", "do", "|", "v", "|", "@vertex_dict", "[", "v", "]", "=", "@vertex_dict", "[", "v", "]", ".", "dup", "end", "@predecessor_dict", "=", "orig", ".", "instance_eval", "{", "@predecessor_dict", "}", ".", "dup", "@predecessor_dict", ".", "keys", ".", "each", "do", "|", "v", "|", "@predecessor_dict", "[", "v", "]", "=", "@predecessor_dict", "[", "v", "]", ".", "dup", "end", "end" ]
Returns a new empty DirectedAdjacencyGraph which has as its edgelist class the given class. The default edgelist class is Set, to ensure set semantics for edges and vertices. If other graphs are passed as parameters their vertices and edges are added to the new graph. Copy internal vertice_dict
[ "Returns", "a", "new", "empty", "DirectedAdjacencyGraph", "which", "has", "as", "its", "edgelist", "class", "the", "given", "class", ".", "The", "default", "edgelist", "class", "is", "Set", "to", "ensure", "set", "semantics", "for", "edges", "and", "vertices", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/adjacency.rb#L49-L58
19,836
michaeledgar/laser
lib/laser/third_party/rgl/adjacency.rb
RGL.DirectedAdjacencyGraph.edgelist_class=
def edgelist_class=(klass) @vertex_dict.keys.each do |v| @vertex_dict[v] = klass.new @vertex_dict[v].to_a end @predecessor_dict.keys.each do |v| @predecessor_dict[v] = klass.new @predecessor_dict[v].to_a end end
ruby
def edgelist_class=(klass) @vertex_dict.keys.each do |v| @vertex_dict[v] = klass.new @vertex_dict[v].to_a end @predecessor_dict.keys.each do |v| @predecessor_dict[v] = klass.new @predecessor_dict[v].to_a end end
[ "def", "edgelist_class", "=", "(", "klass", ")", "@vertex_dict", ".", "keys", ".", "each", "do", "|", "v", "|", "@vertex_dict", "[", "v", "]", "=", "klass", ".", "new", "@vertex_dict", "[", "v", "]", ".", "to_a", "end", "@predecessor_dict", ".", "keys", ".", "each", "do", "|", "v", "|", "@predecessor_dict", "[", "v", "]", "=", "klass", ".", "new", "@predecessor_dict", "[", "v", "]", ".", "to_a", "end", "end" ]
Converts the adjacency list of each vertex to be of type _klass_. The class is expected to have a new contructor which accepts an enumerable as parameter.
[ "Converts", "the", "adjacency", "list", "of", "each", "vertex", "to", "be", "of", "type", "_klass_", ".", "The", "class", "is", "expected", "to", "have", "a", "new", "contructor", "which", "accepts", "an", "enumerable", "as", "parameter", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/adjacency.rb#L140-L147
19,837
michaeledgar/laser
lib/laser/support/module_extensions.rb
Laser.ModuleExtensions.opposite_method
def opposite_method(new_name, old_name) define_method new_name do |*args, &blk| !send(old_name, *args, &blk) end end
ruby
def opposite_method(new_name, old_name) define_method new_name do |*args, &blk| !send(old_name, *args, &blk) end end
[ "def", "opposite_method", "(", "new_name", ",", "old_name", ")", "define_method", "new_name", "do", "|", "*", "args", ",", "&", "blk", "|", "!", "send", "(", "old_name", ",", "args", ",", "blk", ")", "end", "end" ]
Creates a new method that returns the boolean negation of the specified method.
[ "Creates", "a", "new", "method", "that", "returns", "the", "boolean", "negation", "of", "the", "specified", "method", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/support/module_extensions.rb#L9-L13
19,838
michaeledgar/laser
lib/laser/support/module_extensions.rb
Laser.ModuleExtensions.attr_accessor_with_default
def attr_accessor_with_default(name, val) ivar_sym = "@#{name}" define_method name do unless instance_variable_defined?(ivar_sym) instance_variable_set(ivar_sym, val) end instance_variable_get ivar_sym end attr_writer name end
ruby
def attr_accessor_with_default(name, val) ivar_sym = "@#{name}" define_method name do unless instance_variable_defined?(ivar_sym) instance_variable_set(ivar_sym, val) end instance_variable_get ivar_sym end attr_writer name end
[ "def", "attr_accessor_with_default", "(", "name", ",", "val", ")", "ivar_sym", "=", "\"@#{name}\"", "define_method", "name", "do", "unless", "instance_variable_defined?", "(", "ivar_sym", ")", "instance_variable_set", "(", "ivar_sym", ",", "val", ")", "end", "instance_variable_get", "ivar_sym", "end", "attr_writer", "name", "end" ]
Creates an attr_accessor that defaults to a certain value.
[ "Creates", "an", "attr_accessor", "that", "defaults", "to", "a", "certain", "value", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/support/module_extensions.rb#L16-L25
19,839
michaeledgar/laser
lib/laser/support/module_extensions.rb
Laser.ModuleExtensions.cattr_get_and_setter
def cattr_get_and_setter(*attrs) attrs.each do |attr| cattr_accessor attr singleton_class.instance_eval do alias_method "#{attr}_old_get".to_sym, attr define_method attr do |*args, &blk| if args.size > 0 send("#{attr}=", *args) elsif blk != nil send("#{attr}=", blk) else send("#{attr}_old_get") end end end end end
ruby
def cattr_get_and_setter(*attrs) attrs.each do |attr| cattr_accessor attr singleton_class.instance_eval do alias_method "#{attr}_old_get".to_sym, attr define_method attr do |*args, &blk| if args.size > 0 send("#{attr}=", *args) elsif blk != nil send("#{attr}=", blk) else send("#{attr}_old_get") end end end end end
[ "def", "cattr_get_and_setter", "(", "*", "attrs", ")", "attrs", ".", "each", "do", "|", "attr", "|", "cattr_accessor", "attr", "singleton_class", ".", "instance_eval", "do", "alias_method", "\"#{attr}_old_get\"", ".", "to_sym", ",", "attr", "define_method", "attr", "do", "|", "*", "args", ",", "&", "blk", "|", "if", "args", ".", "size", ">", "0", "send", "(", "\"#{attr}=\"", ",", "args", ")", "elsif", "blk", "!=", "nil", "send", "(", "\"#{attr}=\"", ",", "blk", ")", "else", "send", "(", "\"#{attr}_old_get\"", ")", "end", "end", "end", "end", "end" ]
Creates a DSL-friendly set-and-getter method. The method, when called with no arguments, acts as a getter. When called with arguments, it acts as a setter. Uses class instance variables - this is not for generating instance methods. @example class A cattr_get_and_setter :type end class B < A type :silly end p B.type # => :silly
[ "Creates", "a", "DSL", "-", "friendly", "set", "-", "and", "-", "getter", "method", ".", "The", "method", "when", "called", "with", "no", "arguments", "acts", "as", "a", "getter", ".", "When", "called", "with", "arguments", "it", "acts", "as", "a", "setter", ".", "Uses", "class", "instance", "variables", "-", "this", "is", "not", "for", "generating", "instance", "methods", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/support/module_extensions.rb#L76-L92
19,840
michaeledgar/laser
lib/laser/third_party/rgl/dominators.rb
RGL.Graph.dominance_frontier
def dominance_frontier(start_node = self.enter, dom_tree) vertices.inject(Hash.new { |h, k| h[k] = Set.new }) do |result, b| preds = b.real_predecessors if preds.size >= 2 preds.each do |p| b_dominator = dom_tree[b].successors.first break unless b_dominator runner = dom_tree[p] while runner && runner != b_dominator result[runner] << b runner = runner.successors.first end end end result end end
ruby
def dominance_frontier(start_node = self.enter, dom_tree) vertices.inject(Hash.new { |h, k| h[k] = Set.new }) do |result, b| preds = b.real_predecessors if preds.size >= 2 preds.each do |p| b_dominator = dom_tree[b].successors.first break unless b_dominator runner = dom_tree[p] while runner && runner != b_dominator result[runner] << b runner = runner.successors.first end end end result end end
[ "def", "dominance_frontier", "(", "start_node", "=", "self", ".", "enter", ",", "dom_tree", ")", "vertices", ".", "inject", "(", "Hash", ".", "new", "{", "|", "h", ",", "k", "|", "h", "[", "k", "]", "=", "Set", ".", "new", "}", ")", "do", "|", "result", ",", "b", "|", "preds", "=", "b", ".", "real_predecessors", "if", "preds", ".", "size", ">=", "2", "preds", ".", "each", "do", "|", "p", "|", "b_dominator", "=", "dom_tree", "[", "b", "]", ".", "successors", ".", "first", "break", "unless", "b_dominator", "runner", "=", "dom_tree", "[", "p", "]", "while", "runner", "&&", "runner", "!=", "b_dominator", "result", "[", "runner", "]", "<<", "b", "runner", "=", "runner", ".", "successors", ".", "first", "end", "end", "end", "result", "end", "end" ]
Returns the dominance frontier of the graph. If the start node is not provided, it is assumed the receiver is a ControlFlowGraph and has an #enter method. return: Node => Set<Node>
[ "Returns", "the", "dominance", "frontier", "of", "the", "graph", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/dominators.rb#L55-L71
19,841
michaeledgar/laser
lib/laser/third_party/rgl/dominators.rb
RGL.Graph.dominator_set_intersect
def dominator_set_intersect(b1, b2, doms) finger1, finger2 = b1, b2 while finger1.post_order_number != finger2.post_order_number finger1 = doms[finger1] while finger1.post_order_number < finger2.post_order_number finger2 = doms[finger2] while finger2.post_order_number < finger1.post_order_number end finger1 end
ruby
def dominator_set_intersect(b1, b2, doms) finger1, finger2 = b1, b2 while finger1.post_order_number != finger2.post_order_number finger1 = doms[finger1] while finger1.post_order_number < finger2.post_order_number finger2 = doms[finger2] while finger2.post_order_number < finger1.post_order_number end finger1 end
[ "def", "dominator_set_intersect", "(", "b1", ",", "b2", ",", "doms", ")", "finger1", ",", "finger2", "=", "b1", ",", "b2", "while", "finger1", ".", "post_order_number", "!=", "finger2", ".", "post_order_number", "finger1", "=", "doms", "[", "finger1", "]", "while", "finger1", ".", "post_order_number", "<", "finger2", ".", "post_order_number", "finger2", "=", "doms", "[", "finger2", "]", "while", "finger2", ".", "post_order_number", "<", "finger1", ".", "post_order_number", "end", "finger1", "end" ]
performs a set intersection of the dominator tree.
[ "performs", "a", "set", "intersection", "of", "the", "dominator", "tree", "." ]
0e38780eb44466ae35f33d28ec75536a4f3a969b
https://github.com/michaeledgar/laser/blob/0e38780eb44466ae35f33d28ec75536a4f3a969b/lib/laser/third_party/rgl/dominators.rb#L96-L103
19,842
OSC/ood_core
lib/ood_core/cluster.rb
OodCore.Cluster.batch_connect_config
def batch_connect_config(template = nil) if template @batch_connect_config.fetch(template.to_sym, {}).to_h.symbolize_keys.merge(template: template.to_sym) else @batch_connect_config end end
ruby
def batch_connect_config(template = nil) if template @batch_connect_config.fetch(template.to_sym, {}).to_h.symbolize_keys.merge(template: template.to_sym) else @batch_connect_config end end
[ "def", "batch_connect_config", "(", "template", "=", "nil", ")", "if", "template", "@batch_connect_config", ".", "fetch", "(", "template", ".", "to_sym", ",", "{", "}", ")", ".", "to_h", ".", "symbolize_keys", ".", "merge", "(", "template", ":", "template", ".", "to_sym", ")", "else", "@batch_connect_config", "end", "end" ]
The batch connect template configuration used for this cluster @param template [#to_sym, nil] the template type @return [Hash] the batch connect configuration
[ "The", "batch", "connect", "template", "configuration", "used", "for", "this", "cluster" ]
11eb65be194a8a4c956b70fb8c78a715e763b1df
https://github.com/OSC/ood_core/blob/11eb65be194a8a4c956b70fb8c78a715e763b1df/lib/ood_core/cluster.rb#L92-L98
19,843
OSC/ood_core
lib/ood_core/cluster.rb
OodCore.Cluster.batch_connect_template
def batch_connect_template(context = {}) context = context.to_h.symbolize_keys BatchConnect::Factory.build batch_connect_config(context[:template] || :basic).merge(context) end
ruby
def batch_connect_template(context = {}) context = context.to_h.symbolize_keys BatchConnect::Factory.build batch_connect_config(context[:template] || :basic).merge(context) end
[ "def", "batch_connect_template", "(", "context", "=", "{", "}", ")", "context", "=", "context", ".", "to_h", ".", "symbolize_keys", "BatchConnect", "::", "Factory", ".", "build", "batch_connect_config", "(", "context", "[", ":template", "]", "||", ":basic", ")", ".", "merge", "(", "context", ")", "end" ]
Build a batch connect template from the respective configuration @param context [#to_h] the context used for rendering the template @return [BatchConnect::Template] the batch connect template
[ "Build", "a", "batch", "connect", "template", "from", "the", "respective", "configuration" ]
11eb65be194a8a4c956b70fb8c78a715e763b1df
https://github.com/OSC/ood_core/blob/11eb65be194a8a4c956b70fb8c78a715e763b1df/lib/ood_core/cluster.rb#L103-L106
19,844
OSC/ood_core
lib/ood_core/cluster.rb
OodCore.Cluster.custom_allow?
def custom_allow?(feature) allow? && !custom_config(feature).empty? && build_acls(custom_config(feature).fetch(:acls, []).map(&:to_h)).all?(&:allow?) end
ruby
def custom_allow?(feature) allow? && !custom_config(feature).empty? && build_acls(custom_config(feature).fetch(:acls, []).map(&:to_h)).all?(&:allow?) end
[ "def", "custom_allow?", "(", "feature", ")", "allow?", "&&", "!", "custom_config", "(", "feature", ")", ".", "empty?", "&&", "build_acls", "(", "custom_config", "(", "feature", ")", ".", "fetch", "(", ":acls", ",", "[", "]", ")", ".", "map", "(", ":to_h", ")", ")", ".", "all?", "(", ":allow?", ")", "end" ]
Whether the custom feature is allowed based on the ACLs @return [Boolean] is this custom feature allowed
[ "Whether", "the", "custom", "feature", "is", "allowed", "based", "on", "the", "ACLs" ]
11eb65be194a8a4c956b70fb8c78a715e763b1df
https://github.com/OSC/ood_core/blob/11eb65be194a8a4c956b70fb8c78a715e763b1df/lib/ood_core/cluster.rb#L117-L121
19,845
OSC/ood_core
lib/ood_core/cluster.rb
OodCore.Cluster.to_h
def to_h { id: id, metadata: metadata_config, login: login_config, job: job_config, custom: custom_config, acls: acls_config, batch_connect: batch_connect_config } end
ruby
def to_h { id: id, metadata: metadata_config, login: login_config, job: job_config, custom: custom_config, acls: acls_config, batch_connect: batch_connect_config } end
[ "def", "to_h", "{", "id", ":", "id", ",", "metadata", ":", "metadata_config", ",", "login", ":", "login_config", ",", "job", ":", "job_config", ",", "custom", ":", "custom_config", ",", "acls", ":", "acls_config", ",", "batch_connect", ":", "batch_connect_config", "}", "end" ]
Convert object to hash @return [Hash] the hash describing this object
[ "Convert", "object", "to", "hash" ]
11eb65be194a8a4c956b70fb8c78a715e763b1df
https://github.com/OSC/ood_core/blob/11eb65be194a8a4c956b70fb8c78a715e763b1df/lib/ood_core/cluster.rb#L150-L160
19,846
OSC/ood_core
lib/ood_core/job/adapters/drmaa.rb
DRMAA.Session.run_bulk
def run_bulk(t, first, last, incr = 1) retry_until { DRMAA.run_bulk_jobs(t.ptr, first, last, incr) } end
ruby
def run_bulk(t, first, last, incr = 1) retry_until { DRMAA.run_bulk_jobs(t.ptr, first, last, incr) } end
[ "def", "run_bulk", "(", "t", ",", "first", ",", "last", ",", "incr", "=", "1", ")", "retry_until", "{", "DRMAA", ".", "run_bulk_jobs", "(", "t", ".", "ptr", ",", "first", ",", "last", ",", "incr", ")", "}", "end" ]
submits bulk job described by JobTemplate 't' and returns an array of job id strings
[ "submits", "bulk", "job", "described", "by", "JobTemplate", "t", "and", "returns", "an", "array", "of", "job", "id", "strings" ]
11eb65be194a8a4c956b70fb8c78a715e763b1df
https://github.com/OSC/ood_core/blob/11eb65be194a8a4c956b70fb8c78a715e763b1df/lib/ood_core/job/adapters/drmaa.rb#L756-L758
19,847
OSC/ood_core
lib/ood_core/job/adapters/drmaa.rb
DRMAA.Session.wait_each
def wait_each(timeout = -1) if ! block_given? ary = Array.new end while true begin info = DRMAA.wait(ANY_JOB, timeout) rescue DRMAAInvalidJobError break end if block_given? yield info else ary << info end end if ! block_given? return ary end end
ruby
def wait_each(timeout = -1) if ! block_given? ary = Array.new end while true begin info = DRMAA.wait(ANY_JOB, timeout) rescue DRMAAInvalidJobError break end if block_given? yield info else ary << info end end if ! block_given? return ary end end
[ "def", "wait_each", "(", "timeout", "=", "-", "1", ")", "if", "!", "block_given?", "ary", "=", "Array", ".", "new", "end", "while", "true", "begin", "info", "=", "DRMAA", ".", "wait", "(", "ANY_JOB", ",", "timeout", ")", "rescue", "DRMAAInvalidJobError", "break", "end", "if", "block_given?", "yield", "info", "else", "ary", "<<", "info", "end", "end", "if", "!", "block_given?", "return", "ary", "end", "end" ]
run block with JobInfo to finish for each waited session job or return JobInfo array if no block was passed
[ "run", "block", "with", "JobInfo", "to", "finish", "for", "each", "waited", "session", "job", "or", "return", "JobInfo", "array", "if", "no", "block", "was", "passed" ]
11eb65be194a8a4c956b70fb8c78a715e763b1df
https://github.com/OSC/ood_core/blob/11eb65be194a8a4c956b70fb8c78a715e763b1df/lib/ood_core/job/adapters/drmaa.rb#L772-L791
19,848
activerecord-hackery/meta_where
lib/meta_where/relation.rb
MetaWhere.Relation.predicate_visitor
def predicate_visitor join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, association_joins, custom_joins) MetaWhere::Visitors::Predicate.new(join_dependency) end
ruby
def predicate_visitor join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, association_joins, custom_joins) MetaWhere::Visitors::Predicate.new(join_dependency) end
[ "def", "predicate_visitor", "join_dependency", "=", "ActiveRecord", "::", "Associations", "::", "ClassMethods", "::", "JoinDependency", ".", "new", "(", "@klass", ",", "association_joins", ",", "custom_joins", ")", "MetaWhere", "::", "Visitors", "::", "Predicate", ".", "new", "(", "join_dependency", ")", "end" ]
Very occasionally, we need to get a visitor for another relation, so it makes sense to factor these out into a public method despite only being two lines long.
[ "Very", "occasionally", "we", "need", "to", "get", "a", "visitor", "for", "another", "relation", "so", "it", "makes", "sense", "to", "factor", "these", "out", "into", "a", "public", "method", "despite", "only", "being", "two", "lines", "long", "." ]
12f2ee52eb3789ac50b0d77890122dd85b85da9b
https://github.com/activerecord-hackery/meta_where/blob/12f2ee52eb3789ac50b0d77890122dd85b85da9b/lib/meta_where/relation.rb#L116-L119
19,849
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.schedule_blast_from_template
def schedule_blast_from_template(template, list, schedule_time, options={}) post = options ? options : {} post[:copy_template] = template post[:list] = list post[:schedule_time] = schedule_time api_post(:blast, post) end
ruby
def schedule_blast_from_template(template, list, schedule_time, options={}) post = options ? options : {} post[:copy_template] = template post[:list] = list post[:schedule_time] = schedule_time api_post(:blast, post) end
[ "def", "schedule_blast_from_template", "(", "template", ",", "list", ",", "schedule_time", ",", "options", "=", "{", "}", ")", "post", "=", "options", "?", "options", ":", "{", "}", "post", "[", ":copy_template", "]", "=", "template", "post", "[", ":list", "]", "=", "list", "post", "[", ":schedule_time", "]", "=", "schedule_time", "api_post", "(", ":blast", ",", "post", ")", "end" ]
Schedule a mass mail blast from template
[ "Schedule", "a", "mass", "mail", "blast", "from", "template" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L108-L114
19,850
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.schedule_blast_from_blast
def schedule_blast_from_blast(blast_id, schedule_time, options={}) post = options ? options : {} post[:copy_blast] = blast_id #post[:name] = name post[:schedule_time] = schedule_time api_post(:blast, post) end
ruby
def schedule_blast_from_blast(blast_id, schedule_time, options={}) post = options ? options : {} post[:copy_blast] = blast_id #post[:name] = name post[:schedule_time] = schedule_time api_post(:blast, post) end
[ "def", "schedule_blast_from_blast", "(", "blast_id", ",", "schedule_time", ",", "options", "=", "{", "}", ")", "post", "=", "options", "?", "options", ":", "{", "}", "post", "[", ":copy_blast", "]", "=", "blast_id", "#post[:name] = name", "post", "[", ":schedule_time", "]", "=", "schedule_time", "api_post", "(", ":blast", ",", "post", ")", "end" ]
Schedule a mass mail blast from previous blast
[ "Schedule", "a", "mass", "mail", "blast", "from", "previous", "blast" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L117-L123
19,851
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.update_blast
def update_blast(blast_id, name = nil, list = nil, schedule_time = nil, from_name = nil, from_email = nil, subject = nil, content_html = nil, content_text = nil, options = {}) data = options ? options : {} data[:blast_id] = blast_id if name != nil data[:name] = name end if list != nil data[:list] = list end if schedule_time != nil data[:schedule_time] = schedule_time end if from_name != nil data[:from_name] = from_name end if from_email != nil data[:from_email] = from_email end if subject != nil data[:subject] = subject end if content_html != nil data[:content_html] = content_html end if content_text != nil data[:content_text] = content_text end api_post(:blast, data) end
ruby
def update_blast(blast_id, name = nil, list = nil, schedule_time = nil, from_name = nil, from_email = nil, subject = nil, content_html = nil, content_text = nil, options = {}) data = options ? options : {} data[:blast_id] = blast_id if name != nil data[:name] = name end if list != nil data[:list] = list end if schedule_time != nil data[:schedule_time] = schedule_time end if from_name != nil data[:from_name] = from_name end if from_email != nil data[:from_email] = from_email end if subject != nil data[:subject] = subject end if content_html != nil data[:content_html] = content_html end if content_text != nil data[:content_text] = content_text end api_post(:blast, data) end
[ "def", "update_blast", "(", "blast_id", ",", "name", "=", "nil", ",", "list", "=", "nil", ",", "schedule_time", "=", "nil", ",", "from_name", "=", "nil", ",", "from_email", "=", "nil", ",", "subject", "=", "nil", ",", "content_html", "=", "nil", ",", "content_text", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "?", "options", ":", "{", "}", "data", "[", ":blast_id", "]", "=", "blast_id", "if", "name", "!=", "nil", "data", "[", ":name", "]", "=", "name", "end", "if", "list", "!=", "nil", "data", "[", ":list", "]", "=", "list", "end", "if", "schedule_time", "!=", "nil", "data", "[", ":schedule_time", "]", "=", "schedule_time", "end", "if", "from_name", "!=", "nil", "data", "[", ":from_name", "]", "=", "from_name", "end", "if", "from_email", "!=", "nil", "data", "[", ":from_email", "]", "=", "from_email", "end", "if", "subject", "!=", "nil", "data", "[", ":subject", "]", "=", "subject", "end", "if", "content_html", "!=", "nil", "data", "[", ":content_html", "]", "=", "content_html", "end", "if", "content_text", "!=", "nil", "data", "[", ":content_text", "]", "=", "content_text", "end", "api_post", "(", ":blast", ",", "data", ")", "end" ]
params blast_id, Fixnum | String name, String list, String schedule_time, String from_name, String from_email, String subject, String content_html, String content_text, String options, hash updates existing blast
[ "params", "blast_id", "Fixnum", "|", "String", "name", "String", "list", "String", "schedule_time", "String", "from_name", "String", "from_email", "String", "subject", "String", "content_html", "String", "content_text", "String", "options", "hash" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L138-L166
19,852
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.stats_list
def stats_list(list = nil, date = nil) data = {} if list != nil data[:list] = list end if date != nil data[:date] = date end data[:stat] = 'list' api_get(:stats, data) end
ruby
def stats_list(list = nil, date = nil) data = {} if list != nil data[:list] = list end if date != nil data[:date] = date end data[:stat] = 'list' api_get(:stats, data) end
[ "def", "stats_list", "(", "list", "=", "nil", ",", "date", "=", "nil", ")", "data", "=", "{", "}", "if", "list", "!=", "nil", "data", "[", ":list", "]", "=", "list", "end", "if", "date", "!=", "nil", "data", "[", ":date", "]", "=", "date", "end", "data", "[", ":stat", "]", "=", "'list'", "api_get", "(", ":stats", ",", "data", ")", "end" ]
params list, String date, String returns: hash, response from server Retrieve information about your subscriber counts on a particular list, on a particular day.
[ "params", "list", "String", "date", "String" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L411-L421
19,853
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.stats_blast
def stats_blast(blast_id = nil, start_date = nil, end_date = nil, options = {}) data = options if blast_id != nil data[:blast_id] = blast_id end if start_date != nil data[:start_date] = start_date end if end_date != nil data[:end_date] = end_date end data[:stat] = 'blast' api_get(:stats, data) end
ruby
def stats_blast(blast_id = nil, start_date = nil, end_date = nil, options = {}) data = options if blast_id != nil data[:blast_id] = blast_id end if start_date != nil data[:start_date] = start_date end if end_date != nil data[:end_date] = end_date end data[:stat] = 'blast' api_get(:stats, data) end
[ "def", "stats_blast", "(", "blast_id", "=", "nil", ",", "start_date", "=", "nil", ",", "end_date", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "if", "blast_id", "!=", "nil", "data", "[", ":blast_id", "]", "=", "blast_id", "end", "if", "start_date", "!=", "nil", "data", "[", ":start_date", "]", "=", "start_date", "end", "if", "end_date", "!=", "nil", "data", "[", ":end_date", "]", "=", "end_date", "end", "data", "[", ":stat", "]", "=", "'blast'", "api_get", "(", ":stats", ",", "data", ")", "end" ]
params blast_id, String start_date, String end_date, String options, Hash returns: hash, response from server Retrieve information about a particular blast or aggregated information from all of blasts over a specified date range
[ "params", "blast_id", "String", "start_date", "String", "end_date", "String", "options", "Hash" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L432-L445
19,854
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.stats_send
def stats_send(template = nil, start_date = nil, end_date = nil, options = {}) data = options if template != nil data[:template] = template end if start_date != nil data[:start_date] = start_date end if end_date != nil data[:end_date] = end_date end data[:stat] = 'send' api_get(:stats, data) end
ruby
def stats_send(template = nil, start_date = nil, end_date = nil, options = {}) data = options if template != nil data[:template] = template end if start_date != nil data[:start_date] = start_date end if end_date != nil data[:end_date] = end_date end data[:stat] = 'send' api_get(:stats, data) end
[ "def", "stats_send", "(", "template", "=", "nil", ",", "start_date", "=", "nil", ",", "end_date", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "if", "template", "!=", "nil", "data", "[", ":template", "]", "=", "template", "end", "if", "start_date", "!=", "nil", "data", "[", ":start_date", "]", "=", "start_date", "end", "if", "end_date", "!=", "nil", "data", "[", ":end_date", "]", "=", "end_date", "end", "data", "[", ":stat", "]", "=", "'send'", "api_get", "(", ":stats", ",", "data", ")", "end" ]
params template, String start_date, String end_date, String options, Hash returns: hash, response from server Retrieve information about a particular blast or aggregated information from all of blasts over a specified date range
[ "params", "template", "String", "start_date", "String", "end_date", "String", "options", "Hash" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L456-L469
19,855
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.save_alert
def save_alert(email, type, template, _when = nil, options = {}) data = options data[:email] = email data[:type] = type data[:template] = template if (type == 'weekly' || type == 'daily') data[:when] = _when end api_post(:alert, data) end
ruby
def save_alert(email, type, template, _when = nil, options = {}) data = options data[:email] = email data[:type] = type data[:template] = template if (type == 'weekly' || type == 'daily') data[:when] = _when end api_post(:alert, data) end
[ "def", "save_alert", "(", "email", ",", "type", ",", "template", ",", "_when", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", ":email", "]", "=", "email", "data", "[", ":type", "]", "=", "type", "data", "[", ":template", "]", "=", "template", "if", "(", "type", "==", "'weekly'", "||", "type", "==", "'daily'", ")", "data", "[", ":when", "]", "=", "_when", "end", "api_post", "(", ":alert", ",", "data", ")", "end" ]
params email, String type, String template, String _when, String options, hash Add a new alert to a user. You can add either a realtime or a summary alert (daily/weekly). _when is only required when alert type is weekly or daily
[ "params", "email", "String", "type", "String", "template", "String", "_when", "String", "options", "hash" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L566-L575
19,856
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_job
def process_job(job, options = {}, report_email = nil, postback_url = nil, binary_key = nil) data = options data['job'] = job if !report_email.nil? data['report_email'] = report_email end if !postback_url.nil? data['postback_url'] = postback_url end api_post(:job, data, binary_key) end
ruby
def process_job(job, options = {}, report_email = nil, postback_url = nil, binary_key = nil) data = options data['job'] = job if !report_email.nil? data['report_email'] = report_email end if !postback_url.nil? data['postback_url'] = postback_url end api_post(:job, data, binary_key) end
[ "def", "process_job", "(", "job", ",", "options", "=", "{", "}", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "binary_key", "=", "nil", ")", "data", "=", "options", "data", "[", "'job'", "]", "=", "job", "if", "!", "report_email", ".", "nil?", "data", "[", "'report_email'", "]", "=", "report_email", "end", "if", "!", "postback_url", ".", "nil?", "data", "[", "'postback_url'", "]", "=", "postback_url", "end", "api_post", "(", ":job", ",", "data", ",", "binary_key", ")", "end" ]
params job, String options, hash report_email, String postback_url, String binary_key, String interface for making request to job call
[ "params", "job", "String", "options", "hash", "report_email", "String", "postback_url", "String", "binary_key", "String" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L595-L606
19,857
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_import_job
def process_import_job(list, emails, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list data['emails'] = Array(emails).join(',') process_job(:import, data, report_email, postback_url) end
ruby
def process_import_job(list, emails, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list data['emails'] = Array(emails).join(',') process_job(:import, data, report_email, postback_url) end
[ "def", "process_import_job", "(", "list", ",", "emails", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", "'list'", "]", "=", "list", "data", "[", "'emails'", "]", "=", "Array", "(", "emails", ")", ".", "join", "(", "','", ")", "process_job", "(", ":import", ",", "data", ",", "report_email", ",", "postback_url", ")", "end" ]
params emails, String | Array implementation for import_job
[ "params", "emails", "String", "|", "Array", "implementation", "for", "import_job" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L611-L616
19,858
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_import_job_from_file
def process_import_job_from_file(list, file_path, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list data['file'] = file_path process_job(:import, data, report_email, postback_url, 'file') end
ruby
def process_import_job_from_file(list, file_path, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list data['file'] = file_path process_job(:import, data, report_email, postback_url, 'file') end
[ "def", "process_import_job_from_file", "(", "list", ",", "file_path", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", "'list'", "]", "=", "list", "data", "[", "'file'", "]", "=", "file_path", "process_job", "(", ":import", ",", "data", ",", "report_email", ",", "postback_url", ",", "'file'", ")", "end" ]
implementation for import job using file upload
[ "implementation", "for", "import", "job", "using", "file", "upload" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L619-L624
19,859
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_update_job_from_file
def process_update_job_from_file(file_path, report_email = nil, postback_url = nil, options = {}) data = options data['file'] = file_path process_job(:update, data, report_email, postback_url, 'file') end
ruby
def process_update_job_from_file(file_path, report_email = nil, postback_url = nil, options = {}) data = options data['file'] = file_path process_job(:update, data, report_email, postback_url, 'file') end
[ "def", "process_update_job_from_file", "(", "file_path", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", "'file'", "]", "=", "file_path", "process_job", "(", ":update", ",", "data", ",", "report_email", ",", "postback_url", ",", "'file'", ")", "end" ]
implementation for update job using file upload
[ "implementation", "for", "update", "job", "using", "file", "upload" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L627-L631
19,860
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_purchase_import_job_from_file
def process_purchase_import_job_from_file(file_path, report_email = nil, postback_url = nil, options = {}) data = options data['file'] = file_path process_job(:purchase_import, data, report_email, postback_url, 'file') end
ruby
def process_purchase_import_job_from_file(file_path, report_email = nil, postback_url = nil, options = {}) data = options data['file'] = file_path process_job(:purchase_import, data, report_email, postback_url, 'file') end
[ "def", "process_purchase_import_job_from_file", "(", "file_path", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", "'file'", "]", "=", "file_path", "process_job", "(", ":purchase_import", ",", "data", ",", "report_email", ",", "postback_url", ",", "'file'", ")", "end" ]
implementation for purchase import job using file upload
[ "implementation", "for", "purchase", "import", "job", "using", "file", "upload" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L634-L638
19,861
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_snapshot_job
def process_snapshot_job(query = {}, report_email = nil, postback_url = nil, options = {}) data = options data['query'] = query process_job(:snapshot, data, report_email, postback_url) end
ruby
def process_snapshot_job(query = {}, report_email = nil, postback_url = nil, options = {}) data = options data['query'] = query process_job(:snapshot, data, report_email, postback_url) end
[ "def", "process_snapshot_job", "(", "query", "=", "{", "}", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", "'query'", "]", "=", "query", "process_job", "(", ":snapshot", ",", "data", ",", "report_email", ",", "postback_url", ")", "end" ]
implementation for snapshot job
[ "implementation", "for", "snapshot", "job" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L641-L645
19,862
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.process_export_list_job
def process_export_list_job(list, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list process_job(:export_list_data, data, report_email, postback_url) end
ruby
def process_export_list_job(list, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list process_job(:export_list_data, data, report_email, postback_url) end
[ "def", "process_export_list_job", "(", "list", ",", "report_email", "=", "nil", ",", "postback_url", "=", "nil", ",", "options", "=", "{", "}", ")", "data", "=", "options", "data", "[", "'list'", "]", "=", "list", "process_job", "(", ":export_list_data", ",", "data", ",", "report_email", ",", "postback_url", ")", "end" ]
implementation for export list job
[ "implementation", "for", "export", "list", "job" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L648-L652
19,863
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.get_user_by_key
def get_user_by_key(id, key, fields = {}) data = { 'id' => id, 'key' => key, 'fields' => fields } api_get(:user, data) end
ruby
def get_user_by_key(id, key, fields = {}) data = { 'id' => id, 'key' => key, 'fields' => fields } api_get(:user, data) end
[ "def", "get_user_by_key", "(", "id", ",", "key", ",", "fields", "=", "{", "}", ")", "data", "=", "{", "'id'", "=>", "id", ",", "'key'", "=>", "key", ",", "'fields'", "=>", "fields", "}", "api_get", "(", ":user", ",", "data", ")", "end" ]
Get user by specified key
[ "Get", "user", "by", "specified", "key" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L665-L672
19,864
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.get_trigger_by_template
def get_trigger_by_template(template, trigger_id = nil) data = {} data['template'] = template if trigger_id != nil then data['trigger_id'] = trigger_id end api_get(:trigger, data) end
ruby
def get_trigger_by_template(template, trigger_id = nil) data = {} data['template'] = template if trigger_id != nil then data['trigger_id'] = trigger_id end api_get(:trigger, data) end
[ "def", "get_trigger_by_template", "(", "template", ",", "trigger_id", "=", "nil", ")", "data", "=", "{", "}", "data", "[", "'template'", "]", "=", "template", "if", "trigger_id", "!=", "nil", "then", "data", "[", "'trigger_id'", "]", "=", "trigger_id", "end", "api_get", "(", ":trigger", ",", "data", ")", "end" ]
params template, String trigger_id, String Get an existing trigger
[ "params", "template", "String", "trigger_id", "String", "Get", "an", "existing", "trigger" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L691-L696
19,865
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.post_template_trigger
def post_template_trigger(template, time, time_unit, event, zephyr) data = {} data['template'] = template data['time'] = time data['time_unit'] = time_unit data['event'] = event data['zephyr'] = zephyr api_post(:trigger, data) end
ruby
def post_template_trigger(template, time, time_unit, event, zephyr) data = {} data['template'] = template data['time'] = time data['time_unit'] = time_unit data['event'] = event data['zephyr'] = zephyr api_post(:trigger, data) end
[ "def", "post_template_trigger", "(", "template", ",", "time", ",", "time_unit", ",", "event", ",", "zephyr", ")", "data", "=", "{", "}", "data", "[", "'template'", "]", "=", "template", "data", "[", "'time'", "]", "=", "time", "data", "[", "'time_unit'", "]", "=", "time_unit", "data", "[", "'event'", "]", "=", "event", "data", "[", "'zephyr'", "]", "=", "zephyr", "api_post", "(", ":trigger", ",", "data", ")", "end" ]
params template, String time, String time_unit, String event, String zephyr, String Create or update a trigger
[ "params", "template", "String", "time", "String", "time_unit", "String", "event", "String", "zephyr", "String", "Create", "or", "update", "a", "trigger" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L714-L722
19,866
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.post_event_trigger
def post_event_trigger(event, time, time_unit, zephyr) data = {} data['time'] = time data['time_unit'] = time_unit data['event'] = event data['zephyr'] = zephyr api_post(:trigger, data) end
ruby
def post_event_trigger(event, time, time_unit, zephyr) data = {} data['time'] = time data['time_unit'] = time_unit data['event'] = event data['zephyr'] = zephyr api_post(:trigger, data) end
[ "def", "post_event_trigger", "(", "event", ",", "time", ",", "time_unit", ",", "zephyr", ")", "data", "=", "{", "}", "data", "[", "'time'", "]", "=", "time", "data", "[", "'time_unit'", "]", "=", "time_unit", "data", "[", "'event'", "]", "=", "event", "data", "[", "'zephyr'", "]", "=", "zephyr", "api_post", "(", ":trigger", ",", "data", ")", "end" ]
params template, String time, String time_unit, String zephyr, String Create or update a trigger
[ "params", "template", "String", "time", "String", "time_unit", "String", "zephyr", "String", "Create", "or", "update", "a", "trigger" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L730-L737
19,867
sailthru/sailthru-ruby-client
lib/sailthru/client.rb
Sailthru.Client.set_up_post_request
def set_up_post_request(uri, data, headers, binary_key = nil) if !binary_key.nil? binary_data = data[binary_key] if binary_data.is_a?(StringIO) data[binary_key] = UploadIO.new( binary_data, "text/plain", "local.path" ) else data[binary_key] = UploadIO.new( File.open(binary_data), "text/plain" ) end req = Net::HTTP::Post::Multipart.new(uri.path, data) else req = Net::HTTP::Post.new(uri.path, headers) req.set_form_data(data) end req end
ruby
def set_up_post_request(uri, data, headers, binary_key = nil) if !binary_key.nil? binary_data = data[binary_key] if binary_data.is_a?(StringIO) data[binary_key] = UploadIO.new( binary_data, "text/plain", "local.path" ) else data[binary_key] = UploadIO.new( File.open(binary_data), "text/plain" ) end req = Net::HTTP::Post::Multipart.new(uri.path, data) else req = Net::HTTP::Post.new(uri.path, headers) req.set_form_data(data) end req end
[ "def", "set_up_post_request", "(", "uri", ",", "data", ",", "headers", ",", "binary_key", "=", "nil", ")", "if", "!", "binary_key", ".", "nil?", "binary_data", "=", "data", "[", "binary_key", "]", "if", "binary_data", ".", "is_a?", "(", "StringIO", ")", "data", "[", "binary_key", "]", "=", "UploadIO", ".", "new", "(", "binary_data", ",", "\"text/plain\"", ",", "\"local.path\"", ")", "else", "data", "[", "binary_key", "]", "=", "UploadIO", ".", "new", "(", "File", ".", "open", "(", "binary_data", ")", ",", "\"text/plain\"", ")", "end", "req", "=", "Net", "::", "HTTP", "::", "Post", "::", "Multipart", ".", "new", "(", "uri", ".", "path", ",", "data", ")", "else", "req", "=", "Net", "::", "HTTP", "::", "Post", ".", "new", "(", "uri", ".", "path", ",", "headers", ")", "req", ".", "set_form_data", "(", "data", ")", "end", "req", "end" ]
set up our post request
[ "set", "up", "our", "post", "request" ]
978deed2b25769a73de14107cb2a0c93143522e4
https://github.com/sailthru/sailthru-ruby-client/blob/978deed2b25769a73de14107cb2a0c93143522e4/lib/sailthru/client.rb#L824-L844
19,868
basecrm/basecrm-ruby
lib/basecrm/services/tasks_service.rb
BaseCRM.TasksService.create
def create(task) validate_type!(task) attributes = sanitize(task) _, _, root = @client.post("/tasks", attributes) Task.new(root[:data]) end
ruby
def create(task) validate_type!(task) attributes = sanitize(task) _, _, root = @client.post("/tasks", attributes) Task.new(root[:data]) end
[ "def", "create", "(", "task", ")", "validate_type!", "(", "task", ")", "attributes", "=", "sanitize", "(", "task", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/tasks\"", ",", "attributes", ")", "Task", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a task post '/tasks' Creates a new task You can create either a **floating** task or create a **related** task and associate it with one of the resource types below: * [Leads](/docs/rest/reference/leads) * [Contacts](/docs/rest/reference/contacts) * [Deals](/docs/rest/reference/deals) @param task [Task, Hash] Either object of the Task type or Hash. This object's attributes describe the object to be created. @return [Task] The resulting object represting created resource.
[ "Create", "a", "task" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/tasks_service.rb#L63-L70
19,869
basecrm/basecrm-ruby
lib/basecrm/services/tasks_service.rb
BaseCRM.TasksService.update
def update(task) validate_type!(task) params = extract_params!(task, :id) id = params[:id] attributes = sanitize(task) _, _, root = @client.put("/tasks/#{id}", attributes) Task.new(root[:data]) end
ruby
def update(task) validate_type!(task) params = extract_params!(task, :id) id = params[:id] attributes = sanitize(task) _, _, root = @client.put("/tasks/#{id}", attributes) Task.new(root[:data]) end
[ "def", "update", "(", "task", ")", "validate_type!", "(", "task", ")", "params", "=", "extract_params!", "(", "task", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "task", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/tasks/#{id}\"", ",", "attributes", ")", "Task", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a task put '/tasks/{id}' Updates task information If the specified task does not exist, this query will return an error @param task [Task, Hash] Either object of the Task type or Hash. This object's attributes describe the object to be updated. @return [Task] The resulting object represting updated resource.
[ "Update", "a", "task" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/tasks_service.rb#L98-L107
19,870
basecrm/basecrm-ruby
lib/basecrm/services/contacts_service.rb
BaseCRM.ContactsService.create
def create(contact) validate_type!(contact) attributes = sanitize(contact) _, _, root = @client.post("/contacts", attributes) Contact.new(root[:data]) end
ruby
def create(contact) validate_type!(contact) attributes = sanitize(contact) _, _, root = @client.post("/contacts", attributes) Contact.new(root[:data]) end
[ "def", "create", "(", "contact", ")", "validate_type!", "(", "contact", ")", "attributes", "=", "sanitize", "(", "contact", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/contacts\"", ",", "attributes", ")", "Contact", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a contact post '/contacts' Create a new contact A contact may represent a single individual or an organization @param contact [Contact, Hash] Either object of the Contact type or Hash. This object's attributes describe the object to be created. @return [Contact] The resulting object represting created resource.
[ "Create", "a", "contact" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/contacts_service.rb#L58-L65
19,871
basecrm/basecrm-ruby
lib/basecrm/services/contacts_service.rb
BaseCRM.ContactsService.update
def update(contact) validate_type!(contact) params = extract_params!(contact, :id) id = params[:id] attributes = sanitize(contact) _, _, root = @client.put("/contacts/#{id}", attributes) Contact.new(root[:data]) end
ruby
def update(contact) validate_type!(contact) params = extract_params!(contact, :id) id = params[:id] attributes = sanitize(contact) _, _, root = @client.put("/contacts/#{id}", attributes) Contact.new(root[:data]) end
[ "def", "update", "(", "contact", ")", "validate_type!", "(", "contact", ")", "params", "=", "extract_params!", "(", "contact", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "contact", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/contacts/#{id}\"", ",", "attributes", ")", "Contact", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a contact put '/contacts/{id}' Updates contact information If the specified contact does not exist, the request will return an error **Notice** When updating contact tags, you need to provide all tags Any missing tag will be removed from a contact's tags @param contact [Contact, Hash] Either object of the Contact type or Hash. This object's attributes describe the object to be updated. @return [Contact] The resulting object represting updated resource.
[ "Update", "a", "contact" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/contacts_service.rb#L95-L104
19,872
basecrm/basecrm-ruby
lib/basecrm/services/calls_service.rb
BaseCRM.CallsService.create
def create(call) validate_type!(call) attributes = sanitize(call) _, _, root = @client.post("/calls", attributes) Call.new(root[:data]) end
ruby
def create(call) validate_type!(call) attributes = sanitize(call) _, _, root = @client.post("/calls", attributes) Call.new(root[:data]) end
[ "def", "create", "(", "call", ")", "validate_type!", "(", "call", ")", "attributes", "=", "sanitize", "(", "call", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/calls\"", ",", "attributes", ")", "Call", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a call post '/calls' Create a new call @param call [Call, Hash] Either object of the Call type or Hash. This object's attributes describe the object to be created. @return [Call] The resulting object represting created resource.
[ "Create", "a", "call" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/calls_service.rb#L50-L57
19,873
basecrm/basecrm-ruby
lib/basecrm/services/calls_service.rb
BaseCRM.CallsService.update
def update(call) validate_type!(call) params = extract_params!(call, :id) id = params[:id] attributes = sanitize(call) _, _, root = @client.put("/calls/#{id}", attributes) Call.new(root[:data]) end
ruby
def update(call) validate_type!(call) params = extract_params!(call, :id) id = params[:id] attributes = sanitize(call) _, _, root = @client.put("/calls/#{id}", attributes) Call.new(root[:data]) end
[ "def", "update", "(", "call", ")", "validate_type!", "(", "call", ")", "params", "=", "extract_params!", "(", "call", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "call", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/calls/#{id}\"", ",", "attributes", ")", "Call", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a call put '/calls/{id}' Allows to attach a Contact or Lead to an existing Call, or change it’s current association @param call [Call, Hash] Either object of the Call type or Hash. This object's attributes describe the object to be updated. @return [Call] The resulting object represting updated resource.
[ "Update", "a", "call" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/calls_service.rb#L84-L93
19,874
basecrm/basecrm-ruby
lib/basecrm/services/associated_contacts_service.rb
BaseCRM.AssociatedContactsService.where
def where(deal_id, options = {}) _, _, root = @client.get("/deals/#{deal_id}/associated_contacts", options) root[:items].map{ |item| AssociatedContact.new(item[:data]) } end
ruby
def where(deal_id, options = {}) _, _, root = @client.get("/deals/#{deal_id}/associated_contacts", options) root[:items].map{ |item| AssociatedContact.new(item[:data]) } end
[ "def", "where", "(", "deal_id", ",", "options", "=", "{", "}", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "get", "(", "\"/deals/#{deal_id}/associated_contacts\"", ",", "options", ")", "root", "[", ":items", "]", ".", "map", "{", "|", "item", "|", "AssociatedContact", ".", "new", "(", "item", "[", ":data", "]", ")", "}", "end" ]
Retrieve deal's associated contacts get '/deals/{deal_id}/associated_contacts' Returns all deal associated contacts @param deal_id [Integer] Unique identifier of a Deal @param options [Hash] Search options @option options [Integer] :page (1) Page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page. @option options [Integer] :per_page (25) Number of records to return per page. Default limit is *25* and the maximum number that can be returned is *100*. @return [Array<AssociatedContact>] The list of AssociatedContacts for the first page, unless otherwise specified.
[ "Retrieve", "deal", "s", "associated", "contacts" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/associated_contacts_service.rb#L32-L36
19,875
basecrm/basecrm-ruby
lib/basecrm/services/associated_contacts_service.rb
BaseCRM.AssociatedContactsService.create
def create(deal_id, associated_contact) validate_type!(associated_contact) attributes = sanitize(associated_contact) _, _, root = @client.post("/deals/#{deal_id}/associated_contacts", attributes) AssociatedContact.new(root[:data]) end
ruby
def create(deal_id, associated_contact) validate_type!(associated_contact) attributes = sanitize(associated_contact) _, _, root = @client.post("/deals/#{deal_id}/associated_contacts", attributes) AssociatedContact.new(root[:data]) end
[ "def", "create", "(", "deal_id", ",", "associated_contact", ")", "validate_type!", "(", "associated_contact", ")", "attributes", "=", "sanitize", "(", "associated_contact", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/deals/#{deal_id}/associated_contacts\"", ",", "attributes", ")", "AssociatedContact", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create an associated contact post '/deals/{deal_id}/associated_contacts' Creates a deal's associated contact and its role If the specified deal or contact does not exist, the request will return an error @param deal_id [Integer] Unique identifier of a Deal @param associated_contact [AssociatedContact, Hash] Either object of the AssociatedContact type or Hash. This object's attributes describe the object to be created. @return [AssociatedContact] The resulting object represting created resource.
[ "Create", "an", "associated", "contact" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/associated_contacts_service.rb#L49-L56
19,876
basecrm/basecrm-ruby
lib/basecrm/sync.rb
BaseCRM.Sync.fetch
def fetch(&block) return unless block_given? # Set up a new synchronization session for given device's UUID session = @client.sync.start(@device_uuid) # Check if there is anything to synchronize return unless session && session.id # Drain the main queue unitl there is no more data (empty array) loop do queued_data = @client.sync.fetch(@device_uuid, session.id) # nothing more to synchronize ? break unless queued_data # something bad at the backend next if queued_data.empty? ack_keys = [] queued_data.each do |sync_meta, resource| op, ack_key = block.call(sync_meta, resource) ack_keys << ack_key if op == :ack end # As we fetch new data, we need to send ackwledgement keys - if any @client.sync.ack(@device_uuid, ack_keys) unless ack_keys.empty? end end
ruby
def fetch(&block) return unless block_given? # Set up a new synchronization session for given device's UUID session = @client.sync.start(@device_uuid) # Check if there is anything to synchronize return unless session && session.id # Drain the main queue unitl there is no more data (empty array) loop do queued_data = @client.sync.fetch(@device_uuid, session.id) # nothing more to synchronize ? break unless queued_data # something bad at the backend next if queued_data.empty? ack_keys = [] queued_data.each do |sync_meta, resource| op, ack_key = block.call(sync_meta, resource) ack_keys << ack_key if op == :ack end # As we fetch new data, we need to send ackwledgement keys - if any @client.sync.ack(@device_uuid, ack_keys) unless ack_keys.empty? end end
[ "def", "fetch", "(", "&", "block", ")", "return", "unless", "block_given?", "# Set up a new synchronization session for given device's UUID", "session", "=", "@client", ".", "sync", ".", "start", "(", "@device_uuid", ")", "# Check if there is anything to synchronize", "return", "unless", "session", "&&", "session", ".", "id", "# Drain the main queue unitl there is no more data (empty array)", "loop", "do", "queued_data", "=", "@client", ".", "sync", ".", "fetch", "(", "@device_uuid", ",", "session", ".", "id", ")", "# nothing more to synchronize ?", "break", "unless", "queued_data", "# something bad at the backend", "next", "if", "queued_data", ".", "empty?", "ack_keys", "=", "[", "]", "queued_data", ".", "each", "do", "|", "sync_meta", ",", "resource", "|", "op", ",", "ack_key", "=", "block", ".", "call", "(", "sync_meta", ",", "resource", ")", "ack_keys", "<<", "ack_key", "if", "op", "==", ":ack", "end", "# As we fetch new data, we need to send ackwledgement keys - if any", "@client", ".", "sync", ".", "ack", "(", "@device_uuid", ",", "ack_keys", ")", "unless", "ack_keys", ".", "empty?", "end", "end" ]
Intantiate a new BaseCRM Sync API V2 high-level wrapper @param options[Hash] Wrapper options @option options [String] :device_uuid Device's UUID. @option options [BaseCRM::Client] :client BaseCRM API v2 client instance. @raise [ConfigurationError] if no device's uuid provided @raise [ConfigurationError] if no client instance provided @return [Sync] New wrapper instance @see Client @see SyncService Perform a full synchronization flow. See the following example: client = BaseCRM::Client.new(access_token: "<YOUR_ACCESS_TOKEN>") sync = BaseCRM::Sync.new(client: client, device_uuid: "<YOUR_DEVICES_UUID>") sync.fetch do |meta, resource| DB.send(meta.sync.event_type, entity) ? meta.sync.ack : meta.sync.nack end @param block [Proc] Procedure that will be called for every item in the queue. Takes two input arguments: SyncMeta instance associated with the resource, and the resource. You should use either `SyncQueue#ack` or `SyncQueue#nack` to return value from the block. @return nil
[ "Intantiate", "a", "new", "BaseCRM", "Sync", "API", "V2", "high", "-", "level", "wrapper" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/sync.rb#L39-L67
19,877
basecrm/basecrm-ruby
lib/basecrm/services/sync_service.rb
BaseCRM.SyncService.start
def start(device_uuid) validate_device!(device_uuid) status, _, root = @client.post("/sync/start", {}, build_headers(device_uuid)) return nil if status == 204 build_session(root) end
ruby
def start(device_uuid) validate_device!(device_uuid) status, _, root = @client.post("/sync/start", {}, build_headers(device_uuid)) return nil if status == 204 build_session(root) end
[ "def", "start", "(", "device_uuid", ")", "validate_device!", "(", "device_uuid", ")", "status", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/sync/start\"", ",", "{", "}", ",", "build_headers", "(", "device_uuid", ")", ")", "return", "nil", "if", "status", "==", "204", "build_session", "(", "root", ")", "end" ]
Start synchronization flow post '/sync/start' Starts a new synchronization session. This is the first endpoint to call, in order to start a new synchronization session. @param device_uuid [String] Device's UUID for which to perform synchronization. @return [SyncSession] The resulting object is the synchronization session object or nil if there is nothing to synchronize.
[ "Start", "synchronization", "flow" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/sync_service.rb#L17-L24
19,878
basecrm/basecrm-ruby
lib/basecrm/services/sync_service.rb
BaseCRM.SyncService.fetch
def fetch(device_uuid, session_id, queue='main') validate_device!(device_uuid) raise ArgumentError, "session_id must not be nil nor empty" unless session_id && !session_id.strip.empty? raise ArgumentError, "queue name must not be nil nor empty" unless queue && !queue.strip.empty? status, _, root = @client.get("/sync/#{session_id}/queues/#{queue}", {}, build_headers(device_uuid)) return nil if status == 204 root[:items].map do |item| klass = classify_type(item[:meta][:type]) next unless klass [build_meta(item[:meta]), klass.new(item[:data])] end end
ruby
def fetch(device_uuid, session_id, queue='main') validate_device!(device_uuid) raise ArgumentError, "session_id must not be nil nor empty" unless session_id && !session_id.strip.empty? raise ArgumentError, "queue name must not be nil nor empty" unless queue && !queue.strip.empty? status, _, root = @client.get("/sync/#{session_id}/queues/#{queue}", {}, build_headers(device_uuid)) return nil if status == 204 root[:items].map do |item| klass = classify_type(item[:meta][:type]) next unless klass [build_meta(item[:meta]), klass.new(item[:data])] end end
[ "def", "fetch", "(", "device_uuid", ",", "session_id", ",", "queue", "=", "'main'", ")", "validate_device!", "(", "device_uuid", ")", "raise", "ArgumentError", ",", "\"session_id must not be nil nor empty\"", "unless", "session_id", "&&", "!", "session_id", ".", "strip", ".", "empty?", "raise", "ArgumentError", ",", "\"queue name must not be nil nor empty\"", "unless", "queue", "&&", "!", "queue", ".", "strip", ".", "empty?", "status", ",", "_", ",", "root", "=", "@client", ".", "get", "(", "\"/sync/#{session_id}/queues/#{queue}\"", ",", "{", "}", ",", "build_headers", "(", "device_uuid", ")", ")", "return", "nil", "if", "status", "==", "204", "root", "[", ":items", "]", ".", "map", "do", "|", "item", "|", "klass", "=", "classify_type", "(", "item", "[", ":meta", "]", "[", ":type", "]", ")", "next", "unless", "klass", "[", "build_meta", "(", "item", "[", ":meta", "]", ")", ",", "klass", ".", "new", "(", "item", "[", ":data", "]", ")", "]", "end", "end" ]
Get data from queue get '/sync/{session_id}/queues/main' Fetch fresh data from the main queue. Using session identifier you call continously the `#fetch` method to drain the main queue. @param device_uuid [String] Device's UUID for which to perform synchronization @param session_id [String] Unique identifier of a synchronization session. @param queue [String|Symbol] Queue name. @return [Array<Array<Meta, Model>>] The list of sync's metadata associated with data and data, or nil if nothing more to synchronize.
[ "Get", "data", "from", "queue" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/sync_service.rb#L37-L50
19,879
basecrm/basecrm-ruby
lib/basecrm/services/sync_service.rb
BaseCRM.SyncService.ack
def ack(device_uuid, ack_keys) validate_device!(device_uuid) raise ArgumentError, "ack_keys must not be nil and an array" unless ack_keys && ack_keys.is_a?(Array) return true if ack_keys.empty? payload = { :ack_keys => ack_keys.map(&:to_s) } status, _, _ = @client.post('/sync/ack', payload, build_headers(device_uuid)) status == 202 end
ruby
def ack(device_uuid, ack_keys) validate_device!(device_uuid) raise ArgumentError, "ack_keys must not be nil and an array" unless ack_keys && ack_keys.is_a?(Array) return true if ack_keys.empty? payload = { :ack_keys => ack_keys.map(&:to_s) } status, _, _ = @client.post('/sync/ack', payload, build_headers(device_uuid)) status == 202 end
[ "def", "ack", "(", "device_uuid", ",", "ack_keys", ")", "validate_device!", "(", "device_uuid", ")", "raise", "ArgumentError", ",", "\"ack_keys must not be nil and an array\"", "unless", "ack_keys", "&&", "ack_keys", ".", "is_a?", "(", "Array", ")", "return", "true", "if", "ack_keys", ".", "empty?", "payload", "=", "{", ":ack_keys", "=>", "ack_keys", ".", "map", "(", ":to_s", ")", "}", "status", ",", "_", ",", "_", "=", "@client", ".", "post", "(", "'/sync/ack'", ",", "payload", ",", "build_headers", "(", "device_uuid", ")", ")", "status", "==", "202", "end" ]
Acknowledge received data post '/sync/ack' Send acknowledgement keys to let know the Sync service which data you have. As you fetch new data, you need to send acknowledgement keys. @param device_uuid [String] Device's UUID for which to perform synchronization. @param ack_keys [Array<String>] The list of acknowledgement keys. @return [Boolean] Status of the operation.
[ "Acknowledge", "received", "data" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/sync_service.rb#L62-L72
19,880
basecrm/basecrm-ruby
lib/basecrm/services/tags_service.rb
BaseCRM.TagsService.create
def create(tag) validate_type!(tag) attributes = sanitize(tag) _, _, root = @client.post("/tags", attributes) Tag.new(root[:data]) end
ruby
def create(tag) validate_type!(tag) attributes = sanitize(tag) _, _, root = @client.post("/tags", attributes) Tag.new(root[:data]) end
[ "def", "create", "(", "tag", ")", "validate_type!", "(", "tag", ")", "attributes", "=", "sanitize", "(", "tag", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/tags\"", ",", "attributes", ")", "Tag", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a tag post '/tags' Creates a new tag **Notice** the tag's name **must** be unique within the scope of the resource_type @param tag [Tag, Hash] Either object of the Tag type or Hash. This object's attributes describe the object to be created. @return [Tag] The resulting object represting created resource.
[ "Create", "a", "tag" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/tags_service.rb#L52-L59
19,881
basecrm/basecrm-ruby
lib/basecrm/services/tags_service.rb
BaseCRM.TagsService.update
def update(tag) validate_type!(tag) params = extract_params!(tag, :id) id = params[:id] attributes = sanitize(tag) _, _, root = @client.put("/tags/#{id}", attributes) Tag.new(root[:data]) end
ruby
def update(tag) validate_type!(tag) params = extract_params!(tag, :id) id = params[:id] attributes = sanitize(tag) _, _, root = @client.put("/tags/#{id}", attributes) Tag.new(root[:data]) end
[ "def", "update", "(", "tag", ")", "validate_type!", "(", "tag", ")", "params", "=", "extract_params!", "(", "tag", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "tag", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/tags/#{id}\"", ",", "attributes", ")", "Tag", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a tag put '/tags/{id}' Updates a tag's information If the specified tag does not exist, this query will return an error **Notice** if you want to update a tag, you **must** make sure the tag's name is unique within the scope of the specified resource @param tag [Tag, Hash] Either object of the Tag type or Hash. This object's attributes describe the object to be updated. @return [Tag] The resulting object represting updated resource.
[ "Update", "a", "tag" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/tags_service.rb#L88-L97
19,882
basecrm/basecrm-ruby
lib/basecrm/services/loss_reasons_service.rb
BaseCRM.LossReasonsService.create
def create(loss_reason) validate_type!(loss_reason) attributes = sanitize(loss_reason) _, _, root = @client.post("/loss_reasons", attributes) LossReason.new(root[:data]) end
ruby
def create(loss_reason) validate_type!(loss_reason) attributes = sanitize(loss_reason) _, _, root = @client.post("/loss_reasons", attributes) LossReason.new(root[:data]) end
[ "def", "create", "(", "loss_reason", ")", "validate_type!", "(", "loss_reason", ")", "attributes", "=", "sanitize", "(", "loss_reason", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/loss_reasons\"", ",", "attributes", ")", "LossReason", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a loss reason post '/loss_reasons' Create a new loss reason <figure class="notice"> Loss reason's name **must** be unique </figure> @param loss_reason [LossReason, Hash] Either object of the LossReason type or Hash. This object's attributes describe the object to be created. @return [LossReason] The resulting object represting created resource.
[ "Create", "a", "loss", "reason" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/loss_reasons_service.rb#L52-L59
19,883
basecrm/basecrm-ruby
lib/basecrm/services/loss_reasons_service.rb
BaseCRM.LossReasonsService.update
def update(loss_reason) validate_type!(loss_reason) params = extract_params!(loss_reason, :id) id = params[:id] attributes = sanitize(loss_reason) _, _, root = @client.put("/loss_reasons/#{id}", attributes) LossReason.new(root[:data]) end
ruby
def update(loss_reason) validate_type!(loss_reason) params = extract_params!(loss_reason, :id) id = params[:id] attributes = sanitize(loss_reason) _, _, root = @client.put("/loss_reasons/#{id}", attributes) LossReason.new(root[:data]) end
[ "def", "update", "(", "loss_reason", ")", "validate_type!", "(", "loss_reason", ")", "params", "=", "extract_params!", "(", "loss_reason", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "loss_reason", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/loss_reasons/#{id}\"", ",", "attributes", ")", "LossReason", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a loss reason put '/loss_reasons/{id}' Updates a loss reason information If the specified loss reason does not exist, the request will return an error <figure class="notice"> If you want to update loss reason you **must** make sure name of the reason is unique </figure> @param loss_reason [LossReason, Hash] Either object of the LossReason type or Hash. This object's attributes describe the object to be updated. @return [LossReason] The resulting object represting updated resource.
[ "Update", "a", "loss", "reason" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/loss_reasons_service.rb#L90-L99
19,884
basecrm/basecrm-ruby
lib/basecrm/services/notes_service.rb
BaseCRM.NotesService.create
def create(note) validate_type!(note) attributes = sanitize(note) _, _, root = @client.post("/notes", attributes) Note.new(root[:data]) end
ruby
def create(note) validate_type!(note) attributes = sanitize(note) _, _, root = @client.post("/notes", attributes) Note.new(root[:data]) end
[ "def", "create", "(", "note", ")", "validate_type!", "(", "note", ")", "attributes", "=", "sanitize", "(", "note", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/notes\"", ",", "attributes", ")", "Note", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a note post '/notes' Create a new note and associate it with one of the resources listed below: * [Leads](/docs/rest/reference/leads) * [Contacts](/docs/rest/reference/contacts) * [Deals](/docs/rest/reference/deals) @param note [Note, Hash] Either object of the Note type or Hash. This object's attributes describe the object to be created. @return [Note] The resulting object represting created resource.
[ "Create", "a", "note" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/notes_service.rb#L56-L63
19,885
basecrm/basecrm-ruby
lib/basecrm/services/notes_service.rb
BaseCRM.NotesService.update
def update(note) validate_type!(note) params = extract_params!(note, :id) id = params[:id] attributes = sanitize(note) _, _, root = @client.put("/notes/#{id}", attributes) Note.new(root[:data]) end
ruby
def update(note) validate_type!(note) params = extract_params!(note, :id) id = params[:id] attributes = sanitize(note) _, _, root = @client.put("/notes/#{id}", attributes) Note.new(root[:data]) end
[ "def", "update", "(", "note", ")", "validate_type!", "(", "note", ")", "params", "=", "extract_params!", "(", "note", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "note", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/notes/#{id}\"", ",", "attributes", ")", "Note", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a note put '/notes/{id}' Updates note information If the note ID does not exist, this request will return an error @param note [Note, Hash] Either object of the Note type or Hash. This object's attributes describe the object to be updated. @return [Note] The resulting object represting updated resource.
[ "Update", "a", "note" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/notes_service.rb#L91-L100
19,886
basecrm/basecrm-ruby
lib/basecrm/services/sources_service.rb
BaseCRM.SourcesService.create
def create(source) validate_type!(source) attributes = sanitize(source) _, _, root = @client.post("/sources", attributes) Source.new(root[:data]) end
ruby
def create(source) validate_type!(source) attributes = sanitize(source) _, _, root = @client.post("/sources", attributes) Source.new(root[:data]) end
[ "def", "create", "(", "source", ")", "validate_type!", "(", "source", ")", "attributes", "=", "sanitize", "(", "source", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/sources\"", ",", "attributes", ")", "Source", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a source post '/sources' Creates a new source <figure class="notice"> Source's name **must** be unique </figure> @param source [Source, Hash] Either object of the Source type or Hash. This object's attributes describe the object to be created. @return [Source] The resulting object represting created resource.
[ "Create", "a", "source" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/sources_service.rb#L52-L59
19,887
basecrm/basecrm-ruby
lib/basecrm/services/orders_service.rb
BaseCRM.OrdersService.create
def create(order) validate_type!(order) attributes = sanitize(order) _, _, root = @client.post("/orders", attributes) Order.new(root[:data]) end
ruby
def create(order) validate_type!(order) attributes = sanitize(order) _, _, root = @client.post("/orders", attributes) Order.new(root[:data]) end
[ "def", "create", "(", "order", ")", "validate_type!", "(", "order", ")", "attributes", "=", "sanitize", "(", "order", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/orders\"", ",", "attributes", ")", "Order", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create an order post '/orders' Create a new order for a deal User needs to have access to the deal to create an order Each deal can have at most one order and error is returned when attempting to create more @param order [Order, Hash] Either object of the Order type or Hash. This object's attributes describe the object to be created. @return [Order] The resulting object represting created resource.
[ "Create", "an", "order" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/orders_service.rb#L51-L58
19,888
basecrm/basecrm-ruby
lib/basecrm/services/orders_service.rb
BaseCRM.OrdersService.update
def update(order) validate_type!(order) params = extract_params!(order, :id) id = params[:id] attributes = sanitize(order) _, _, root = @client.put("/orders/#{id}", attributes) Order.new(root[:data]) end
ruby
def update(order) validate_type!(order) params = extract_params!(order, :id) id = params[:id] attributes = sanitize(order) _, _, root = @client.put("/orders/#{id}", attributes) Order.new(root[:data]) end
[ "def", "update", "(", "order", ")", "validate_type!", "(", "order", ")", "params", "=", "extract_params!", "(", "order", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "order", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/orders/#{id}\"", ",", "attributes", ")", "Order", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update an order put '/orders/{id}' Updates order information If the specified order does not exist, the request will return an error @param order [Order, Hash] Either object of the Order type or Hash. This object's attributes describe the object to be updated. @return [Order] The resulting object represting updated resource.
[ "Update", "an", "order" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/orders_service.rb#L86-L95
19,889
basecrm/basecrm-ruby
lib/basecrm/services/leads_service.rb
BaseCRM.LeadsService.create
def create(lead) validate_type!(lead) attributes = sanitize(lead) _, _, root = @client.post("/leads", attributes) Lead.new(root[:data]) end
ruby
def create(lead) validate_type!(lead) attributes = sanitize(lead) _, _, root = @client.post("/leads", attributes) Lead.new(root[:data]) end
[ "def", "create", "(", "lead", ")", "validate_type!", "(", "lead", ")", "attributes", "=", "sanitize", "(", "lead", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/leads\"", ",", "attributes", ")", "Lead", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a lead post '/leads' Creates a new lead A lead may represent a single individual or an organization @param lead [Lead, Hash] Either object of the Lead type or Hash. This object's attributes describe the object to be created. @return [Lead] The resulting object represting created resource.
[ "Create", "a", "lead" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/leads_service.rb#L59-L66
19,890
basecrm/basecrm-ruby
lib/basecrm/services/leads_service.rb
BaseCRM.LeadsService.update
def update(lead) validate_type!(lead) params = extract_params!(lead, :id) id = params[:id] attributes = sanitize(lead) _, _, root = @client.put("/leads/#{id}", attributes) Lead.new(root[:data]) end
ruby
def update(lead) validate_type!(lead) params = extract_params!(lead, :id) id = params[:id] attributes = sanitize(lead) _, _, root = @client.put("/leads/#{id}", attributes) Lead.new(root[:data]) end
[ "def", "update", "(", "lead", ")", "validate_type!", "(", "lead", ")", "params", "=", "extract_params!", "(", "lead", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "lead", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/leads/#{id}\"", ",", "attributes", ")", "Lead", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a lead put '/leads/{id}' Updates lead information If the specified lead does not exist, this query returns an error <figure class="notice"> In order to modify tags, you need to supply the entire set of tags `tags` are replaced every time they are used in a request </figure> @param lead [Lead, Hash] Either object of the Lead type or Hash. This object's attributes describe the object to be updated. @return [Lead] The resulting object represting updated resource.
[ "Update", "a", "lead" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/leads_service.rb#L98-L107
19,891
basecrm/basecrm-ruby
lib/basecrm/services/deals_service.rb
BaseCRM.DealsService.create
def create(deal) validate_type!(deal) attributes = sanitize(deal) _, _, root = @client.post("/deals", attributes) Deal.new(root[:data]) end
ruby
def create(deal) validate_type!(deal) attributes = sanitize(deal) _, _, root = @client.post("/deals", attributes) Deal.new(root[:data]) end
[ "def", "create", "(", "deal", ")", "validate_type!", "(", "deal", ")", "attributes", "=", "sanitize", "(", "deal", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/deals\"", ",", "attributes", ")", "Deal", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a deal post '/deals' Create a new deal @param deal [Deal, Hash] Either object of the Deal type or Hash. This object's attributes describe the object to be created. @return [Deal] The resulting object represting created resource.
[ "Create", "a", "deal" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/deals_service.rb#L56-L63
19,892
basecrm/basecrm-ruby
lib/basecrm/services/deals_service.rb
BaseCRM.DealsService.update
def update(deal) validate_type!(deal) params = extract_params!(deal, :id) id = params[:id] attributes = sanitize(deal) _, _, root = @client.put("/deals/#{id}", attributes) Deal.new(root[:data]) end
ruby
def update(deal) validate_type!(deal) params = extract_params!(deal, :id) id = params[:id] attributes = sanitize(deal) _, _, root = @client.put("/deals/#{id}", attributes) Deal.new(root[:data]) end
[ "def", "update", "(", "deal", ")", "validate_type!", "(", "deal", ")", "params", "=", "extract_params!", "(", "deal", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "deal", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/deals/#{id}\"", ",", "attributes", ")", "Deal", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a deal put '/deals/{id}' Updates deal information If the specified deal does not exist, the request will return an error <figure class="notice"> In order to modify tags used on a record, you need to supply the entire set `tags` are replaced every time they are used in a request </figure> @param deal [Deal, Hash] Either object of the Deal type or Hash. This object's attributes describe the object to be updated. @return [Deal] The resulting object represting updated resource.
[ "Update", "a", "deal" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/deals_service.rb#L95-L104
19,893
basecrm/basecrm-ruby
lib/basecrm/services/line_items_service.rb
BaseCRM.LineItemsService.where
def where(order_id, options = {}) _, _, root = @client.get("/orders/#{order_id}/line_items", options) root[:items].map{ |item| LineItem.new(item[:data]) } end
ruby
def where(order_id, options = {}) _, _, root = @client.get("/orders/#{order_id}/line_items", options) root[:items].map{ |item| LineItem.new(item[:data]) } end
[ "def", "where", "(", "order_id", ",", "options", "=", "{", "}", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "get", "(", "\"/orders/#{order_id}/line_items\"", ",", "options", ")", "root", "[", ":items", "]", ".", "map", "{", "|", "item", "|", "LineItem", ".", "new", "(", "item", "[", ":data", "]", ")", "}", "end" ]
Retrieve order's line items get '/orders/{order_id}/line_items' Returns all line items associated to order @param order_id [Integer] Unique identifier of a Order @param options [Hash] Search options @option options [String] :ids Comma-separated list of line item IDs to be returned in a request. @option options [Integer] :quantity Quantity of line item. @option options [Integer] :value Value of line item. @option options [Integer] :page (1) Page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page. @option options [Integer] :per_page (25) Number of records to return per page. Default limit is *25* and the maximum number that can be returned is *100*. @option options [String] :sort_by (id:asc) A field to sort by. **Default** ordering is **ascending**. If you want to change the sort ordering to descending, append `:desc` to the field e.g. `sort_by=value:desc`. @return [Array<LineItem>] The list of LineItems for the first page, unless otherwise specified.
[ "Retrieve", "order", "s", "line", "items" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/line_items_service.rb#L36-L40
19,894
basecrm/basecrm-ruby
lib/basecrm/services/line_items_service.rb
BaseCRM.LineItemsService.create
def create(order_id, line_item) validate_type!(line_item) attributes = sanitize(line_item) _, _, root = @client.post("/orders/#{order_id}/line_items", attributes) LineItem.new(root[:data]) end
ruby
def create(order_id, line_item) validate_type!(line_item) attributes = sanitize(line_item) _, _, root = @client.post("/orders/#{order_id}/line_items", attributes) LineItem.new(root[:data]) end
[ "def", "create", "(", "order_id", ",", "line_item", ")", "validate_type!", "(", "line_item", ")", "attributes", "=", "sanitize", "(", "line_item", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/orders/#{order_id}/line_items\"", ",", "attributes", ")", "LineItem", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a line item post '/orders/{order_id}/line_items' Adds a new line item to an existing order Line items correspond to products in the catalog, so first you must create products Because products allow defining different prices in different currencies, when creating a line item, the parameter currency is required @param order_id [Integer] Unique identifier of a Order @param line_item [LineItem, Hash] Either object of the LineItem type or Hash. This object's attributes describe the object to be created. @return [LineItem] The resulting object represting created resource.
[ "Create", "a", "line", "item" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/line_items_service.rb#L54-L61
19,895
basecrm/basecrm-ruby
lib/basecrm/services/line_items_service.rb
BaseCRM.LineItemsService.find
def find(order_id, id) _, _, root = @client.get("/orders/#{order_id}/line_items/#{id}") LineItem.new(root[:data]) end
ruby
def find(order_id, id) _, _, root = @client.get("/orders/#{order_id}/line_items/#{id}") LineItem.new(root[:data]) end
[ "def", "find", "(", "order_id", ",", "id", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "get", "(", "\"/orders/#{order_id}/line_items/#{id}\"", ")", "LineItem", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Retrieve a single line item get '/orders/{order_id}/line_items/{id}' Returns a single line item of an order, according to the unique line item ID provided @param order_id [Integer] Unique identifier of a Order @param id [Integer] Unique identifier of a LineItem @return [LineItem] Searched resource object.
[ "Retrieve", "a", "single", "line", "item" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/line_items_service.rb#L73-L77
19,896
basecrm/basecrm-ruby
lib/basecrm/services/products_service.rb
BaseCRM.ProductsService.create
def create(product) validate_type!(product) attributes = sanitize(product) _, _, root = @client.post("/products", attributes) Product.new(root[:data]) end
ruby
def create(product) validate_type!(product) attributes = sanitize(product) _, _, root = @client.post("/products", attributes) Product.new(root[:data]) end
[ "def", "create", "(", "product", ")", "validate_type!", "(", "product", ")", "attributes", "=", "sanitize", "(", "product", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/products\"", ",", "attributes", ")", "Product", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a product post '/products' Create a new product @param product [Product, Hash] Either object of the Product type or Hash. This object's attributes describe the object to be created. @return [Product] The resulting object represting created resource.
[ "Create", "a", "product" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/products_service.rb#L53-L60
19,897
basecrm/basecrm-ruby
lib/basecrm/services/products_service.rb
BaseCRM.ProductsService.update
def update(product) validate_type!(product) params = extract_params!(product, :id) id = params[:id] attributes = sanitize(product) _, _, root = @client.put("/products/#{id}", attributes) Product.new(root[:data]) end
ruby
def update(product) validate_type!(product) params = extract_params!(product, :id) id = params[:id] attributes = sanitize(product) _, _, root = @client.put("/products/#{id}", attributes) Product.new(root[:data]) end
[ "def", "update", "(", "product", ")", "validate_type!", "(", "product", ")", "params", "=", "extract_params!", "(", "product", ",", ":id", ")", "id", "=", "params", "[", ":id", "]", "attributes", "=", "sanitize", "(", "product", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "put", "(", "\"/products/#{id}\"", ",", "attributes", ")", "Product", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Update a product put '/products/{id}' Updates product information If the specified product does not exist, the request will return an error <figure class="notice"><p>In order to modify prices used on a record, you need to supply the entire set <code>prices</code> are replaced every time they are used in a request </p></figure> @param product [Product, Hash] Either object of the Product type or Hash. This object's attributes describe the object to be updated. @return [Product] The resulting object represting updated resource.
[ "Update", "a", "product" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/products_service.rb#L91-L100
19,898
basecrm/basecrm-ruby
lib/basecrm/services/deal_unqualified_reasons_service.rb
BaseCRM.DealUnqualifiedReasonsService.where
def where(options = {}) _, _, root = @client.get("/deal_unqualified_reasons", options) root[:items].map{ |item| DealUnqualifiedReason.new(item[:data]) } end
ruby
def where(options = {}) _, _, root = @client.get("/deal_unqualified_reasons", options) root[:items].map{ |item| DealUnqualifiedReason.new(item[:data]) } end
[ "def", "where", "(", "options", "=", "{", "}", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "get", "(", "\"/deal_unqualified_reasons\"", ",", "options", ")", "root", "[", ":items", "]", ".", "map", "{", "|", "item", "|", "DealUnqualifiedReason", ".", "new", "(", "item", "[", ":data", "]", ")", "}", "end" ]
Retrieve all deal unqualified reasons get '/deal_unqualified_reasons' Returns all deal unqualified reasons available to the user according to the parameters provided @param options [Hash] Search options @option options [String] :ids Comma separated list of deal unqualified reasons unique identifiers to be returned in a request. @option options [String] :name Name of the deal unqualified reason to search for. This parameter is used in a strict sense. @option options [Integer] :page (1) Page number to start from. Page numbering is 1-based and omitting `page` parameter will return the first page. @option options [Integer] :per_page (25) Number of records to return per page. Default limit is *25* and maximum number that can be returned is *100*. @option options [String] :sort_by (id:asc) A field to sort by. **Default** ordering is **ascending**. If you want to change the sort ordering to descending, append `:desc` to the field e.g. `sort_by=name:desc`. @return [Array<DealUnqualifiedReason>] The list of DealUnqualifiedReasons for the first page, unless otherwise specified.
[ "Retrieve", "all", "deal", "unqualified", "reasons" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/deal_unqualified_reasons_service.rb#L34-L38
19,899
basecrm/basecrm-ruby
lib/basecrm/services/deal_unqualified_reasons_service.rb
BaseCRM.DealUnqualifiedReasonsService.create
def create(deal_unqualified_reason) validate_type!(deal_unqualified_reason) attributes = sanitize(deal_unqualified_reason) _, _, root = @client.post("/deal_unqualified_reasons", attributes) DealUnqualifiedReason.new(root[:data]) end
ruby
def create(deal_unqualified_reason) validate_type!(deal_unqualified_reason) attributes = sanitize(deal_unqualified_reason) _, _, root = @client.post("/deal_unqualified_reasons", attributes) DealUnqualifiedReason.new(root[:data]) end
[ "def", "create", "(", "deal_unqualified_reason", ")", "validate_type!", "(", "deal_unqualified_reason", ")", "attributes", "=", "sanitize", "(", "deal_unqualified_reason", ")", "_", ",", "_", ",", "root", "=", "@client", ".", "post", "(", "\"/deal_unqualified_reasons\"", ",", "attributes", ")", "DealUnqualifiedReason", ".", "new", "(", "root", "[", ":data", "]", ")", "end" ]
Create a deal unqualified reason post '/deal_unqualified_reasons' Create a new deal unqualified reason <figure class="notice"> Deal unqualified reason's name **must** be unique </figure> @param deal_unqualified_reason [DealUnqualifiedReason, Hash] Either object of the DealUnqualifiedReason type or Hash. This object's attributes describe the object to be created. @return [DealUnqualifiedReason] The resulting object represting created resource.
[ "Create", "a", "deal", "unqualified", "reason" ]
c39ea72477d41c3122805d49587043399ee454ea
https://github.com/basecrm/basecrm-ruby/blob/c39ea72477d41c3122805d49587043399ee454ea/lib/basecrm/services/deal_unqualified_reasons_service.rb#L52-L59