ticketmaster-basecamp 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -195,6 +195,9 @@ class BasecampAPI
195
195
  end
196
196
  end
197
197
 
198
+ class Account < Resource
199
+ end
200
+
198
201
  class Project < Resource
199
202
  end
200
203
 
@@ -292,11 +295,11 @@ class BasecampAPI
292
295
  # are returned. If complete is false, only uncompleted lists are returned.
293
296
  def self.all(project_id, complete = nil)
294
297
  filter = case complete
295
- when nil then "all"
296
- when true then "finished"
297
- when false then "pending"
298
- else raise ArgumentError, "invalid value for `complete'"
299
- end
298
+ when nil then "all"
299
+ when true then "finished"
300
+ when false then "pending"
301
+ else raise ArgumentError, "invalid value for `complete'"
302
+ end
300
303
 
301
304
  find(:all, :params => { :project_id => project_id, :filter => filter })
302
305
  end
@@ -396,10 +399,10 @@ class BasecampAPI
396
399
  case @hash[name]
397
400
  when Hash then
398
401
  @hash[name] = if (@hash[name].keys.length == 1 && @hash[name].values.first.is_a?(Array))
399
- @hash[name].values.first.map { |v| Record.new(@hash[name].keys.first, v) }
400
- else
401
- Record.new(name, @hash[name])
402
- end
402
+ @hash[name].values.first.map { |v| Record.new(@hash[name].keys.first, v) }
403
+ else
404
+ Record.new(name, @hash[name])
405
+ end
403
406
  else
404
407
  @hash[name]
405
408
  end
@@ -435,9 +438,9 @@ class BasecampAPI
435
438
 
436
439
  private
437
440
 
438
- def dashify(name)
439
- name.to_s.tr("_", "-")
440
- end
441
+ def dashify(name)
442
+ name.to_s.tr("_", "-")
443
+ end
441
444
  end
442
445
 
443
446
  attr_accessor :use_xml
@@ -511,7 +514,7 @@ class BasecampAPI
511
514
  # Updates an existing milestone.
512
515
  def update_milestone(id, data, move = false, move_off_weekends = false)
513
516
  record "/milestones/update/#{id}", :milestone => data,
514
- :move_upcoming_milestones => move,
517
+ :move_upcoming_milestones => move,
515
518
  :move_upcoming_milestones_off_weekends => move_off_weekends
516
519
  end
517
520
 
@@ -532,96 +535,96 @@ class BasecampAPI
532
535
 
533
536
  private
534
537
 
535
- # Make a raw web-service request to Basecamp. This will return a Hash of
536
- # Arrays of the response, and may seem a little odd to the uninitiated.
537
- def request(path, parameters = {})
538
- response = Basecamp.connection.post(path, convert_body(parameters), "Content-Type" => content_type)
538
+ # Make a raw web-service request to Basecamp. This will return a Hash of
539
+ # Arrays of the response, and may seem a little odd to the uninitiated.
540
+ def request(path, parameters = {})
541
+ response = Basecamp.connection.post(path, convert_body(parameters), "Content-Type" => content_type)
539
542
 
540
- if response.code.to_i / 100 == 2
541
- result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)
542
- typecast_value(result)
543
- else
544
- raise "#{response.message} (#{response.code})"
545
- end
543
+ if response.code.to_i / 100 == 2
544
+ result = XmlSimple.xml_in(response.body, 'keeproot' => true, 'contentkey' => '__content__', 'forcecontent' => true)
545
+ typecast_value(result)
546
+ else
547
+ raise "#{response.message} (#{response.code})"
546
548
  end
549
+ end
547
550
 
548
- # A convenience method for wrapping the result of a query in a Record
549
- # object. This assumes that the result is a singleton, not a collection.
550
- def record(path, parameters={})
551
- result = request(path, parameters)
552
- (result && !result.empty?) ? Record.new(result.keys.first, result.values.first) : nil
553
- end
551
+ # A convenience method for wrapping the result of a query in a Record
552
+ # object. This assumes that the result is a singleton, not a collection.
553
+ def record(path, parameters={})
554
+ result = request(path, parameters)
555
+ (result && !result.empty?) ? Record.new(result.keys.first, result.values.first) : nil
556
+ end
554
557
 
