vigetlabs-unfuzzle 0.1.1 → 0.1.2

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.
Files changed (39) hide show
  1. data/README.rdoc +21 -1
  2. data/Rakefile +2 -2
  3. data/lib/unfuzzle.rb +13 -2
  4. data/lib/unfuzzle/component.rb +31 -0
  5. data/lib/unfuzzle/milestone.rb +17 -26
  6. data/lib/unfuzzle/priority.rb +30 -0
  7. data/lib/unfuzzle/project.rb +13 -20
  8. data/lib/unfuzzle/request.rb +5 -8
  9. data/lib/unfuzzle/response.rb +0 -7
  10. data/lib/unfuzzle/severity.rb +31 -0
  11. data/lib/unfuzzle/ticket.rb +58 -25
  12. data/lib/unfuzzle/version.rb +1 -1
  13. data/test/fixtures/component.xml +8 -0
  14. data/test/fixtures/components.xml +17 -0
  15. data/test/fixtures/milestone.xml +12 -0
  16. data/test/fixtures/milestones.xml +25 -0
  17. data/test/fixtures/project.xml +17 -0
  18. data/test/fixtures/projects.xml +35 -0
  19. data/test/fixtures/severities.xml +24 -0
  20. data/test/fixtures/severity.xml +8 -0
  21. data/test/fixtures/ticket.xml +25 -0
  22. data/test/fixtures/tickets.xml +51 -0
  23. data/test/test_helper.rb +5 -7
  24. data/test/unit/unfuzzle/component_test.rb +36 -0
  25. data/test/unit/unfuzzle/milestone_test.rb +12 -44
  26. data/test/unit/unfuzzle/priority_test.rb +25 -0
  27. data/test/unit/unfuzzle/project_test.rb +17 -37
  28. data/test/unit/unfuzzle/request_test.rb +3 -13
  29. data/test/unit/unfuzzle/response_test.rb +0 -28
  30. data/test/unit/unfuzzle/severity_test.rb +36 -0
  31. data/test/unit/unfuzzle/ticket_test.rb +108 -47
  32. metadata +21 -12
  33. data/lib/unfuzzle/model.rb +0 -56
  34. data/test/fixtures/milestone.json +0 -11
  35. data/test/fixtures/milestones.json +0 -22
  36. data/test/fixtures/project.json +0 -16
  37. data/test/fixtures/projects.json +0 -32
  38. data/test/fixtures/tickets.json +0 -44
  39. data/test/unit/unfuzzle/model_test.rb +0 -55
