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
sequence | docstring
stringlengths 8
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 94
266
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
acquia/sf-sdk-ruby | lib/sfrest/task.rb | SFRest.Task.globally_paused? | def globally_paused?
paused = false
current_path = '/api/v1/variables?name=wip_pause_global'
begin
res = @conn.get(current_path)
paused = res['wip_pause_global']
rescue SFRest::SFError => error
paused = false if error.message =~ /Variable not found/
end
paused
end | ruby | def globally_paused?
paused = false
current_path = '/api/v1/variables?name=wip_pause_global'
begin
res = @conn.get(current_path)
paused = res['wip_pause_global']
rescue SFRest::SFError => error
paused = false if error.message =~ /Variable not found/
end
paused
end | [
"def",
"globally_paused?",
"paused",
"=",
"false",
"current_path",
"=",
"'/api/v1/variables?name=wip_pause_global'",
"begin",
"res",
"=",
"@conn",
".",
"get",
"(",
"current_path",
")",
"paused",
"=",
"res",
"[",
"'wip_pause_global'",
"]",
"rescue",
"SFRest",
"::",
"SFError",
"=>",
"error",
"paused",
"=",
"false",
"if",
"error",
".",
"message",
"=~",
"/",
"/",
"end",
"paused",
"end"
] | Gets the value of a vairable
@TODO: this is missnamed becasue it does not check the global paused variable
@return [Boolean] | [
"Gets",
"the",
"value",
"of",
"a",
"vairable"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L217-L227 | train |
acquia/sf-sdk-ruby | lib/sfrest/task.rb | SFRest.Task.pause_task | def pause_task(task_id, level = 'family')
current_path = '/api/v1/pause/' << task_id.to_s
payload = { 'paused' => true, 'level' => level }.to_json
@conn.post(current_path, payload)
end | ruby | def pause_task(task_id, level = 'family')
current_path = '/api/v1/pause/' << task_id.to_s
payload = { 'paused' => true, 'level' => level }.to_json
@conn.post(current_path, payload)
end | [
"def",
"pause_task",
"(",
"task_id",
",",
"level",
"=",
"'family'",
")",
"current_path",
"=",
"'/api/v1/pause/'",
"<<",
"task_id",
".",
"to_s",
"payload",
"=",
"{",
"'paused'",
"=>",
"true",
",",
"'level'",
"=>",
"level",
"}",
".",
"to_json",
"@conn",
".",
"post",
"(",
"current_path",
",",
"payload",
")",
"end"
] | Pauses a specific task identified by its task id.
This can pause either the task and it's children or just the task
@param [Integer] task_id
@param [String] level family|task | [
"Pauses",
"a",
"specific",
"task",
"identified",
"by",
"its",
"task",
"id",
".",
"This",
"can",
"pause",
"either",
"the",
"task",
"and",
"it",
"s",
"children",
"or",
"just",
"the",
"task"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L233-L237 | train |
acquia/sf-sdk-ruby | lib/sfrest/task.rb | SFRest.Task.resume_task | def resume_task(task_id, level = 'family')
current_path = '/api/v1/pause/' << task_id.to_s
payload = { 'paused' => false, 'level' => level }.to_json
@conn.post(current_path, payload)
end | ruby | def resume_task(task_id, level = 'family')
current_path = '/api/v1/pause/' << task_id.to_s
payload = { 'paused' => false, 'level' => level }.to_json
@conn.post(current_path, payload)
end | [
"def",
"resume_task",
"(",
"task_id",
",",
"level",
"=",
"'family'",
")",
"current_path",
"=",
"'/api/v1/pause/'",
"<<",
"task_id",
".",
"to_s",
"payload",
"=",
"{",
"'paused'",
"=>",
"false",
",",
"'level'",
"=>",
"level",
"}",
".",
"to_json",
"@conn",
".",
"post",
"(",
"current_path",
",",
"payload",
")",
"end"
] | Resumes a specific task identified by its task id.
This can resume either the task and it's children or just the task
@param [Integer] task_id
@param [String] level family|task | [
"Resumes",
"a",
"specific",
"task",
"identified",
"by",
"its",
"task",
"id",
".",
"This",
"can",
"resume",
"either",
"the",
"task",
"and",
"it",
"s",
"children",
"or",
"just",
"the",
"task"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L243-L247 | train |
acquia/sf-sdk-ruby | lib/sfrest/task.rb | SFRest.Task.wait_until_state | def wait_until_state(task_id, state, max_nap)
blink_time = 5 # wake up and scan
nap_start = Time.now
state_method = method("task_#{state}?".to_sym)
loop do
break if state_method.call(task_id)
raise TaskNotDoneError, "Task: #{task_id} has taken too long to complete!" if Time.new > (nap_start + max_nap)
sleep blink_time
end
task_id
end | ruby | def wait_until_state(task_id, state, max_nap)
blink_time = 5 # wake up and scan
nap_start = Time.now
state_method = method("task_#{state}?".to_sym)
loop do
break if state_method.call(task_id)
raise TaskNotDoneError, "Task: #{task_id} has taken too long to complete!" if Time.new > (nap_start + max_nap)
sleep blink_time
end
task_id
end | [
"def",
"wait_until_state",
"(",
"task_id",
",",
"state",
",",
"max_nap",
")",
"blink_time",
"=",
"5",
"# wake up and scan",
"nap_start",
"=",
"Time",
".",
"now",
"state_method",
"=",
"method",
"(",
"\"task_#{state}?\"",
".",
"to_sym",
")",
"loop",
"do",
"break",
"if",
"state_method",
".",
"call",
"(",
"task_id",
")",
"raise",
"TaskNotDoneError",
",",
"\"Task: #{task_id} has taken too long to complete!\"",
"if",
"Time",
".",
"new",
">",
"(",
"nap_start",
"+",
"max_nap",
")",
"sleep",
"blink_time",
"end",
"task_id",
"end"
] | Blocks until a task reaches a specific status
@param [Integer] task_id
@param [String] state state to reach
@param [Integer] max_nap seconds to try before giving up | [
"Blocks",
"until",
"a",
"task",
"reaches",
"a",
"specific",
"status"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/task.rb#L293-L304 | train |
acquia/sf-sdk-ruby | lib/sfrest/collection.rb | SFRest.Collection.collection_list | def collection_list
page = 1
not_done = true
count = 0
while not_done
current_path = '/api/v1/collections?page=' << page.to_s
res = @conn.get(current_path)
if res['collections'] == []
not_done = false
elsif !res['message'].nil?
return { 'message' => res['message'] }
elsif page == 1
count = res['count']
collections = res['collections']
else
res['collections'].each do |collection|
collections << collection
end
end
page += 1
end
{ 'count' => count, 'collections' => collections }
end | ruby | def collection_list
page = 1
not_done = true
count = 0
while not_done
current_path = '/api/v1/collections?page=' << page.to_s
res = @conn.get(current_path)
if res['collections'] == []
not_done = false
elsif !res['message'].nil?
return { 'message' => res['message'] }
elsif page == 1
count = res['count']
collections = res['collections']
else
res['collections'].each do |collection|
collections << collection
end
end
page += 1
end
{ 'count' => count, 'collections' => collections }
end | [
"def",
"collection_list",
"page",
"=",
"1",
"not_done",
"=",
"true",
"count",
"=",
"0",
"while",
"not_done",
"current_path",
"=",
"'/api/v1/collections?page='",
"<<",
"page",
".",
"to_s",
"res",
"=",
"@conn",
".",
"get",
"(",
"current_path",
")",
"if",
"res",
"[",
"'collections'",
"]",
"==",
"[",
"]",
"not_done",
"=",
"false",
"elsif",
"!",
"res",
"[",
"'message'",
"]",
".",
"nil?",
"return",
"{",
"'message'",
"=>",
"res",
"[",
"'message'",
"]",
"}",
"elsif",
"page",
"==",
"1",
"count",
"=",
"res",
"[",
"'count'",
"]",
"collections",
"=",
"res",
"[",
"'collections'",
"]",
"else",
"res",
"[",
"'collections'",
"]",
".",
"each",
"do",
"|",
"collection",
"|",
"collections",
"<<",
"collection",
"end",
"end",
"page",
"+=",
"1",
"end",
"{",
"'count'",
"=>",
"count",
",",
"'collections'",
"=>",
"collections",
"}",
"end"
] | Gets the complete list of collections
Makes multiple requests to the factory to get all the collections on the factory
@return [Hash{'count' => Integer, 'sites' => Hash}] | [
"Gets",
"the",
"complete",
"list",
"of",
"collections",
"Makes",
"multiple",
"requests",
"to",
"the",
"factory",
"to",
"get",
"all",
"the",
"collections",
"on",
"the",
"factory"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/collection.rb#L59-L81 | train |
acquia/sf-sdk-ruby | lib/sfrest/collection.rb | SFRest.Collection.create | def create(name, sites, groups, internal_domain_prefix = nil)
sites = Array(sites)
groups = Array(groups)
current_path = '/api/v1/collections'
payload = { 'name' => name, 'site_ids' => sites, 'group_ids' => groups,
'internal_domain_prefix' => internal_domain_prefix }.to_json
@conn.post(current_path, payload)
end | ruby | def create(name, sites, groups, internal_domain_prefix = nil)
sites = Array(sites)
groups = Array(groups)
current_path = '/api/v1/collections'
payload = { 'name' => name, 'site_ids' => sites, 'group_ids' => groups,
'internal_domain_prefix' => internal_domain_prefix }.to_json
@conn.post(current_path, payload)
end | [
"def",
"create",
"(",
"name",
",",
"sites",
",",
"groups",
",",
"internal_domain_prefix",
"=",
"nil",
")",
"sites",
"=",
"Array",
"(",
"sites",
")",
"groups",
"=",
"Array",
"(",
"groups",
")",
"current_path",
"=",
"'/api/v1/collections'",
"payload",
"=",
"{",
"'name'",
"=>",
"name",
",",
"'site_ids'",
"=>",
"sites",
",",
"'group_ids'",
"=>",
"groups",
",",
"'internal_domain_prefix'",
"=>",
"internal_domain_prefix",
"}",
".",
"to_json",
"@conn",
".",
"post",
"(",
"current_path",
",",
"payload",
")",
"end"
] | create a site collection
@param [String] name site collection name
@param [int|Array] sites nid or array of site nids. First nid is primary
@param [int|Array] groups gid or array of group ids.
@param [String] internal_domain_prefix optional the prefix for the internal domain
defaults to name
@return [Hash { "id" => Integer, "name" => String,
"time" => "2016-11-25T13:18:44+00:00",
"internal_domain" => String }] | [
"create",
"a",
"site",
"collection"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/collection.rb#L92-L99 | train |
acquia/sf-sdk-ruby | lib/sfrest/collection.rb | SFRest.Collection.set_primary_site | def set_primary_site(id, site)
payload = { 'site_id' => site }.to_json
current_path = "/api/v1/collections/#{id}/set-primary"
@conn.post(current_path, payload)
end | ruby | def set_primary_site(id, site)
payload = { 'site_id' => site }.to_json
current_path = "/api/v1/collections/#{id}/set-primary"
@conn.post(current_path, payload)
end | [
"def",
"set_primary_site",
"(",
"id",
",",
"site",
")",
"payload",
"=",
"{",
"'site_id'",
"=>",
"site",
"}",
".",
"to_json",
"current_path",
"=",
"\"/api/v1/collections/#{id}/set-primary\"",
"@conn",
".",
"post",
"(",
"current_path",
",",
"payload",
")",
"end"
] | sets a site to be a primary site in a site collection
@param [int] id of the collection where the primary site is being changed
@param [int] site nid to become the primary site
@return [Hash{ "id" => Integer,
"name" => String,
"time" => "2016-10-28T09:25:26+00:00",
"primary_site_id": Integer,
"switched" => Boolean,
"message" => String }] | [
"sets",
"a",
"site",
"to",
"be",
"a",
"primary",
"site",
"in",
"a",
"site",
"collection"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/collection.rb#L154-L158 | train |
acquia/sf-sdk-ruby | lib/sfrest/update.rb | SFRest.Update.modify_status | def modify_status(site_creation, site_duplication, domain_management, bulk_operations)
current_path = '/api/v1/status'
payload = { 'site_creation' => site_creation,
'site_duplication' => site_duplication,
'domain_management' => domain_management,
'bulk_operations' => bulk_operations }.to_json
@conn.put(current_path, payload)
end | ruby | def modify_status(site_creation, site_duplication, domain_management, bulk_operations)
current_path = '/api/v1/status'
payload = { 'site_creation' => site_creation,
'site_duplication' => site_duplication,
'domain_management' => domain_management,
'bulk_operations' => bulk_operations }.to_json
@conn.put(current_path, payload)
end | [
"def",
"modify_status",
"(",
"site_creation",
",",
"site_duplication",
",",
"domain_management",
",",
"bulk_operations",
")",
"current_path",
"=",
"'/api/v1/status'",
"payload",
"=",
"{",
"'site_creation'",
"=>",
"site_creation",
",",
"'site_duplication'",
"=>",
"site_duplication",
",",
"'domain_management'",
"=>",
"domain_management",
",",
"'bulk_operations'",
"=>",
"bulk_operations",
"}",
".",
"to_json",
"@conn",
".",
"put",
"(",
"current_path",
",",
"payload",
")",
"end"
] | Modifies the status information. | [
"Modifies",
"the",
"status",
"information",
"."
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/update.rb#L16-L23 | train |
acquia/sf-sdk-ruby | lib/sfrest/update.rb | SFRest.Update.start_update | def start_update(ref)
if update_version == 'v2'
raise InvalidApiVersion, 'There is more than one codebase use sfrest.update.update directly.'
end
update_data = { scope: 'sites', sites_type: 'code, db', sites_ref: ref }
update(update_data)
end | ruby | def start_update(ref)
if update_version == 'v2'
raise InvalidApiVersion, 'There is more than one codebase use sfrest.update.update directly.'
end
update_data = { scope: 'sites', sites_type: 'code, db', sites_ref: ref }
update(update_data)
end | [
"def",
"start_update",
"(",
"ref",
")",
"if",
"update_version",
"==",
"'v2'",
"raise",
"InvalidApiVersion",
",",
"'There is more than one codebase use sfrest.update.update directly.'",
"end",
"update_data",
"=",
"{",
"scope",
":",
"'sites'",
",",
"sites_type",
":",
"'code, db'",
",",
"sites_ref",
":",
"ref",
"}",
"update",
"(",
"update_data",
")",
"end"
] | Starts an update. | [
"Starts",
"an",
"update",
"."
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/update.rb#L32-L39 | train |
acquia/sf-sdk-ruby | lib/sfrest/group.rb | SFRest.Group.group_list | def group_list
page = 1
not_done = true
count = 0
while not_done
current_path = '/api/v1/groups?page=' << page.to_s
res = @conn.get(current_path)
if res['groups'] == []
not_done = false
elsif !res['message'].nil?
return { 'message' => res['message'] }
elsif page == 1
count = res['count']
groups = res['groups']
else
res['groups'].each do |group|
groups << group
end
end
page += 1
end
{ 'count' => count, 'groups' => groups }
end | ruby | def group_list
page = 1
not_done = true
count = 0
while not_done
current_path = '/api/v1/groups?page=' << page.to_s
res = @conn.get(current_path)
if res['groups'] == []
not_done = false
elsif !res['message'].nil?
return { 'message' => res['message'] }
elsif page == 1
count = res['count']
groups = res['groups']
else
res['groups'].each do |group|
groups << group
end
end
page += 1
end
{ 'count' => count, 'groups' => groups }
end | [
"def",
"group_list",
"page",
"=",
"1",
"not_done",
"=",
"true",
"count",
"=",
"0",
"while",
"not_done",
"current_path",
"=",
"'/api/v1/groups?page='",
"<<",
"page",
".",
"to_s",
"res",
"=",
"@conn",
".",
"get",
"(",
"current_path",
")",
"if",
"res",
"[",
"'groups'",
"]",
"==",
"[",
"]",
"not_done",
"=",
"false",
"elsif",
"!",
"res",
"[",
"'message'",
"]",
".",
"nil?",
"return",
"{",
"'message'",
"=>",
"res",
"[",
"'message'",
"]",
"}",
"elsif",
"page",
"==",
"1",
"count",
"=",
"res",
"[",
"'count'",
"]",
"groups",
"=",
"res",
"[",
"'groups'",
"]",
"else",
"res",
"[",
"'groups'",
"]",
".",
"each",
"do",
"|",
"group",
"|",
"groups",
"<<",
"group",
"end",
"end",
"page",
"+=",
"1",
"end",
"{",
"'count'",
"=>",
"count",
",",
"'groups'",
"=>",
"groups",
"}",
"end"
] | Gets a list of all site groups.
@return [Hash] all the groups on the factory plus a count
{'count' => count, 'groups' => Hash }
this will iterate through the group pages | [
"Gets",
"a",
"list",
"of",
"all",
"site",
"groups",
"."
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/group.rb#L30-L52 | train |
acquia/sf-sdk-ruby | lib/sfrest/user.rb | SFRest.User.get_user_id | def get_user_id(username)
pglimit = 100
res = @conn.get('/api/v1/users&limit=' + pglimit.to_s)
usercount = res['count'].to_i
id = user_data_from_results(res, username, 'uid')
return id if id
pages = (usercount / pglimit) + 1
2.upto(pages) do |i|
res = @conn.get('/api/v1/users&limit=' + pglimit.to_s + '?page=' + i.to_s)
id = user_data_from_results(res, username, 'uid')
return id if id
end
nil
end | ruby | def get_user_id(username)
pglimit = 100
res = @conn.get('/api/v1/users&limit=' + pglimit.to_s)
usercount = res['count'].to_i
id = user_data_from_results(res, username, 'uid')
return id if id
pages = (usercount / pglimit) + 1
2.upto(pages) do |i|
res = @conn.get('/api/v1/users&limit=' + pglimit.to_s + '?page=' + i.to_s)
id = user_data_from_results(res, username, 'uid')
return id if id
end
nil
end | [
"def",
"get_user_id",
"(",
"username",
")",
"pglimit",
"=",
"100",
"res",
"=",
"@conn",
".",
"get",
"(",
"'/api/v1/users&limit='",
"+",
"pglimit",
".",
"to_s",
")",
"usercount",
"=",
"res",
"[",
"'count'",
"]",
".",
"to_i",
"id",
"=",
"user_data_from_results",
"(",
"res",
",",
"username",
",",
"'uid'",
")",
"return",
"id",
"if",
"id",
"pages",
"=",
"(",
"usercount",
"/",
"pglimit",
")",
"+",
"1",
"2",
".",
"upto",
"(",
"pages",
")",
"do",
"|",
"i",
"|",
"res",
"=",
"@conn",
".",
"get",
"(",
"'/api/v1/users&limit='",
"+",
"pglimit",
".",
"to_s",
"+",
"'?page='",
"+",
"i",
".",
"to_s",
")",
"id",
"=",
"user_data_from_results",
"(",
"res",
",",
"username",
",",
"'uid'",
")",
"return",
"id",
"if",
"id",
"end",
"nil",
"end"
] | gets the site ID for the site named sitename
will page through all the sites available searching for the site
@param [String] username drupal username (not email)
@return [Integer] the uid of the drupal user | [
"gets",
"the",
"site",
"ID",
"for",
"the",
"site",
"named",
"sitename",
"will",
"page",
"through",
"all",
"the",
"sites",
"available",
"searching",
"for",
"the",
"site"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/user.rb#L40-L54 | train |
acquia/sf-sdk-ruby | lib/sfrest/user.rb | SFRest.User.user_data_from_results | def user_data_from_results(res, username, key)
users = res['users']
users.each do |user|
return user[key] if user['name'] == username
end
nil
end | ruby | def user_data_from_results(res, username, key)
users = res['users']
users.each do |user|
return user[key] if user['name'] == username
end
nil
end | [
"def",
"user_data_from_results",
"(",
"res",
",",
"username",
",",
"key",
")",
"users",
"=",
"res",
"[",
"'users'",
"]",
"users",
".",
"each",
"do",
"|",
"user",
"|",
"return",
"user",
"[",
"key",
"]",
"if",
"user",
"[",
"'name'",
"]",
"==",
"username",
"end",
"nil",
"end"
] | Extract the user data for 'key' based on the user result object
@param [Hash] res result from a request to /users
@param [String] username
@param [String] key one of the user data returned (uid, mail, tfa_status...)
@return [Object] Integer, String, Array, Hash depending on the user data | [
"Extract",
"the",
"user",
"data",
"for",
"key",
"based",
"on",
"the",
"user",
"result",
"object"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/user.rb#L61-L67 | train |
acquia/sf-sdk-ruby | lib/sfrest/user.rb | SFRest.User.create_user | def create_user(name, email, datum = nil)
current_path = '/api/v1/users'
payload = { name: name, mail: email }
payload.merge!(datum) unless datum.nil?
@conn.post(current_path, payload.to_json)
end | ruby | def create_user(name, email, datum = nil)
current_path = '/api/v1/users'
payload = { name: name, mail: email }
payload.merge!(datum) unless datum.nil?
@conn.post(current_path, payload.to_json)
end | [
"def",
"create_user",
"(",
"name",
",",
"email",
",",
"datum",
"=",
"nil",
")",
"current_path",
"=",
"'/api/v1/users'",
"payload",
"=",
"{",
"name",
":",
"name",
",",
"mail",
":",
"email",
"}",
"payload",
".",
"merge!",
"(",
"datum",
")",
"unless",
"datum",
".",
"nil?",
"@conn",
".",
"post",
"(",
"current_path",
",",
"payload",
".",
"to_json",
")",
"end"
] | Creates a user.
@param [String] name
@param [String] email
@param [Hash] datum hash with elements :pass => string,
:status => 0|1,
:roles => Array | [
"Creates",
"a",
"user",
"."
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/user.rb#L82-L87 | train |
acquia/sf-sdk-ruby | lib/sfrest/stage.rb | SFRest.Stage.staging_versions | def staging_versions
possible_versions = [1, 2]
@versions ||= []
possible_versions.each do |version|
begin
@conn.get "/api/v#{version}/stage"
@versions.push version
rescue SFRest::InvalidResponse
nil
end
end
@versions
end | ruby | def staging_versions
possible_versions = [1, 2]
@versions ||= []
possible_versions.each do |version|
begin
@conn.get "/api/v#{version}/stage"
@versions.push version
rescue SFRest::InvalidResponse
nil
end
end
@versions
end | [
"def",
"staging_versions",
"possible_versions",
"=",
"[",
"1",
",",
"2",
"]",
"@versions",
"||=",
"[",
"]",
"possible_versions",
".",
"each",
"do",
"|",
"version",
"|",
"begin",
"@conn",
".",
"get",
"\"/api/v#{version}/stage\"",
"@versions",
".",
"push",
"version",
"rescue",
"SFRest",
"::",
"InvalidResponse",
"nil",
"end",
"end",
"@versions",
"end"
] | determine what version are available for staging
@return [Array] Array of available api endpoints | [
"determine",
"what",
"version",
"are",
"available",
"for",
"staging"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/stage.rb#L57-L69 | train |
acquia/sf-sdk-ruby | lib/sfrest/connection.rb | SFRest.Connection.put | def put(uri, payload)
headers = { 'Content-Type' => 'application/json' }
res = Excon.put(@base_url + uri.to_s,
headers: headers,
user: username,
password: password,
ssl_verify_peer: false,
body: payload)
api_response res
end | ruby | def put(uri, payload)
headers = { 'Content-Type' => 'application/json' }
res = Excon.put(@base_url + uri.to_s,
headers: headers,
user: username,
password: password,
ssl_verify_peer: false,
body: payload)
api_response res
end | [
"def",
"put",
"(",
"uri",
",",
"payload",
")",
"headers",
"=",
"{",
"'Content-Type'",
"=>",
"'application/json'",
"}",
"res",
"=",
"Excon",
".",
"put",
"(",
"@base_url",
"+",
"uri",
".",
"to_s",
",",
"headers",
":",
"headers",
",",
"user",
":",
"username",
",",
"password",
":",
"password",
",",
"ssl_verify_peer",
":",
"false",
",",
"body",
":",
"payload",
")",
"api_response",
"res",
"end"
] | http request via put
@param [string] uri
@return [Object] ruby representation of the json response
if the reponse body does not parse, raises
a SFRest::InvalidResponse | [
"http",
"request",
"via",
"put"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/connection.rb#L67-L76 | train |
acquia/sf-sdk-ruby | lib/sfrest/connection.rb | SFRest.Connection.delete | def delete(uri)
headers = { 'Content-Type' => 'application/json' }
res = Excon.delete(@base_url + uri.to_s,
headers: headers,
user: username,
password: password,
ssl_verify_peer: false)
api_response res
end | ruby | def delete(uri)
headers = { 'Content-Type' => 'application/json' }
res = Excon.delete(@base_url + uri.to_s,
headers: headers,
user: username,
password: password,
ssl_verify_peer: false)
api_response res
end | [
"def",
"delete",
"(",
"uri",
")",
"headers",
"=",
"{",
"'Content-Type'",
"=>",
"'application/json'",
"}",
"res",
"=",
"Excon",
".",
"delete",
"(",
"@base_url",
"+",
"uri",
".",
"to_s",
",",
"headers",
":",
"headers",
",",
"user",
":",
"username",
",",
"password",
":",
"password",
",",
"ssl_verify_peer",
":",
"false",
")",
"api_response",
"res",
"end"
] | http request via delete
@param [string] uri
@return [Object] ruby representation of the json response
if the reponse body does not parse, raises
a SFRest::InvalidResponse | [
"http",
"request",
"via",
"delete"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/connection.rb#L83-L91 | train |
acquia/sf-sdk-ruby | lib/sfrest/connection.rb | SFRest.Connection.api_response | def api_response(res, return_status = false)
data = access_check JSON(res.body), res.status
return_status ? [res.status, data] : data
rescue JSON::ParserError
message = "Invalid data, status #{res.status}, body: #{res.body}"
raise SFRest::InvalidResponse, message
end | ruby | def api_response(res, return_status = false)
data = access_check JSON(res.body), res.status
return_status ? [res.status, data] : data
rescue JSON::ParserError
message = "Invalid data, status #{res.status}, body: #{res.body}"
raise SFRest::InvalidResponse, message
end | [
"def",
"api_response",
"(",
"res",
",",
"return_status",
"=",
"false",
")",
"data",
"=",
"access_check",
"JSON",
"(",
"res",
".",
"body",
")",
",",
"res",
".",
"status",
"return_status",
"?",
"[",
"res",
".",
"status",
",",
"data",
"]",
":",
"data",
"rescue",
"JSON",
"::",
"ParserError",
"message",
"=",
"\"Invalid data, status #{res.status}, body: #{res.body}\"",
"raise",
"SFRest",
"::",
"InvalidResponse",
",",
"message",
"end"
] | Confirm that the result looks adequate
@param [Excon::Response] res
@param [Boolean] return_status If true returns the integer status
with the reponse
@return [Array|Object] if return_status then [int, Object]
else Object | [
"Confirm",
"that",
"the",
"result",
"looks",
"adequate"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/connection.rb#L99-L105 | train |
acquia/sf-sdk-ruby | lib/sfrest/pathbuilder.rb | SFRest.Pathbuilder.build_url_query | def build_url_query(current_path, datum = nil)
unless datum.nil?
current_path += '?'
current_path += URI.encode_www_form datum
end
current_path
end | ruby | def build_url_query(current_path, datum = nil)
unless datum.nil?
current_path += '?'
current_path += URI.encode_www_form datum
end
current_path
end | [
"def",
"build_url_query",
"(",
"current_path",
",",
"datum",
"=",
"nil",
")",
"unless",
"datum",
".",
"nil?",
"current_path",
"+=",
"'?'",
"current_path",
"+=",
"URI",
".",
"encode_www_form",
"datum",
"end",
"current_path",
"end"
] | build a get query
@param [String] current_path the uri like /api/v1/foo
@param [Hash] datum k,v hash of get query param and value | [
"build",
"a",
"get",
"query"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/pathbuilder.rb#L9-L15 | train |
acquia/sf-sdk-ruby | lib/sfrest/variable.rb | SFRest.Variable.set_variable | def set_variable(name, value)
current_path = '/api/v1/variables'
payload = { 'name' => name, 'value' => value }.to_json
@conn.put(current_path, payload)
end | ruby | def set_variable(name, value)
current_path = '/api/v1/variables'
payload = { 'name' => name, 'value' => value }.to_json
@conn.put(current_path, payload)
end | [
"def",
"set_variable",
"(",
"name",
",",
"value",
")",
"current_path",
"=",
"'/api/v1/variables'",
"payload",
"=",
"{",
"'name'",
"=>",
"name",
",",
"'value'",
"=>",
"value",
"}",
".",
"to_json",
"@conn",
".",
"put",
"(",
"current_path",
",",
"payload",
")",
"end"
] | Sets the key and value of a variable. | [
"Sets",
"the",
"key",
"and",
"value",
"of",
"a",
"variable",
"."
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/variable.rb#L22-L26 | train |
acquia/sf-sdk-ruby | lib/sfrest/site.rb | SFRest.Site.site_list | def site_list(show_incomplete = true)
page = 1
not_done = true
count = 0
sites = []
while not_done
current_path = '/api/v1/sites?page=' << page.to_s
current_path <<= '&show_incomplete=true' if show_incomplete
res = @conn.get(current_path)
if res['sites'] == []
not_done = false
elsif !res['message'].nil?
return { 'message' => res['message'] }
elsif page == 1
count = res['count']
sites = res['sites']
else
res['sites'].each do |site|
sites << site
end
end
page += 1
end
{ 'count' => count, 'sites' => sites }
end | ruby | def site_list(show_incomplete = true)
page = 1
not_done = true
count = 0
sites = []
while not_done
current_path = '/api/v1/sites?page=' << page.to_s
current_path <<= '&show_incomplete=true' if show_incomplete
res = @conn.get(current_path)
if res['sites'] == []
not_done = false
elsif !res['message'].nil?
return { 'message' => res['message'] }
elsif page == 1
count = res['count']
sites = res['sites']
else
res['sites'].each do |site|
sites << site
end
end
page += 1
end
{ 'count' => count, 'sites' => sites }
end | [
"def",
"site_list",
"(",
"show_incomplete",
"=",
"true",
")",
"page",
"=",
"1",
"not_done",
"=",
"true",
"count",
"=",
"0",
"sites",
"=",
"[",
"]",
"while",
"not_done",
"current_path",
"=",
"'/api/v1/sites?page='",
"<<",
"page",
".",
"to_s",
"current_path",
"<<=",
"'&show_incomplete=true'",
"if",
"show_incomplete",
"res",
"=",
"@conn",
".",
"get",
"(",
"current_path",
")",
"if",
"res",
"[",
"'sites'",
"]",
"==",
"[",
"]",
"not_done",
"=",
"false",
"elsif",
"!",
"res",
"[",
"'message'",
"]",
".",
"nil?",
"return",
"{",
"'message'",
"=>",
"res",
"[",
"'message'",
"]",
"}",
"elsif",
"page",
"==",
"1",
"count",
"=",
"res",
"[",
"'count'",
"]",
"sites",
"=",
"res",
"[",
"'sites'",
"]",
"else",
"res",
"[",
"'sites'",
"]",
".",
"each",
"do",
"|",
"site",
"|",
"sites",
"<<",
"site",
"end",
"end",
"page",
"+=",
"1",
"end",
"{",
"'count'",
"=>",
"count",
",",
"'sites'",
"=>",
"sites",
"}",
"end"
] | Gets the complete list of sites
Makes multiple requests to the factory to get all the sites on the factory
@param [Boolean] show_incomplete whether to include incomplete sites in
the list. The default differs from UI/SF to maintain backward compatibility.
@return [Hash{'count' => Integer, 'sites' => Hash}] | [
"Gets",
"the",
"complete",
"list",
"of",
"sites",
"Makes",
"multiple",
"requests",
"to",
"the",
"factory",
"to",
"get",
"all",
"the",
"sites",
"on",
"the",
"factory"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/site.rb#L61-L85 | train |
acquia/sf-sdk-ruby | lib/sfrest/site.rb | SFRest.Site.create_site | def create_site(sitename, group_id, install_profile = nil, codebase = nil)
current_path = '/api/v1/sites'
payload = { 'site_name' => sitename, 'group_ids' => [group_id],
'install_profile' => install_profile, 'codebase' => codebase }.to_json
@conn.post(current_path, payload)
end | ruby | def create_site(sitename, group_id, install_profile = nil, codebase = nil)
current_path = '/api/v1/sites'
payload = { 'site_name' => sitename, 'group_ids' => [group_id],
'install_profile' => install_profile, 'codebase' => codebase }.to_json
@conn.post(current_path, payload)
end | [
"def",
"create_site",
"(",
"sitename",
",",
"group_id",
",",
"install_profile",
"=",
"nil",
",",
"codebase",
"=",
"nil",
")",
"current_path",
"=",
"'/api/v1/sites'",
"payload",
"=",
"{",
"'site_name'",
"=>",
"sitename",
",",
"'group_ids'",
"=>",
"[",
"group_id",
"]",
",",
"'install_profile'",
"=>",
"install_profile",
",",
"'codebase'",
"=>",
"codebase",
"}",
".",
"to_json",
"@conn",
".",
"post",
"(",
"current_path",
",",
"payload",
")",
"end"
] | Creates a site.
@param [String] sitename The name of the site to create.
@param [Integer] group_id The Id of the group the site is to be a member of.
@param [String] install_profile The install profile to use when creating the site.
@param [Integer] codebase The codebase index to use in installs. | [
"Creates",
"a",
"site",
"."
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/site.rb#L92-L97 | train |
acquia/sf-sdk-ruby | lib/sfrest/role.rb | SFRest.Role.get_role_id | def get_role_id(rolename)
pglimit = 100
res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s)
rolecount = res['count'].to_i
id = role_data_from_results(res, rolename)
return id if id
pages = (rolecount / pglimit) + 1
2.upto(pages) do |i|
res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s + '?page=' + i.to_s)
id = role_data_from_results(res, rolename)
return id if id
end
nil
end | ruby | def get_role_id(rolename)
pglimit = 100
res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s)
rolecount = res['count'].to_i
id = role_data_from_results(res, rolename)
return id if id
pages = (rolecount / pglimit) + 1
2.upto(pages) do |i|
res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s + '?page=' + i.to_s)
id = role_data_from_results(res, rolename)
return id if id
end
nil
end | [
"def",
"get_role_id",
"(",
"rolename",
")",
"pglimit",
"=",
"100",
"res",
"=",
"@conn",
".",
"get",
"(",
"'/api/v1/roles&limit='",
"+",
"pglimit",
".",
"to_s",
")",
"rolecount",
"=",
"res",
"[",
"'count'",
"]",
".",
"to_i",
"id",
"=",
"role_data_from_results",
"(",
"res",
",",
"rolename",
")",
"return",
"id",
"if",
"id",
"pages",
"=",
"(",
"rolecount",
"/",
"pglimit",
")",
"+",
"1",
"2",
".",
"upto",
"(",
"pages",
")",
"do",
"|",
"i",
"|",
"res",
"=",
"@conn",
".",
"get",
"(",
"'/api/v1/roles&limit='",
"+",
"pglimit",
".",
"to_s",
"+",
"'?page='",
"+",
"i",
".",
"to_s",
")",
"id",
"=",
"role_data_from_results",
"(",
"res",
",",
"rolename",
")",
"return",
"id",
"if",
"id",
"end",
"nil",
"end"
] | gets the role ID for the role named rolename
will page through all the roles available searching for the site
@param [String] rolename the name of the role to find
@return [Integer] the id of rolename
this will iterate through the roles pages | [
"gets",
"the",
"role",
"ID",
"for",
"the",
"role",
"named",
"rolename",
"will",
"page",
"through",
"all",
"the",
"roles",
"available",
"searching",
"for",
"the",
"site"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/role.rb#L43-L57 | train |
acquia/sf-sdk-ruby | lib/sfrest/role.rb | SFRest.Role.role_data_from_results | def role_data_from_results(res, rolename)
roles = res['roles']
roles.each do |role|
return role[0].to_i if role[1] == rolename
end
nil
end | ruby | def role_data_from_results(res, rolename)
roles = res['roles']
roles.each do |role|
return role[0].to_i if role[1] == rolename
end
nil
end | [
"def",
"role_data_from_results",
"(",
"res",
",",
"rolename",
")",
"roles",
"=",
"res",
"[",
"'roles'",
"]",
"roles",
".",
"each",
"do",
"|",
"role",
"|",
"return",
"role",
"[",
"0",
"]",
".",
"to_i",
"if",
"role",
"[",
"1",
"]",
"==",
"rolename",
"end",
"nil",
"end"
] | Extract the role data for rolename based on the role result object
@param [Hash] res result from a request to /roles
@param [String] rolename
@return [Object] Integer, String, Array, Hash depending on the user data | [
"Extract",
"the",
"role",
"data",
"for",
"rolename",
"based",
"on",
"the",
"role",
"result",
"object"
] | c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8 | https://github.com/acquia/sf-sdk-ruby/blob/c0e9f2a72cd111b1d3213d012bfe7868d88eb1f8/lib/sfrest/role.rb#L63-L69 | train |
damjack/spree_banner | app/models/spree/banner_box.rb | Spree.BannerBox.duplicate | def duplicate
enhance_settings
p = self.dup
p.category = 'COPY OF ' + category
p.created_at = p.updated_at = nil
p.url = url
p.attachment = attachment
# allow site to do some customization
p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra)
p.save!
p
end | ruby | def duplicate
enhance_settings
p = self.dup
p.category = 'COPY OF ' + category
p.created_at = p.updated_at = nil
p.url = url
p.attachment = attachment
# allow site to do some customization
p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra)
p.save!
p
end | [
"def",
"duplicate",
"enhance_settings",
"p",
"=",
"self",
".",
"dup",
"p",
".",
"category",
"=",
"'COPY OF '",
"+",
"category",
"p",
".",
"created_at",
"=",
"p",
".",
"updated_at",
"=",
"nil",
"p",
".",
"url",
"=",
"url",
"p",
".",
"attachment",
"=",
"attachment",
"# allow site to do some customization",
"p",
".",
"send",
"(",
":duplicate_extra",
",",
"self",
")",
"if",
"p",
".",
"respond_to?",
"(",
":duplicate_extra",
")",
"p",
".",
"save!",
"p",
"end"
] | for adding banner_boxes which are closely related to existing ones
define "duplicate_extra" for site-specific actions, eg for additional fields | [
"for",
"adding",
"banner_boxes",
"which",
"are",
"closely",
"related",
"to",
"existing",
"ones",
"define",
"duplicate_extra",
"for",
"site",
"-",
"specific",
"actions",
"eg",
"for",
"additional",
"fields"
] | b14044b13e1242b8e4f4ef2623f9056d4e83f081 | https://github.com/damjack/spree_banner/blob/b14044b13e1242b8e4f4ef2623f9056d4e83f081/app/models/spree/banner_box.rb#L38-L50 | train |
learn-co/learn-co | lib/learn/options_sanitizer.rb | Learn.OptionsSanitizer.handle_missing_or_unknown_args | def handle_missing_or_unknown_args
if first_arg_not_a_flag_or_file?
exit_with_unknown_command
elsif has_output_flag? || has_format_flag?
check_for_output_file if has_output_flag?
check_for_format_type if has_format_flag?
elsif only_has_flag_arguments?
add_test_command
else
exit_with_cannot_understand
end
end | ruby | def handle_missing_or_unknown_args
if first_arg_not_a_flag_or_file?
exit_with_unknown_command
elsif has_output_flag? || has_format_flag?
check_for_output_file if has_output_flag?
check_for_format_type if has_format_flag?
elsif only_has_flag_arguments?
add_test_command
else
exit_with_cannot_understand
end
end | [
"def",
"handle_missing_or_unknown_args",
"if",
"first_arg_not_a_flag_or_file?",
"exit_with_unknown_command",
"elsif",
"has_output_flag?",
"||",
"has_format_flag?",
"check_for_output_file",
"if",
"has_output_flag?",
"check_for_format_type",
"if",
"has_format_flag?",
"elsif",
"only_has_flag_arguments?",
"add_test_command",
"else",
"exit_with_cannot_understand",
"end",
"end"
] | Arg manipulation methods | [
"Arg",
"manipulation",
"methods"
] | 9a63701fc9efda53e2162b15f62405dfe2e2e105 | https://github.com/learn-co/learn-co/blob/9a63701fc9efda53e2162b15f62405dfe2e2e105/lib/learn/options_sanitizer.rb#L69-L80 | train |
mongoid/origin | lib/origin/selectable.rb | Origin.Selectable.between | def between(criterion = nil)
selection(criterion) do |selector, field, value|
selector.store(
field,
{ "$gte" => value.min, "$lte" => value.max }
)
end
end | ruby | def between(criterion = nil)
selection(criterion) do |selector, field, value|
selector.store(
field,
{ "$gte" => value.min, "$lte" => value.max }
)
end
end | [
"def",
"between",
"(",
"criterion",
"=",
"nil",
")",
"selection",
"(",
"criterion",
")",
"do",
"|",
"selector",
",",
"field",
",",
"value",
"|",
"selector",
".",
"store",
"(",
"field",
",",
"{",
"\"$gte\"",
"=>",
"value",
".",
"min",
",",
"\"$lte\"",
"=>",
"value",
".",
"max",
"}",
")",
"end",
"end"
] | Add the range selection.
@example Match on results within a single range.
selectable.between(field: 1..2)
@example Match on results between multiple ranges.
selectable.between(field: 1..2, other: 5..7)
@param [ Hash ] criterion Multiple key/range pairs.
@return [ Selectable ] The cloned selectable.
@since 1.0.0 | [
"Add",
"the",
"range",
"selection",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selectable.rb#L77-L84 | train |
mongoid/origin | lib/origin/selectable.rb | Origin.Selectable.not | def not(*criterion)
if criterion.empty?
tap { |query| query.negating = true }
else
__override__(criterion.first, "$not")
end
end | ruby | def not(*criterion)
if criterion.empty?
tap { |query| query.negating = true }
else
__override__(criterion.first, "$not")
end
end | [
"def",
"not",
"(",
"*",
"criterion",
")",
"if",
"criterion",
".",
"empty?",
"tap",
"{",
"|",
"query",
"|",
"query",
".",
"negating",
"=",
"true",
"}",
"else",
"__override__",
"(",
"criterion",
".",
"first",
",",
"\"$not\"",
")",
"end",
"end"
] | Negate the next selection.
@example Negate the selection.
selectable.not.in(field: [ 1, 2 ])
@example Add the $not criterion.
selectable.not(name: /Bob/)
@example Execute a $not in a where query.
selectable.where(:field.not => /Bob/)
@param [ Hash ] criterion The field/value pairs to negate.
@return [ Selectable ] The negated selectable.
@since 1.0.0 | [
"Negate",
"the",
"next",
"selection",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selectable.rb#L421-L427 | train |
mongoid/origin | lib/origin/selectable.rb | Origin.Selectable.text_search | def text_search(terms, opts = nil)
clone.tap do |query|
if terms
criterion = { :$text => { :$search => terms } }
criterion[:$text].merge!(opts) if opts
query.selector = criterion
end
end
end | ruby | def text_search(terms, opts = nil)
clone.tap do |query|
if terms
criterion = { :$text => { :$search => terms } }
criterion[:$text].merge!(opts) if opts
query.selector = criterion
end
end
end | [
"def",
"text_search",
"(",
"terms",
",",
"opts",
"=",
"nil",
")",
"clone",
".",
"tap",
"do",
"|",
"query",
"|",
"if",
"terms",
"criterion",
"=",
"{",
":$text",
"=>",
"{",
":$search",
"=>",
"terms",
"}",
"}",
"criterion",
"[",
":$text",
"]",
".",
"merge!",
"(",
"opts",
")",
"if",
"opts",
"query",
".",
"selector",
"=",
"criterion",
"end",
"end",
"end"
] | Construct a text search selector.
@example Construct a text search selector.
selectable.text_search("testing")
@example Construct a text search selector with options.
selectable.text_search("testing", :$language => "fr")
@param [ String, Symbol ] terms A string of terms that MongoDB parses
and uses to query the text index.
@param [ Hash ] opts Text search options. See MongoDB documentation
for options.
@return [ Selectable ] The cloned selectable.
@since 2.2.0 | [
"Construct",
"a",
"text",
"search",
"selector",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selectable.rb#L510-L518 | train |
mongoid/origin | lib/origin/selectable.rb | Origin.Selectable.typed_override | def typed_override(criterion, operator)
if criterion
criterion.update_values do |value|
yield(value)
end
end
__override__(criterion, operator)
end | ruby | def typed_override(criterion, operator)
if criterion
criterion.update_values do |value|
yield(value)
end
end
__override__(criterion, operator)
end | [
"def",
"typed_override",
"(",
"criterion",
",",
"operator",
")",
"if",
"criterion",
"criterion",
".",
"update_values",
"do",
"|",
"value",
"|",
"yield",
"(",
"value",
")",
"end",
"end",
"__override__",
"(",
"criterion",
",",
"operator",
")",
"end"
] | Force the values of the criterion to be evolved.
@api private
@example Force values to booleans.
selectable.force_typing(criterion) do |val|
Boolean.evolve(val)
end
@param [ Hash ] criterion The criterion.
@since 1.0.0 | [
"Force",
"the",
"values",
"of",
"the",
"criterion",
"to",
"be",
"evolved",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selectable.rb#L571-L578 | train |
mongoid/origin | lib/origin/selectable.rb | Origin.Selectable.selection | def selection(criterion = nil)
clone.tap do |query|
if criterion
criterion.each_pair do |field, value|
yield(query.selector, field.is_a?(Key) ? field : field.to_s, value)
end
end
query.reset_strategies!
end
end | ruby | def selection(criterion = nil)
clone.tap do |query|
if criterion
criterion.each_pair do |field, value|
yield(query.selector, field.is_a?(Key) ? field : field.to_s, value)
end
end
query.reset_strategies!
end
end | [
"def",
"selection",
"(",
"criterion",
"=",
"nil",
")",
"clone",
".",
"tap",
"do",
"|",
"query",
"|",
"if",
"criterion",
"criterion",
".",
"each_pair",
"do",
"|",
"field",
",",
"value",
"|",
"yield",
"(",
"query",
".",
"selector",
",",
"field",
".",
"is_a?",
"(",
"Key",
")",
"?",
"field",
":",
"field",
".",
"to_s",
",",
"value",
")",
"end",
"end",
"query",
".",
"reset_strategies!",
"end",
"end"
] | Take the provided criterion and store it as a selection in the query
selector.
@api private
@example Store the selection.
selectable.selection({ field: "value" })
@param [ Hash ] criterion The selection to store.
@return [ Selectable ] The cloned selectable.
@since 1.0.0 | [
"Take",
"the",
"provided",
"criterion",
"and",
"store",
"it",
"as",
"a",
"selection",
"in",
"the",
"query",
"selector",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selectable.rb#L611-L620 | train |
mongoid/origin | lib/origin/queryable.rb | Origin.Queryable.initialize_copy | def initialize_copy(other)
@options = other.options.__deep_copy__
@selector = other.selector.__deep_copy__
@pipeline = other.pipeline.__deep_copy__
end | ruby | def initialize_copy(other)
@options = other.options.__deep_copy__
@selector = other.selector.__deep_copy__
@pipeline = other.pipeline.__deep_copy__
end | [
"def",
"initialize_copy",
"(",
"other",
")",
"@options",
"=",
"other",
".",
"options",
".",
"__deep_copy__",
"@selector",
"=",
"other",
".",
"selector",
".",
"__deep_copy__",
"@pipeline",
"=",
"other",
".",
"pipeline",
".",
"__deep_copy__",
"end"
] | Is this queryable equal to another object? Is true if the selector and
options are equal.
@example Are the objects equal?
queryable == criteria
@param [ Object ] other The object to compare against.
@return [ true, false ] If the objects are equal.
@since 1.0.0
Initialize the new queryable. Will yield itself to the block if a block
is provided for objects that need additional behaviour.
@example Initialize the queryable.
Origin::Queryable.new
@param [ Hash ] aliases The optional field aliases.
@param [ Hash ] serializers The optional field serializers.
@param [ Symbol ] driver The driver being used.
@since 1.0.0
Handle the creation of a copy via #clone or #dup.
@example Handle copy initialization.
queryable.initialize_copy(criteria)
@param [ Queryable ] other The original copy.
@since 1.0.0 | [
"Is",
"this",
"queryable",
"equal",
"to",
"another",
"object?",
"Is",
"true",
"if",
"the",
"selector",
"and",
"options",
"are",
"equal",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/queryable.rb#L77-L81 | train |
mongoid/origin | lib/origin/pipeline.rb | Origin.Pipeline.evolve | def evolve(entry)
aggregate = Selector.new(aliases)
entry.each_pair do |field, value|
aggregate.merge!(field.to_s => value)
end
aggregate
end | ruby | def evolve(entry)
aggregate = Selector.new(aliases)
entry.each_pair do |field, value|
aggregate.merge!(field.to_s => value)
end
aggregate
end | [
"def",
"evolve",
"(",
"entry",
")",
"aggregate",
"=",
"Selector",
".",
"new",
"(",
"aliases",
")",
"entry",
".",
"each_pair",
"do",
"|",
"field",
",",
"value",
"|",
"aggregate",
".",
"merge!",
"(",
"field",
".",
"to_s",
"=>",
"value",
")",
"end",
"aggregate",
"end"
] | Evolve the entry using the aliases.
@api private
@example Evolve the entry.
pipeline.evolve(name: 1)
@param [ Hash ] entry The entry to evolve.
@return [ Hash ] The evolved entry.
@since 2.0.0 | [
"Evolve",
"the",
"entry",
"using",
"the",
"aliases",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/pipeline.rb#L99-L105 | train |
mongoid/origin | lib/origin/forwardable.rb | Origin.Forwardable.select_with | def select_with(receiver)
(Selectable.forwardables + Optional.forwardables).each do |name|
__forward__(name, receiver)
end
end | ruby | def select_with(receiver)
(Selectable.forwardables + Optional.forwardables).each do |name|
__forward__(name, receiver)
end
end | [
"def",
"select_with",
"(",
"receiver",
")",
"(",
"Selectable",
".",
"forwardables",
"+",
"Optional",
".",
"forwardables",
")",
".",
"each",
"do",
"|",
"name",
"|",
"__forward__",
"(",
"name",
",",
"receiver",
")",
"end",
"end"
] | Tells origin with method on the class to delegate to when calling an
original selectable or optional method on the class.
@example Tell origin where to select from.
class Band
extend Origin::Forwardable
select_with :criteria
def self.criteria
Query.new
end
end
@param [ Symbol ] receiver The name of the receiver method.
@return [ Array<Symbol> ] The names of the forwarded methods.
@since 1.0.0 | [
"Tells",
"origin",
"with",
"method",
"on",
"the",
"class",
"to",
"delegate",
"to",
"when",
"calling",
"an",
"original",
"selectable",
"or",
"optional",
"method",
"on",
"the",
"class",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/forwardable.rb#L26-L30 | train |
mongoid/origin | lib/origin/aggregable.rb | Origin.Aggregable.aggregation | def aggregation(operation)
return self unless operation
clone.tap do |query|
unless aggregating?
query.pipeline.concat(query.selector.to_pipeline)
query.pipeline.concat(query.options.to_pipeline)
query.aggregating = true
end
yield(query.pipeline)
end
end | ruby | def aggregation(operation)
return self unless operation
clone.tap do |query|
unless aggregating?
query.pipeline.concat(query.selector.to_pipeline)
query.pipeline.concat(query.options.to_pipeline)
query.aggregating = true
end
yield(query.pipeline)
end
end | [
"def",
"aggregation",
"(",
"operation",
")",
"return",
"self",
"unless",
"operation",
"clone",
".",
"tap",
"do",
"|",
"query",
"|",
"unless",
"aggregating?",
"query",
".",
"pipeline",
".",
"concat",
"(",
"query",
".",
"selector",
".",
"to_pipeline",
")",
"query",
".",
"pipeline",
".",
"concat",
"(",
"query",
".",
"options",
".",
"to_pipeline",
")",
"query",
".",
"aggregating",
"=",
"true",
"end",
"yield",
"(",
"query",
".",
"pipeline",
")",
"end",
"end"
] | Add the aggregation operation.
@api private
@example Aggregate on the operation.
aggregation(operation) do |pipeline|
pipeline.push("$project" => operation)
end
@param [ Hash ] operation The operation for the pipeline.
@return [ Aggregable ] The cloned aggregable.
@since 2.0.0 | [
"Add",
"the",
"aggregation",
"operation",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/aggregable.rb#L104-L114 | train |
mongoid/origin | lib/origin/smash.rb | Origin.Smash.storage_pair | def storage_pair(key)
field = key.to_s
name = aliases[field] || field
[ name, serializers[name] ]
end | ruby | def storage_pair(key)
field = key.to_s
name = aliases[field] || field
[ name, serializers[name] ]
end | [
"def",
"storage_pair",
"(",
"key",
")",
"field",
"=",
"key",
".",
"to_s",
"name",
"=",
"aliases",
"[",
"field",
"]",
"||",
"field",
"[",
"name",
",",
"serializers",
"[",
"name",
"]",
"]",
"end"
] | Get the pair of objects needed to store the value in a hash by the
provided key. This is the database field name and the serializer.
@api private
@example Get the name and serializer.
smash.storage_pair("id")
@param [ Symbol, String ] key The key provided to the selection.
@return [ Array<String, Object> ] The name of the db field and
serializer.
@since 1.0.0 | [
"Get",
"the",
"pair",
"of",
"objects",
"needed",
"to",
"store",
"the",
"value",
"in",
"a",
"hash",
"by",
"the",
"provided",
"key",
".",
"This",
"is",
"the",
"database",
"field",
"name",
"and",
"the",
"serializer",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/smash.rb#L93-L97 | train |
mongoid/origin | lib/origin/mergeable.rb | Origin.Mergeable.with_strategy | def with_strategy(strategy, criterion, operator)
selection(criterion) do |selector, field, value|
selector.store(
field,
selector[field].send(strategy, prepare(field, operator, value))
)
end
end | ruby | def with_strategy(strategy, criterion, operator)
selection(criterion) do |selector, field, value|
selector.store(
field,
selector[field].send(strategy, prepare(field, operator, value))
)
end
end | [
"def",
"with_strategy",
"(",
"strategy",
",",
"criterion",
",",
"operator",
")",
"selection",
"(",
"criterion",
")",
"do",
"|",
"selector",
",",
"field",
",",
"value",
"|",
"selector",
".",
"store",
"(",
"field",
",",
"selector",
"[",
"field",
"]",
".",
"send",
"(",
"strategy",
",",
"prepare",
"(",
"field",
",",
"operator",
",",
"value",
")",
")",
")",
"end",
"end"
] | Add criterion to the selection with the named strategy.
@api private
@example Add criterion with a strategy.
mergeable.with_strategy(:__union__, [ 1, 2, 3 ], "$in")
@param [ Symbol ] strategy The name of the strategy method.
@param [ Object ] criterion The criterion to add.
@param [ String ] operator The MongoDB operator.
@return [ Mergeable ] The cloned query.
@since 1.0.0 | [
"Add",
"criterion",
"to",
"the",
"selection",
"with",
"the",
"named",
"strategy",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/mergeable.rb#L235-L242 | train |
mongoid/origin | lib/origin/mergeable.rb | Origin.Mergeable.prepare | def prepare(field, operator, value)
unless operator =~ /exists|type|size/
value = value.__expand_complex__
serializer = serializers[field]
value = serializer ? serializer.evolve(value) : value
end
selection = { operator => value }
negating? ? { "$not" => selection } : selection
end | ruby | def prepare(field, operator, value)
unless operator =~ /exists|type|size/
value = value.__expand_complex__
serializer = serializers[field]
value = serializer ? serializer.evolve(value) : value
end
selection = { operator => value }
negating? ? { "$not" => selection } : selection
end | [
"def",
"prepare",
"(",
"field",
",",
"operator",
",",
"value",
")",
"unless",
"operator",
"=~",
"/",
"/",
"value",
"=",
"value",
".",
"__expand_complex__",
"serializer",
"=",
"serializers",
"[",
"field",
"]",
"value",
"=",
"serializer",
"?",
"serializer",
".",
"evolve",
"(",
"value",
")",
":",
"value",
"end",
"selection",
"=",
"{",
"operator",
"=>",
"value",
"}",
"negating?",
"?",
"{",
"\"$not\"",
"=>",
"selection",
"}",
":",
"selection",
"end"
] | Prepare the value for merging.
@api private
@example Prepare the value.
mergeable.prepare("field", "$gt", 10)
@param [ String ] field The name of the field.
@param [ Object ] value The value.
@return [ Object ] The serialized value.
@since 1.0.0 | [
"Prepare",
"the",
"value",
"for",
"merging",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/mergeable.rb#L257-L265 | train |
mongoid/origin | lib/origin/selector.rb | Origin.Selector.merge! | def merge!(other)
other.each_pair do |key, value|
if value.is_a?(Hash) && self[key.to_s].is_a?(Hash)
value = self[key.to_s].merge(value) do |_key, old_val, new_val|
if in?(_key)
new_val & old_val
elsif nin?(_key)
(old_val + new_val).uniq
else
new_val
end
end
end
if multi_selection?(key)
value = (self[key.to_s] || []).concat(value)
end
store(key, value)
end
end | ruby | def merge!(other)
other.each_pair do |key, value|
if value.is_a?(Hash) && self[key.to_s].is_a?(Hash)
value = self[key.to_s].merge(value) do |_key, old_val, new_val|
if in?(_key)
new_val & old_val
elsif nin?(_key)
(old_val + new_val).uniq
else
new_val
end
end
end
if multi_selection?(key)
value = (self[key.to_s] || []).concat(value)
end
store(key, value)
end
end | [
"def",
"merge!",
"(",
"other",
")",
"other",
".",
"each_pair",
"do",
"|",
"key",
",",
"value",
"|",
"if",
"value",
".",
"is_a?",
"(",
"Hash",
")",
"&&",
"self",
"[",
"key",
".",
"to_s",
"]",
".",
"is_a?",
"(",
"Hash",
")",
"value",
"=",
"self",
"[",
"key",
".",
"to_s",
"]",
".",
"merge",
"(",
"value",
")",
"do",
"|",
"_key",
",",
"old_val",
",",
"new_val",
"|",
"if",
"in?",
"(",
"_key",
")",
"new_val",
"&",
"old_val",
"elsif",
"nin?",
"(",
"_key",
")",
"(",
"old_val",
"+",
"new_val",
")",
".",
"uniq",
"else",
"new_val",
"end",
"end",
"end",
"if",
"multi_selection?",
"(",
"key",
")",
"value",
"=",
"(",
"self",
"[",
"key",
".",
"to_s",
"]",
"||",
"[",
"]",
")",
".",
"concat",
"(",
"value",
")",
"end",
"store",
"(",
"key",
",",
"value",
")",
"end",
"end"
] | Merges another selector into this one.
@example Merge in another selector.
selector.merge!(name: "test")
@param [ Hash, Selector ] other The object to merge in.
@return [ Selector ] The selector.
@since 1.0.0 | [
"Merges",
"another",
"selector",
"into",
"this",
"one",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selector.rb#L18-L36 | train |
mongoid/origin | lib/origin/selector.rb | Origin.Selector.store | def store(key, value)
name, serializer = storage_pair(key)
if multi_selection?(name)
super(name, evolve_multi(value))
else
super(normalized_key(name, serializer), evolve(serializer, value))
end
end | ruby | def store(key, value)
name, serializer = storage_pair(key)
if multi_selection?(name)
super(name, evolve_multi(value))
else
super(normalized_key(name, serializer), evolve(serializer, value))
end
end | [
"def",
"store",
"(",
"key",
",",
"value",
")",
"name",
",",
"serializer",
"=",
"storage_pair",
"(",
"key",
")",
"if",
"multi_selection?",
"(",
"name",
")",
"super",
"(",
"name",
",",
"evolve_multi",
"(",
"value",
")",
")",
"else",
"super",
"(",
"normalized_key",
"(",
"name",
",",
"serializer",
")",
",",
"evolve",
"(",
"serializer",
",",
"value",
")",
")",
"end",
"end"
] | Store the value in the selector for the provided key. The selector will
handle all necessary serialization and localization in this step.
@example Store a value in the selector.
selector.store(:key, "testing")
@param [ String, Symbol ] key The name of the attribute.
@param [ Object ] value The value to add.
@return [ Object ] The stored object.
@since 1.0.0 | [
"Store",
"the",
"value",
"in",
"the",
"selector",
"for",
"the",
"provided",
"key",
".",
"The",
"selector",
"will",
"handle",
"all",
"necessary",
"serialization",
"and",
"localization",
"in",
"this",
"step",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selector.rb#L50-L57 | train |
mongoid/origin | lib/origin/selector.rb | Origin.Selector.evolve | def evolve(serializer, value)
case value
when Hash
evolve_hash(serializer, value)
when Array
evolve_array(serializer, value)
else
(serializer || value.class).evolve(value)
end
end | ruby | def evolve(serializer, value)
case value
when Hash
evolve_hash(serializer, value)
when Array
evolve_array(serializer, value)
else
(serializer || value.class).evolve(value)
end
end | [
"def",
"evolve",
"(",
"serializer",
",",
"value",
")",
"case",
"value",
"when",
"Hash",
"evolve_hash",
"(",
"serializer",
",",
"value",
")",
"when",
"Array",
"evolve_array",
"(",
"serializer",
",",
"value",
")",
"else",
"(",
"serializer",
"||",
"value",
".",
"class",
")",
".",
"evolve",
"(",
"value",
")",
"end",
"end"
] | Evolve a single key selection with various types of values.
@api private
@example Evolve a simple selection.
selector.evolve(field, 5)
@param [ Object ] serializer The optional serializer for the field.
@param [ Object ] value The value to serialize.
@return [ Object ] The serialized object.
@since 1.0.0 | [
"Evolve",
"a",
"single",
"key",
"selection",
"with",
"various",
"types",
"of",
"values",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/selector.rb#L112-L121 | train |
mongoid/origin | lib/origin/options.rb | Origin.Options.to_pipeline | def to_pipeline
pipeline = []
pipeline.push({ "$skip" => skip }) if skip
pipeline.push({ "$limit" => limit }) if limit
pipeline.push({ "$sort" => sort }) if sort
pipeline
end | ruby | def to_pipeline
pipeline = []
pipeline.push({ "$skip" => skip }) if skip
pipeline.push({ "$limit" => limit }) if limit
pipeline.push({ "$sort" => sort }) if sort
pipeline
end | [
"def",
"to_pipeline",
"pipeline",
"=",
"[",
"]",
"pipeline",
".",
"push",
"(",
"{",
"\"$skip\"",
"=>",
"skip",
"}",
")",
"if",
"skip",
"pipeline",
".",
"push",
"(",
"{",
"\"$limit\"",
"=>",
"limit",
"}",
")",
"if",
"limit",
"pipeline",
".",
"push",
"(",
"{",
"\"$sort\"",
"=>",
"sort",
"}",
")",
"if",
"sort",
"pipeline",
"end"
] | Convert the options to aggregation pipeline friendly options.
@example Convert the options to a pipeline.
options.to_pipeline
@return [ Array<Hash> ] The options in pipeline form.
@since 2.0.0 | [
"Convert",
"the",
"options",
"to",
"aggregation",
"pipeline",
"friendly",
"options",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/options.rb#L81-L87 | train |
mongoid/origin | lib/origin/macroable.rb | Origin.Macroable.key | def key(name, strategy, operator, additional = nil, &block)
::Symbol.add_key(name, strategy, operator, additional, &block)
end | ruby | def key(name, strategy, operator, additional = nil, &block)
::Symbol.add_key(name, strategy, operator, additional, &block)
end | [
"def",
"key",
"(",
"name",
",",
"strategy",
",",
"operator",
",",
"additional",
"=",
"nil",
",",
"&",
"block",
")",
"::",
"Symbol",
".",
"add_key",
"(",
"name",
",",
"strategy",
",",
"operator",
",",
"additional",
",",
"block",
")",
"end"
] | Adds a method on Symbol for convenience in where queries for the
provided operators.
@example Add a symbol key.
key :all, "$all
@param [ Symbol ] name The name of the method.
@param [ Symbol ] strategy The merge strategy.
@param [ String ] operator The MongoDB operator.
@param [ String ] additional The additional MongoDB operator.
@since 1.0.0 | [
"Adds",
"a",
"method",
"on",
"Symbol",
"for",
"convenience",
"in",
"where",
"queries",
"for",
"the",
"provided",
"operators",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/macroable.rb#L19-L21 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.order_by | def order_by(*spec)
option(spec) do |options, query|
spec.compact.each do |criterion|
criterion.__sort_option__.each_pair do |field, direction|
add_sort_option(options, field, direction)
end
query.pipeline.push("$sort" => options[:sort]) if aggregating?
end
end
end | ruby | def order_by(*spec)
option(spec) do |options, query|
spec.compact.each do |criterion|
criterion.__sort_option__.each_pair do |field, direction|
add_sort_option(options, field, direction)
end
query.pipeline.push("$sort" => options[:sort]) if aggregating?
end
end
end | [
"def",
"order_by",
"(",
"*",
"spec",
")",
"option",
"(",
"spec",
")",
"do",
"|",
"options",
",",
"query",
"|",
"spec",
".",
"compact",
".",
"each",
"do",
"|",
"criterion",
"|",
"criterion",
".",
"__sort_option__",
".",
"each_pair",
"do",
"|",
"field",
",",
"direction",
"|",
"add_sort_option",
"(",
"options",
",",
"field",
",",
"direction",
")",
"end",
"query",
".",
"pipeline",
".",
"push",
"(",
"\"$sort\"",
"=>",
"options",
"[",
":sort",
"]",
")",
"if",
"aggregating?",
"end",
"end",
"end"
] | Adds sorting criterion to the options.
@example Add sorting options via a hash with integer directions.
optional.order_by(name: 1, dob: -1)
@example Add sorting options via a hash with symbol directions.
optional.order_by(name: :asc, dob: :desc)
@example Add sorting options via a hash with string directions.
optional.order_by(name: "asc", dob: "desc")
@example Add sorting options via an array with integer directions.
optional.order_by([[ name, 1 ], [ dob, -1 ]])
@example Add sorting options via an array with symbol directions.
optional.order_by([[ name, :asc ], [ dob, :desc ]])
@example Add sorting options via an array with string directions.
optional.order_by([[ name, "asc" ], [ dob, "desc" ]])
@example Add sorting options with keys.
optional.order_by(:name.asc, :dob.desc)
@example Add sorting options via a string.
optional.order_by("name ASC, dob DESC")
@param [ Array, Hash, String ] spec The sorting specification.
@return [ Optional ] The cloned optional.
@since 1.0.0 | [
"Adds",
"sorting",
"criterion",
"to",
"the",
"options",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L170-L179 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.skip | def skip(value = nil)
option(value) do |options, query|
val = value.to_i
options.store(:skip, val)
query.pipeline.push("$skip" => val) if aggregating?
end
end | ruby | def skip(value = nil)
option(value) do |options, query|
val = value.to_i
options.store(:skip, val)
query.pipeline.push("$skip" => val) if aggregating?
end
end | [
"def",
"skip",
"(",
"value",
"=",
"nil",
")",
"option",
"(",
"value",
")",
"do",
"|",
"options",
",",
"query",
"|",
"val",
"=",
"value",
".",
"to_i",
"options",
".",
"store",
"(",
":skip",
",",
"val",
")",
"query",
".",
"pipeline",
".",
"push",
"(",
"\"$skip\"",
"=>",
"val",
")",
"if",
"aggregating?",
"end",
"end"
] | Add the number of documents to skip.
@example Add the number to skip.
optional.skip(100)
@param [ Integer ] value The number to skip.
@return [ Optional ] The cloned optional.
@since 1.0.0 | [
"Add",
"the",
"number",
"of",
"documents",
"to",
"skip",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L208-L214 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.slice | def slice(criterion = nil)
option(criterion) do |options|
options.__union__(
fields: criterion.inject({}) do |option, (field, val)|
option.tap { |opt| opt.store(field, { "$slice" => val }) }
end
)
end
end | ruby | def slice(criterion = nil)
option(criterion) do |options|
options.__union__(
fields: criterion.inject({}) do |option, (field, val)|
option.tap { |opt| opt.store(field, { "$slice" => val }) }
end
)
end
end | [
"def",
"slice",
"(",
"criterion",
"=",
"nil",
")",
"option",
"(",
"criterion",
")",
"do",
"|",
"options",
"|",
"options",
".",
"__union__",
"(",
"fields",
":",
"criterion",
".",
"inject",
"(",
"{",
"}",
")",
"do",
"|",
"option",
",",
"(",
"field",
",",
"val",
")",
"|",
"option",
".",
"tap",
"{",
"|",
"opt",
"|",
"opt",
".",
"store",
"(",
"field",
",",
"{",
"\"$slice\"",
"=>",
"val",
"}",
")",
"}",
"end",
")",
"end",
"end"
] | Limit the returned results via slicing embedded arrays.
@example Slice the returned results.
optional.slice(aliases: [ 0, 5 ])
@param [ Hash ] criterion The slice options.
@return [ Optional ] The cloned optional.
@since 1.0.0 | [
"Limit",
"the",
"returned",
"results",
"via",
"slicing",
"embedded",
"arrays",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L227-L235 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.without | def without(*args)
args = args.flatten
option(*args) do |options|
options.store(
:fields, args.inject(options[:fields] || {}){ |sub, field| sub.tap { sub[field] = 0 }}
)
end
end | ruby | def without(*args)
args = args.flatten
option(*args) do |options|
options.store(
:fields, args.inject(options[:fields] || {}){ |sub, field| sub.tap { sub[field] = 0 }}
)
end
end | [
"def",
"without",
"(",
"*",
"args",
")",
"args",
"=",
"args",
".",
"flatten",
"option",
"(",
"args",
")",
"do",
"|",
"options",
"|",
"options",
".",
"store",
"(",
":fields",
",",
"args",
".",
"inject",
"(",
"options",
"[",
":fields",
"]",
"||",
"{",
"}",
")",
"{",
"|",
"sub",
",",
"field",
"|",
"sub",
".",
"tap",
"{",
"sub",
"[",
"field",
"]",
"=",
"0",
"}",
"}",
")",
"end",
"end"
] | Limits the results to only contain the fields not provided.
@example Limit the results to the fields not provided.
optional.without(:name, :dob)
@param [ Array<Symbol> ] args The fields to ignore.
@return [ Optional ] The cloned optional.
@since 1.0.0 | [
"Limits",
"the",
"results",
"to",
"only",
"contain",
"the",
"fields",
"not",
"provided",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L261-L268 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.add_sort_option | def add_sort_option(options, field, direction)
if driver == :mongo1x
sorting = (options[:sort] || []).dup
sorting.push([ field, direction ])
options.store(:sort, sorting)
else
sorting = (options[:sort] || {}).dup
sorting[field] = direction
options.store(:sort, sorting)
end
end | ruby | def add_sort_option(options, field, direction)
if driver == :mongo1x
sorting = (options[:sort] || []).dup
sorting.push([ field, direction ])
options.store(:sort, sorting)
else
sorting = (options[:sort] || {}).dup
sorting[field] = direction
options.store(:sort, sorting)
end
end | [
"def",
"add_sort_option",
"(",
"options",
",",
"field",
",",
"direction",
")",
"if",
"driver",
"==",
":mongo1x",
"sorting",
"=",
"(",
"options",
"[",
":sort",
"]",
"||",
"[",
"]",
")",
".",
"dup",
"sorting",
".",
"push",
"(",
"[",
"field",
",",
"direction",
"]",
")",
"options",
".",
"store",
"(",
":sort",
",",
"sorting",
")",
"else",
"sorting",
"=",
"(",
"options",
"[",
":sort",
"]",
"||",
"{",
"}",
")",
".",
"dup",
"sorting",
"[",
"field",
"]",
"=",
"direction",
"options",
".",
"store",
"(",
":sort",
",",
"sorting",
")",
"end",
"end"
] | Add a single sort option.
@api private
@example Add a single sort option.
optional.add_sort_option({}, :name, 1)
@param [ Hash ] options The options.
@param [ String ] field The field name.
@param [ Integer ] direction The sort direction.
@return [ Optional ] The cloned optional.
@since 1.0.0 | [
"Add",
"a",
"single",
"sort",
"option",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L336-L346 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.option | def option(*args)
clone.tap do |query|
unless args.compact.empty?
yield(query.options, query)
end
end
end | ruby | def option(*args)
clone.tap do |query|
unless args.compact.empty?
yield(query.options, query)
end
end
end | [
"def",
"option",
"(",
"*",
"args",
")",
"clone",
".",
"tap",
"do",
"|",
"query",
"|",
"unless",
"args",
".",
"compact",
".",
"empty?",
"yield",
"(",
"query",
".",
"options",
",",
"query",
")",
"end",
"end",
"end"
] | Take the provided criterion and store it as an option in the query
options.
@api private
@example Store the option.
optional.option({ skip: 10 })
@param [ Array ] args The options.
@return [ Queryable ] The cloned queryable.
@since 1.0.0 | [
"Take",
"the",
"provided",
"criterion",
"and",
"store",
"it",
"as",
"an",
"option",
"in",
"the",
"query",
"options",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L361-L367 | train |
mongoid/origin | lib/origin/optional.rb | Origin.Optional.sort_with_list | def sort_with_list(*fields, direction)
option(fields) do |options, query|
fields.flatten.compact.each do |field|
add_sort_option(options, field, direction)
end
query.pipeline.push("$sort" => options[:sort]) if aggregating?
end
end | ruby | def sort_with_list(*fields, direction)
option(fields) do |options, query|
fields.flatten.compact.each do |field|
add_sort_option(options, field, direction)
end
query.pipeline.push("$sort" => options[:sort]) if aggregating?
end
end | [
"def",
"sort_with_list",
"(",
"*",
"fields",
",",
"direction",
")",
"option",
"(",
"fields",
")",
"do",
"|",
"options",
",",
"query",
"|",
"fields",
".",
"flatten",
".",
"compact",
".",
"each",
"do",
"|",
"field",
"|",
"add_sort_option",
"(",
"options",
",",
"field",
",",
"direction",
")",
"end",
"query",
".",
"pipeline",
".",
"push",
"(",
"\"$sort\"",
"=>",
"options",
"[",
":sort",
"]",
")",
"if",
"aggregating?",
"end",
"end"
] | Add multiple sort options at once.
@api private
@example Add multiple sort options.
optional.sort_with_list(:name, :dob, 1)
@param [ Array<String> ] fields The field names.
@param [ Integer ] direction The sort direction.
@return [ Optional ] The cloned optional.
@since 1.0.0 | [
"Add",
"multiple",
"sort",
"options",
"at",
"once",
"."
] | b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63 | https://github.com/mongoid/origin/blob/b0bb0504d4e9289882cf9cd2fcc8dbd62cc29d63/lib/origin/optional.rb#L382-L389 | train |
technoweenie/guillotine | lib/guillotine.rb | Guillotine.Adapter.parse_url | def parse_url(url, options)
url.gsub!(/\s/, '')
url.gsub!(/\?.*/, '') if options.strip_query?
url.gsub!(/\#.*/, '') if options.strip_anchor?
Addressable::URI.parse(url)
end | ruby | def parse_url(url, options)
url.gsub!(/\s/, '')
url.gsub!(/\?.*/, '') if options.strip_query?
url.gsub!(/\#.*/, '') if options.strip_anchor?
Addressable::URI.parse(url)
end | [
"def",
"parse_url",
"(",
"url",
",",
"options",
")",
"url",
".",
"gsub!",
"(",
"/",
"\\s",
"/",
",",
"''",
")",
"url",
".",
"gsub!",
"(",
"/",
"\\?",
"/",
",",
"''",
")",
"if",
"options",
".",
"strip_query?",
"url",
".",
"gsub!",
"(",
"/",
"\\#",
"/",
",",
"''",
")",
"if",
"options",
".",
"strip_anchor?",
"Addressable",
"::",
"URI",
".",
"parse",
"(",
"url",
")",
"end"
] | Parses and sanitizes a URL.
url - A String URL.
options - A Guillotine::Service::Options object.
Returns an Addressable::URI. | [
"Parses",
"and",
"sanitizes",
"a",
"URL",
"."
] | 73afb1c435086b487467914f300bfebe3821c2f3 | https://github.com/technoweenie/guillotine/blob/73afb1c435086b487467914f300bfebe3821c2f3/lib/guillotine.rb#L68-L73 | train |
technoweenie/guillotine | lib/guillotine/adapters/riak_adapter.rb | Guillotine.RiakAdapter.add | def add(url, code = nil, options = nil)
sha = url_key url
url_obj = @url_bucket.get_or_new sha, :r => 1
if url_obj.raw_data
fix_url_object(url_obj)
code = url_obj.data
end
code = get_code(url, code, options)
code_obj = @code_bucket.get_or_new code
code_obj.content_type = url_obj.content_type = PLAIN
if existing_url = code_obj.data # key exists
raise DuplicateCodeError.new(existing_url, url, code) if url_key(existing_url) != sha
end
if !url_obj.data # unsaved
url_obj.data = code
url_obj.store
end
code_obj.data = url
code_obj.store
code
end | ruby | def add(url, code = nil, options = nil)
sha = url_key url
url_obj = @url_bucket.get_or_new sha, :r => 1
if url_obj.raw_data
fix_url_object(url_obj)
code = url_obj.data
end
code = get_code(url, code, options)
code_obj = @code_bucket.get_or_new code
code_obj.content_type = url_obj.content_type = PLAIN
if existing_url = code_obj.data # key exists
raise DuplicateCodeError.new(existing_url, url, code) if url_key(existing_url) != sha
end
if !url_obj.data # unsaved
url_obj.data = code
url_obj.store
end
code_obj.data = url
code_obj.store
code
end | [
"def",
"add",
"(",
"url",
",",
"code",
"=",
"nil",
",",
"options",
"=",
"nil",
")",
"sha",
"=",
"url_key",
"url",
"url_obj",
"=",
"@url_bucket",
".",
"get_or_new",
"sha",
",",
":r",
"=>",
"1",
"if",
"url_obj",
".",
"raw_data",
"fix_url_object",
"(",
"url_obj",
")",
"code",
"=",
"url_obj",
".",
"data",
"end",
"code",
"=",
"get_code",
"(",
"url",
",",
"code",
",",
"options",
")",
"code_obj",
"=",
"@code_bucket",
".",
"get_or_new",
"code",
"code_obj",
".",
"content_type",
"=",
"url_obj",
".",
"content_type",
"=",
"PLAIN",
"if",
"existing_url",
"=",
"code_obj",
".",
"data",
"# key exists",
"raise",
"DuplicateCodeError",
".",
"new",
"(",
"existing_url",
",",
"url",
",",
"code",
")",
"if",
"url_key",
"(",
"existing_url",
")",
"!=",
"sha",
"end",
"if",
"!",
"url_obj",
".",
"data",
"# unsaved",
"url_obj",
".",
"data",
"=",
"code",
"url_obj",
".",
"store",
"end",
"code_obj",
".",
"data",
"=",
"url",
"code_obj",
".",
"store",
"code",
"end"
] | Initializes the adapter.
code_bucket - The Riak::Bucket for all code keys.
url_bucket - The Riak::Bucket for all url keys. If this is not
given, the code bucket is used for all keys.
Public: Stores the shortened version of a URL.
url - The String URL to shorten and store.
code - Optional String code for the URL.
options - Optional Guillotine::Service::Options
Returns the unique String code for the URL. If the URL is added
multiple times, this should return the same code. | [
"Initializes",
"the",
"adapter",
"."
] | 73afb1c435086b487467914f300bfebe3821c2f3 | https://github.com/technoweenie/guillotine/blob/73afb1c435086b487467914f300bfebe3821c2f3/lib/guillotine/adapters/riak_adapter.rb#L27-L51 | train |
technoweenie/guillotine | lib/guillotine/adapters/riak_adapter.rb | Guillotine.RiakAdapter.url_object | def url_object(code)
@code_bucket.get(code, :r => 1)
rescue Riak::FailedRequest => err
raise unless err.not_found?
end | ruby | def url_object(code)
@code_bucket.get(code, :r => 1)
rescue Riak::FailedRequest => err
raise unless err.not_found?
end | [
"def",
"url_object",
"(",
"code",
")",
"@code_bucket",
".",
"get",
"(",
"code",
",",
":r",
"=>",
"1",
")",
"rescue",
"Riak",
"::",
"FailedRequest",
"=>",
"err",
"raise",
"unless",
"err",
".",
"not_found?",
"end"
] | Retrieves a URL riak value from the code.
code - The String code to lookup the URL.
Returns a Riak::RObject, or nil if none is found. | [
"Retrieves",
"a",
"URL",
"riak",
"value",
"from",
"the",
"code",
"."
] | 73afb1c435086b487467914f300bfebe3821c2f3 | https://github.com/technoweenie/guillotine/blob/73afb1c435086b487467914f300bfebe3821c2f3/lib/guillotine/adapters/riak_adapter.rb#L104-L108 | train |
technoweenie/guillotine | lib/guillotine/adapters/riak_adapter.rb | Guillotine.RiakAdapter.code_object | def code_object(url)
sha = url_key url
if o = @url_bucket.get(sha, :r => 1)
fix_url_object(o)
end
rescue Riak::FailedRequest => err
raise unless err.not_found?
end | ruby | def code_object(url)
sha = url_key url
if o = @url_bucket.get(sha, :r => 1)
fix_url_object(o)
end
rescue Riak::FailedRequest => err
raise unless err.not_found?
end | [
"def",
"code_object",
"(",
"url",
")",
"sha",
"=",
"url_key",
"url",
"if",
"o",
"=",
"@url_bucket",
".",
"get",
"(",
"sha",
",",
":r",
"=>",
"1",
")",
"fix_url_object",
"(",
"o",
")",
"end",
"rescue",
"Riak",
"::",
"FailedRequest",
"=>",
"err",
"raise",
"unless",
"err",
".",
"not_found?",
"end"
] | Retrieves the code riak value for a given URL.
url - The String URL to lookup.
Returns a Riak::RObject, or nil if none is found. | [
"Retrieves",
"the",
"code",
"riak",
"value",
"for",
"a",
"given",
"URL",
"."
] | 73afb1c435086b487467914f300bfebe3821c2f3 | https://github.com/technoweenie/guillotine/blob/73afb1c435086b487467914f300bfebe3821c2f3/lib/guillotine/adapters/riak_adapter.rb#L115-L122 | train |
rayh/xcoder | lib/xcode/configuration_list.rb | Xcode.ConfigurationList.create_config | def create_config(name)
name = ConfigurationList.symbol_config_name_to_config_name[name] if ConfigurationList.symbol_config_name_to_config_name[name]
# @todo a configuration has additional fields that are ususally set with
# some target information for the title.
new_config = @registry.add_object(Configuration.default_properties(name))
@properties['buildConfigurations'] << new_config.identifier
yield new_config if block_given?
new_config.save!
end | ruby | def create_config(name)
name = ConfigurationList.symbol_config_name_to_config_name[name] if ConfigurationList.symbol_config_name_to_config_name[name]
# @todo a configuration has additional fields that are ususally set with
# some target information for the title.
new_config = @registry.add_object(Configuration.default_properties(name))
@properties['buildConfigurations'] << new_config.identifier
yield new_config if block_given?
new_config.save!
end | [
"def",
"create_config",
"(",
"name",
")",
"name",
"=",
"ConfigurationList",
".",
"symbol_config_name_to_config_name",
"[",
"name",
"]",
"if",
"ConfigurationList",
".",
"symbol_config_name_to_config_name",
"[",
"name",
"]",
"# @todo a configuration has additional fields that are ususally set with",
"# some target information for the title.",
"new_config",
"=",
"@registry",
".",
"add_object",
"(",
"Configuration",
".",
"default_properties",
"(",
"name",
")",
")",
"@properties",
"[",
"'buildConfigurations'",
"]",
"<<",
"new_config",
".",
"identifier",
"yield",
"new_config",
"if",
"block_given?",
"new_config",
".",
"save!",
"end"
] | Create a configuration for this ConfigurationList. This configuration needs
to have a name.
@note unique names are currently not enforced but likely necessary for the
the target to be build successfully.
@param [Types] name Description | [
"Create",
"a",
"configuration",
"for",
"this",
"ConfigurationList",
".",
"This",
"configuration",
"needs",
"to",
"have",
"a",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration_list.rb#L39-L52 | train |
rayh/xcoder | lib/xcode/resource.rb | Xcode.Resource.define_property | def define_property name, value
# Save the properties within the resource within a custom hash. This
# provides access to them without the indirection that we are about to
# set up.
@properties[name] = value
# Generate a getter method for this property based on the given name.
self.class.send :define_method, name.underscore do
# Retrieve the value that is current stored for this name.
raw_value = @properties[name]
# If the value is an array then we want to examine each element within
# the array to see if any of them are identifiers that we should replace
# finally returning all of the items as their resource representations
# or as their raw values.
#
# If the value is not an array then we want to examine that item and
# return the resource representation or the raw value.
if raw_value.is_a?(Array)
Array(raw_value).map do |sub_value|
if Registry.is_identifier? sub_value
Resource.new sub_value, @registry
else
sub_value
end
end
else
if Registry.is_identifier? raw_value
Resource.new raw_value, @registry
else
raw_value
end
end
end
# Generate a setter method for this property based on the given name.
self.class.send :define_method, "#{name.underscore}=" do |new_value|
@properties[name] = new_value
end
end | ruby | def define_property name, value
# Save the properties within the resource within a custom hash. This
# provides access to them without the indirection that we are about to
# set up.
@properties[name] = value
# Generate a getter method for this property based on the given name.
self.class.send :define_method, name.underscore do
# Retrieve the value that is current stored for this name.
raw_value = @properties[name]
# If the value is an array then we want to examine each element within
# the array to see if any of them are identifiers that we should replace
# finally returning all of the items as their resource representations
# or as their raw values.
#
# If the value is not an array then we want to examine that item and
# return the resource representation or the raw value.
if raw_value.is_a?(Array)
Array(raw_value).map do |sub_value|
if Registry.is_identifier? sub_value
Resource.new sub_value, @registry
else
sub_value
end
end
else
if Registry.is_identifier? raw_value
Resource.new raw_value, @registry
else
raw_value
end
end
end
# Generate a setter method for this property based on the given name.
self.class.send :define_method, "#{name.underscore}=" do |new_value|
@properties[name] = new_value
end
end | [
"def",
"define_property",
"name",
",",
"value",
"# Save the properties within the resource within a custom hash. This ",
"# provides access to them without the indirection that we are about to",
"# set up.",
"@properties",
"[",
"name",
"]",
"=",
"value",
"# Generate a getter method for this property based on the given name.",
"self",
".",
"class",
".",
"send",
":define_method",
",",
"name",
".",
"underscore",
"do",
"# Retrieve the value that is current stored for this name.",
"raw_value",
"=",
"@properties",
"[",
"name",
"]",
"# If the value is an array then we want to examine each element within",
"# the array to see if any of them are identifiers that we should replace",
"# finally returning all of the items as their resource representations",
"# or as their raw values.",
"# ",
"# If the value is not an array then we want to examine that item and",
"# return the resource representation or the raw value.",
"if",
"raw_value",
".",
"is_a?",
"(",
"Array",
")",
"Array",
"(",
"raw_value",
")",
".",
"map",
"do",
"|",
"sub_value",
"|",
"if",
"Registry",
".",
"is_identifier?",
"sub_value",
"Resource",
".",
"new",
"sub_value",
",",
"@registry",
"else",
"sub_value",
"end",
"end",
"else",
"if",
"Registry",
".",
"is_identifier?",
"raw_value",
"Resource",
".",
"new",
"raw_value",
",",
"@registry",
"else",
"raw_value",
"end",
"end",
"end",
"# Generate a setter method for this property based on the given name.",
"self",
".",
"class",
".",
"send",
":define_method",
",",
"\"#{name.underscore}=\"",
"do",
"|",
"new_value",
"|",
"@properties",
"[",
"name",
"]",
"=",
"new_value",
"end",
"end"
] | Definiing a property allows the creation of an alias to the actual value.
This level of indirection allows for the replacement of values which are
identifiers with a resource representation of it.
@note This is used internally by the resource when it is created to create
the getter/setter methods.
@param [String] name of the property
@param [String] value of the property | [
"Definiing",
"a",
"property",
"allows",
"the",
"creation",
"of",
"an",
"alias",
"to",
"the",
"actual",
"value",
".",
"This",
"level",
"of",
"indirection",
"allows",
"for",
"the",
"replacement",
"of",
"values",
"which",
"are",
"identifiers",
"with",
"a",
"resource",
"representation",
"of",
"it",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/resource.rb#L113-L167 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.file | def file(name_with_path)
path, name = File.split(name_with_path)
group(path).file(name).first
end | ruby | def file(name_with_path)
path, name = File.split(name_with_path)
group(path).file(name).first
end | [
"def",
"file",
"(",
"name_with_path",
")",
"path",
",",
"name",
"=",
"File",
".",
"split",
"(",
"name_with_path",
")",
"group",
"(",
"path",
")",
".",
"file",
"(",
"name",
")",
".",
"first",
"end"
] | Return the file that matches the specified path. This will traverse
the project's groups and find the file at the end of the path.
@param [String] name_with_path the path to the file
@return [FileReference] the file that matches the name, nil if no file
matches the path. | [
"Return",
"the",
"file",
"that",
"matches",
"the",
"specified",
"path",
".",
"This",
"will",
"traverse",
"the",
"project",
"s",
"groups",
"and",
"find",
"the",
"file",
"at",
"the",
"end",
"of",
"the",
"path",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L156-L159 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.products_group | def products_group
current_group = groups.group('Products').first
current_group.instance_eval(&block) if block_given? and current_group
current_group
end | ruby | def products_group
current_group = groups.group('Products').first
current_group.instance_eval(&block) if block_given? and current_group
current_group
end | [
"def",
"products_group",
"current_group",
"=",
"groups",
".",
"group",
"(",
"'Products'",
")",
".",
"first",
"current_group",
".",
"instance_eval",
"(",
"block",
")",
"if",
"block_given?",
"and",
"current_group",
"current_group",
"end"
] | Most Xcode projects have a products group where products are placed. This
will generate an exception if there is no products group.
@return [Group] the 'Products' group of the project. | [
"Most",
"Xcode",
"projects",
"have",
"a",
"products",
"group",
"where",
"products",
"are",
"placed",
".",
"This",
"will",
"generate",
"an",
"exception",
"if",
"there",
"is",
"no",
"products",
"group",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L166-L170 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.frameworks_group | def frameworks_group
current_group = groups.group('Frameworks').first
current_group.instance_eval(&block) if block_given? and current_group
current_group
end | ruby | def frameworks_group
current_group = groups.group('Frameworks').first
current_group.instance_eval(&block) if block_given? and current_group
current_group
end | [
"def",
"frameworks_group",
"current_group",
"=",
"groups",
".",
"group",
"(",
"'Frameworks'",
")",
".",
"first",
"current_group",
".",
"instance_eval",
"(",
"block",
")",
"if",
"block_given?",
"and",
"current_group",
"current_group",
"end"
] | Most Xcode projects have a Frameworks gorup where all the imported
frameworks are shown. This will generate an exception if there is no
Frameworks group.
@return [Group] the 'Frameworks' group of the projet. | [
"Most",
"Xcode",
"projects",
"have",
"a",
"Frameworks",
"gorup",
"where",
"all",
"the",
"imported",
"frameworks",
"are",
"shown",
".",
"This",
"will",
"generate",
"an",
"exception",
"if",
"there",
"is",
"no",
"Frameworks",
"group",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L178-L182 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.save | def save(path)
Dir.mkdir(path) unless File.exists?(path)
project_filepath = "#{path}/project.pbxproj"
# @toodo Save the workspace when the project is saved
# FileUtils.cp_r "#{path}/project.xcworkspace", "#{path}/project.xcworkspace"
Xcode::PLUTILProjectParser.save "#{path}/project.pbxproj", to_xcplist
end | ruby | def save(path)
Dir.mkdir(path) unless File.exists?(path)
project_filepath = "#{path}/project.pbxproj"
# @toodo Save the workspace when the project is saved
# FileUtils.cp_r "#{path}/project.xcworkspace", "#{path}/project.xcworkspace"
Xcode::PLUTILProjectParser.save "#{path}/project.pbxproj", to_xcplist
end | [
"def",
"save",
"(",
"path",
")",
"Dir",
".",
"mkdir",
"(",
"path",
")",
"unless",
"File",
".",
"exists?",
"(",
"path",
")",
"project_filepath",
"=",
"\"#{path}/project.pbxproj\"",
"# @toodo Save the workspace when the project is saved",
"# FileUtils.cp_r \"#{path}/project.xcworkspace\", \"#{path}/project.xcworkspace\"",
"Xcode",
"::",
"PLUTILProjectParser",
".",
"save",
"\"#{path}/project.pbxproj\"",
",",
"to_xcplist",
"end"
] | Saves the current project at the specified path.
@note currently this does not support saving the workspaces associated
with the project to their new location.
@param [String] path the path to save the project | [
"Saves",
"the",
"current",
"project",
"at",
"the",
"specified",
"path",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L217-L227 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.scheme | def scheme(name)
scheme = schemes.select {|t| t.name == name.to_s}.first
raise "No such scheme #{name}, available schemes are #{schemes.map {|t| t.name}.join(', ')}" if scheme.nil?
yield scheme if block_given?
scheme
end | ruby | def scheme(name)
scheme = schemes.select {|t| t.name == name.to_s}.first
raise "No such scheme #{name}, available schemes are #{schemes.map {|t| t.name}.join(', ')}" if scheme.nil?
yield scheme if block_given?
scheme
end | [
"def",
"scheme",
"(",
"name",
")",
"scheme",
"=",
"schemes",
".",
"select",
"{",
"|",
"t",
"|",
"t",
".",
"name",
"==",
"name",
".",
"to_s",
"}",
".",
"first",
"raise",
"\"No such scheme #{name}, available schemes are #{schemes.map {|t| t.name}.join(', ')}\"",
"if",
"scheme",
".",
"nil?",
"yield",
"scheme",
"if",
"block_given?",
"scheme",
"end"
] | Return the scheme with the specified name. Raises an error if no schemes
match the specified name.
@note if two schemes match names, the first matching scheme is returned.
@param [String] name of the specific scheme
@return [Scheme] the specific scheme that matches the name specified | [
"Return",
"the",
"scheme",
"with",
"the",
"specified",
"name",
".",
"Raises",
"an",
"error",
"if",
"no",
"schemes",
"match",
"the",
"specified",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L238-L243 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.target | def target(name)
target = targets.select {|t| t.name == name.to_s}.first
raise "No such target #{name}, available targets are #{targets.map {|t| t.name}.join(', ')}" if target.nil?
yield target if block_given?
target
end | ruby | def target(name)
target = targets.select {|t| t.name == name.to_s}.first
raise "No such target #{name}, available targets are #{targets.map {|t| t.name}.join(', ')}" if target.nil?
yield target if block_given?
target
end | [
"def",
"target",
"(",
"name",
")",
"target",
"=",
"targets",
".",
"select",
"{",
"|",
"t",
"|",
"t",
".",
"name",
"==",
"name",
".",
"to_s",
"}",
".",
"first",
"raise",
"\"No such target #{name}, available targets are #{targets.map {|t| t.name}.join(', ')}\"",
"if",
"target",
".",
"nil?",
"yield",
"target",
"if",
"block_given?",
"target",
"end"
] | Return the target with the specified name. Raises an error if no targets
match the specified name.
@note if two targets match names, the first matching target is returned.
@param [String] name of the specific target
@return [Target] the specific target that matches the name specified | [
"Return",
"the",
"target",
"with",
"the",
"specified",
"name",
".",
"Raises",
"an",
"error",
"if",
"no",
"targets",
"match",
"the",
"specified",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L267-L272 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.create_target | def create_target(name,type=:native)
target = @registry.add_object Target.send(type)
@project.properties['targets'] << target.identifier
target.name = name
build_configuration_list = @registry.add_object(ConfigurationList.configuration_list)
target.build_configuration_list = build_configuration_list.identifier
target.project = self
yield target if block_given?
target.save!
end | ruby | def create_target(name,type=:native)
target = @registry.add_object Target.send(type)
@project.properties['targets'] << target.identifier
target.name = name
build_configuration_list = @registry.add_object(ConfigurationList.configuration_list)
target.build_configuration_list = build_configuration_list.identifier
target.project = self
yield target if block_given?
target.save!
end | [
"def",
"create_target",
"(",
"name",
",",
"type",
"=",
":native",
")",
"target",
"=",
"@registry",
".",
"add_object",
"Target",
".",
"send",
"(",
"type",
")",
"@project",
".",
"properties",
"[",
"'targets'",
"]",
"<<",
"target",
".",
"identifier",
"target",
".",
"name",
"=",
"name",
"build_configuration_list",
"=",
"@registry",
".",
"add_object",
"(",
"ConfigurationList",
".",
"configuration_list",
")",
"target",
".",
"build_configuration_list",
"=",
"build_configuration_list",
".",
"identifier",
"target",
".",
"project",
"=",
"self",
"yield",
"target",
"if",
"block_given?",
"target",
".",
"save!",
"end"
] | Creates a new target within the Xcode project. This will by default not
generate all the additional build phases, configurations, and files
that create a project.
Available targts:
* native
* aggregate
@param [String] name the name to provide to the target. This will also
be the value that other defaults will be based on.
@param [String,Symbol] type the type of build target to create.
@return [Target] the target created. | [
"Creates",
"a",
"new",
"target",
"within",
"the",
"Xcode",
"project",
".",
"This",
"will",
"by",
"default",
"not",
"generate",
"all",
"the",
"additional",
"build",
"phases",
"configurations",
"and",
"files",
"that",
"create",
"a",
"project",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L290-L305 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.remove_target | def remove_target(name)
found_target = targets.find {|target| target.name == name }
if found_target
@project.properties['targets'].delete found_target.identifier
@registry.remove_object found_target.identifier
end
found_target
end | ruby | def remove_target(name)
found_target = targets.find {|target| target.name == name }
if found_target
@project.properties['targets'].delete found_target.identifier
@registry.remove_object found_target.identifier
end
found_target
end | [
"def",
"remove_target",
"(",
"name",
")",
"found_target",
"=",
"targets",
".",
"find",
"{",
"|",
"target",
"|",
"target",
".",
"name",
"==",
"name",
"}",
"if",
"found_target",
"@project",
".",
"properties",
"[",
"'targets'",
"]",
".",
"delete",
"found_target",
".",
"identifier",
"@registry",
".",
"remove_object",
"found_target",
".",
"identifier",
"end",
"found_target",
"end"
] | Remove a target from the Xcode project.
@note this will remove the first target that matches the specified name.
@note this will remove only the project entry at the moment and not the
the files that may be associated with the target. All build phases,
build files, and configurations will automatically be cleaned up when
Xcode is opened.
@param [String] name the name of the target to remove from the Xcode
project.
@return [Target] the target that has been removed. | [
"Remove",
"a",
"target",
"from",
"the",
"Xcode",
"project",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L322-L329 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.describe | def describe
puts "Project #{name} contains"
targets.each do |t|
puts " + target:#{t.name}"
t.configs.each do |c|
puts " + config:#{c.name}"
end
end
schemes.each do |s|
puts " + scheme #{s.name}"
puts " + targets: #{s.build_targets.map{|t| t.name}}"
puts " + config: #{s.build_config}"
end
end | ruby | def describe
puts "Project #{name} contains"
targets.each do |t|
puts " + target:#{t.name}"
t.configs.each do |c|
puts " + config:#{c.name}"
end
end
schemes.each do |s|
puts " + scheme #{s.name}"
puts " + targets: #{s.build_targets.map{|t| t.name}}"
puts " + config: #{s.build_config}"
end
end | [
"def",
"describe",
"puts",
"\"Project #{name} contains\"",
"targets",
".",
"each",
"do",
"|",
"t",
"|",
"puts",
"\" + target:#{t.name}\"",
"t",
".",
"configs",
".",
"each",
"do",
"|",
"c",
"|",
"puts",
"\" + config:#{c.name}\"",
"end",
"end",
"schemes",
".",
"each",
"do",
"|",
"s",
"|",
"puts",
"\" + scheme #{s.name}\"",
"puts",
"\" + targets: #{s.build_targets.map{|t| t.name}}\"",
"puts",
"\" + config: #{s.build_config}\"",
"end",
"end"
] | Prints to STDOUT a description of this project's targets, configuration and schemes. | [
"Prints",
"to",
"STDOUT",
"a",
"description",
"of",
"this",
"project",
"s",
"targets",
"configuration",
"and",
"schemes",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L334-L347 | train |
rayh/xcoder | lib/xcode/project.rb | Xcode.Project.parse_pbxproj | def parse_pbxproj
registry = Xcode::PLUTILProjectParser.parse "#{@path}/project.pbxproj"
class << registry
include Xcode::Registry
end
registry
end | ruby | def parse_pbxproj
registry = Xcode::PLUTILProjectParser.parse "#{@path}/project.pbxproj"
class << registry
include Xcode::Registry
end
registry
end | [
"def",
"parse_pbxproj",
"registry",
"=",
"Xcode",
"::",
"PLUTILProjectParser",
".",
"parse",
"\"#{@path}/project.pbxproj\"",
"class",
"<<",
"registry",
"include",
"Xcode",
"::",
"Registry",
"end",
"registry",
"end"
] | Using the sytem tool plutil, the specified project file is parsed and
converted to JSON, which is then converted to a hash object. This content
contains all the data within the project file and is used to create the
Registry.
@return [Registry] the representation of the project, this is a Hash with
additional methods to provide easier functionality. | [
"Using",
"the",
"sytem",
"tool",
"plutil",
"the",
"specified",
"project",
"file",
"is",
"parsed",
"and",
"converted",
"to",
"JSON",
"which",
"is",
"then",
"converted",
"to",
"a",
"hash",
"object",
".",
"This",
"content",
"contains",
"all",
"the",
"data",
"within",
"the",
"project",
"file",
"and",
"is",
"used",
"to",
"create",
"the",
"Registry",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project.rb#L360-L368 | train |
rayh/xcoder | lib/xcode/parsers/plutil_project_parser.rb | Xcode.PLUTILProjectParser.parse | def parse(path)
registry = Plist.parse_xml open_project_file(path)
raise "Failed to correctly parse the project file #{path}" unless registry
registry
end | ruby | def parse(path)
registry = Plist.parse_xml open_project_file(path)
raise "Failed to correctly parse the project file #{path}" unless registry
registry
end | [
"def",
"parse",
"(",
"path",
")",
"registry",
"=",
"Plist",
".",
"parse_xml",
"open_project_file",
"(",
"path",
")",
"raise",
"\"Failed to correctly parse the project file #{path}\"",
"unless",
"registry",
"registry",
"end"
] | Using the sytem tool plutil, the specified project file is parsed and
converted to XML, and then converted into a ruby hash object. | [
"Using",
"the",
"sytem",
"tool",
"plutil",
"the",
"specified",
"project",
"file",
"is",
"parsed",
"and",
"converted",
"to",
"XML",
"and",
"then",
"converted",
"into",
"a",
"ruby",
"hash",
"object",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/parsers/plutil_project_parser.rb#L13-L19 | train |
rayh/xcoder | lib/xcode/terminal_output.rb | Xcode.TerminalOutput.print_input | def print_input message, level=:debug
return if LEVELS.index(level) > LEVELS.index(@@log_level)
puts format_lhs("", "", "<") + message, :default
end | ruby | def print_input message, level=:debug
return if LEVELS.index(level) > LEVELS.index(@@log_level)
puts format_lhs("", "", "<") + message, :default
end | [
"def",
"print_input",
"message",
",",
"level",
"=",
":debug",
"return",
"if",
"LEVELS",
".",
"index",
"(",
"level",
")",
">",
"LEVELS",
".",
"index",
"(",
"@@log_level",
")",
"puts",
"format_lhs",
"(",
"\"\"",
",",
"\"\"",
",",
"\"<\"",
")",
"+",
"message",
",",
":default",
"end"
] | Print an IO input interaction | [
"Print",
"an",
"IO",
"input",
"interaction"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/terminal_output.rb#L40-L43 | train |
rayh/xcoder | lib/xcode/terminal_output.rb | Xcode.TerminalOutput.print_output | def print_output message, level=:debug
return if LEVELS.index(level) > LEVELS.index(@@log_level)
puts format_lhs("", "", ">") + message, :default
end | ruby | def print_output message, level=:debug
return if LEVELS.index(level) > LEVELS.index(@@log_level)
puts format_lhs("", "", ">") + message, :default
end | [
"def",
"print_output",
"message",
",",
"level",
"=",
":debug",
"return",
"if",
"LEVELS",
".",
"index",
"(",
"level",
")",
">",
"LEVELS",
".",
"index",
"(",
"@@log_level",
")",
"puts",
"format_lhs",
"(",
"\"\"",
",",
"\"\"",
",",
"\">\"",
")",
"+",
"message",
",",
":default",
"end"
] | Print an IO output interaction | [
"Print",
"an",
"IO",
"output",
"interaction"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/terminal_output.rb#L47-L50 | train |
rayh/xcoder | lib/xcode/target.rb | Xcode.Target.create_build_phases | def create_build_phases *base_phase_names
base_phase_names.compact.flatten.map do |phase_name|
build_phase = create_build_phase phase_name do |build_phase|
yield build_phase if block_given?
end
build_phase.save!
end
end | ruby | def create_build_phases *base_phase_names
base_phase_names.compact.flatten.map do |phase_name|
build_phase = create_build_phase phase_name do |build_phase|
yield build_phase if block_given?
end
build_phase.save!
end
end | [
"def",
"create_build_phases",
"*",
"base_phase_names",
"base_phase_names",
".",
"compact",
".",
"flatten",
".",
"map",
"do",
"|",
"phase_name",
"|",
"build_phase",
"=",
"create_build_phase",
"phase_name",
"do",
"|",
"build_phase",
"|",
"yield",
"build_phase",
"if",
"block_given?",
"end",
"build_phase",
".",
"save!",
"end",
"end"
] | Create multiple build phases at the same time.
@param [Array<String,Symbol>] base_phase_names are the names of the phases
that you want to create for a target.
@return [Array] the phases created. | [
"Create",
"multiple",
"build",
"phases",
"at",
"the",
"same",
"time",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/target.rb#L184-L194 | train |
rayh/xcoder | lib/xcode/target.rb | Xcode.Target.create_product_reference | def create_product_reference(name)
product = project.products_group.create_product_reference(name)
product_reference = product.identifier
product
end | ruby | def create_product_reference(name)
product = project.products_group.create_product_reference(name)
product_reference = product.identifier
product
end | [
"def",
"create_product_reference",
"(",
"name",
")",
"product",
"=",
"project",
".",
"products_group",
".",
"create_product_reference",
"(",
"name",
")",
"product_reference",
"=",
"product",
".",
"identifier",
"product",
"end"
] | Create a product reference file and add it to the product. This is by
default added to the 'Products' group.
@param [String] name of the product reference to add to the product
@return [Resource] the product created | [
"Create",
"a",
"product",
"reference",
"file",
"and",
"add",
"it",
"to",
"the",
"product",
".",
"This",
"is",
"by",
"default",
"added",
"to",
"the",
"Products",
"group",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/target.rb#L217-L221 | train |
rayh/xcoder | lib/xcode/keychain.rb | Xcode.Keychain.in_search_path | def in_search_path(&block)
keychains = Keychains.search_path
begin
Keychains.search_path = [self] + keychains
yield
ensure
Keychains.search_path = keychains
# print_task 'keychain', "Restored search path"
end
end | ruby | def in_search_path(&block)
keychains = Keychains.search_path
begin
Keychains.search_path = [self] + keychains
yield
ensure
Keychains.search_path = keychains
# print_task 'keychain', "Restored search path"
end
end | [
"def",
"in_search_path",
"(",
"&",
"block",
")",
"keychains",
"=",
"Keychains",
".",
"search_path",
"begin",
"Keychains",
".",
"search_path",
"=",
"[",
"self",
"]",
"+",
"keychains",
"yield",
"ensure",
"Keychains",
".",
"search_path",
"=",
"keychains",
"# print_task 'keychain', \"Restored search path\"",
"end",
"end"
] | Installs this keychain in the head of teh search path and restores the original on
completion of the block
@param the block to be invoked with the modified search path | [
"Installs",
"this",
"keychain",
"in",
"the",
"head",
"of",
"teh",
"search",
"path",
"and",
"restores",
"the",
"original",
"on",
"completion",
"of",
"the",
"block"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/keychain.rb#L71-L80 | train |
rayh/xcoder | lib/xcode/keychain.rb | Xcode.Keychain.import | def import(cert, password)
cmd = Xcode::Shell::Command.new "security"
cmd << "import '#{cert}'"
cmd << "-k \"#{@path}\""
cmd << "-P #{password}"
cmd << "-T /usr/bin/codesign"
cmd.execute
end | ruby | def import(cert, password)
cmd = Xcode::Shell::Command.new "security"
cmd << "import '#{cert}'"
cmd << "-k \"#{@path}\""
cmd << "-P #{password}"
cmd << "-T /usr/bin/codesign"
cmd.execute
end | [
"def",
"import",
"(",
"cert",
",",
"password",
")",
"cmd",
"=",
"Xcode",
"::",
"Shell",
"::",
"Command",
".",
"new",
"\"security\"",
"cmd",
"<<",
"\"import '#{cert}'\"",
"cmd",
"<<",
"\"-k \\\"#{@path}\\\"\"",
"cmd",
"<<",
"\"-P #{password}\"",
"cmd",
"<<",
"\"-T /usr/bin/codesign\"",
"cmd",
".",
"execute",
"end"
] | Import the .p12 certificate file into the keychain using the provided password
@param [String] the path to the .p12 certificate file
@param [String] the password to open the certificate file | [
"Import",
"the",
".",
"p12",
"certificate",
"file",
"into",
"the",
"keychain",
"using",
"the",
"provided",
"password"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/keychain.rb#L88-L95 | train |
rayh/xcoder | lib/xcode/keychain.rb | Xcode.Keychain.identities | def identities
names = []
cmd = Xcode::Shell::Command.new "security"
cmd << "find-certificate"
cmd << "-a"
cmd << "\"#{@path}\""
cmd.show_output = false
cmd.execute.join("").scan /\s+"labl"<blob>="([^"]+)"/ do |m|
names << m[0]
end
names
end | ruby | def identities
names = []
cmd = Xcode::Shell::Command.new "security"
cmd << "find-certificate"
cmd << "-a"
cmd << "\"#{@path}\""
cmd.show_output = false
cmd.execute.join("").scan /\s+"labl"<blob>="([^"]+)"/ do |m|
names << m[0]
end
names
end | [
"def",
"identities",
"names",
"=",
"[",
"]",
"cmd",
"=",
"Xcode",
"::",
"Shell",
"::",
"Command",
".",
"new",
"\"security\"",
"cmd",
"<<",
"\"find-certificate\"",
"cmd",
"<<",
"\"-a\"",
"cmd",
"<<",
"\"\\\"#{@path}\\\"\"",
"cmd",
".",
"show_output",
"=",
"false",
"cmd",
".",
"execute",
".",
"join",
"(",
"\"\"",
")",
".",
"scan",
"/",
"\\s",
"/",
"do",
"|",
"m",
"|",
"names",
"<<",
"m",
"[",
"0",
"]",
"end",
"names",
"end"
] | Returns a list of identities in the keychain.
@return [Array<String>] a list of identity names | [
"Returns",
"a",
"list",
"of",
"identities",
"in",
"the",
"keychain",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/keychain.rb#L102-L113 | train |
rayh/xcoder | lib/xcode/keychain.rb | Xcode.Keychain.lock | def lock
cmd = Xcode::Shell::Command.new "security"
cmd << "lock-keychain"
cmd << "\"#{@path}\""
cmd.execute
end | ruby | def lock
cmd = Xcode::Shell::Command.new "security"
cmd << "lock-keychain"
cmd << "\"#{@path}\""
cmd.execute
end | [
"def",
"lock",
"cmd",
"=",
"Xcode",
"::",
"Shell",
"::",
"Command",
".",
"new",
"\"security\"",
"cmd",
"<<",
"\"lock-keychain\"",
"cmd",
"<<",
"\"\\\"#{@path}\\\"\"",
"cmd",
".",
"execute",
"end"
] | Secure the keychain | [
"Secure",
"the",
"keychain"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/keychain.rb#L118-L123 | train |
rayh/xcoder | lib/xcode/keychain.rb | Xcode.Keychain.unlock | def unlock(password)
cmd = Xcode::Shell::Command.new "security"
cmd << "unlock-keychain"
cmd << "-p #{password}"
cmd << "\"#{@path}\""
cmd.execute
end | ruby | def unlock(password)
cmd = Xcode::Shell::Command.new "security"
cmd << "unlock-keychain"
cmd << "-p #{password}"
cmd << "\"#{@path}\""
cmd.execute
end | [
"def",
"unlock",
"(",
"password",
")",
"cmd",
"=",
"Xcode",
"::",
"Shell",
"::",
"Command",
".",
"new",
"\"security\"",
"cmd",
"<<",
"\"unlock-keychain\"",
"cmd",
"<<",
"\"-p #{password}\"",
"cmd",
"<<",
"\"\\\"#{@path}\\\"\"",
"cmd",
".",
"execute",
"end"
] | Unlock the keychain using the provided password
@param [String] the password to open the keychain | [
"Unlock",
"the",
"keychain",
"using",
"the",
"provided",
"password"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/keychain.rb#L130-L136 | train |
rayh/xcoder | lib/xcode/configuration_owner.rb | Xcode.ConfigurationOwner.config | def config(name)
config = configs.select {|config| config.name == name.to_s }.first
raise "No such config #{name}, available configs are #{configs.map {|c| c.name}.join(', ')}" if config.nil?
yield config if block_given?
config
end | ruby | def config(name)
config = configs.select {|config| config.name == name.to_s }.first
raise "No such config #{name}, available configs are #{configs.map {|c| c.name}.join(', ')}" if config.nil?
yield config if block_given?
config
end | [
"def",
"config",
"(",
"name",
")",
"config",
"=",
"configs",
".",
"select",
"{",
"|",
"config",
"|",
"config",
".",
"name",
"==",
"name",
".",
"to_s",
"}",
".",
"first",
"raise",
"\"No such config #{name}, available configs are #{configs.map {|c| c.name}.join(', ')}\"",
"if",
"config",
".",
"nil?",
"yield",
"config",
"if",
"block_given?",
"config",
"end"
] | Return a specific build configuration.
@note an exception is raised if no configuration matches the specified name.
@param [String] name of a configuration to return
@return [BuildConfiguration] a specific build configuration that
matches the specified name. | [
"Return",
"a",
"specific",
"build",
"configuration",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration_owner.rb#L26-L31 | train |
rayh/xcoder | lib/xcode/configuration_owner.rb | Xcode.ConfigurationOwner.create_configuration | def create_configuration(name)
# To create a configuration, we need to create or retrieve the configuration list
created_config = build_configuration_list.create_config(name) do |config|
yield config if block_given?
end
created_config
end | ruby | def create_configuration(name)
# To create a configuration, we need to create or retrieve the configuration list
created_config = build_configuration_list.create_config(name) do |config|
yield config if block_given?
end
created_config
end | [
"def",
"create_configuration",
"(",
"name",
")",
"# To create a configuration, we need to create or retrieve the configuration list",
"created_config",
"=",
"build_configuration_list",
".",
"create_config",
"(",
"name",
")",
"do",
"|",
"config",
"|",
"yield",
"config",
"if",
"block_given?",
"end",
"created_config",
"end"
] | Create a configuration for the target or project.
@example creating a new 'App Store Submission' configuration for a project
project.create_config 'App Store Submission' # => Configuration
@example creating a new 'Ad Hoc' configuration for a target
target.create_config 'Ad Hoc' do |config|
# configuration the new debug config.
end
@param [String] name of the configuration to create
@return [BuildConfiguration] that is created | [
"Create",
"a",
"configuration",
"for",
"the",
"target",
"or",
"project",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration_owner.rb#L49-L57 | train |
rayh/xcoder | lib/xcode/configuration_owner.rb | Xcode.ConfigurationOwner.create_configurations | def create_configurations(*configuration_names)
configuration_names.compact.flatten.map do |config_name|
created_config = create_configuration config_name do |config|
yield config if block_given?
end
created_config.save!
end
end | ruby | def create_configurations(*configuration_names)
configuration_names.compact.flatten.map do |config_name|
created_config = create_configuration config_name do |config|
yield config if block_given?
end
created_config.save!
end
end | [
"def",
"create_configurations",
"(",
"*",
"configuration_names",
")",
"configuration_names",
".",
"compact",
".",
"flatten",
".",
"map",
"do",
"|",
"config_name",
"|",
"created_config",
"=",
"create_configuration",
"config_name",
"do",
"|",
"config",
"|",
"yield",
"config",
"if",
"block_given?",
"end",
"created_config",
".",
"save!",
"end",
"end"
] | Create multiple configurations for a target or project.
@example creating 'Release' and 'Debug for a new target
new_target = project.create_target 'UniversalBinary'
new_target.create_configurations 'Debug', 'Release' do |config|
# set up the configurations
end
@param [String,Array<String>] configuration_names the names of the
configurations to create. | [
"Create",
"multiple",
"configurations",
"for",
"a",
"target",
"or",
"project",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration_owner.rb#L72-L82 | train |
rayh/xcoder | lib/xcode/build_phase.rb | Xcode.BuildPhase.file | def file(name)
files.find {|file| file.file_ref.name == name or file.file_ref.path == name }
end | ruby | def file(name)
files.find {|file| file.file_ref.name == name or file.file_ref.path == name }
end | [
"def",
"file",
"(",
"name",
")",
"files",
".",
"find",
"{",
"|",
"file",
"|",
"file",
".",
"file_ref",
".",
"name",
"==",
"name",
"or",
"file",
".",
"file_ref",
".",
"path",
"==",
"name",
"}",
"end"
] | Return the BuildFile given the file name.
@param [String] name of the FileReference that is being built.
@return [BuildFile] the BuildFile that links to the file specified with
the name. | [
"Return",
"the",
"BuildFile",
"given",
"the",
"file",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/build_phase.rb#L79-L81 | train |
rayh/xcoder | lib/xcode/build_phase.rb | Xcode.BuildPhase.build_file | def build_file(name)
build_files.find {|file| file.name == name or file.path == name }
end | ruby | def build_file(name)
build_files.find {|file| file.name == name or file.path == name }
end | [
"def",
"build_file",
"(",
"name",
")",
"build_files",
".",
"find",
"{",
"|",
"file",
"|",
"file",
".",
"name",
"==",
"name",
"or",
"file",
".",
"path",
"==",
"name",
"}",
"end"
] | Find the first file that has the name or path that matches the specified
parameter.
@note this is the FileReference, the file being built and not the instance
of the BuildFile.
@see #file
@param [String] name the name or the path of the file.
@return [FileReference] the file referenced that matches the name or path;
nil if no file is found. | [
"Find",
"the",
"first",
"file",
"that",
"has",
"the",
"name",
"or",
"path",
"that",
"matches",
"the",
"specified",
"parameter",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/build_phase.rb#L108-L110 | train |
rayh/xcoder | lib/xcode/build_phase.rb | Xcode.BuildPhase.add_build_file | def add_build_file(file,settings = {})
find_file_by = file.path || file.name
unless build_file(find_file_by)
new_build_file = @registry.add_object BuildFile.buildfile(file.identifier,settings)
@properties['files'] << new_build_file.identifier
end
end | ruby | def add_build_file(file,settings = {})
find_file_by = file.path || file.name
unless build_file(find_file_by)
new_build_file = @registry.add_object BuildFile.buildfile(file.identifier,settings)
@properties['files'] << new_build_file.identifier
end
end | [
"def",
"add_build_file",
"(",
"file",
",",
"settings",
"=",
"{",
"}",
")",
"find_file_by",
"=",
"file",
".",
"path",
"||",
"file",
".",
"name",
"unless",
"build_file",
"(",
"find_file_by",
")",
"new_build_file",
"=",
"@registry",
".",
"add_object",
"BuildFile",
".",
"buildfile",
"(",
"file",
".",
"identifier",
",",
"settings",
")",
"@properties",
"[",
"'files'",
"]",
"<<",
"new_build_file",
".",
"identifier",
"end",
"end"
] | Add the specified file to the Build Phase.
First a BuildFile entry is created for the file and then the build file
entry is added to the particular build phase. A BuildFile identifier must
exist for each target.
@example adding a source file to the sources build phase
spec_file = project.group('Specs/Controller').create_file('FirstControllerSpec.m')
project.target('Specs').sources_build_phase.add_build_file spec_file
@example adding a source file, that does not use ARC, to the sources build phase
spec_file = project.group('Specs/Controller').create_file('FirstControllerSpec.m')
project.target('Specs').sources_build_phase.add_build_file spec_file, { 'COMPILER_FLAGS' => "-fno-objc-arc" }
@param [FileReference] file the FileReference Resource to add to the build
phase.
@param [Hash] settings additional build settings that are specifically applied
to this individual file. | [
"Add",
"the",
"specified",
"file",
"to",
"the",
"Build",
"Phase",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/build_phase.rb#L134-L140 | train |
rayh/xcoder | lib/xcode/registry.rb | Xcode.Registry.add_object | def add_object(object_properties)
new_identifier = SimpleIdentifierGenerator.generate :existing_keys => objects.keys
objects[new_identifier] = object_properties
Resource.new new_identifier, self
end | ruby | def add_object(object_properties)
new_identifier = SimpleIdentifierGenerator.generate :existing_keys => objects.keys
objects[new_identifier] = object_properties
Resource.new new_identifier, self
end | [
"def",
"add_object",
"(",
"object_properties",
")",
"new_identifier",
"=",
"SimpleIdentifierGenerator",
".",
"generate",
":existing_keys",
"=>",
"objects",
".",
"keys",
"objects",
"[",
"new_identifier",
"]",
"=",
"object_properties",
"Resource",
".",
"new",
"new_identifier",
",",
"self",
"end"
] | Provides a method to generically add objects to the registry. This will
create a unqiue identifier and add the specified parameters to the
registry. As all objecst within a the project maintain a reference to this
registry they can immediately query for newly created items.
@note generally this method should not be called directly and instead
resources should provide the ability to assist with generating the
correct objects for the registry.
@param [Hash] object_properties a hash that contains all the properties
that are known for the particular item. | [
"Provides",
"a",
"method",
"to",
"generically",
"add",
"objects",
"to",
"the",
"registry",
".",
"This",
"will",
"create",
"a",
"unqiue",
"identifier",
"and",
"add",
"the",
"specified",
"parameters",
"to",
"the",
"registry",
".",
"As",
"all",
"objecst",
"within",
"a",
"the",
"project",
"maintain",
"a",
"reference",
"to",
"this",
"registry",
"they",
"can",
"immediately",
"query",
"for",
"newly",
"created",
"items",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/registry.rb#L167-L173 | train |
rayh/xcoder | lib/xcode/workspace.rb | Xcode.Workspace.project | def project(name)
project = @projects.select {|c| c.name == name.to_s}.first
raise "No such project #{name} in #{self}, available projects are #{@projects.map {|c| c.name}.join(', ')}" if project.nil?
yield project if block_given?
project
end | ruby | def project(name)
project = @projects.select {|c| c.name == name.to_s}.first
raise "No such project #{name} in #{self}, available projects are #{@projects.map {|c| c.name}.join(', ')}" if project.nil?
yield project if block_given?
project
end | [
"def",
"project",
"(",
"name",
")",
"project",
"=",
"@projects",
".",
"select",
"{",
"|",
"c",
"|",
"c",
".",
"name",
"==",
"name",
".",
"to_s",
"}",
".",
"first",
"raise",
"\"No such project #{name} in #{self}, available projects are #{@projects.map {|c| c.name}.join(', ')}\"",
"if",
"project",
".",
"nil?",
"yield",
"project",
"if",
"block_given?",
"project",
"end"
] | Return the names project. Raises an error if no projects
match the specified name.
@note if two projects match names, the first matching scheme is returned.
@param [String] name of the specific scheme
@return [Project] the specific project that matches the name specified | [
"Return",
"the",
"names",
"project",
".",
"Raises",
"an",
"error",
"if",
"no",
"projects",
"match",
"the",
"specified",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/workspace.rb#L63-L68 | train |
rayh/xcoder | lib/xcode/target_dependency.rb | Xcode.TargetDependency.create_dependency_on | def create_dependency_on(target)
@properties['target'] = target.identifier
container_item_proxy = ContainerItemProxy.default target.project.project.identifier, target.identifier, target.name
container_item_proxy = @registry.add_object(container_item_proxy)
@properties['targetProxy'] = container_item_proxy.identifier
save!
end | ruby | def create_dependency_on(target)
@properties['target'] = target.identifier
container_item_proxy = ContainerItemProxy.default target.project.project.identifier, target.identifier, target.name
container_item_proxy = @registry.add_object(container_item_proxy)
@properties['targetProxy'] = container_item_proxy.identifier
save!
end | [
"def",
"create_dependency_on",
"(",
"target",
")",
"@properties",
"[",
"'target'",
"]",
"=",
"target",
".",
"identifier",
"container_item_proxy",
"=",
"ContainerItemProxy",
".",
"default",
"target",
".",
"project",
".",
"project",
".",
"identifier",
",",
"target",
".",
"identifier",
",",
"target",
".",
"name",
"container_item_proxy",
"=",
"@registry",
".",
"add_object",
"(",
"container_item_proxy",
")",
"@properties",
"[",
"'targetProxy'",
"]",
"=",
"container_item_proxy",
".",
"identifier",
"save!",
"end"
] | Establish the Target that this Target Dependency is dependent.
@param [Target] target the target this dependency is based on | [
"Establish",
"the",
"Target",
"that",
"this",
"Target",
"Dependency",
"is",
"dependent",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/target_dependency.rb#L43-L53 | train |
rayh/xcoder | lib/xcode/configuration.rb | Xcode.Configuration.info_plist | def info_plist
info = Xcode::InfoPlist.new(self, info_plist_location)
yield info if block_given?
info.save
info
end | ruby | def info_plist
info = Xcode::InfoPlist.new(self, info_plist_location)
yield info if block_given?
info.save
info
end | [
"def",
"info_plist",
"info",
"=",
"Xcode",
"::",
"InfoPlist",
".",
"new",
"(",
"self",
",",
"info_plist_location",
")",
"yield",
"info",
"if",
"block_given?",
"info",
".",
"save",
"info",
"end"
] | Opens the info plist associated with the configuration and allows you to
edit the configuration.
@example Editing the configuration
config = Xcode.project('MyProject.xcodeproj').target('Application').config('Debug')
config.info_plist do |plist|
puts plist.version # => 1.0
plist.version = 1.1
marketing_version = 12.1
end
@see InfoPlist | [
"Opens",
"the",
"info",
"plist",
"associated",
"with",
"the",
"configuration",
"and",
"allows",
"you",
"to",
"edit",
"the",
"configuration",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration.rb#L329-L334 | train |
rayh/xcoder | lib/xcode/configuration.rb | Xcode.Configuration.get | def get(name)
if respond_to?(name)
send(name)
elsif Configuration.setting_name_to_property(name)
send Configuration.setting_name_to_property(name)
else
build_settings[name]
end
end | ruby | def get(name)
if respond_to?(name)
send(name)
elsif Configuration.setting_name_to_property(name)
send Configuration.setting_name_to_property(name)
else
build_settings[name]
end
end | [
"def",
"get",
"(",
"name",
")",
"if",
"respond_to?",
"(",
"name",
")",
"send",
"(",
"name",
")",
"elsif",
"Configuration",
".",
"setting_name_to_property",
"(",
"name",
")",
"send",
"Configuration",
".",
"setting_name_to_property",
"(",
"name",
")",
"else",
"build_settings",
"[",
"name",
"]",
"end",
"end"
] | Retrieve the configuration value for the given name
@param [String] name of the configuration settings to return
@return [String,Array,Hash] the value stored for the specified configuration | [
"Retrieve",
"the",
"configuration",
"value",
"for",
"the",
"given",
"name"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration.rb#L347-L355 | train |
rayh/xcoder | lib/xcode/configuration.rb | Xcode.Configuration.set | def set(name, value)
if respond_to?(name)
send("#{name}=",value)
elsif Configuration.setting_name_to_property(name)
send("#{Configuration.setting_name_to_property(name)}=",value)
else
build_settings[name] = value
end
end | ruby | def set(name, value)
if respond_to?(name)
send("#{name}=",value)
elsif Configuration.setting_name_to_property(name)
send("#{Configuration.setting_name_to_property(name)}=",value)
else
build_settings[name] = value
end
end | [
"def",
"set",
"(",
"name",
",",
"value",
")",
"if",
"respond_to?",
"(",
"name",
")",
"send",
"(",
"\"#{name}=\"",
",",
"value",
")",
"elsif",
"Configuration",
".",
"setting_name_to_property",
"(",
"name",
")",
"send",
"(",
"\"#{Configuration.setting_name_to_property(name)}=\"",
",",
"value",
")",
"else",
"build_settings",
"[",
"name",
"]",
"=",
"value",
"end",
"end"
] | Set the configuration value for the given name
@param [String] name of the the configuration setting
@param [String,Array,Hash] value the value to store for the specific setting | [
"Set",
"the",
"configuration",
"value",
"for",
"the",
"given",
"name"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration.rb#L363-L371 | train |
rayh/xcoder | lib/xcode/configuration.rb | Xcode.Configuration.append | def append(name, value)
if respond_to?(name)
send("append_to_#{name}",value)
elsif Configuration.setting_name_to_property(name)
send("append_to_#{Configuration.setting_name_to_property(name)}",value)
else
# @note this will likely raise some errors if trying to append a booleans
# to fixnums, strings to booleans, symbols + arrays, etc. but that likely
# means a new property should be defined so that the appending logic
# wil behave correctly.
if build_settings[name].is_a?(Array)
# Ensure that we are appending an array to the array; Array() does not
# work in this case in the event we were to pass in a Hash.
value = value.is_a?(Array) ? value : [ value ]
build_settings[name] = build_settings[name] + value.compact
else
# Ensure we handle the cases where a nil value is present that we append
# correctly to the value. We also need to try and leave intact boolean
# values which may be stored
value = "" unless value
build_settings[name] = "" unless build_settings[name]
build_settings[name] = build_settings[name] + value
end
end
end | ruby | def append(name, value)
if respond_to?(name)
send("append_to_#{name}",value)
elsif Configuration.setting_name_to_property(name)
send("append_to_#{Configuration.setting_name_to_property(name)}",value)
else
# @note this will likely raise some errors if trying to append a booleans
# to fixnums, strings to booleans, symbols + arrays, etc. but that likely
# means a new property should be defined so that the appending logic
# wil behave correctly.
if build_settings[name].is_a?(Array)
# Ensure that we are appending an array to the array; Array() does not
# work in this case in the event we were to pass in a Hash.
value = value.is_a?(Array) ? value : [ value ]
build_settings[name] = build_settings[name] + value.compact
else
# Ensure we handle the cases where a nil value is present that we append
# correctly to the value. We also need to try and leave intact boolean
# values which may be stored
value = "" unless value
build_settings[name] = "" unless build_settings[name]
build_settings[name] = build_settings[name] + value
end
end
end | [
"def",
"append",
"(",
"name",
",",
"value",
")",
"if",
"respond_to?",
"(",
"name",
")",
"send",
"(",
"\"append_to_#{name}\"",
",",
"value",
")",
"elsif",
"Configuration",
".",
"setting_name_to_property",
"(",
"name",
")",
"send",
"(",
"\"append_to_#{Configuration.setting_name_to_property(name)}\"",
",",
"value",
")",
"else",
"# @note this will likely raise some errors if trying to append a booleans",
"# to fixnums, strings to booleans, symbols + arrays, etc. but that likely ",
"# means a new property should be defined so that the appending logic",
"# wil behave correctly.",
"if",
"build_settings",
"[",
"name",
"]",
".",
"is_a?",
"(",
"Array",
")",
"# Ensure that we are appending an array to the array; Array() does not",
"# work in this case in the event we were to pass in a Hash.",
"value",
"=",
"value",
".",
"is_a?",
"(",
"Array",
")",
"?",
"value",
":",
"[",
"value",
"]",
"build_settings",
"[",
"name",
"]",
"=",
"build_settings",
"[",
"name",
"]",
"+",
"value",
".",
"compact",
"else",
"# Ensure we handle the cases where a nil value is present that we append",
"# correctly to the value. We also need to try and leave intact boolean",
"# values which may be stored",
"value",
"=",
"\"\"",
"unless",
"value",
"build_settings",
"[",
"name",
"]",
"=",
"\"\"",
"unless",
"build_settings",
"[",
"name",
"]",
"build_settings",
"[",
"name",
"]",
"=",
"build_settings",
"[",
"name",
"]",
"+",
"value",
"end",
"end",
"end"
] | Append a value to the the configuration value for the given name
@param [String] name of the the configuration setting
@param [String,Array,Hash] value the value to store for the specific setting | [
"Append",
"a",
"value",
"to",
"the",
"the",
"configuration",
"value",
"for",
"the",
"given",
"name"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/configuration.rb#L379-L412 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.group | def group(name)
groups.find_all {|group| group.name == name or group.path == name }
end | ruby | def group(name)
groups.find_all {|group| group.name == name or group.path == name }
end | [
"def",
"group",
"(",
"name",
")",
"groups",
".",
"find_all",
"{",
"|",
"group",
"|",
"group",
".",
"name",
"==",
"name",
"or",
"group",
".",
"path",
"==",
"name",
"}",
"end"
] | Find all the child groups that have a name that matches the specified name.
@param [String] name of the group that you are looking to return.
@return [Array<Group>] the groups with the same matching name. This
could be no groups, one group, or multiple groups. | [
"Find",
"all",
"the",
"child",
"groups",
"that",
"have",
"a",
"name",
"that",
"matches",
"the",
"specified",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L66-L68 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.file | def file(name)
files.find_all {|file| file.name == name or file.path == name }
end | ruby | def file(name)
files.find_all {|file| file.name == name or file.path == name }
end | [
"def",
"file",
"(",
"name",
")",
"files",
".",
"find_all",
"{",
"|",
"file",
"|",
"file",
".",
"name",
"==",
"name",
"or",
"file",
".",
"path",
"==",
"name",
"}",
"end"
] | Find all the files that have have a name that matches the specified name.
@param [String] name of the file that you are looking to return.
@return [Array<FileReference>] the files with the same mathching
name. This could be no files, one file, or multiple files. | [
"Find",
"all",
"the",
"files",
"that",
"have",
"have",
"a",
"name",
"that",
"matches",
"the",
"specified",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L87-L89 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.exists? | def exists?(name)
children.find_all do |child|
child.name ? (child.name == name) : (File.basename(child.path) == name)
end
end | ruby | def exists?(name)
children.find_all do |child|
child.name ? (child.name == name) : (File.basename(child.path) == name)
end
end | [
"def",
"exists?",
"(",
"name",
")",
"children",
".",
"find_all",
"do",
"|",
"child",
"|",
"child",
".",
"name",
"?",
"(",
"child",
".",
"name",
"==",
"name",
")",
":",
"(",
"File",
".",
"basename",
"(",
"child",
".",
"path",
")",
"==",
"name",
")",
"end",
"end"
] | Check whether a file or group is contained within this group that has a name
that matches the one specified
@param [String] name of the group attempting to be found.
@return [Array<Resource>] resource with the name that matches; empty array
if no matches were found. | [
"Check",
"whether",
"a",
"file",
"or",
"group",
"is",
"contained",
"within",
"this",
"group",
"that",
"has",
"a",
"name",
"that",
"matches",
"the",
"one",
"specified"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L100-L104 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.create_group | def create_group(name)
new_group = create_child_object Group.logical_group(name)
new_group.supergroup = self
new_group
end | ruby | def create_group(name)
new_group = create_child_object Group.logical_group(name)
new_group.supergroup = self
new_group
end | [
"def",
"create_group",
"(",
"name",
")",
"new_group",
"=",
"create_child_object",
"Group",
".",
"logical_group",
"(",
"name",
")",
"new_group",
".",
"supergroup",
"=",
"self",
"new_group",
"end"
] | Adds a group as a child to current group with the given name.
@note A group may be added that has the same name as another group as they
are distinguished by a unique identifier and not by name.
@param [String] name of the group that you want to add as a child group of
the specified group.
@return [Group] the created group | [
"Adds",
"a",
"group",
"as",
"a",
"child",
"to",
"current",
"group",
"with",
"the",
"given",
"name",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L117-L121 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.create_file | def create_file(file_properties)
# This allows both support for the string value or the hash as the parameter
file_properties = { 'path' => file_properties } if file_properties.is_a? String
# IF the file already exists then we will not create the file with the
# parameters that are being supplied, instead we will return what we
# found.
find_file_by = file_properties['name'] || file_properties['path']
found_or_created_file = exists?(find_file_by).first
unless found_or_created_file
found_or_created_file = create_child_object FileReference.file(file_properties)
end
found_or_created_file.supergroup = self
found_or_created_file
end | ruby | def create_file(file_properties)
# This allows both support for the string value or the hash as the parameter
file_properties = { 'path' => file_properties } if file_properties.is_a? String
# IF the file already exists then we will not create the file with the
# parameters that are being supplied, instead we will return what we
# found.
find_file_by = file_properties['name'] || file_properties['path']
found_or_created_file = exists?(find_file_by).first
unless found_or_created_file
found_or_created_file = create_child_object FileReference.file(file_properties)
end
found_or_created_file.supergroup = self
found_or_created_file
end | [
"def",
"create_file",
"(",
"file_properties",
")",
"# This allows both support for the string value or the hash as the parameter",
"file_properties",
"=",
"{",
"'path'",
"=>",
"file_properties",
"}",
"if",
"file_properties",
".",
"is_a?",
"String",
"# IF the file already exists then we will not create the file with the",
"# parameters that are being supplied, instead we will return what we",
"# found.",
"find_file_by",
"=",
"file_properties",
"[",
"'name'",
"]",
"||",
"file_properties",
"[",
"'path'",
"]",
"found_or_created_file",
"=",
"exists?",
"(",
"find_file_by",
")",
".",
"first",
"unless",
"found_or_created_file",
"found_or_created_file",
"=",
"create_child_object",
"FileReference",
".",
"file",
"(",
"file_properties",
")",
"end",
"found_or_created_file",
".",
"supergroup",
"=",
"self",
"found_or_created_file",
"end"
] | Add a file to the specified group. Currently the file creation requires
the path to the physical file.
@example creating a file with just a path
project.main_group.create_file 'AppDelegate.m'
@example creating a file with a name and path
project.main_group.create_file 'name' => 'AppDelegate.m', 'path' => 'Subfolder/AppDelegate.m'
@param [String,Hash] path to the file that is being added or a hash that
contains the values would be merged with the default values.
@return [FileReference] the file created. | [
"Add",
"a",
"file",
"to",
"the",
"specified",
"group",
".",
"Currently",
"the",
"file",
"creation",
"requires",
"the",
"path",
"to",
"the",
"physical",
"file",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L140-L159 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.remove! | def remove!(&block)
# @note #groups and #files is used because it adds the very precious
# supergroup to each of the child items.
groups.each {|group| group.remove!(&block) }
files.each {|file| file.remove!(&block) }
yield self if block_given?
child_identifier = identifier
supergroup.instance_eval { remove_child_object(child_identifier) }
@registry.remove_object identifier
end | ruby | def remove!(&block)
# @note #groups and #files is used because it adds the very precious
# supergroup to each of the child items.
groups.each {|group| group.remove!(&block) }
files.each {|file| file.remove!(&block) }
yield self if block_given?
child_identifier = identifier
supergroup.instance_eval { remove_child_object(child_identifier) }
@registry.remove_object identifier
end | [
"def",
"remove!",
"(",
"&",
"block",
")",
"# @note #groups and #files is used because it adds the very precious",
"# supergroup to each of the child items.",
"groups",
".",
"each",
"{",
"|",
"group",
"|",
"group",
".",
"remove!",
"(",
"block",
")",
"}",
"files",
".",
"each",
"{",
"|",
"file",
"|",
"file",
".",
"remove!",
"(",
"block",
")",
"}",
"yield",
"self",
"if",
"block_given?",
"child_identifier",
"=",
"identifier",
"supergroup",
".",
"instance_eval",
"{",
"remove_child_object",
"(",
"child_identifier",
")",
"}",
"@registry",
".",
"remove_object",
"identifier",
"end"
] | Remove the resource from the registry.
@note all children objects of this group are removed as well. | [
"Remove",
"the",
"resource",
"from",
"the",
"registry",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L240-L252 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.find_or_create_child_object | def find_or_create_child_object(child_properties)
found_child = children.find {|child| child.name == child_properties['name'] or child.path == child_properties['path'] }
found_child = create_child_object(child_properties) unless found_child
found_child
end | ruby | def find_or_create_child_object(child_properties)
found_child = children.find {|child| child.name == child_properties['name'] or child.path == child_properties['path'] }
found_child = create_child_object(child_properties) unless found_child
found_child
end | [
"def",
"find_or_create_child_object",
"(",
"child_properties",
")",
"found_child",
"=",
"children",
".",
"find",
"{",
"|",
"child",
"|",
"child",
".",
"name",
"==",
"child_properties",
"[",
"'name'",
"]",
"or",
"child",
".",
"path",
"==",
"child_properties",
"[",
"'path'",
"]",
"}",
"found_child",
"=",
"create_child_object",
"(",
"child_properties",
")",
"unless",
"found_child",
"found_child",
"end"
] | This method is used internally to find the specified object or add the object
as a child of this group.
@param [Hash] child_properties the hash of resource to add as a child
object of this group if it does not already exist as a child.
@return [Resource] returns the resource that was added a child | [
"This",
"method",
"is",
"used",
"internally",
"to",
"find",
"the",
"specified",
"object",
"or",
"add",
"the",
"object",
"as",
"a",
"child",
"of",
"this",
"group",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L278-L282 | train |
rayh/xcoder | lib/xcode/group.rb | Xcode.Group.remove_child_object | def remove_child_object(identifier)
found_child = children.find {|child| child.identifier == identifier }
@properties['children'].delete identifier
save!
found_child
end | ruby | def remove_child_object(identifier)
found_child = children.find {|child| child.identifier == identifier }
@properties['children'].delete identifier
save!
found_child
end | [
"def",
"remove_child_object",
"(",
"identifier",
")",
"found_child",
"=",
"children",
".",
"find",
"{",
"|",
"child",
"|",
"child",
".",
"identifier",
"==",
"identifier",
"}",
"@properties",
"[",
"'children'",
"]",
".",
"delete",
"identifier",
"save!",
"found_child",
"end"
] | This method is used internally to remove a child object from this and the
registry.
@param [String] identifier of the child object to be removed.
@return [Resource] the removed child resource | [
"This",
"method",
"is",
"used",
"internally",
"to",
"remove",
"a",
"child",
"object",
"from",
"this",
"and",
"the",
"registry",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/group.rb#L290-L295 | train |
rayh/xcoder | lib/xcoder/rake_task.rb | Xcode.RakeTask.define_per_project_scheme_builder_tasks | def define_per_project_scheme_builder_tasks
projects.each do |project|
project.schemes.each do |scheme|
builder_actions.each do |action|
description = "#{action.capitalize} #{project.name} #{scheme.name}"
task_name = friendlyname("#{name}:#{project.name}:scheme:#{scheme.name}:#{action}")
define_task_with description, task_name do
scheme.builder.send(action)
end
end
end
end
end | ruby | def define_per_project_scheme_builder_tasks
projects.each do |project|
project.schemes.each do |scheme|
builder_actions.each do |action|
description = "#{action.capitalize} #{project.name} #{scheme.name}"
task_name = friendlyname("#{name}:#{project.name}:scheme:#{scheme.name}:#{action}")
define_task_with description, task_name do
scheme.builder.send(action)
end
end
end
end
end | [
"def",
"define_per_project_scheme_builder_tasks",
"projects",
".",
"each",
"do",
"|",
"project",
"|",
"project",
".",
"schemes",
".",
"each",
"do",
"|",
"scheme",
"|",
"builder_actions",
".",
"each",
"do",
"|",
"action",
"|",
"description",
"=",
"\"#{action.capitalize} #{project.name} #{scheme.name}\"",
"task_name",
"=",
"friendlyname",
"(",
"\"#{name}:#{project.name}:scheme:#{scheme.name}:#{action}\"",
")",
"define_task_with",
"description",
",",
"task_name",
"do",
"scheme",
".",
"builder",
".",
"send",
"(",
"action",
")",
"end",
"end",
"end",
"end",
"end"
] | Generate all the Builder Tasks for all the matrix of all the Projects and
Schemes | [
"Generate",
"all",
"the",
"Builder",
"Tasks",
"for",
"all",
"the",
"matrix",
"of",
"all",
"the",
"Projects",
"and",
"Schemes"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcoder/rake_task.rb#L142-L159 | train |
rayh/xcoder | lib/xcoder/rake_task.rb | Xcode.RakeTask.define_per_project_config_builder_tasks | def define_per_project_config_builder_tasks
projects.each do |project|
project.targets.each do |target|
target.configs.each do |config|
builder_actions.each do |action|
description = "#{action.capitalize} #{project.name} #{target.name} #{config.name}"
task_name = friendlyname("#{name}:#{project.name}:#{target.name}:#{config.name}:#{action}")
define_task_with description, task_name do
config.builder.send(action)
end
end
end
end
end
end | ruby | def define_per_project_config_builder_tasks
projects.each do |project|
project.targets.each do |target|
target.configs.each do |config|
builder_actions.each do |action|
description = "#{action.capitalize} #{project.name} #{target.name} #{config.name}"
task_name = friendlyname("#{name}:#{project.name}:#{target.name}:#{config.name}:#{action}")
define_task_with description, task_name do
config.builder.send(action)
end
end
end
end
end
end | [
"def",
"define_per_project_config_builder_tasks",
"projects",
".",
"each",
"do",
"|",
"project",
"|",
"project",
".",
"targets",
".",
"each",
"do",
"|",
"target",
"|",
"target",
".",
"configs",
".",
"each",
"do",
"|",
"config",
"|",
"builder_actions",
".",
"each",
"do",
"|",
"action",
"|",
"description",
"=",
"\"#{action.capitalize} #{project.name} #{target.name} #{config.name}\"",
"task_name",
"=",
"friendlyname",
"(",
"\"#{name}:#{project.name}:#{target.name}:#{config.name}:#{action}\"",
")",
"define_task_with",
"description",
",",
"task_name",
"do",
"config",
".",
"builder",
".",
"send",
"(",
"action",
")",
"end",
"end",
"end",
"end",
"end",
"end"
] | Generate all the Builder Tasks for all the matrix of all the Projects,
Targets, and Configs | [
"Generate",
"all",
"the",
"Builder",
"Tasks",
"for",
"all",
"the",
"matrix",
"of",
"all",
"the",
"Projects",
"Targets",
"and",
"Configs"
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcoder/rake_task.rb#L165-L187 | train |
rayh/xcoder | lib/xcode/project_reference.rb | Xcode.ProjectReference.group | def group(name,options = {},&block)
# By default create missing groups along the way
options = { :create => true }.merge(options)
current_group = main_group
# @todo consider this traversing and find/create as a normal procedure when
# traversing the project.
name.split("/").each do |path_component|
found_group = current_group.group(path_component).first
if options[:create] and found_group.nil?
found_group = current_group.create_group(path_component)
end
current_group = found_group
break unless current_group
end
current_group.instance_eval(&block) if block_given? and current_group
current_group
end | ruby | def group(name,options = {},&block)
# By default create missing groups along the way
options = { :create => true }.merge(options)
current_group = main_group
# @todo consider this traversing and find/create as a normal procedure when
# traversing the project.
name.split("/").each do |path_component|
found_group = current_group.group(path_component).first
if options[:create] and found_group.nil?
found_group = current_group.create_group(path_component)
end
current_group = found_group
break unless current_group
end
current_group.instance_eval(&block) if block_given? and current_group
current_group
end | [
"def",
"group",
"(",
"name",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"# By default create missing groups along the way",
"options",
"=",
"{",
":create",
"=>",
"true",
"}",
".",
"merge",
"(",
"options",
")",
"current_group",
"=",
"main_group",
"# @todo consider this traversing and find/create as a normal procedure when",
"# traversing the project.",
"name",
".",
"split",
"(",
"\"/\"",
")",
".",
"each",
"do",
"|",
"path_component",
"|",
"found_group",
"=",
"current_group",
".",
"group",
"(",
"path_component",
")",
".",
"first",
"if",
"options",
"[",
":create",
"]",
"and",
"found_group",
".",
"nil?",
"found_group",
"=",
"current_group",
".",
"create_group",
"(",
"path_component",
")",
"end",
"current_group",
"=",
"found_group",
"break",
"unless",
"current_group",
"end",
"current_group",
".",
"instance_eval",
"(",
"block",
")",
"if",
"block_given?",
"and",
"current_group",
"current_group",
"end"
] | Returns the group specified. If any part of the group does not exist along
the path the group is created. Also paths can be specified to make the
traversing of the groups easier.
@note this will attempt to find the paths specified, if it fails to find them
it will create one and then continue traversing.
@example Traverse a path through the various sub-groups.
project.group('Vendor/MyCode/Support Files')
# is equivalent to ...
project.group('Vendor').first.group('MyCode').first.group('Supporting Files')
@note this path functionality current is only exercised from the project level
all groups will treat the path division `/` as simply a character.
@param [String] name the group name to find/create
@return [Group] the group with the specified name. | [
"Returns",
"the",
"group",
"specified",
".",
"If",
"any",
"part",
"of",
"the",
"group",
"does",
"not",
"exist",
"along",
"the",
"path",
"the",
"group",
"is",
"created",
".",
"Also",
"paths",
"can",
"be",
"specified",
"to",
"make",
"the",
"traversing",
"of",
"the",
"groups",
"easier",
"."
] | 0affa3e8f0a5c138ea25c004341d62b23c6b6711 | https://github.com/rayh/xcoder/blob/0affa3e8f0a5c138ea25c004341d62b23c6b6711/lib/xcode/project_reference.rb#L26-L50 | train |
pusher/cide | lib/cide/runner.rb | CIDE.Runner.run! | def run!(interactive: false)
start_links!
run_options = ['--detach']
@env.each_pair do |key, value|
run_options.push '--env', [key, value].join('=')
end
@links.each do |link|
run_options.push '--link', [link.id, link.name].join(':')
end
run_options.push '--name', @id
run_options.push '--user', @user if @user
run_options.push('--interactive', '--tty') if interactive
run_options.push @tag
run_options.push(*@command)
id = docker(:run, *run_options, capture: true).strip
@containers << id
docker(:attach, id)
end | ruby | def run!(interactive: false)
start_links!
run_options = ['--detach']
@env.each_pair do |key, value|
run_options.push '--env', [key, value].join('=')
end
@links.each do |link|
run_options.push '--link', [link.id, link.name].join(':')
end
run_options.push '--name', @id
run_options.push '--user', @user if @user
run_options.push('--interactive', '--tty') if interactive
run_options.push @tag
run_options.push(*@command)
id = docker(:run, *run_options, capture: true).strip
@containers << id
docker(:attach, id)
end | [
"def",
"run!",
"(",
"interactive",
":",
"false",
")",
"start_links!",
"run_options",
"=",
"[",
"'--detach'",
"]",
"@env",
".",
"each_pair",
"do",
"|",
"key",
",",
"value",
"|",
"run_options",
".",
"push",
"'--env'",
",",
"[",
"key",
",",
"value",
"]",
".",
"join",
"(",
"'='",
")",
"end",
"@links",
".",
"each",
"do",
"|",
"link",
"|",
"run_options",
".",
"push",
"'--link'",
",",
"[",
"link",
".",
"id",
",",
"link",
".",
"name",
"]",
".",
"join",
"(",
"':'",
")",
"end",
"run_options",
".",
"push",
"'--name'",
",",
"@id",
"run_options",
".",
"push",
"'--user'",
",",
"@user",
"if",
"@user",
"run_options",
".",
"push",
"(",
"'--interactive'",
",",
"'--tty'",
")",
"if",
"interactive",
"run_options",
".",
"push",
"@tag",
"run_options",
".",
"push",
"(",
"@command",
")",
"id",
"=",
"docker",
"(",
":run",
",",
"run_options",
",",
"capture",
":",
"true",
")",
".",
"strip",
"@containers",
"<<",
"id",
"docker",
"(",
":attach",
",",
"id",
")",
"end"
] | !!!! Don't call run twice !!!! | [
"!!!!",
"Don",
"t",
"call",
"run",
"twice",
"!!!!"
] | 2827b1d283d7ed3f0db81b7e0428ce2de5a98555 | https://github.com/pusher/cide/blob/2827b1d283d7ed3f0db81b7e0428ce2de5a98555/lib/cide/runner.rb#L29-L54 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.