555
- # A convenience method for wrapping the result of a query in Record
556
- # objects. This assumes that the result is a collection--any singleton
557
- # result will be wrapped in an array.
558
- def records(node, path, parameters={})
559
- result = request(path, parameters).values.first or return []
560
- result = result[node] or return []
561
- result = [result] unless Array === result
562
- result.map { |row| Record.new(node, row) }
563
- end
558
+ # A convenience method for wrapping the result of a query in Record
559
+ # objects. This assumes that the result is a collection--any singleton
560
+ # result will be wrapped in an array.
561
+ def records(node, path, parameters={})
562
+ result = request(path, parameters).values.first or return []
563
+ result = result[node] or return []
564
+ result = [result] unless Array === result
565
+ result.map { |row| Record.new(node, row) }
566
+ end
564
567
 
565
- def convert_body(body)
566
- body = use_xml ? body.to_legacy_xml : body.to_yaml
567
- end
568
+ def convert_body(body)
569
+ body = use_xml ? body.to_legacy_xml : body.to_yaml
570
+ end
568
571
 
569
- def content_type
570
- use_xml ? "application/xml" : "application/x-yaml"
571
- end
572
+ def content_type
573
+ use_xml ? "application/xml" : "application/x-yaml"
574
+ end
572
575
 
573
- def typecast_value(value)
574
- case value
575
- when Hash
576
- if value.has_key?("__content__")
577
- content = translate_entities(value["__content__"]).strip
578
- case value["type"]
579
- when "integer" then content.to_i
580
- when "boolean" then content == "true"
581
- when "datetime" then Time.parse(content)
582
- when "date" then Date.parse(content)
583
- else content
584
- end
576
+ def typecast_value(value)
577
+ case value
578
+ when Hash
579
+ if value.has_key?("__content__")
580
+ content = translate_entities(value["__content__"]).strip
581
+ case value["type"]
582
+ when "integer" then content.to_i
583
+ when "boolean" then content == "true"
584
+ when "datetime" then Time.parse(content)
585
+ when "date" then Date.parse(content)
586
+ else content
587
+ end
585
588
  # a special case to work-around a bug in XmlSimple. When you have an empty
586
589
  # tag that has an attribute, XmlSimple will not add the __content__ key
587
590
  # to the returned hash. Thus, we check for the presense of the 'type'
588
591
  # attribute to look for empty, typed tags, and simply return nil for
589
592
  # their value.
590
- elsif value.keys == %w(type)
591
- nil
592
- elsif value["nil"] == "true"
593
- nil
593
+ elsif value.keys == %w(type)
594
+ nil
595
+ elsif value["nil"] == "true"
596
+ nil
594
597
  # another special case, introduced by the latest rails, where an array
595
598
  # type now exists. This is parsed by XmlSimple as a two-key hash, where
596
599
  # one key is 'type' and the other is the actual array value.
597
- elsif value.keys.length == 2 && value["type"] == "array"
598
- value.delete("type")
599
- typecast_value(value)
600
- else
601
- value.empty? ? nil : value.inject({}) do |h,(k,v)|
602
- h[k] = typecast_value(v)
603
- h
604
- end
605
- end
606
- when Array
607
- value.map! { |i| typecast_value(i) }
608
- case value.length
609
- when 0 then nil
610
- when 1 then value.first
611
- else value
612
- end
600
+ elsif value.keys.length == 2 && value["type"] == "array"
601
+ value.delete("type")
602
+ typecast_value(value)
613
603
  else
614
- raise "can't typecast #{value.inspect}"
604
+ value.empty? ? nil : value.inject({}) do |h,(k,v)|
605
+ h[k] = typecast_value(v)
606
+ h
607
+ end
608
+ end
609
+ when Array
610
+ value.map! { |i| typecast_value(i) }
611
+ case value.length
612
+ when 0 then nil
613
+ when 1 then value.first
614
+ else value
615
615
  end
