jsonapi-resources 0.7.1.beta1 → 0.7.1.beta2

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +248 -74
  3. data/lib/jsonapi-resources.rb +5 -3
  4. data/lib/jsonapi/acts_as_resource_controller.rb +77 -14
  5. data/lib/jsonapi/configuration.rb +77 -16
  6. data/lib/jsonapi/error.rb +12 -0
  7. data/lib/jsonapi/error_codes.rb +2 -0
  8. data/lib/jsonapi/exceptions.rb +29 -9
  9. data/lib/jsonapi/formatter.rb +29 -4
  10. data/lib/jsonapi/link_builder.rb +18 -18
  11. data/lib/jsonapi/mime_types.rb +25 -6
  12. data/lib/jsonapi/naive_cache.rb +30 -0
  13. data/lib/jsonapi/operation.rb +10 -342
  14. data/lib/jsonapi/operation_dispatcher.rb +87 -0
  15. data/lib/jsonapi/operation_result.rb +2 -1
  16. data/lib/jsonapi/paginator.rb +6 -2
  17. data/lib/jsonapi/processor.rb +283 -0
  18. data/lib/jsonapi/relationship.rb +6 -4
  19. data/lib/jsonapi/{request.rb → request_parser.rb} +46 -35
  20. data/lib/jsonapi/resource.rb +88 -13
  21. data/lib/jsonapi/resource_controller.rb +2 -14
  22. data/lib/jsonapi/resource_controller_metal.rb +17 -0
  23. data/lib/jsonapi/resource_serializer.rb +62 -47
  24. data/lib/jsonapi/resources/version.rb +1 -1
  25. data/lib/jsonapi/response_document.rb +13 -2
  26. data/lib/jsonapi/routing_ext.rb +49 -11
  27. metadata +37 -129
  28. data/.gitignore +0 -22
  29. data/.travis.yml +0 -9
  30. data/Gemfile +0 -23
  31. data/Rakefile +0 -20
  32. data/jsonapi-resources.gemspec +0 -29
  33. data/lib/jsonapi/active_record_operations_processor.rb +0 -35
  34. data/lib/jsonapi/operations_processor.rb +0 -120
  35. data/locales/en.yml +0 -80
  36. data/test/config/database.yml +0 -5
  37. data/test/controllers/controller_test.rb +0 -3312
  38. data/test/fixtures/active_record.rb +0 -1486
  39. data/test/fixtures/author_details.yml +0 -9
  40. data/test/fixtures/book_authors.yml +0 -3
  41. data/test/fixtures/book_comments.yml +0 -12
  42. data/test/fixtures/books.yml +0 -7
  43. data/test/fixtures/categories.yml +0 -35
  44. data/test/fixtures/comments.yml +0 -21
  45. data/test/fixtures/comments_tags.yml +0 -20
  46. data/test/fixtures/companies.yml +0 -4
  47. data/test/fixtures/craters.yml +0 -9
  48. data/test/fixtures/customers.yml +0 -11
  49. data/test/fixtures/documents.yml +0 -3
  50. data/test/fixtures/expense_entries.yml +0 -13
  51. data/test/fixtures/facts.yml +0 -11
  52. data/test/fixtures/hair_cuts.yml +0 -3
  53. data/test/fixtures/iso_currencies.yml +0 -17
  54. data/test/fixtures/line_items.yml +0 -37
  55. data/test/fixtures/makes.yml +0 -2
  56. data/test/fixtures/moons.yml +0 -6
  57. data/test/fixtures/numeros_telefone.yml +0 -3
  58. data/test/fixtures/order_flags.yml +0 -7
  59. data/test/fixtures/people.yml +0 -31
  60. data/test/fixtures/pictures.yml +0 -15
  61. data/test/fixtures/planet_types.yml +0 -19
  62. data/test/fixtures/planets.yml +0 -47
  63. data/test/fixtures/posts.yml +0 -102
  64. data/test/fixtures/posts_tags.yml +0 -59
  65. data/test/fixtures/preferences.yml +0 -14
  66. data/test/fixtures/products.yml +0 -3
  67. data/test/fixtures/purchase_orders.yml +0 -23
  68. data/test/fixtures/sections.yml +0 -8
  69. data/test/fixtures/tags.yml +0 -39
  70. data/test/fixtures/vehicles.yml +0 -17
  71. data/test/fixtures/web_pages.yml +0 -3
  72. data/test/helpers/assertions.rb +0 -13
  73. data/test/helpers/functional_helpers.rb +0 -59
  74. data/test/helpers/value_matchers.rb +0 -60
  75. data/test/helpers/value_matchers_test.rb +0 -40
  76. data/test/integration/requests/namespaced_model_test.rb +0 -13
  77. data/test/integration/requests/request_test.rb +0 -932
  78. data/test/integration/routes/routes_test.rb +0 -218
  79. data/test/integration/sti_fields_test.rb +0 -18
  80. data/test/lib/generators/jsonapi/controller_generator_test.rb +0 -25
  81. data/test/lib/generators/jsonapi/resource_generator_test.rb +0 -30
  82. data/test/test_helper.rb +0 -342
  83. data/test/unit/formatters/dasherized_key_formatter_test.rb +0 -8
  84. data/test/unit/jsonapi_request/jsonapi_request_test.rb +0 -199
  85. data/test/unit/operation/operations_processor_test.rb +0 -528
  86. data/test/unit/pagination/offset_paginator_test.rb +0 -245
  87. data/test/unit/pagination/paged_paginator_test.rb +0 -242
  88. data/test/unit/resource/resource_test.rb +0 -560
  89. data/test/unit/serializer/include_directives_test.rb +0 -113
  90. data/test/unit/serializer/link_builder_test.rb +0 -244
  91. data/test/unit/serializer/polymorphic_serializer_test.rb +0 -383
  92. data/test/unit/serializer/response_document_test.rb +0 -61
  93. data/test/unit/serializer/serializer_test.rb +0 -1939
