enterprisifier 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.md +3 -0
  5. data/Rakefile +57 -0
  6. data/VERSION +1 -0
  7. data/lib/enterprisifier.rb +7 -0
  8. data/lib/enterprisifier/code_generation.rb +1 -0
  9. data/lib/enterprisifier/code_generation/code_builder.rb +33 -0
  10. data/lib/enterprisifier/code_generation/code_generator.rb +281 -0
  11. data/lib/enterprisifier/code_generation/generator.rb +102 -0
  12. data/lib/enterprisifier/code_generation/generators/attribute_generator.rb +22 -0
  13. data/lib/enterprisifier/code_generation/generators/choice_generator.rb +12 -0
  14. data/lib/enterprisifier/code_generation/generators/complex_content_generator.rb +12 -0
  15. data/lib/enterprisifier/code_generation/generators/complex_type_generator.rb +12 -0
  16. data/lib/enterprisifier/code_generation/generators/element_generator.rb +28 -0
  17. data/lib/enterprisifier/code_generation/generators/extension_generator.rb +11 -0
  18. data/lib/enterprisifier/code_generation/generators/group_generator.rb +27 -0
  19. data/lib/enterprisifier/code_generation/generators/restriction_generator.rb +11 -0
  20. data/lib/enterprisifier/code_generation/generators/sequence_generator.rb +12 -0
  21. data/lib/enterprisifier/code_generation/generators/simple_content_generator.rb +12 -0
  22. data/lib/enterprisifier/code_generation/generators/simple_type_generator.rb +11 -0
  23. data/lib/enterprisifier/code_generation/generators/union_generator.rb +34 -0
  24. data/lib/enterprisifier/constants.rb +3 -0
  25. data/lib/enterprisifier/logging.rb +5 -0
  26. data/lib/enterprisifier/marshalling.rb +0 -0
  27. data/lib/enterprisifier/marshalling/builder.rb +11 -0
  28. data/lib/enterprisifier/marshalling/instantiatable_element.rb +170 -0
  29. data/lib/enterprisifier/marshalling/namespace.rb +23 -0
  30. data/lib/enterprisifier/marshalling/reification.rb +30 -0
  31. data/lib/enterprisifier/marshalling/schema_composition.rb +170 -0
  32. data/lib/enterprisifier/marshalling/xsd/schema/attribute.rb +48 -0
  33. data/lib/enterprisifier/marshalling/xsd/schema/choice.rb +18 -0
  34. data/lib/enterprisifier/marshalling/xsd/schema/complex_content.rb +18 -0
  35. data/lib/enterprisifier/marshalling/xsd/schema/complex_type.rb +28 -0
  36. data/lib/enterprisifier/marshalling/xsd/schema/element.rb +92 -0
  37. data/lib/enterprisifier/marshalling/xsd/schema/extension.rb +29 -0
  38. data/lib/enterprisifier/marshalling/xsd/schema/group.rb +22 -0
  39. data/lib/enterprisifier/marshalling/xsd/schema/restriction.rb +29 -0
  40. data/lib/enterprisifier/marshalling/xsd/schema/sequence.rb +21 -0
  41. data/lib/enterprisifier/marshalling/xsd/schema/simple_content.rb +18 -0
  42. data/lib/enterprisifier/marshalling/xsd/schema/simple_type.rb +23 -0
  43. data/lib/enterprisifier/marshalling/xsd/schema/union.rb +23 -0
  44. data/lib/enterprisifier/marshalling/xsd/types/boolean.rb +14 -0
  45. data/lib/enterprisifier/marshalling/xsd/types/date.rb +13 -0
  46. data/lib/enterprisifier/marshalling/xsd/types/date_time.rb +13 -0
  47. data/lib/enterprisifier/marshalling/xsd/types/decimal.rb +13 -0
  48. data/lib/enterprisifier/marshalling/xsd/types/string.rb +14 -0
  49. data/lib/enterprisifier/marshalling/xsd/types/time.rb +14 -0
  50. data/lib/enterprisifier/schema.rb +1 -0
  51. data/lib/enterprisifier/schema/base_element.rb +156 -0
  52. data/lib/enterprisifier/schema/element_factory.rb +29 -0
  53. data/lib/enterprisifier/schema/elements/annotation.rb +20 -0
  54. data/lib/enterprisifier/schema/elements/attribute.rb +22 -0
  55. data/lib/enterprisifier/schema/elements/choice.rb +13 -0
  56. data/lib/enterprisifier/schema/elements/complex_content.rb +13 -0
  57. data/lib/enterprisifier/schema/elements/complex_type.rb +13 -0
  58. data/lib/enterprisifier/schema/elements/documentation.rb +12 -0
  59. data/lib/enterprisifier/schema/elements/element.rb +23 -0
  60. data/lib/enterprisifier/schema/elements/enumeration.rb +12 -0
  61. data/lib/enterprisifier/schema/elements/extension.rb +12 -0
  62. data/lib/enterprisifier/schema/elements/fraction_digits.rb +12 -0
  63. data/lib/enterprisifier/schema/elements/group.rb +12 -0
  64. data/lib/enterprisifier/schema/elements/import.rb +28 -0
  65. data/lib/enterprisifier/schema/elements/include.rb +28 -0
  66. data/lib/enterprisifier/schema/elements/max_inclusive.rb +12 -0
  67. data/lib/enterprisifier/schema/elements/min_inclusive.rb +12 -0
  68. data/lib/enterprisifier/schema/elements/pattern.rb +12 -0
  69. data/lib/enterprisifier/schema/elements/restriction.rb +12 -0
  70. data/lib/enterprisifier/schema/elements/schema.rb +71 -0
  71. data/lib/enterprisifier/schema/elements/sequence.rb +12 -0
  72. data/lib/enterprisifier/schema/elements/simple_content.rb +12 -0
  73. data/lib/enterprisifier/schema/elements/simple_type.rb +12 -0
  74. data/lib/enterprisifier/schema/elements/union.rb +17 -0
  75. data/lib/enterprisifier/schema/elements/unknown_element.rb +12 -0
  76. data/lib/enterprisifier/schema/loader.rb +61 -0
  77. data/test/enterprisifier_test.rb +35 -0
  78. data/test/example/e_business_for_media/aaaa/elements/aaaa_message_header.rb +15 -0
  79. data/test/example/e_business_for_media/aaaa/elements/aaaa_values.rb +52 -0
  80. data/test/example/e_business_for_media/aaaa/elements/action.rb +17 -0
  81. data/test/example/e_business_for_media/aaaa/elements/business_object.rb +17 -0
  82. data/test/example/e_business_for_media/aaaa/elements/media.rb +17 -0
  83. data/test/example/e_business_for_media/aaaa/elements/schema_name.rb +17 -0
  84. data/test/example/e_business_for_media/aaaa/elements/schema_version.rb +17 -0
  85. data/test/example/e_business_for_media/aaaa/elements/unique_message_id.rb +19 -0
  86. data/test/example/e_business_for_media/aaaa/types/aaaa_message_type.rb +58 -0
  87. data/test/example/e_business_for_media/aaaa/types/action_string.rb +18 -0
  88. data/test/example/e_business_for_media/aaaa/types/business_object_string.rb +18 -0
  89. data/test/example/e_business_for_media/aaaa/types/guid.rb +20 -0
  90. data/test/example/e_business_for_media/aaaa/types/media_string.rb +19 -0
  91. data/test/example/e_business_for_media/aaaa/types/schema_name_string.rb +18 -0
  92. data/test/example/e_business_for_media/aaaa/types/schema_version_string.rb +18 -0
  93. data/test/example/e_business_for_media/aaaa/types/unique_message_id.rb +18 -0
  94. data/test/example/e_business_for_media/iab/attributes/currency.rb +17 -0
  95. data/test/example/e_business_for_media/iab/attributes/id_owner.rb +19 -0
  96. data/test/example/e_business_for_media/iab/attributes/name.rb +19 -0
  97. data/test/example/e_business_for_media/iab/attributes/prefix.rb +18 -0
  98. data/test/example/e_business_for_media/iab/attributes/primary.rb +33 -0
  99. data/test/example/e_business_for_media/iab/attributes/script.rb +23 -0
  100. data/test/example/e_business_for_media/iab/attributes/sms_enabled.rb +20 -0
  101. data/test/example/e_business_for_media/iab/attributes/type.rb +30 -0
  102. data/test/example/e_business_for_media/iab/attributes/valid_from.rb +18 -0
  103. data/test/example/e_business_for_media/iab/attributes/valid_to.rb +18 -0
  104. data/test/example/e_business_for_media/iab/elements/ad_server.rb +17 -0
  105. data/test/example/e_business_for_media/iab/elements/additional_metrics.rb +16 -0
  106. data/test/example/e_business_for_media/iab/elements/address.rb +16 -0
  107. data/test/example/e_business_for_media/iab/elements/address_line.rb +22 -0
  108. data/test/example/e_business_for_media/iab/elements/advertiser.rb +17 -0
  109. data/test/example/e_business_for_media/iab/elements/affix.rb +53 -0
  110. data/test/example/e_business_for_media/iab/elements/agency.rb +19 -0
  111. data/test/example/e_business_for_media/iab/elements/agency_commission.rb +19 -0
  112. data/test/example/e_business_for_media/iab/elements/alternate_script.rb +147 -0
  113. data/test/example/e_business_for_media/iab/elements/amount.rb +16 -0
  114. data/test/example/e_business_for_media/iab/elements/area_city_code.rb +18 -0
  115. data/test/example/e_business_for_media/iab/elements/attachments.rb +18 -0
  116. data/test/example/e_business_for_media/iab/elements/audience.rb +17 -0
  117. data/test/example/e_business_for_media/iab/elements/background.rb +15 -0
  118. data/test/example/e_business_for_media/iab/elements/basis.rb +26 -0
  119. data/test/example/e_business_for_media/iab/elements/billing_frequency.rb +15 -0
  120. data/test/example/e_business_for_media/iab/elements/billing_info.rb +16 -0
  121. data/test/example/e_business_for_media/iab/elements/billing_notes.rb +16 -0
  122. data/test/example/e_business_for_media/iab/elements/billing_partner.rb +16 -0
  123. data/test/example/e_business_for_media/iab/elements/billing_statistics_source.rb +16 -0
  124. data/test/example/e_business_for_media/iab/elements/brand_name.rb +17 -0
  125. data/test/example/e_business_for_media/iab/elements/budget.rb +16 -0
  126. data/test/example/e_business_for_media/iab/elements/building_number.rb +23 -0
  127. data/test/example/e_business_for_media/iab/elements/campaign_brief.rb +38 -0
  128. data/test/example/e_business_for_media/iab/elements/campaign_reference_id.rb +18 -0
  129. data/test/example/e_business_for_media/iab/elements/campaign_reference_info.rb +16 -0
  130. data/test/example/e_business_for_media/iab/elements/category.rb +16 -0
  131. data/test/example/e_business_for_media/iab/elements/context.rb +17 -0
  132. data/test/example/e_business_for_media/iab/elements/contract_details.rb +17 -0
  133. data/test/example/e_business_for_media/iab/elements/count.rb +16 -0
  134. data/test/example/e_business_for_media/iab/elements/country_code.rb +23 -0
  135. data/test/example/e_business_for_media/iab/elements/created_date.rb +15 -0
  136. data/test/example/e_business_for_media/iab/elements/creating_system.rb +16 -0
  137. data/test/example/e_business_for_media/iab/elements/date.rb +16 -0
  138. data/test/example/e_business_for_media/iab/elements/delivery.rb +17 -0
  139. data/test/example/e_business_for_media/iab/elements/delivery_address.rb +72 -0
  140. data/test/example/e_business_for_media/iab/elements/description.rb +16 -0
  141. data/test/example/e_business_for_media/iab/elements/desired_positioning_notes.rb +16 -0
  142. data/test/example/e_business_for_media/iab/elements/destination_system.rb +16 -0
  143. data/test/example/e_business_for_media/iab/elements/discount.rb +19 -0
  144. data/test/example/e_business_for_media/iab/elements/distribution.rb +15 -0
  145. data/test/example/e_business_for_media/iab/elements/document_id.rb +20 -0
  146. data/test/example/e_business_for_media/iab/elements/document_name.rb +16 -0
  147. data/test/example/e_business_for_media/iab/elements/document_sender.rb +17 -0
  148. data/test/example/e_business_for_media/iab/elements/due_date.rb +15 -0
  149. data/test/example/e_business_for_media/iab/elements/end_date.rb +16 -0
  150. data/test/example/e_business_for_media/iab/elements/extension.rb +17 -0
  151. data/test/example/e_business_for_media/iab/elements/family_name.rb +55 -0
  152. data/test/example/e_business_for_media/iab/elements/fax.rb +16 -0
  153. data/test/example/e_business_for_media/iab/elements/flight_exclusivity_guidelines.rb +16 -0
  154. data/test/example/e_business_for_media/iab/elements/format.rb +16 -0
  155. data/test/example/e_business_for_media/iab/elements/formatted_name.rb +22 -0
  156. data/test/example/e_business_for_media/iab/elements/formatted_number.rb +18 -0
  157. data/test/example/e_business_for_media/iab/elements/geographic_considerations.rb +15 -0
  158. data/test/example/e_business_for_media/iab/elements/given_name.rb +19 -0
  159. data/test/example/e_business_for_media/iab/elements/goal.rb +29 -0
  160. data/test/example/e_business_for_media/iab/elements/gross_cost.rb +16 -0
  161. data/test/example/e_business_for_media/iab/elements/iab_advertiser_info.rb +15 -0
  162. data/test/example/e_business_for_media/iab/elements/iab_billing_info.rb +15 -0
  163. data/test/example/e_business_for_media/iab/elements/iab_message_base.rb +15 -0
  164. data/test/example/e_business_for_media/iab/elements/iab_message_header.rb +17 -0
  165. data/test/example/e_business_for_media/iab/elements/iab_publisher_info.rb +15 -0
  166. data/test/example/e_business_for_media/iab/elements/iab_type_of_contact.rb +17 -0
  167. data/test/example/e_business_for_media/iab/elements/id.rb +17 -0
  168. data/test/example/e_business_for_media/iab/elements/id_value.rb +34 -0
  169. data/test/example/e_business_for_media/iab/elements/in_reference_to.rb +33 -0
  170. data/test/example/e_business_for_media/iab/elements/industry.rb +17 -0
  171. data/test/example/e_business_for_media/iab/elements/instructions.rb +15 -0
  172. data/test/example/e_business_for_media/iab/elements/international_country_code.rb +17 -0
  173. data/test/example/e_business_for_media/iab/elements/internet_email_address.rb +16 -0
  174. data/test/example/e_business_for_media/iab/elements/internet_web_address.rb +17 -0
  175. data/test/example/e_business_for_media/iab/elements/legal_name.rb +19 -0
  176. data/test/example/e_business_for_media/iab/elements/link.rb +16 -0
  177. data/test/example/e_business_for_media/iab/elements/location.rb +17 -0
  178. data/test/example/e_business_for_media/iab/elements/make_good_policy.rb +16 -0
  179. data/test/example/e_business_for_media/iab/elements/middle_name.rb +17 -0
  180. data/test/example/e_business_for_media/iab/elements/mobile.rb +17 -0
  181. data/test/example/e_business_for_media/iab/elements/municipality.rb +17 -0
  182. data/test/example/e_business_for_media/iab/elements/name.rb +16 -0
  183. data/test/example/e_business_for_media/iab/elements/national_number.rb +19 -0
  184. data/test/example/e_business_for_media/iab/elements/net_cost.rb +16 -0
  185. data/test/example/e_business_for_media/iab/elements/non_standard_value.rb +16 -0
  186. data/test/example/e_business_for_media/iab/elements/notes.rb +16 -0
  187. data/test/example/e_business_for_media/iab/elements/order_status.rb +17 -0
  188. data/test/example/e_business_for_media/iab/elements/other_contacts.rb +18 -0
  189. data/test/example/e_business_for_media/iab/elements/other_id.rb +20 -0
  190. data/test/example/e_business_for_media/iab/elements/other_target.rb +17 -0
  191. data/test/example/e_business_for_media/iab/elements/out_clause.rb +16 -0
  192. data/test/example/e_business_for_media/iab/elements/pager.rb +16 -0
  193. data/test/example/e_business_for_media/iab/elements/partner.rb +19 -0
  194. data/test/example/e_business_for_media/iab/elements/payment_terms.rb +16 -0
  195. data/test/example/e_business_for_media/iab/elements/payment_type.rb +15 -0
  196. data/test/example/e_business_for_media/iab/elements/percent.rb +16 -0
  197. data/test/example/e_business_for_media/iab/elements/person_name.rb +16 -0
  198. data/test/example/e_business_for_media/iab/elements/post_office_box.rb +18 -0
  199. data/test/example/e_business_for_media/iab/elements/postal_address.rb +16 -0
  200. data/test/example/e_business_for_media/iab/elements/postal_code.rb +18 -0
  201. data/test/example/e_business_for_media/iab/elements/preferred_given_name.rb +18 -0
  202. data/test/example/e_business_for_media/iab/elements/primary_contact.rb +16 -0
  203. data/test/example/e_business_for_media/iab/elements/primary_id.rb +17 -0
  204. data/test/example/e_business_for_media/iab/elements/primary_success_metric.rb +15 -0
  205. data/test/example/e_business_for_media/iab/elements/product_name.rb +17 -0
  206. data/test/example/e_business_for_media/iab/elements/property_name.rb +16 -0
  207. data/test/example/e_business_for_media/iab/elements/publisher.rb +17 -0
  208. data/test/example/e_business_for_media/iab/elements/referenced_document_id.rb +15 -0
  209. data/test/example/e_business_for_media/iab/elements/referenced_version.rb +22 -0
  210. data/test/example/e_business_for_media/iab/elements/region.rb +21 -0
  211. data/test/example/e_business_for_media/iab/elements/request_for_proposal.rb +16 -0
  212. data/test/example/e_business_for_media/iab/elements/rfp_details.rb +15 -0
  213. data/test/example/e_business_for_media/iab/elements/rfp_response_requirements.rb +15 -0
  214. data/test/example/e_business_for_media/iab/elements/role.rb +31 -0
  215. data/test/example/e_business_for_media/iab/elements/selection_criteria.rb +16 -0
  216. data/test/example/e_business_for_media/iab/elements/sent_date.rb +15 -0
  217. data/test/example/e_business_for_media/iab/elements/standard_value.rb +16 -0
  218. data/test/example/e_business_for_media/iab/elements/start_date.rb +16 -0
  219. data/test/example/e_business_for_media/iab/elements/street_name.rb +21 -0
  220. data/test/example/e_business_for_media/iab/elements/subscriber_number.rb +19 -0
  221. data/test/example/e_business_for_media/iab/elements/target_audience.rb +15 -0
  222. data/test/example/e_business_for_media/iab/elements/targeting.rb +42 -0
  223. data/test/example/e_business_for_media/iab/elements/telephone.rb +16 -0
  224. data/test/example/e_business_for_media/iab/elements/terms_and_conditions.rb +27 -0
  225. data/test/example/e_business_for_media/iab/elements/terms_attachment.rb +15 -0
  226. data/test/example/e_business_for_media/iab/elements/terms_text.rb +15 -0
  227. data/test/example/e_business_for_media/iab/elements/time.rb +17 -0
  228. data/test/example/e_business_for_media/iab/elements/title.rb +17 -0
  229. data/test/example/e_business_for_media/iab/elements/ttytdd.rb +17 -0
  230. data/test/example/e_business_for_media/iab/elements/type.rb +15 -0
  231. data/test/example/e_business_for_media/iab/elements/unit.rb +21 -0
  232. data/test/example/e_business_for_media/iab/elements/use.rb +17 -0
  233. data/test/example/e_business_for_media/iab/elements/value.rb +15 -0
  234. data/test/example/e_business_for_media/iab/elements/version.rb +24 -0
  235. data/test/example/e_business_for_media/iab/elements/when_available.rb +19 -0
  236. data/test/example/e_business_for_media/iab/elements/zero_cost.rb +15 -0
  237. data/test/example/e_business_for_media/iab/groups/telcom_number_group.rb +52 -0
  238. data/test/example/e_business_for_media/iab/types/attachment_type.rb +32 -0
  239. data/test/example/e_business_for_media/iab/types/base_cost.rb +32 -0
  240. data/test/example/e_business_for_media/iab/types/base_target_type.rb +31 -0
  241. data/test/example/e_business_for_media/iab/types/base_unit.rb +27 -0
  242. data/test/example/e_business_for_media/iab/types/campaign_reference_info_type.rb +81 -0
  243. data/test/example/e_business_for_media/iab/types/contact_method_location_pattern_extension_type.rb +22 -0
  244. data/test/example/e_business_for_media/iab/types/contact_method_location_type.rb +24 -0
  245. data/test/example/e_business_for_media/iab/types/contact_method_type.rb +81 -0
  246. data/test/example/e_business_for_media/iab/types/contact_method_use_pattern_extension_type.rb +22 -0
  247. data/test/example/e_business_for_media/iab/types/contact_method_use_type.rb +23 -0
  248. data/test/example/e_business_for_media/iab/types/contact_method_when_available_type.rb +20 -0
  249. data/test/example/e_business_for_media/iab/types/contract_details_type.rb +46 -0
  250. data/test/example/e_business_for_media/iab/types/cost_method_enumeration.rb +29 -0
  251. data/test/example/e_business_for_media/iab/types/cost_method_type.rb +28 -0
  252. data/test/example/e_business_for_media/iab/types/currency_code_type.rb +20 -0
  253. data/test/example/e_business_for_media/iab/types/discount_type.rb +36 -0
  254. data/test/example/e_business_for_media/iab/types/entity_id_type.rb +57 -0
  255. data/test/example/e_business_for_media/iab/types/generic_target_type.rb +31 -0
  256. data/test/example/e_business_for_media/iab/types/iab_advertiser_info_type.rb +38 -0
  257. data/test/example/e_business_for_media/iab/types/iab_billing_info_type.rb +54 -0
  258. data/test/example/e_business_for_media/iab/types/iab_contact_method_type.rb +44 -0
  259. data/test/example/e_business_for_media/iab/types/iab_date_time_type.rb +28 -0
  260. data/test/example/e_business_for_media/iab/types/iab_distribution_enumerated_type.rb +22 -0
  261. data/test/example/e_business_for_media/iab/types/iab_distribution_type.rb +20 -0
  262. data/test/example/e_business_for_media/iab/types/iab_message_base_type.rb +47 -0
  263. data/test/example/e_business_for_media/iab/types/iab_message_header_type.rb +34 -0
  264. data/test/example/e_business_for_media/iab/types/iab_partner_info_type.rb +67 -0
  265. data/test/example/e_business_for_media/iab/types/iab_payment_terms_enumerated_type.rb +23 -0
  266. data/test/example/e_business_for_media/iab/types/iab_payment_terms_type.rb +20 -0
  267. data/test/example/e_business_for_media/iab/types/iab_payment_type_enumerated_type.rb +21 -0
  268. data/test/example/e_business_for_media/iab/types/iab_publisher_info_type.rb +29 -0
  269. data/test/example/e_business_for_media/iab/types/iab_type_of_contact_type.rb +30 -0
  270. data/test/example/e_business_for_media/iab/types/internet_email_address_type.rb +19 -0
  271. data/test/example/e_business_for_media/iab/types/internet_web_address_type.rb +20 -0
  272. data/test/example/e_business_for_media/iab/types/mobile_telcom_number_type.rb +33 -0
  273. data/test/example/e_business_for_media/iab/types/monetary_type.rb +28 -0
  274. data/test/example/e_business_for_media/iab/types/percentage_type.rb +21 -0
  275. data/test/example/e_business_for_media/iab/types/person_name_type.rb +282 -0
  276. data/test/example/e_business_for_media/iab/types/postal_address_type.rb +120 -0
  277. data/test/example/e_business_for_media/iab/types/request_for_proposal_type.rb +35 -0
  278. data/test/example/e_business_for_media/iab/types/rfp_details_type.rb +118 -0
  279. data/test/example/e_business_for_media/iab/types/rfp_response_requirements_type.rb +33 -0
  280. data/test/example/e_business_for_media/iab/types/telcom_number_type.rb +34 -0
  281. data/test/example/e_business_for_media/iab/types/unit_type.rb +28 -0
  282. data/test/example/e_business_for_media/iab/types/unit_type_enumeration.rb +27 -0
  283. data/test/example/e_business_for_media/iab/types/zero_cost_type.rb +29 -0
  284. data/test/example/e_business_for_media/iab/types/zero_cost_type_enumeration.rb +21 -0
  285. data/test/marshalling_test.rb +13 -0
  286. data/test/mocks.rb +10 -0
  287. data/test/teststrap.rb +23 -0
  288. data/test/xsd/AAAA_Common.xsd +76 -0
  289. data/test/xsd/HRXMLlicense.txt +32 -0
  290. data/test/xsd/IAB_Acknowledgement.xsd +181 -0
  291. data/test/xsd/IAB_AdvertiserCommon.xsd +40 -0
  292. data/test/xsd/IAB_BillingCommon.xsd +75 -0
  293. data/test/xsd/IAB_CampaignCommon.xsd +80 -0
  294. data/test/xsd/IAB_Common.xsd +1176 -0
  295. data/test/xsd/IAB_ContractCommon.xsd +54 -0
  296. data/test/xsd/IAB_InsertionOrderCommon.xsd +40 -0
  297. data/test/xsd/IAB_LineItemCommon.xsd +328 -0
  298. data/test/xsd/IAB_MessageCommon.xsd +66 -0
  299. data/test/xsd/IAB_OrderCommon.xsd +98 -0
  300. data/test/xsd/IAB_ProposalCommon.xsd +30 -0
  301. data/test/xsd/IAB_PublisherCommon.xsd +26 -0
  302. data/test/xsd/IAB_RFPCommon.xsd +126 -0
  303. metadata +626 -0
@@ -0,0 +1,170 @@
1
+ require 'enterprisifier/marshalling/namespace'
2
+
3
+ module Enterprisifier
4
+ module Marshalling
5
+ module SchemaComposition
6
+ mattr_accessor :schema_elements
7
+ self.schema_elements = {}
8
+
9
+ def self.included(base)
10
+ super
11
+ base.instance_eval do
12
+ include InstanceMethods
13
+ extend ClassMethods
14
+ end
15
+ self.schema_elements[base.base_name] = base
16
+ end
17
+
18
+ module TypeDefSetting
19
+
20
+ def reify_self
21
+ @type.reify(reified) if @type
22
+ end
23
+
24
+ private
25
+ #
26
+ # @todo - this shit sucks bad
27
+ def set_type_def(type_def)
28
+ if type_def.is_a?(String)
29
+ @name = type_def
30
+ type_or_ref = nil
31
+ elsif type_def.is_a?(Hash)
32
+ @name = type_def.keys.first
33
+ type_or_ref = type_def.values.last
34
+ else
35
+ type_or_ref = type_def
36
+ end
37
+
38
+ if type_or_ref && type_or_ref.respond_to?(:is_referable?) && type_or_ref.is_referable?
39
+ @reference = type_or_ref
40
+ elsif type_or_ref
41
+ @type = type_or_ref
42
+ end
43
+ end
44
+
45
+ end # InstanceMethods
46
+
47
+ module InstanceMethods
48
+
49
+ def initialize(*args)
50
+ yield(self) if block_given?
51
+ end
52
+
53
+ def namespace
54
+ if @parent
55
+ @parent.namespace
56
+ else
57
+ self.class.namespace
58
+ end
59
+ end
60
+
61
+ def evaluate(block)
62
+ instance_eval(&block) if block
63
+ end
64
+
65
+ def reify(reifiable)
66
+ composition.each do |comp|
67
+ Array(instance_variable_get("@#{comp.to_s.underscore.pluralize}")).each {|c| c.reify(reifiable) }
68
+ end
69
+ end
70
+
71
+ def definition_changed(change_name, def_i)
72
+ return nil unless respond_to?(:reified, true)
73
+ def_i.reify(reified)
74
+ end
75
+
76
+ end # InstanceMethods
77
+
78
+ module ClassMethods
79
+
80
+ def self.extended(base)
81
+ base.class_eval <<-EOM
82
+ attr_accessor :parent
83
+ class_inheritable_accessor :instance
84
+ class_inheritable_array :composition
85
+ write_inheritable_array :composition, []
86
+
87
+ class << self
88
+ private :new
89
+ delegate :reify, :to => :instance
90
+ end
91
+
92
+ def self.#{base.base_name.to_s.underscore}(*args, &block)
93
+ self.instance = build(*args, &block)
94
+ end
95
+ EOM
96
+ end
97
+
98
+ def is_referable?
99
+ false
100
+ end
101
+
102
+ def build(*args, &block)
103
+ new(*args).tap do |i|
104
+ i.evaluate(block)
105
+ i.reify_self if i.respond_to?(:reify_self, true)
106
+ end
107
+ end
108
+
109
+ def build_with_parent(parent, *args, &block)
110
+ new(*args) do |i|
111
+ i.parent = parent
112
+ i
113
+ end.tap do |i|
114
+ i.evaluate(block)
115
+ i.reify_self if i.respond_to?(:reify_self, true)
116
+ end
117
+ end
118
+
119
+ def base_name
120
+ name.demodulize.to_sym
121
+ end
122
+
123
+ def namespace(ns_settings = nil)
124
+ if ns_settings
125
+ @namespace = Enterprisifier::Marshalling::Namespace.new(*(ns_settings.to_a.first))
126
+ else
127
+ @namespace
128
+ end
129
+ end
130
+
131
+ def macros(*args)
132
+ options = args.extract_options!
133
+ args.each do |m|
134
+ class_eval <<-EOM
135
+ def #{m}(val = nil)
136
+ return @#{m} unless val
137
+ #{if options[:allow_multiple]
138
+ "(@#{m.to_s.pluralize} ||= []) << val"
139
+ else
140
+ "@#{m.to_s.pluralize} = val"
141
+ end}
142
+ end
143
+ EOM
144
+ end
145
+ end
146
+
147
+ def composed_of(*schema_elements)
148
+ write_inheritable_array :composition, schema_elements
149
+ schema_elements.each do |se|
150
+ class_eval <<-EOM
151
+ attr_accessor #{se.to_s.underscore.pluralize.inspect}
152
+
153
+ def #{se.to_s.underscore}(*args, &block)
154
+ builder = ::Enterprisifier::Marshalling::SchemaComposition.schema_elements[#{se.inspect}]
155
+ builder.build_with_parent(self, *args, &block).tap do |def_i|
156
+ (self.#{se.to_s.underscore.pluralize} ||= []) << def_i
157
+ definition_changed(#{se.to_s.underscore.to_sym.inspect}, def_i) if respond_to?(:definition_changed, true)
158
+ end
159
+ end
160
+
161
+ class << self
162
+ delegate #{se.to_s.underscore.inspect}, :to => :instance
163
+ end
164
+ EOM
165
+ end
166
+ end
167
+ end # ClassMethods
168
+ end # SchemaComposition
169
+ end # Marshalling
170
+ end # Enterprisifier
@@ -0,0 +1,48 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/simple_type'
3
+
4
+ module Enterprisifier
5
+ module Marshalling
6
+ module XSD
7
+ module Schema
8
+ class Attribute
9
+ include Enterprisifier::Marshalling::SchemaComposition
10
+ include Enterprisifier::Marshalling::SchemaComposition::TypeDefSetting
11
+ composed_of :SimpleType
12
+ macros :default, :fixed, :form, :use
13
+ attr_reader :name
14
+
15
+ class InstantiatableAttribute
16
+ delegate :attribute_name, :to => "self.class"
17
+ delegate :attribute_namespace, :to => "self.class"
18
+ class << self
19
+ attr_accessor :attribute_name, :attribute_namespace
20
+ end
21
+
22
+ end # InstantiatableAttribute
23
+
24
+ def initialize(type_def = nil)
25
+ super
26
+ set_type_def(type_def)
27
+ end
28
+
29
+ def reify(reifiable)
30
+ super
31
+ reifiable.has_attribute(namespace, name, reified)
32
+ end
33
+
34
+ #
35
+ # @todo - uuuugly
36
+ def reified
37
+ return @reference.reified if @reference && @reference.respond_to?(:reified)
38
+ @reified ||= Class.new(InstantiatableAttribute).tap do |inst|
39
+ inst.attribute_name = name
40
+ inst.attribute_namespace = namespace
41
+ end
42
+ end
43
+
44
+ end # Attribute
45
+ end # Schema
46
+ end # XSD
47
+ end # Marshalling
48
+ end # Enterprisifier
@@ -0,0 +1,18 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/element'
3
+ require 'enterprisifier/marshalling/xsd/schema/group'
4
+ require 'enterprisifier/marshalling/xsd/schema/sequence'
5
+
6
+ module Enterprisifier
7
+ module Marshalling
8
+ module XSD
9
+ module Schema
10
+ class Choice
11
+ include Enterprisifier::Marshalling::SchemaComposition
12
+ composed_of :Element, :Group, :Choice, :Sequence
13
+
14
+ end # Choice
15
+ end # Schema
16
+ end # XSD
17
+ end # Marshalling
18
+ end # Enterprisifier
@@ -0,0 +1,18 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/restriction'
3
+ require 'enterprisifier/marshalling/xsd/schema/extension'
4
+
5
+ module Enterprisifier
6
+ module Marshalling
7
+ module XSD
8
+ module Schema
9
+ class ComplexContent
10
+ include Enterprisifier::Marshalling::SchemaComposition
11
+ composed_of :Restriction, :Extension
12
+ macros :mixed
13
+
14
+ end # ComplexContent
15
+ end # Schema
16
+ end # XSD
17
+ end # Marshalling
18
+ end # Enterprisifier
@@ -0,0 +1,28 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/simple_content'
3
+ require 'enterprisifier/marshalling/xsd/schema/complex_content'
4
+ require 'enterprisifier/marshalling/xsd/schema/group'
5
+ require 'enterprisifier/marshalling/xsd/schema/choice'
6
+ require 'enterprisifier/marshalling/xsd/schema/sequence'
7
+ require 'enterprisifier/marshalling/xsd/schema/attribute'
8
+
9
+ module Enterprisifier
10
+ module Marshalling
11
+ module XSD
12
+ module Schema
13
+ class ComplexType
14
+ include Enterprisifier::Marshalling::SchemaComposition
15
+ composed_of :SimpleContent, :ComplexContent, :Group, :Choice, :Sequence, :Attribute
16
+ macros :abstract, :mixed, :block, :final
17
+ attr_reader :name
18
+
19
+ def initialize(name = nil)
20
+ super
21
+ @name = name
22
+ end
23
+
24
+ end # ComplexType
25
+ end # Schema
26
+ end # XSD
27
+ end # Marshalling
28
+ end # Enterprisifier
@@ -0,0 +1,92 @@
1
+ require 'enterprisifier/marshalling/builder'
2
+ require 'enterprisifier/marshalling/instantiatable_element'
3
+ require 'enterprisifier/marshalling/schema_composition'
4
+ require 'enterprisifier/marshalling/xsd/schema/simple_type'
5
+ require 'enterprisifier/marshalling/xsd/schema/complex_type'
6
+ require 'observer'
7
+
8
+ module Enterprisifier
9
+ module Marshalling
10
+ module XSD
11
+ module Schema
12
+ class Element
13
+ include Enterprisifier::Marshalling::SchemaComposition
14
+ include Enterprisifier::Marshalling::SchemaComposition::TypeDefSetting
15
+
16
+ composed_of :SimpleType, :ComplexType
17
+ macros :max_occurs, :min_occurs
18
+ attr_reader :name
19
+ class << self
20
+ delegate :create, :reified, :to => :instance
21
+
22
+ def is_referable?
23
+ true
24
+ end
25
+
26
+ def implementation(&block)
27
+ if block_given?
28
+ reified.class_eval(&block)
29
+ else
30
+ reified
31
+ end
32
+ end
33
+ end # << self
34
+
35
+ def initialize(type_def = nil)
36
+ super
37
+ set_type_def(type_def)
38
+ end
39
+
40
+ def reference?
41
+ !!@reference
42
+ end
43
+
44
+ def reify(reifiable)
45
+ super
46
+ return @reference.reify(reifiable) if reference?
47
+ many? ? reify_many(reifiable) : reify_one(reifiable)
48
+ end
49
+
50
+ def create(*args, &block)
51
+ reified.create(*args, &block)
52
+ end
53
+
54
+ #
55
+ # @todo - uuuugly
56
+ def reified
57
+ return @reference.reified if reference? && @reference.respond_to?(:reified)
58
+ @reified ||= Class.new(InstantiatableElement).tap do |inst|
59
+ inst.element_name = name
60
+ inst.element_namespace = namespace
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def reify_many(reifiable)
67
+ reifiable.has_many(pluralized, self.reified)
68
+ end
69
+
70
+ def reify_one(reifiable)
71
+ reifiable.has_one(singularized, self.reified)
72
+ end
73
+
74
+ def many?
75
+ (max_occurs == "unbounded") || (max_occurs && max_occurs.to_i > 1)
76
+ end
77
+
78
+ def pluralized
79
+ name.to_s.underscore.pluralize
80
+ end
81
+
82
+ #
83
+ # @todo - singularizing breaks for a lot of things, just assume here
84
+ def singularized
85
+ name.to_s.underscore
86
+ end
87
+
88
+ end # Element
89
+ end # Schema
90
+ end # XSD
91
+ end # Marshalling
92
+ end # Enterprisifier
@@ -0,0 +1,29 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/group'
3
+ require 'enterprisifier/marshalling/xsd/schema/choice'
4
+ require 'enterprisifier/marshalling/xsd/schema/sequence'
5
+ require 'enterprisifier/marshalling/xsd/schema/attribute'
6
+
7
+ module Enterprisifier
8
+ module Marshalling
9
+ module XSD
10
+ module Schema
11
+ class Extension
12
+ include Enterprisifier::Marshalling::SchemaComposition
13
+ composed_of :Group, :Choice, :Sequence, :Attribute
14
+
15
+ def initialize(base)
16
+ super
17
+ @base = base
18
+ end
19
+
20
+ def reify(reifiable)
21
+ super
22
+ @base.reify(reifiable)
23
+ end
24
+
25
+ end # Extension
26
+ end # Schema
27
+ end # XSD
28
+ end # Marshalling
29
+ end # Enterprisifier
@@ -0,0 +1,22 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/choice'
3
+ require 'enterprisifier/marshalling/xsd/schema/sequence'
4
+
5
+ module Enterprisifier
6
+ module Marshalling
7
+ module XSD
8
+ module Schema
9
+ class Group
10
+ include Enterprisifier::Marshalling::SchemaComposition
11
+ composed_of :Choice, :Sequence
12
+ macros :ref
13
+
14
+ def initialize(type_def = nil)
15
+ super
16
+ @type_def = type_def
17
+ end
18
+ end # Group
19
+ end # Schema
20
+ end # XSD
21
+ end # Marshalling
22
+ end # Enterprisifier
@@ -0,0 +1,29 @@
1
+ require 'enterprisifier/marshalling/schema_composition'
2
+ require 'enterprisifier/marshalling/xsd/schema/simple_type'
3
+ require 'enterprisifier/marshalling/xsd/schema/attribute'
4
+ require 'enterprisifier/marshalling/xsd/schema/group'
5
+ require 'enterprisifier/marshalling/xsd/schema/choice'
6
+ require 'enterprisifier/marshalling/xsd/schema/sequence'
7
+
8
+ module Enterprisifier
9
+ module Marshalling
10
+ module XSD
11
+ module Schema
12
+ class Restriction
13
+ include Enterprisifier::Marshalling::SchemaComposition
14
+ composed_of :SimpleType, :Attribute, :Group, :Choice, :Sequence
15
+ macros :enumeration, :fraction_digits, :length, :max_exclusive, :max_inclusive, :max_length,
16
+ :min_exclusive, :min_inclusive, :min_length, :pattern, :total_digits, :white_space,
17
+ :allow_multiple => true
18
+ attr_reader :base
19
+
20
+ def initialize(base)
21
+ super
22
+ @base = base
23
+ end
24
+
25
+ end # Restriction
26
+ end # Schema
27
+ end # XSD
28
+ end # Marshalling
29
+ end # Enterprisifier