@@ -1,56 +0,0 @@
1
- module Unfuzzle
2
- module Model # :nodoc:
3
-
4
- module ClassMethods
5
- def attribute(name, options = {}) # :nodoc:
6
- key = options.delete(:from) || name
7
-
8
- class_eval <<-CODE
9
- def #{name}
10
- @response_data['#{key}']
11
- end
12
-
13
- def #{name}=(value)
14
- @response_data['#{key}'] = value
15
- end
16
- CODE
17
- end
18
- end
19
-
20
- module InstanceMethods
21
-
22
- def initialize(response_data)
23
- @response_data = response_data
24
- end
25
-
26
- def to_hash
27
- @response_data
28
- end
29
-
30
- def tag_name
31
- full_class_name = self.class.to_s
32
- class_name = full_class_name.split('::').last
33
-
34
- class_name.downcase
35
- end
36
-
37
- def to_xml
38
- xml = Builder::XmlMarkup.new
39
- xml.instruct!
40
- xml.tag! tag_name do
41
- to_hash.each do |attribute, value|
42
- xml.tag! attribute, value
43
- end
44
- end
45
- xml.target!
46
- end
47
-
48
- end
49
-
50
- def self.included(other)
51
- other.send(:extend, Unfuzzle::Model::ClassMethods)
52
- other.send(:include, Unfuzzle::Model::InstanceMethods)
53
- end
54
-
55
- end
56
- end
@@ -1,11 +0,0 @@
1
- {
2
- "archived": false,
3
- "created_at": "2009-04-02T19:43:16Z",
4
- "completed": false,
5
- "title": "Projekt",
6
- "due_on": "2009-04-03",
7
- "person_responsible_id": 123,
8
- "updated_at": "2009-07-02T16:40:28Z",
9
- "id": 2,
10
- "project_id": 1
11
- }
@@ -1,22 +0,0 @@
1
- [{
2
- "archived": false,
3
- "created_at": "2008-07-30T22:12:37Z",
4
- "completed": true,
5
- "title": "Milestone 1",
6
- "person_responsible_id": 12345,
7
- "due_on": "2008-07-30",
8
- "updated_at": "2008-12-26T22:32:03Z",
9
- "id": 1,
10
- "project_id": 1
11
- },
12
- {
13
- "archived": false,
14
- "created_at": "2009-02-09T15:15:30Z",
15
- "completed": true,
16
- "title": "Milestone 2",
17
- "person_responsible_id": 12344,
18
- "due_on": "2009-02-13",
19
- "updated_at": "2009-02-17T15:37:01Z",
20
- "id": 2,
21
- "project_id": 1
22
- }]
@@ -1,16 +0,0 @@
1
- {
2
- "archived": false,
3
- "short_name": "blip",
4
- "created_at": "2008-07-28T16:57:10Z",
5
- "title": "Blip Bleep Co.",
6
- "close_ticket_simultaneously_default": true,
7
- "account_id": 1,
8
- "description": "This is the project for Blip Bleep Co.",
9
- "enable_time_tracking": true,
10
- "default_ticket_report_id": 0,
11
- "updated_at": "2009-04-28T18:48:52Z",
12
- "id": 1,
13
- "theme": "teal",
14
- "disk_usage": 1416,
15
- "assignee_on_resolve": "none"
16
- }
@@ -1,32 +0,0 @@
1
- [{
2
- "archived": false,
3
- "short_name": "aa",
4
- "created_at": "2008-07-28T16:57:10Z",
5
- "title": "A Client",
6
- "close_ticket_simultaneously_default": true,
7
- "account_id": 12345,
8
- "description": "A great project",
9
- "enable_time_tracking": true,
10
- "default_ticket_report_id": 0,
11
- "updated_at": "2009-04-28T18:48:52Z",
12
- "id": 1,
13
- "theme": "teal",
14
- "disk_usage": 1416,
15
- "assignee_on_resolve": "none"
16
- },
17
- {
18
- "archived": true,
19
- "short_name": "zz",
20
- "created_at": "2008-06-23T21:06:01Z",
21
- "title": "Zee Client",
22
- "close_ticket_simultaneously_default": false,
23
- "account_id": 12345,
24
- "description": null,
25
- "enable_time_tracking": true,
26
- "default_ticket_report_id": null,
27
- "updated_at": "2009-05-20T23:15:24Z",
28
- "id": 2,
29
- "theme": "grey",
30
- "disk_usage": 14008,
31
- "assignee_on_resolve": "reporter"
32
- }]
@@ -1,44 +0,0 @@
1
- [{
2
- "severity_id": null,
3
- "hours_estimate_current": 0.0,
4
- "resolution_description": "",
5
- "reporter_id": 1,
6
- "created_at": "2008-11-25T14:00:19Z",
7
- "priority": "4",
8
- "number": 1,
9
- "milestone_id": 1,
10
- "description": "Do something important",
11
- "assignee_id": null,
12
- "due_on": null,
13
- "status": "closed",
14
- "summary": "Ticket #1",
15
- "resolution": "fixed",
16
- "component_id": null,
17
- "version_id": null,
18
- "updated_at": "2008-12-31T15:51:41Z",
19
- "id": 1,
20
- "project_id": 1,
21
- "hours_estimate_initial": 1.75
22
- },
23
- {
24
- "severity_id": null,
25
- "hours_estimate_current": 0.25,
26
- "resolution_description": "",
27
- "reporter_id": 1,
28
- "created_at": "2009-02-09T15:17:52Z",
29
- "priority": "3",
30
- "number": 2,
31
- "milestone_id": 1,
32
- "description": "Do something else important",
33
- "assignee_id": null,
34
- "due_on": null,
35
- "status": "closed",
36
- "summary": "Ticket #2",
37
- "resolution": "fixed",
38
- "component_id": null,
39
- "version_id": null,
40
- "updated_at": "2009-02-17T15:36:40Z",
41
- "id": 2,
42
- "project_id": 1,
43
- "hours_estimate_initial": 0.0
44
- }]
@@ -1,55 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
-
3
- class MyModel
4
- include Unfuzzle::Model
5
- attribute :foo
6
- end
7
-
8
- module MyModule
9
- class MyModel
10
- include Unfuzzle::Model
11
- attribute :bar
12
- end
13
- end
14
-
15
- module Unfuzzle
16
- class ModelTest < Test::Unit::TestCase
17
-
18
- context "An instance of the MyModel class" do
19
- should "have an accessor for :foo" do
20
- m = MyModel.new({})
21
- m.foo = 'bar'
22
- m.foo.should == 'bar'
23
- end
24
-
25
- should "be able to generate a hash representation of its data" do
26
- m = MyModel.new('foo' => 'bar')
27
- m.to_hash.should == {'foo' => 'bar'}
28
- end
29
-
30
- should "be able to generate its tag name when the class is not namespaced" do
31
- m = MyModel.new({})
32
- m.tag_name.should == 'mymodel'
33
- end
34
-
35
- should "be able to generate its tag name when the class is namespaced" do
36
- m = MyModule::MyModel.new({})
37
- m.tag_name.should == 'mymodel'
38
- end
39
-
40
- should "be able to generate an XML representation of its data" do
41
- m = MyModel.new('foo' => 'bar')
42
- m.foo = 'bar'
43
-
44
- xml = <<-XML
45
- <?xml version="1.0" encoding="UTF-8"?>
46
-
47
- XML
48
-
49
- m.to_xml.should == '<?xml version="1.0" encoding="UTF-8"?><mymodel><foo>bar</foo></mymodel>'
50
- end
51
-
52
- end
53
-
54
- end
55
- end