@@ -1,9 +0,0 @@
1
- a:
2
- id: 1
3
- person_id: 1
4
- author_stuff: blah blah
5
-
6
- b:
7
- id: 2
8
- person_id: 2
9
- author_stuff: blah blah blah
@@ -1,3 +0,0 @@
1
- book_author_1_1:
2
- book_id: 1
3
- person_id: 1
@@ -1,12 +0,0 @@
1
- <% comment_id = 0 %>
2
- <% for book_num in 0..4 %>
3
- <% for comment_num in 0..50 %>
4
- book_<%= book_num %>_comment_<%= comment_num %>:
5
- id: <%= comment_id %>
6
- body: This is comment <%= comment_num %> on book <%= book_num %>.
7
- author_id: <%= book_num.even? ? comment_id % 2 : (comment_id % 2) + 2 %>
8
- book_id: <%= book_num %>
9
- approved: <%= comment_num.even? %>
10
- <% comment_id = comment_id + 1 %>
11
- <% end %>
12
- <% end %>
@@ -1,7 +0,0 @@
1
- <% for book_num in 0..999 %>
2
- book_<%= book_num %>:
3
- id: <%= book_num %>
4
- title: Book <%= book_num %>
5
- isbn: 12345-<%= book_num %>-6789
6
- banned: <%= book_num > 600 && book_num < 700 %>
7
- <% end %>
@@ -1,35 +0,0 @@
1
- category_a:
2
- id: 1
3
- name: Category A
4
- status: active
5
-
6
- category_b:
7
- id: 2
8
- name: Category B
9
- status: active
10
-
11
- category_c:
12
- id: 3
13
- name: Category C
14
- status: active
15
-
16
- category_d:
17
- id: 4
18
- name: Category D
19
- status: inactive
20
-
21
- category_e:
22
- id: 5
23
- name: Category E
24
- status: inactive
25
-
26
- category_f:
27
- id: 6
28
- name: Category F
29
- status: inactive
30
-
31
- category_g:
32
- id: 7
33
- name: Category G
34
- status: inactive
35
-
@@ -1,21 +0,0 @@
1
- post_1_dumb_post:
2
- id: 1
3
- post_id: 1
4
- body: what a dumb post
5
- author_id: 1
6
-
7
- post_1_i_liked_it:
8
- id: 2
9
- post_id: 1
10
- body: i liked it
11
- author_id: 2
12
-
13
- post_2_thanks_man:
14
- id: 3
15
- post_id: 2
16
- body: Thanks man. Great post. But what is JR?
17
- author_id: 2
18
-
19
- rogue_comment:
20
- body: Rogue Comment Here
21
- author_id: 3
@@ -1,20 +0,0 @@
1
- post_1_dumb_post_whiny:
2
- comment_id: 1
3
- tag_id: 2
4
-
5
- post_1_dumb_post_short:
6
- comment_id: 1
7
- tag_id: 1
8
-
9
- post_1_i_liked_it_happy:
10
- comment_id: 2
11
- tag_id: 4
12
-
13
- post_1_i_liked_it_short:
14
- comment_id: 2
15
- tag_id: 1
16
-
17
- post_2_thanks_man_jr:
18
- comment_id: 3
19
- tag_id: 5
20
-
@@ -1,4 +0,0 @@
1
- firm1:
2
- type: Firm
3
- name: JSON Consulting Services
4
- address: 456 1st Ave.
@@ -1,9 +0,0 @@
1
- crater1:
2
- code: S56D
3
- description: Very large crater
4
- moon_id: 1
5
-
6
- crater2:
7
- code: A4D3
8
- description: Small crater
9
- moon_id: 1
@@ -1,11 +0,0 @@
1
- xyz_corp:
2
- id: 1
3
- name: XYZ Corporation
4
-
5
- abc_corp:
6
- id: 2
7
- name: ABC Corporation
8
-
9
- asdfg_corp:
10
- id: 3
11
- name: ASDFG Corporation
@@ -1,3 +0,0 @@
1
- document_1:
2
- id: 1
3
- name: Company Brochure
@@ -1,13 +0,0 @@
1
- entry_1:
2
- id: 1
3
- currency_code: USD
4
- employee_id: 3
5
- cost: 12.05
6
- transaction_date: <%= Date.parse('2014-04-15') %>
7
-
8
- entry_2:
9
- id: 2
10
- currency_code: USD
11
- employee_id: 3
12
- cost: 12.06
13
- transaction_date: <%= Date.parse('2014-04-15') %>
@@ -1,11 +0,0 @@
1
- fact_1:
2
- id: 1
3
- spouse_name: Jane Author
4
- bio: First man to run across Antartica.
5
- quality_rating: <%= 23.89/45.6 %>
6
- salary: 47000.56
7
- date_time_joined: 2013-08-07 20:25:00 UTC +00:00
8
- birthday: 1965-06-30
9
- bedtime: 2000-01-01 20:00:00 UTC +00:00
10
- photo: abc
11
- cool: false
@@ -1,3 +0,0 @@
1
- mohawk:
2
- id: 1
3
- style: mohawk
@@ -1,17 +0,0 @@
1
- usd:
2
- code: USD
3
- name: United States Dollar
4
- country_name: United States
5
- minor_unit: cent
6
-
7
- eur:
8
- code: EUR
9
- name: Euro Member Countries
10
- country_name: Euro Member Countries
11
- minor_unit: cent
12
-
13
- cad:
14
- code: CAD
15
- name: Canadian dollar
16
- country_name: Canada
17
- minor_unit: cent
@@ -1,37 +0,0 @@
1
- po_1_li_1:
2
- id: 1
3
- purchase_order_id: 1
4
- part_number: 556324
5
- quantity: 1
6
- item_cost: 45.67
7
-
8
- po_1_li_2:
9
- id: 2
10
- purchase_order_id: 1
11
- part_number: 79324231A
12
- quantity: 3
13
- item_cost: 19.99
14
-
15
- li_3:
16
- id: 3
17
- part_number: 79324231A
18
- quantity: 67
19
- item_cost: 19.99
20
-
21
- li_4:
22
- id: 4
23
- part_number: 5678
24
- quantity: 2
25
- item_cost: 199.99
26
-
27
- li_5:
28
- id: 5
29
- part_number: 5WERT
30
- quantity: 1
31
- item_cost: 299.98
32
-
33
- li_6:
34
- id: 6
35
- part_number: 25washer
36
- quantity: 10
37
- item_cost: 0.98
@@ -1,2 +0,0 @@
1
- make1:
2
- model: A model attribute
@@ -1,6 +0,0 @@
1
- titan:
2
- id: 1
3
- name: Titan
4
- description: Best known of the Saturn moons.
5
- planet_id: 1
6
-
@@ -1,3 +0,0 @@
1
- info:
2
- id: 1
3
- numero_telefone: 1-800-555-1212
@@ -1,7 +0,0 @@
1
- rush_order_flag:
2
- id: 1
3
- name: Rush
4
-
5
- ship_together_order_flag:
6
- id: 2
7
- name: Ship Together
@@ -1,31 +0,0 @@
1
- a:
2
- id: 1
3
- name: Joe Author
4
- email: joe@xyz.fake
5
- date_joined: <%= DateTime.parse('2013-08-07 20:25:00 UTC +00:00') %>
6
- preferences_id: 1
7
-
8
- b:
9
- id: 2
10
- name: Fred Reader
11
- email: fred@xyz.fake
12
- date_joined: <%= DateTime.parse('2013-10-31 20:25:00 UTC +00:00') %>
13
-
14
- c:
15
- id: 3
16
- name: Lazy Author
17
- email: lazy@xyz.fake
18
- date_joined: <%= DateTime.parse('2013-10-31 21:25:00 UTC +00:00') %>
19
-
20
- d:
21
- id: 4
22
- name: Tag Crazy Author
23
- email: taggy@xyz.fake
24
- date_joined: <%= DateTime.parse('2013-11-30 4:20:00 UTC +00:00') %>
25
-
26
- e:
27
- id: 5
28
- name: Wilma Librarian
29
- email: lib@xyz.fake
30
- date_joined: <%= DateTime.parse('2013-11-30 4:20:00 UTC +00:00') %>
31
- book_admin: true
@@ -1,15 +0,0 @@
1
- picture_1:
2
- id: 1
3
- name: enterprise_gizmo.jpg
4
- imageable_id: 1
5
- imageable_type: Product
6
-
7
- picture_2:
8
- id: 2
9
- name: company_brochure.jpg
10
- imageable_id: 1
11
- imageable_type: Document
12
-
13
- picture_3:
14
- id: 3
15
- name: group_photo.jpg
@@ -1,19 +0,0 @@
1
- gas_giant:
2
- id: 1
3
- name: Gas Giant
4
-
5
- planetoid:
6
- id: 2
7
- name: Planetoid
8
-
9
- terrestrial:
10
- id: 3
11
- name: Terrestrial
12
-
13
- sulfuric:
14
- id: 4
15
- name: Sulfuric
16
-
17
- unknown:
18
- id: 5
19
- name: unknown
@@ -1,47 +0,0 @@
1
- saturn:
2
- id: 1
3
- name: Satern
4
- description: Saturn is the sixth planet from the Sun and the second largest planet in the Solar System, after Jupiter.
5
- planet_type_id: 2
6
-
7
- makemake:
8
- id: 2
9
- name: Makemake
10
- description: A small planetoid in the Kuiperbelt.
11
- planet_type_id: 2
12
-
13
- uranus:
14
- id: 3
15
- name: Uranus
16
- description: Insert adolescent jokes here.
17
- planet_type_id: 1
18
-
19
- jupiter:
20
- id: 4
21
- name: Jupiter
22
- description: A gas giant.
23
- planet_type_id: 1
24
-
25
- betax:
26
- id: 5
27
- name: Beta X
28
- description: Newly discovered Planet X
29
- planet_type_id: 5
30
-
31
- betay:
32
- id: 6
33
- name: Beta X
34
- description: Newly discovered Planet Y
35
- planet_type_id: 5
36
-
37
- betaz:
38
- id: 7
39
- name: Beta X
40
- description: Newly discovered Planet Z
41
- planet_type_id: 5
42
-
43
- betaw:
44
- id: 8
45
- name: Beta W
46
- description: Newly discovered Planet W
47
- planet_type_id:
@@ -1,102 +0,0 @@
1
- post_1:
2
- id: 1
3
- title: New post
4
- body: A body!!!
5
- author_id: 1
6
-
7
- post_2:
8
- id: 2
9
- title: JR Solves your serialization woes!
10
- body: Use JR
11
- author_id: 1
12
- section_id: 2
13
-
14
- post_3:
15
- id: 3
16
- title: Update This Later
17
- body: AAAA
18
- author_id: 3
19
-
20
- post_4:
21
- id: 4
22
- title: Delete This Later - Single
23
- body: AAAA
24
- author_id: 3
25
-
26
- post_5:
27
- id: 5
28
- title: Delete This Later - Multiple1
29
- body: AAAA
30
- author_id: 3
31
-
32
- post_6:
33
- id: 6
34
- title: Delete This Later - Multiple2
35
- body: AAAA
36
- author_id: 3
37
-
38
- post_7:
39
- id: 7
40
- title: Delete This Later - Single2
41
- body: AAAA
42
- author_id: 3
43
-
44
- post_8:
45
- id: 8
46
- title: Delete This Later - Multiple2-1
47
- body: AAAA
48
- author_id: 3
49
-
50
- post_9:
51
- id: 9
52
- title: Delete This Later - Multiple2-2
53
- body: AAAA
54
- author_id: 3
55
-
56
- post_10:
57
- id: 10
58
- title: Update This Later - Multiple
59
- body: AAAA
60
- author_id: 3
61
-
62
- post_11:
63
- id: 11
64
- title: JR How To
65
- body: Use JR to write API apps
66
- author_id: 1
67
-
68
- post_12:
69
- id: 12
70
- title: Tagged up post 1
71
- body: AAAA
72
- author_id: 4
73
-
74
- post_13:
75
- id: 13
76
- title: Tagged up post 2
77
- body: BBBB
78
- author_id: 4
79
-
80
- post_14:
81
- id: 14
82
- title: A First Post
83
- body: A First Post!!!!!!!!!
84
- author_id: 3
85
-
86
- post_15:
87
- id: 15
88
- title: AAAA First Post
89
- body: First!!!!!!!!!
90
- author_id: 3
91
-
92
- post_16:
93
- id: 16
94
- title: SDFGH
95
- body: Not First!!!!
96
- author_id: 3
97
-
98
- post_17:
99
- id: 17
100
- title: No Author!!!!!!
101
- body: This post has no Author
102
- author_id: