Class: DataMapper::Adapters::BugzillaAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- DataMapper::Adapters::BugzillaAdapter
- Defined in:
- lib/dm-bugzilla-adapter.rb,
lib/dm-bugzilla-adapter/misc.rb,
lib/dm-bugzilla-adapter/read.rb,
lib/dm-bugzilla-adapter/create.rb,
lib/dm-bugzilla-adapter/delete.rb,
lib/dm-bugzilla-adapter/update.rb
Instance Method Summary collapse
- #create(resources) ⇒ Object
-
#delete(collection) ⇒ Integer
Constructs and executes DELETE statement for given query.
-
#get_bugs(ids) ⇒ Object
get Bugs by ids.
-
#initialize(name, options) ⇒ BugzillaAdapter
constructor
A new instance of BugzillaAdapter.
-
#named_query(name) ⇒ Object
run named query, return Array of bug ids.
-
#read(query) ⇒ Array
Retrieves records for a particular model.
-
#update(attributes, collection) ⇒ Integer
Constructs and executes UPDATE statement for given attributes and a query.
Constructor Details
#initialize(name, options) ⇒ BugzillaAdapter
Returns a new instance of BugzillaAdapter.
63 64 65 66 67 68 |
# File 'lib/dm-bugzilla-adapter.rb', line 63 def initialize(name, ) super require 'uri' @uri = URI.parse([:url]) @client = Bicho::Client.new(@uri) end |
Instance Method Details
#create(resources) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dm-bugzilla-adapter/create.rb', line 4 def create(resources) STDERR.puts "BugzillaAdapter::create" table_groups = group_resources_by_table(resources) table_groups.each do |table, resources| # make # class User # property :id, Serial # end # work resources.each do |resource| initialize_serial(resource, worksheet_record_cound(table)+1) post_resource_to_worksheet(resource,table) end end resources.size end |
#delete(collection) ⇒ Integer
Constructs and executes DELETE statement for given query
14 15 16 17 18 19 20 |
# File 'lib/dm-bugzilla-adapter/delete.rb', line 14 def delete(collection) each_resource_with_edit_url(collection) do |resource, edit_url| connection.delete(edit_url, 'If-Match' => "*") end # return count collection.size end |
#get_bugs(ids) ⇒ Object
get Bugs by ids
71 72 73 |
# File 'lib/dm-bugzilla-adapter.rb', line 71 def get_bugs(ids) @client.get_bugs(*ids) end |
#named_query(name) ⇒ Object
run named query, return Array of bug ids
76 77 78 |
# File 'lib/dm-bugzilla-adapter.rb', line 76 def named_query(name) @client.get_bugs(name) end |
#read(query) ⇒ Array
Retrieves records for a particular model.
16 17 18 19 20 21 22 23 24 |
# File 'lib/dm-bugzilla-adapter/read.rb', line 16 def read(query) # STDERR.puts "BugzillaAdapter::read" # fields = query.fields # STDERR.puts "fields #{fields.inspect}" # types = fields.map { |property| property.primitive } # STDERR.puts "types #{types.inspect}" records = records_for(query) # query.filter_records(records) end |
#update(attributes, collection) ⇒ Integer
Constructs and executes UPDATE statement for given attributes and a query
16 17 18 19 20 21 22 |
# File 'lib/dm-bugzilla-adapter/update.rb', line 16 def update(attributes, collection) each_resource_with_edit_url(collection) do |resource, edit_url| put_updated_resource(edit_url, resource) end # return count collection.size end |