616
+ else
617
+ raise "can't typecast #{value.inspect}"
616
618
  end
619
+ end
617
620
 
618
- def translate_entities(value)
619
- value.gsub(/&lt;/, "<").
620
- gsub(/&gt;/, ">").
621
- gsub(/&quot;/, '"').
622
- gsub(/&apos;/, "'").
623
- gsub(/&amp;/, "&")
624
- end
621
+ def translate_entities(value)
622
+ value.gsub(/&lt;/, "<").
623
+ gsub(/&gt;/, ">").
624
+ gsub(/&quot;/, '"').
625
+ gsub(/&apos;/, "'").
626
+ gsub(/&amp;/, "&")
627
+ end
625
628
  end
626
629
 
627
630
  # A minor hack to let Xml-Simple serialize symbolic keys in hashes
@@ -26,9 +26,14 @@ module TicketMaster::Provider
26
26
  end
27
27
 
28
28
  def valid?
29
- BasecampAPI.connection ? true : false
29
+ begin
30
+ project_count = BasecampAPI::Project.find(:count)
31
+ project_count.active >= 0 || project_count.archived >= 0 || project_count.on_hold >= 0
32
+ rescue
33
+ false
34
+ end
30
35
  end
31
-
36
+
32
37
  end
33
38
  end
34
39
 
@@ -0,0 +1,5 @@
1
+ <count>
2
+ <active type="integer">5</active>
3
+ <on-hold type="integer">2</on-hold>
4
+ <archived type="integer">11</archived>
5
+ </count>
@@ -2,6 +2,10 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "TicketmasterBasecamp" do
4
4
  before(:each) do
5
+ headers = {'Authorization' => 'Basic MDAwMDAwOkJhc2VjYW1w'}
6
+ ActiveResource::HttpMock.respond_to do |mock|
7
+ mock.get '/projects/count.xml', headers, fixture_for('project_count'), 200
8
+ end
5
9
  @ticketmaster = TicketMaster.new(:basecamp, {:domain => 'ticketmaster.basecamphq.com', :token => '000000'})
6
10
  end
7
11
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ticketmaster-basecamp}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["HybridGroup"]
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "spec/fixtures/comments.xml",
33
33
  "spec/fixtures/comments/74197051.xml",
34
34
  "spec/fixtures/comments/74197096.xml",
35
+ "spec/fixtures/project_count.xml",
35
36
  "spec/fixtures/projects.xml",
36
37
  "spec/fixtures/projects/5220065.xml",
37
38
  "spec/fixtures/projects/create.xml",
@@ -47,7 +48,7 @@ Gem::Specification.new do |s|
47
48
  ]
48
49
  s.homepage = %q{http://github.com/kiafaldorius/ticketmaster-basecamp}
49
50
  s.require_paths = ["lib"]
50
- s.rubygems_version = %q{1.6.0}
51
+ s.rubygems_version = %q{1.6.1}
51
52
  s.summary = %q{The basecamp provider for ticketmaster}
52
53
 
53
54
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-basecamp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - HybridGroup
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-02 00:00:00 +00:00
18
+ date: 2011-06-02 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,7 @@ files:
75
75
  - spec/fixtures/comments.xml
76
76
  - spec/fixtures/comments/74197051.xml
77
77
  - spec/fixtures/comments/74197096.xml
78
+ - spec/fixtures/project_count.xml
78
79
  - spec/fixtures/projects.xml
79
80
  - spec/fixtures/projects/5220065.xml
80
81
  - spec/fixtures/projects/create.xml
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  requirements: []
118
119
 
119
120
  rubyforge_project:
120
- rubygems_version: 1.6.0
121
+ rubygems_version: 1.6.1
121
122
  signing_key:
122
123
  specification_version: 3
123
124
  summary: The basecamp provider for ticketmaster