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,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ output/*
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 gabrielg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = enterprisifier
2
+
3
+ THIS ISN'T READY TO USE YET DON'T USE IT.
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "enterprisifier"
8
+ gem.summary = %Q{Makes things enterprisey.}
9
+ gem.description = %Q{ENTERPRISE}
10
+ gem.email = "gabriel.gironda@gmail.com"
11
+ gem.homepage = "http://github.com/gabrielg/enterprisifier"
12
+ gem.authors = ["gabrielg"]
13
+ gem.add_dependency "nokogiri"
14
+ gem.add_dependency "activesupport"
15
+ gem.add_development_dependency "riot", ">= 0"
16
+ gem.add_development_dependency "yard", ">= 0"
17
+ gem.add_development_dependency "ruby-debug", ">= 0"
18
+ gem.add_development_dependency "faker", ">= 0"
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
+ end
25
+
26
+ require 'rake/testtask'
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << 'lib' << 'test'
29
+ test.pattern = 'test/**/*_test.rb'
30
+ test.verbose = true
31
+ end
32
+
33
+ begin
34
+ require 'rcov/rcovtask'
35
+ Rcov::RcovTask.new do |test|
36
+ test.libs << 'test'
37
+ test.pattern = 'test/**/*_test.rb'
38
+ test.verbose = true
39
+ end
40
+ rescue LoadError
41
+ task :rcov do
42
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
43
+ end
44
+ end
45
+
46
+ task :test => :check_dependencies
47
+
48
+ task :default => :test
49
+
50
+ begin
51
+ require 'yard'
52
+ YARD::Rake::YardocTask.new
53
+ rescue LoadError
54
+ task :yardoc do
55
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
56
+ end
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,7 @@
1
+ require 'nokogiri'
2
+ require 'active_support'
3
+ require 'enterprisifier/constants'
4
+ require 'enterprisifier/logging'
5
+ require 'enterprisifier/schema'
6
+ require 'enterprisifier/code_generation'
7
+ require 'enterprisifier/marshalling'
@@ -0,0 +1 @@
1
+ require 'enterprisifier/code_generation/generator'
@@ -0,0 +1,33 @@
1
+ module Enterprisifier
2
+ module CodeGeneration
3
+ class CodeBuilder
4
+ IndentationLevel = 2
5
+ def initialize(indentation = 0)
6
+ @code = ''
7
+ @indentation = indentation
8
+ end
9
+
10
+ def <<(string)
11
+ string.to_s.each_line do |line|
12
+ @code << "#{" " * @indentation}#{line.chomp}\n"
13
+ end
14
+ end
15
+
16
+ def indent
17
+ @indentation += IndentationLevel
18
+ yield
19
+ ensure
20
+ @indentation -= IndentationLevel
21
+ end
22
+
23
+ def to_s
24
+ @code
25
+ end
26
+
27
+ def blank?
28
+ @code.blank?
29
+ end
30
+
31
+ end # CodeBuilder
32
+ end # CodeGeneration
33
+ end # CodeBuilder
@@ -0,0 +1,281 @@
1
+ require 'enterprisifier/code_generation/code_builder'
2
+
3
+ #
4
+ # @todo - this fucking sucks too
5
+ module Enterprisifier
6
+ module CodeGeneration
7
+ class CodeGenerator
8
+ FacetElements = %w[enumeration fractionDigits length maxExclusive maxInclusive maxLength
9
+ minExclusive minInclusive minLength pattern totalDigits whiteSpace]
10
+
11
+ attr_reader :dependencies
12
+
13
+ class_inheritable_hash :registered_types
14
+ write_inheritable_hash :registered_types, {}
15
+
16
+ class_inheritable_accessor :registered_as
17
+ class_inheritable_accessor :extension_type
18
+
19
+ class_inheritable_hash :registration_options
20
+ write_inheritable_hash :registration_options, {}
21
+
22
+ write_inheritable_array :macro_mappings, []
23
+
24
+ class << self
25
+
26
+ def extends(extension_type)
27
+ self.extension_type = extension_type
28
+ end
29
+
30
+ def register(xsd_type, opts = {})
31
+ self.registered_as = xsd_type.to_sym
32
+ write_inheritable_hash(:registration_options, opts)
33
+ CodeGenerator.registered_types[xsd_type.to_sym] = self
34
+ end
35
+
36
+ def macro_mappings(*mappings)
37
+ write_inheritable_array :macro_mappings, mappings
38
+ end
39
+
40
+ def build(generator, node, mod_name, entity_name = nil)
41
+ if code_generator = CodeGenerator.registered_types[node.registered_as.to_sym]
42
+ code_generator.new(generator, node, mod_name, entity_name)
43
+ else
44
+ raise NotImplementedError, "No generator for '#{node.registered_as}' found."
45
+ end
46
+ end
47
+ end # << self
48
+
49
+ attr_reader :entity_name
50
+
51
+ def initialize(generator, node, mod_name = nil, entity_name = nil)
52
+ @generator = generator
53
+ @base_mod, @mod_name, @entity_name, @node = generator.base_module, mod_name, entity_name, node
54
+ @dependencies = []
55
+ @built = false
56
+ @code = CodeBuilder.new
57
+ end
58
+
59
+ def name
60
+ @node.name
61
+ end
62
+
63
+ def entity_or_attr_name
64
+ entity_name || begin
65
+ name ? name[:value] : nil
66
+ end
67
+ end
68
+
69
+ def to_s
70
+ to_ruby.to_s
71
+ end
72
+
73
+ def to_ruby
74
+ return @code.to_s if @built
75
+ entity_name ? build_qualified_ruby : build_unqualified_ruby
76
+ @built = true
77
+ @code.to_s
78
+ end
79
+
80
+ def requires
81
+ @requires ||= ([extension_require, macro_reference_require] + child_generators.map(&:requires)).flatten.compact.uniq.sort
82
+ end
83
+
84
+ def extension_require
85
+ extension_type.split("::").map(&:underscore).join("/")
86
+ end
87
+
88
+ def macro_reference_require
89
+ return nil unless macro_reference_type
90
+ macro_reference_type.split("::").map(&:underscore).join("/")
91
+ end
92
+
93
+ def write_file
94
+ return nil unless filesystem_path
95
+ @generator.write_file(filesystem_path, to_ruby)
96
+ end
97
+
98
+ private
99
+
100
+ def parent_ns
101
+ registration_options[:in] || (registration_options[:namespace] ? registered_as.to_s.gsub(/[^a-z0-9]/i, "_").camelize.pluralize : nil)
102
+ end
103
+
104
+ def build_qualified_ruby
105
+ write_requires
106
+ namespaced(parent_ns) do
107
+ comment(@node.documentation)
108
+ new_class(constantized_name, extension_type) { write_full_implementation }
109
+ end
110
+ end
111
+
112
+ def build_unqualified_ruby
113
+ comment(@node.documentation)
114
+ write_partial_implementation
115
+ end
116
+
117
+ def child_generators
118
+ @child_generators ||= begin
119
+ [].tap do |a|
120
+ @node.each_child(true) do |child|
121
+ next if facet_element?(child)
122
+ a << @generator.code_generator.build(@generator, child, @mod_name)
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ def facet_element?(node)
129
+ FacetElements.include?(node.registered_as.to_s)
130
+ end
131
+
132
+ def filesystem_path
133
+ return nil unless module_path
134
+ module_path.split("::").map(&:underscore).join("/")
135
+ end
136
+
137
+ def module_path
138
+ return nil unless constantized_name && @base_mod && @mod_name && parent_ns
139
+ [@base_mod, @mod_name, parent_ns, constantized_name].compact.join("::")
140
+ end
141
+
142
+ def constantized_name
143
+ return nil unless entity_name
144
+ @constantized_name ||= entity_name.gsub(/[^a-z0-9]/i, "_").camelize
145
+ end
146
+
147
+ def namespaced(*extra_mods)
148
+ new_module(*([@base_mod, @mod_name, *extra_mods].compact)) { yield }
149
+ end
150
+
151
+ def new_module(*mod_names, &block)
152
+ if mod_names.empty?
153
+ block.call
154
+ else
155
+ write("module #{mod_names[0]}", "end") { new_module(*mod_names[1..-1], &block) }
156
+ end
157
+ end
158
+
159
+ def new_class(class_name, extends = nil)
160
+ class_def = "class #{class_name}"
161
+ class_def << " < #{extends}" if extends
162
+ write(class_def, "end") { yield if block_given? }
163
+ end
164
+
165
+ def write_full_implementation
166
+ write_namespace
167
+ write_macros
168
+ write_children
169
+ end
170
+
171
+ def write_partial_implementation
172
+ if child_generators.empty?
173
+ write_macros
174
+ else
175
+ write_macros { write_children }
176
+ end
177
+ end
178
+
179
+ def write_requires
180
+ requires.each do |req|
181
+ write("require #{req.inspect}")
182
+ end
183
+ write("\n\n")
184
+ end
185
+
186
+ def write_namespace
187
+ write("namespace #{@mod_name.underscore.inspect} => #{@node.default_namespace.inspect}")
188
+ end
189
+
190
+ def write_macros
191
+ if macros.empty? && !block_given?
192
+ write("#{macro_setup_code}\n\n")
193
+ else
194
+ write("#{macro_setup_code} do", "end") do
195
+ macros.each { |(k,v)| write("#{k} #{v}") }
196
+ yield if block_given?
197
+ end
198
+ end
199
+ end
200
+
201
+ def macro_setup_code
202
+ if entity_or_attr_name && macro_reference_type
203
+ "#{macro_setup_name} #{entity_or_attr_name.inspect} => #{macro_reference_type}"
204
+ elsif entity_or_attr_name
205
+ "#{macro_setup_name} #{entity_or_attr_name.inspect}"
206
+ elsif macro_reference_type
207
+ "#{macro_setup_name} #{macro_reference_type}"
208
+ else
209
+ macro_setup_name
210
+ end
211
+ end
212
+
213
+ def macro_setup_name
214
+ registered_as.to_s.underscore
215
+ end
216
+
217
+ def macro_reference_type
218
+ if @node.base
219
+ @generator.modularize_type(@node.base, @mod_name, "Types")
220
+ else
221
+ nil
222
+ end
223
+ end
224
+
225
+ def write_children
226
+ child_generators.each { |child_gen| write(child_gen.to_ruby) }
227
+ end
228
+
229
+ def macros
230
+ @macros ||= attribute_macros + facet_macros
231
+ end
232
+
233
+ def attribute_macros
234
+ @attribute_macros ||= [].tap do |m|
235
+ self.class.read_inheritable_attribute(:macro_mappings).each do |mm|
236
+ m << [mm, @node.send(mm).inspect] if @node.send(mm)
237
+ end
238
+ end
239
+ end
240
+
241
+ def facet_macros
242
+ @facet_macros ||= [].tap do |m|
243
+ @node.each_child(true) do |child|
244
+ next unless facet_element?(child)
245
+ m << [child.registered_as.to_s.underscore, child.value.inspect]
246
+ end
247
+ end
248
+ end
249
+
250
+ def indent
251
+ @code.indent { yield }
252
+ end
253
+
254
+ def write(string, end_string = nil)
255
+ if block_given? && end_string
256
+ write(string)
257
+ indent { yield }
258
+ write(end_string)
259
+ else
260
+ @code << string
261
+ end
262
+ end
263
+
264
+ def comment(docs)
265
+ return nil unless docs
266
+ wrap_text(docs).each_line do |line|
267
+ next if line.blank?
268
+ write("# #{line.strip}")
269
+ end
270
+ end
271
+
272
+ # http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
273
+ def wrap_text(txt, col = 80)
274
+ txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n")
275
+ end
276
+
277
+ end # CodeBuilder
278
+ end # CodeGeneration
279
+ end # CodeBuilder
280
+
281
+ Dir["#{File.dirname(__FILE__)}/generators/*.rb"].each { |f| require f }
@@ -0,0 +1,102 @@
1
+ require 'enterprisifier/code_generation/code_generator'
2
+ require 'pathname'
3
+
4
+ module Enterprisifier
5
+ module CodeGeneration
6
+ class Generator
7
+ attr_accessor :base_module, :output_directory
8
+
9
+ def initialize(schema)
10
+ @schema = schema
11
+ @modules_for_namespaces = {}
12
+ @generated = []
13
+ yield(self)
14
+ self.output_directory = Pathname(output_directory.to_s).expand_path if output_directory
15
+ end
16
+
17
+ def add_module_for_namespace(namespace, mod_name)
18
+ @modules_for_namespaces[namespace] = mod_name
19
+ end
20
+
21
+ def module_for_namespace(namespace)
22
+ @modules_for_namespaces[namespace]
23
+ end
24
+
25
+ def to_ruby
26
+ build
27
+ @generated.to_s
28
+ end
29
+
30
+ def build
31
+ @generated.clear
32
+ @schema.registries.each do |namespace,registry|
33
+ mod_name = module_for_namespace(namespace)
34
+ raise "No module for namespace '#{namespace}' is known. Try setting one with add_module_for_namespace." unless mod_name
35
+ registry.each do |xsd_type,nodes|
36
+ nodes.each do |name,node|
37
+ @generated << code_generator.build(self, node, mod_name, name)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def write_files
44
+ raise "An output directory must be provided" unless output_directory
45
+ build
46
+ output_directory.mkpath
47
+ @generated.each { |g| g.write_file }
48
+ end
49
+
50
+ def write_file(fs_path, code)
51
+ raise "An output directory must be provided" unless output_directory
52
+ output_file = Pathname((output_directory + fs_path).expand_path.to_s + ".rb")
53
+ output_file.parent.mkpath
54
+ raise "Output file already exists at #{output_file}" if output_file.exist?
55
+ output_file.open('w') do |f|
56
+ f << code
57
+ end
58
+ end
59
+
60
+ #
61
+ # @todo - this fucking sucks
62
+ def resolve_type(type_name)
63
+ found_ns = @schema.namespaces.detect do |ns|
64
+ ns[0] == type_name[:namespace]
65
+ end
66
+
67
+ ns_aliases = @schema.namespaces.select do |ns|
68
+ ns != found_ns && ns.last == found_ns.last
69
+ end if found_ns
70
+
71
+ mod_for_ns = @modules_for_namespaces.detect do |(url, mod_name)|
72
+ url == found_ns.last
73
+ end unless ns_aliases.empty?
74
+
75
+ raise "Couldn't resolve #{type_name.inspect}" unless mod_for_ns
76
+ mod_for_ns.last
77
+ end
78
+
79
+ def xsd_namespace?(namespace_ref)
80
+ @schema.xsd_namespace?(namespace_ref)
81
+ end
82
+
83
+ def code_generator
84
+ Enterprisifier::CodeGeneration::CodeGenerator
85
+ end
86
+
87
+ def modularize_type(type_name, mod_name, type_ns = "Types")
88
+ camelized = type_name[:value].camelize
89
+ if xsd_namespace?(type_name[:namespace])
90
+ "Enterprisifier::Marshalling::XSD::#{type_ns}::#{camelized}"
91
+ elsif !type_name[:namespace] || mod_name == resolve_type(type_name)
92
+ "#{@base_module}::#{mod_name}::#{type_ns}::#{camelized}"
93
+ elsif type_name[:namespace] && resolved = resolve_type(type_name)
94
+ "#{@base_module}::#{resolved}::#{type_ns}::#{camelized}"
95
+ else
96
+ raise "Wuh-oh."
97
+ end
98
+ end
99
+
100
+ end # Generator
101
+ end # CodeGeneration
102
+ end # Enterprisifier