Module: Elibri::XmlMocks::Examples

Extended by:
Examples, Mocha::API
Included in:
Examples
Defined in:
lib/elibri_onix_mocks/mocks/xml_mocks.rb

Overview

Przykładowe produkty dla generatora XML. Są to sztuczne twory (nie ma sensu tworzyć rekordów w bazie). Mają tylko służyć jako model, z którego można utworzyć jak najwięcej tagów z subsetu ONIX wykorzystywanego w Elibri. TODO: Czy to jest dobre miejsce na coś takiego?

Instance Method Summary collapse

Instance Method Details

#authorship_kind_mock(options = {}) ⇒ Object



681
682
683
684
685
686
687
688
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 681

def authorship_kind_mock(options = {})
  attributes = {
    :user_given? => true,
    :collective? => false,
    :no_contributor? => false
  }.merge(options)
  stub('AuthorshipKind', attributes)
end

#basic_product(options = {}) ⇒ Object

Najprostszy produkt, dla którego XML się waliduje przez RelaxNG



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 52

def basic_product(options = {})
  attributes = {
    :title => "Nielegalni",
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
    :ean => nil,
    :isbn_value => '9788324799992',
    :record_reference => "fdb8fa072be774d97a97",
    :publisher => stub("Pulisher", :id => 10, :name => "Wydawnictwo Nowe", :city => "Warszawa")
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("basic_product", attributes).extend(OnixHelpers::InstanceMethods)
end

#book_example(options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 66

def book_example(options = {})
  attributes = {
    :state => "published",
    :public? => true,
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
    :cover_type_id => Elibri::XmlMocks::PAPERBACK,
    :publishing_status_onix_code => Elibri::ONIX::Dict::Release_3_0::PublishingStatusCode::ACTIVE,
    :publication_year => 2011,
    :publication_month => 2,
    :publication_day => 10,
    :publisher_symbol => "W pustyni i w puszczy",
    :record_reference => "fdb8fa072be774d97a97",
    :imprint => stub('Imprint', :name => 'National Geographic'),
    :publisher_name => 'GREG',
    :publisher_id => 11,
    :publisher => stub("Publisher", :id => 11, :name => "GREG", :city => "Warszawa"),
    :ean => '9788324788882',
    :isbn_value => '9788324799992',
    :pack_quantity => 7,
    :price_printed_on_product_onix_code => Elibri::ONIX::Dict::Release_3_0::PricePrintedOnProduct::YES,
    :width => 125,
    :height => 195,
    :thickness => 20,
    :weight => 90,
    :number_of_pages => 250,
    :number_of_illustrations => 32,
    :kind_of_book? => true,
    :kind_of_ebook? => true,
    :digital? => true,
    :kind_of_audio? => true,
    :kind_of_map? => true,
    :kind_of_measurable? => true,
    #:map_scale => '20000',
    :elibri_product_category1_id => 1110,
    :elibri_product_category2_id => 491,
    :elibri_product_categories => [],
    :deletion_text => 'Rekord miał sporo błędów',
    :sale_restricted? => true,
    :sale_restricted_for => 'sklep.gildia.pl',
    :sale_restricted_to =>  Date.new(2012, 7, 22),
    :audience_age_from => 7,
    :audience_age_to => 25,
    # Trochę oszukujemy, żeby w XML`u pokazać wszystkie 3 opcje:
    :authorship_kind => stub('AuthorshipKind', :user_given? => true, :collective? => false, :no_contributor? => false),
    :contributors => [
      stub('Contributor',
        :artificial_id => 257,
        :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::TRANSLATOR,
        :language_onix_code => 'pol',
        :title => 'prof.',
        :name => 'Henryk',
        :last_name_prefix => 'von',
        :last_name => 'Sienkiewicz',
        :last_name_postfix => 'Ibrahim',
        :biography => stub('OtherText', :text => 'Biografia Sienkiewicza', :exportable? => true, :is_a_review? => false, :resource_link => 'http://example').extend(MockMethodMissing),
        :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
      ).extend(MockMethodMissing)
    ],
    :original_title => "Tytuł oryginalny",
    :trade_title => "Tytuł handlowy",
    :vat => 5,
    :pkwiu => "58.11.1",
    :price_amount => 12.99,
    :collection_part => 'Tom 1',
    :title => 'Tytuł',
    :subtitle => 'Podtytuł',
    :collection => stub('PublisherCollection', :name => 'Nazwa kolekcji'),
    :edition_statement => 'wyd. 3, poprawione',
    :languages => [stub('Language', :language_onix_code => 'pol', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_TEXT)],
    :other_texts => [
      stub_everything('OtherText',
           :artificial_id => 137,
           :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
           :text => 'Recenzja książki',
           :text_author => 'Jan Kowalski', 
           :updated_at => Date.new(2011, 12, 03).to_time + 19.hours + 5.minutes + 28.seconds,
           :exportable? => true,
           :is_a_review? => true,
           :resource_link => 'http://example'
          )
    ],
    :series_membership_kind => stub('series_membership_kind', :user_given? => true),
    :series_memberships => [
      stub('SeriesMembership', :series_name => 'Lektury szkolne', :number_within_series => '2').extend(MockMethodMissing)
    ],
    :facsimiles => [stub('Product', :publisher_name => 'PWN', :publisher_id => 12, :publisher_symbol => 'Tytuł dodruku', :isbn_value => '9788324705818', :record_reference => 'abcdefghijk')],
    :similar_products => [stub('Product', :publisher_name => 'WNT', :publisher_id => 13, :publisher_symbol => 'Tytuł podobnej książki', :isbn_value => '9788324799992', :record_reference => 'kjihgfedcba')],
    :attachments => [
      stub('ProductAttachment', 
           :id => 668,
           :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::FRONT_COVER,
           :file_content_type => 'image/png',
           :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::IMAGE,
           :file => stub('Paperclip::Attachment', :url => 'http://elibri.com.pl/sciezka/do/pliku.png'),
           :updated_at => Date.new(2011, 12, 01).to_time + 19.hours + 5.minutes + 28.seconds
          ).extend(MockMethodMissing)
    ],
    :product_availabilities => [
      stub('ProductAvailability',
           :supplier_identifier => 'GILD-123',
           :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
           :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
           :supplier => stub('Supplier',
                             :name => 'Gildia.pl',
                             :nip => '521-33-59-408',
                             :phone => '22 631 40 83',
                             :email => '[email protected]',
                             :website => 'http://gildia.pl'
                            ),
           :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
           :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
          ).extend(MockMethodMissing),

      stub('ProductAvailability',
           :supplier_identifier => 'pl.pwn.ksiegarnia.produkt.id.76734',
           :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER,
           :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
           :supplier => stub('Supplier',
                              :name => 'PWN',
                             :nip => '521-33-59-408',
                             :phone => '22 631 40 83',
                             :email => '[email protected]',
                             :website => 'http://pwn.pl'
                            ).extend(MockMethodMissing),
           :stock_info => stub('stock_info', :exact_info? => false, :quantity_code => 'mało'),
           :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 10, :amount => 14.99, :vat => 7, :currency_code => 'PLN') ]
          ).extend(MockMethodMissing)
    ]
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("book_example", attributes).extend(OnixHelpers::InstanceMethods)
end

#collection_mock(options = {}) ⇒ Object



673
674
675
676
677
678
679
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 673

def collection_mock(options = {})
  attributes =
  {
    :name => 'Nazwa kolekcji'
  }.merge(options)
  stub_everything('PublisherCollection', attributes)
end

#contributor_mock(options = {}) ⇒ Object



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 616

def contributor_mock(options = {})
  attributes = {
    :artificial_id => 240,
    :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
    :language_onix_code => 'pol',
    :title => 'prof.',
    :name => 'Henryk',
    :last_name_prefix => 'von',
    :last_name => 'Sienkiewicz',
    :last_name_postfix => 'Ibrahim',
    :biography => stub('OtherText', :text => 'Biografia Sienkiewicza', :exportable? => true, :is_a_review? => false, :resource_link => 'http://example').extend(MockMethodMissing),
    :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
  }.merge(options)
  stub_everything('Contributor', attributes)
end

#defaultsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 32

def defaults
  {
    :notification_type => stub('NotificationType', :onix_code => Elibri::ONIX::Dict::Release_3_0::NotificationType::CONFIRMED_ON_PUBLICATION),
    :publishing_status_onix_code => Elibri::ONIX::Dict::Release_3_0::PublishingStatusCode::ACTIVE,
    :public? => true,
    :facsimiles => [],
    :similar_products => [],
    :state => "published",
    :elibri_product_categories => [],
    :product_availabilities => [],
    :languages => [],
    :other_texts => [],
    :attachments => [],
    :contributors => [],
    :series_membership_kind => stub('SeriesMemebershipKind', :user_given? => false),
    :authorship_kind => stub('AuthorshipKind', :user_given? => true, :collective? => false, :no_contributor? => false),
  }
end

#description_mock(options = {}) ⇒ Object



690
691
692
693
694
695
696
697
698
699
700
701
702
703
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 690

def description_mock(options = {})
  attributes = 
  {
    :artificial_id => 137,
    :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::MAIN_DESCRIPTION,
    :text => 'Recenzja książki',
    :text_author => 'Jan Kowalski', 
    :updated_at => Date.new(2011, 12, 03).to_time + 19.hours + 5.minutes + 28.seconds,
    :exportable? => true,
    :is_a_review? => false,
    :resource_link => 'http://example' 
  }.merge(options)
  stub_everything('OtherText', attributes)
end

#imprint_mock(options = {}) ⇒ Object



664
665
666
667
668
669
670
671
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 664

def imprint_mock(options = {})
  attributes =
  {
    :name => 'National Geographic'
  }.merge(options)

  stub_everything('Imprint', attributes)
end

#onix_announced_product_example(options = {}) ⇒ Object



420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 420

def onix_announced_product_example(options = {})
  attributes = {
    :state => :announced,
    :publisher_symbol => "Światu nie mamy czego zazdrościć.",
    :original_title => "Nothing to Envy: Ordinary Lives in North Korea",
    :collection_part => '33',
    :title => 'Światu nie mamy czego zazdrościć.',
    :subtitle => "Zwyczajne losy mieszkańców Korei Północnej.",
    :publication_year => 2011
  }.merge(options)
  basic_product(attributes)
end

#onix_audience_range_example(options = {}) ⇒ Object



309
310
311
312
313
314
315
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 309

def onix_audience_range_example(options = {})
  attributes = {
    :audience_age_from => 7,
    :audience_age_to => 10
  }.merge(options)
  basic_product(attributes)
end

#onix_audiobook_extent_example(options = {}) ⇒ Object



365
366
367
368
369
370
371
372
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 365

def onix_audiobook_extent_example(options = {})
  attributes = {
    :example_title => 'Audio CD z długością ścieżki',
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::AUDIO_CD,
    :duration => 340
  }.merge(options)
  basic_product(attributes)
end

#onix_collective_work_example(options = {}) ⇒ Object



382
383
384
385
386
387
388
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 382

def onix_collective_work_example(options = {})
  attributes = {
    :example_title => 'Praca zbiorowa',
    :authorship_kind => ActiveSupport::StringInquirer.new("collective")
  }.merge(options)
  basic_product(attributes)
end

#onix_contributors_example(options = {}) ⇒ Object



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 390

def onix_contributors_example(options = {})
  attributes = {
    :example_title => 'Wyszczególnieni autorzy',
    :title => "Taka jest nasza wiara",
    :authorship_kind => ActiveSupport::StringInquirer.new("user_given"),
    :contributors => [
      stub('Contributor',
           :artificial_id => 255,
           :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
           :missing_parts => true,
           :full_name => 'Św. Tomasz z Akwinu',
           :biography => stub('OtherText', :text => 'Tomasz z Akwinu, Akwinata, łac. Thoma de Aquino (ur. 1225, zm. 7 marca 1274) – filozof scholastyczny, teolog, członek zakonu dominikanów. Był jednym z najwybitniejszych myślicieli w dziejach chrześcijaństwa. Święty Kościoła katolickiego, jeden z doktorów Kościoła, który nauczając przekazywał owoce swej kontemplacji (łac. contemplata aliis tradere).'),
           :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
          ).extend(MockMethodMissing),
            stub('Contributor',
                 :artificial_id => 256,
                 :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::TRANSLATOR,
                 :language_onix_code => 'lat',
                 :title => 'prof. ks.',
                 :name => 'Henryk',
                 :last_name_prefix => 'von',
                 :last_name => 'Hausswolff',
                 :last_name_postfix => 'OP',
                 :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
                ).extend(MockMethodMissing)
  ]
  }.merge(options)
  basic_product(attributes)
end

#onix_ebook_extent_example(options = {}) ⇒ Object



354
355
356
357
358
359
360
361
362
363
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 354

def onix_ebook_extent_example(options = {})
  attributes = {
    :example_title => 'E-book (rozmiar pliku, ilość stron i obrazków)',
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::EBOOK,
    :file_size => 1.22,
    :number_of_pages => 150,
    :number_of_illustrations => 12
  }.merge(options)
  basic_product(attributes)
end

#onix_edition_example(options = {}) ⇒ Object



346
347
348
349
350
351
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 346

def onix_edition_example(options = {})
  attributes = {
    :edition_statement => 'wyd. 3, poprawione'
  }.merge(options)
  basic_product(attributes)
end

#onix_elibri_extensions_example(options = {}) ⇒ Object



604
605
606
607
608
609
610
611
612
613
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 604

def onix_elibri_extensions_example(options = {})
  attributes = {
    :cover_type_id => Elibri::XmlMocks::PAPERBACK,
    :vat => 5,
    :pkwiu => "58.11.1",
    :price_amount => 12.99,
    :preview_exists? => true
  }.merge(options)
  basic_product(attributes)
end

#onix_epub_details_example(options = {}) ⇒ Object



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 242

def onix_epub_details_example(options = {})
  attributes = {
    :title => "Nielegalni",
    :ean => nil,
    :isbn_value => '9788324799992',
    :record_reference => "fdb8fa072be774d97a97",
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::EBOOK,
    :epub_technical_protection_onix_code => Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::DRM,
    :product_form_detail_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::EPUB,
    :state => "published",
    :public? => true,
    :product_availabilities => [],
    :publisher => stub("Publisher", :id => 10, :name => "Wydawnictwo Nowe", :city => "Warszawa")
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("onix_epub_details_example", attributes).extend(OnixHelpers::InstanceMethods)
end

#onix_languages_example(options = {}) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 260

def onix_languages_example(options = {})
  attributes = {
     :publisher => stub("Publisher", :id => 10, :name => "Wydawnictwo Nowe", :city => "Warszawa"),
     :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
     :record_reference => "fdb8fa072be774d97a97",
     :languages => [
        stub('Language', :language_onix_code => 'pol', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_TEXT),
        stub('Language', :language_onix_code => 'eng', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_ABSTRACTS)
      ]
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("onix_languages_example", attributes).extend(OnixHelpers::InstanceMethods)
end

#onix_measurement_example(options = {}) ⇒ Object



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 275

def onix_measurement_example(options = {})
  attributes = {
    :title => "Katowice, mapa",
    :ean => nil,
    :isbn_value => '9788324799992',
    :record_reference => "fdb8fa072be774d97a97",
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::SHEET_MAP,
    :width => 125,
    :height => 195,
    :thickness => 20,
    :weight => 90,
    :map_scale => 50_000, 
    :state => "published",
    :public? => true,
    :publisher => stub("Publisher", :id => 10, :name => "Wydawnictwo Nowe", :city => "Warszawa")
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("onix_measurement_example", attributes).extend(OnixHelpers::InstanceMethods)
end

#onix_no_contributors_example(options = {}) ⇒ Object



374
375
376
377
378
379
380
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 374

def onix_no_contributors_example(options = {})
  attributes = {
    :example_title => 'Brak autorów',
    :authorship_kind => ActiveSupport::StringInquirer.new("no_contributor")
  }.merge(options)
  basic_product(attributes)
end

#onix_out_of_print_product_example(options = {}) ⇒ Object



452
453
454
455
456
457
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 452

def onix_out_of_print_product_example(options = {})
  attributes = {
    :state => :out_of_print
  }.merge(options)
  basic_product(attributes)
end

#onix_preorder_product_example(options = {}) ⇒ Object



433
434
435
436
437
438
439
440
441
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 433

def onix_preorder_product_example(options = {})
  attributes = {
    :state => :preorder,
    :publication_year => 2011,
    :publication_month => 2,
    :publication_day => 10
  }.merge(options)
  basic_product(attributes)
end

#onix_product_form_example(options = {}) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 224

def onix_product_form_example(options = {})
  attributes = {
    :title => "Nielegalni",
    :ean => nil,
    :isbn_value => '9788324799992',
    :record_reference => "fdb8fa072be774d97a97",
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
    :cover_type_id => Elibri::XmlMocks::PAPERBACK,
    :state => "published",
    :public? => true,
    :product_availabilities => [],
    :publisher => stub("Publisher", :id => 10, :name => "Wydawnictwo Nowe", :city => "Warszawa")
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("onix_product_form_example", attributes).extend(OnixHelpers::InstanceMethods)
end

#onix_published_product_example(options = {}) ⇒ Object



443
444
445
446
447
448
449
450
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 443

def onix_published_product_example(options = {})
  attributes = {
    :state => :published,
    :publication_year => 2011,
    :publication_month => 2
  }.merge(options)
  basic_product(attributes)
end

#onix_publisher_info_example(options = {}) ⇒ Object



318
319
320
321
322
323
324
325
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 318

def onix_publisher_info_example(options = {})
  attributes = {
    :publisher_name => 'G+J Gruner+Jahr Polska',
    :publisher_id => 14,
    :imprint => stub('Imprint', :name => 'National Geographic')
  }.merge(options)
  basic_product(attributes)
end

#onix_record_identifiers_example(options = {}) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 199

def onix_record_identifiers_example(options = {})
  attributes = {
    :state => "published",
    :title => "Nielegalni",
    :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
    :record_reference => "fdb8fa072be774d97a97",
    :ean => '9788324788882',
    :isbn_value => '9788324799992',
    :public? => true,
    :publisher => stub("Publisher", :id => 10, :name => "Wydawnictwo Nowe", :city => "Warszawa"),
    :product_availabilities => [
      stub('ProductAvailability', :supplier_identifier => '355006',
           :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
           :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
           :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ],
           :supplier => stub('Supplier', :name => "Olesiejuk",
                                         :nip => "527-22-62-432", :phone => "22 721 70 07", :email => "", :website => "www.olesiejuk.pl"),
           :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER).extend(MockMethodMissing)
    ]
  }
  attributes = defaults.merge(attributes).merge(options)
  stub_everything("onix_record_identifiers_example", attributes).extend(OnixHelpers::InstanceMethods)
end


520
521
522
523
524
525
526
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 520

def onix_related_products_example(options = {})
  attributes = {
    :facsimiles => [stub('Product', :publisher_name => 'PWN', :publisher_id => 12, :publisher_symbol => 'Tytuł dodruku', :isbn_value => '9788324705818', :record_reference => 'abcdefghijk')],
    :similar_products => [stub('Product', :publisher_name => 'WNT', :publisher_id => 13, :publisher_symbol => 'Tytuł podobnej książki', :isbn_value => '9788324799992', :record_reference => 'kjihgfedcba')]
  }.merge(options)
  basic_product(attributes)
end

#onix_sale_restrictions_example(options = {}) ⇒ Object



296
297
298
299
300
301
302
303
304
305
306
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 296

def onix_sale_restrictions_example(options = {})
  attributes = {
    :sale_restricted? => true,
    :sale_restricted_for => 'Empik',
    :sale_restricted_to =>  Date.new(2012, 7, 22),
    :publication_year => 2012,
    :publication_month => 7,
    :publication_day => 12
  }.merge(options)
  basic_product(attributes)
end

#onix_series_memberships_example(options = {}) ⇒ Object



567
568
569
570
571
572
573
574
575
576
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 567

def onix_series_memberships_example(options = {})
  attributes = {
    :series_membership_kind => stub('series_membership_kind', :user_given? => true),
    :series_memberships => [
      stub('SeriesMembership', :series_name => 'Lektury szkolne', :number_within_series => '2'),
      stub('SeriesMembership', :series_name => 'Dla Bystrzaków', :number_within_series => '1')
    ]
  }.merge(options)
  basic_product(attributes)
end

#onix_subjects_example(options = {}) ⇒ Object



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 329

def onix_subjects_example(options={})
  category1_id = options.has_key?(:elibri_product_category1_id) ? options[:elibri_product_category1_id] : 491
  category2_id = options.has_key?(:elibri_product_category2_id) ? options[:elibri_product_category2_id] : 1110

  categories = []
  categories << stub('ElibriProductCategory', :id => category1_id, :full_node_path_name => "Kategoria #{category1_id}") if category1_id
  categories << stub('ElibriProductCategory', :id => category2_id, :full_node_path_name => "Kategoria #{category2_id}") if category2_id

  attributes = {
    :elibri_product_category1_id => category1_id,
    :elibri_product_category2_id => category2_id,
    :elibri_product_categories => categories
  }.merge(options)
  basic_product(attributes)
end

#onix_supply_details_example(options = {}) ⇒ Object



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 529

def onix_supply_details_example(options = {})
  attributes = {
     :product_availabilities => [
        stub('ProductAvailability',
             :supplier_identifier => 'GILD-123',
             :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
             :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
             :supplier => stub('Supplier',
                               :name => 'Gildia.pl',
                               :nip => '521-33-59-408',
                               :phone => '22 631 40 83',
                               :email => '[email protected]',
                               :website => 'http://gildia.pl'
                              ),
             :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
             :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
            ),

        stub('ProductAvailability',
             :supplier_identifier => 'pl.pwn.ksiegarnia.produkt.id.76734',
             :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER,
             :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
             :supplier => stub('Supplier',
                               :name => 'PWN',
                               :nip => '521-33-59-408',
                               :phone => '22 631 40 83',
                               :email => '[email protected]',
                               :website => 'http://www.pwn.pl'
                              ),
             :stock_info => stub('stock_info', :exact_info? => false, :quantity_code => 'mało'),
             :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 10, :amount => 14.99, :vat => 7, :currency_code => 'PLN') ]
            )
      ]
  }.merge(options)
  basic_product(attributes)
end

#onix_supporting_resources_example(options = {}) ⇒ Object



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 579

def onix_supporting_resources_example(options = {})
  attributes = {    
    :attachments => [
      stub('ProductAttachment', 
           :id => 667,
           :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::FRONT_COVER,
           :file_content_type => 'image/png',
           :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::IMAGE,
           :file => stub('Paperclip::Attachment', :url => 'http://elibri.com.pl/sciezka/do/pliku.png'), 
           :updated_at => Date.new(2011, 12, 01).to_time + 18.hours + 5.minutes + 28.seconds
          ),
      stub('ProductAttachment', 
           :id => 668,
           :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::SAMPLE_CONTENT,
           :file_content_type => 'application/pdf',
           :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::TEXT,
           :file => stub('Paperclip::Attachment', :url => 'http://elibri.com.pl/sciezka/do/pliku.pdf'),
           :updated_at => Date.new(2011, 12, 01).to_time + 18.hours + 9.minutes + 18.seconds
          )
    ]
  }.merge(options)
  basic_product(attributes)
end

#onix_texts_example(options = {}) ⇒ Object



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 483

def onix_texts_example(options = {})
  attributes = {
      :other_texts => [
        stub('OtherText',
             :artificial_id => 133,
             :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::TABLE_OF_CONTENTS,
             :text => '1. Wprowadzenie<br/>2. Rozdział pierwszy<br/>[...]',
             :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 15.minutes + 5.seconds
            ).extend(MockMethodMissing),
        stub('OtherText',
             :artificial_id => 134,
             :exportable_review => true,
             :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
             :text => 'Recenzja książki<br/>[...]',
             :resource_link => 'http://nakanapie.pl/books/420469/reviews/2892.odnalezc-swa-droge',
             :source_title => 'nakanapie.pl',
             :text_author => 'Jan Kowalski',
             :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 18.minutes + 15.seconds
            ).extend(MockMethodMissing),
        stub('OtherText',
             :artificial_id => 135,
             :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::MAIN_DESCRIPTION,
             :text => 'Opis książki<br/>[...]',
             :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 25.minutes + 18.seconds
            ).extend(MockMethodMissing),
        stub('OtherText',
             :artificial_id => 136,
             :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::EXCERPT,
             :text => 'Fragment książki<br/>[...]', 
             :updated_at => Date.new(2011, 12, 04).to_time + 13.hours + 35.minutes + 2.seconds
            ).extend(MockMethodMissing),
      ]
  }.merge(options)
  basic_product(attributes)
end

#onix_title_with_collection_example(options = {}) ⇒ Object



470
471
472
473
474
475
476
477
478
479
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 470

def onix_title_with_collection_example(options = {})
  attributes = {
    :publisher_symbol => "Thorgal 33 Statek-Miecz TWARDA",
    :original_title => "Thorgal: Le Bateau-Sabre",
    :collection_part => '33',
    :title => 'Statek-Miecz',
    :collection => stub('PublisherCollection', :name => 'Thorgal')
  }.merge(options)
  basic_product(attributes)
end

#onix_titles_example(options = {}) ⇒ Object



459
460
461
462
463
464
465
466
467
468
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 459

def onix_titles_example(options = {})
  attributes = {
    :publisher_symbol => "Światu nie mamy czego zazdrościć.",
    :original_title => "Nothing to Envy: Ordinary Lives in North Korea",
    :collection_part => '33',
    :title => 'Światu nie mamy czego zazdrościć.',
    :subtitle => "Zwyczajne losy mieszkańców Korei Północnej."
  }.merge(options)
  basic_product(attributes)
end

#paperclip_attachment_mock(options = {}) ⇒ Object



717
718
719
720
721
722
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 717

def paperclip_attachment_mock(options = {})
  attributes = {
    :url => 'http://elibri.com.pl/sciezka/do/pliku.png' 
  }.merge(options)
  stub_everything('Paperclip::Attachment', attributes)
end

#product_attachment_mock(options = {}) ⇒ Object



705
706
707
708
709
710
711
712
713
714
715
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 705

def product_attachment_mock(options = {})
  attributes = {
     :id => 668,
     :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::FRONT_COVER,
     :file_content_type => 'image/png',
     :onix_resource_mode => Elibri::ONIX::Dict::Release_3_0::ResourceMode::IMAGE,
     :file => paperclip_attachment_mock,
     :updated_at => Date.new(2011, 12, 01).to_time + 19.hours + 5.minutes + 28.seconds
  }.merge(options)
  stub_everything('ProductAttachment', attributes)
end

#product_with_similars_mock(options = {}) ⇒ Object



724
725
726
727
728
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 724

def product_with_similars_mock(options = {})
  product_1 = Elibri::XmlMocks::Examples.book_example(:title => 'title_1', :record_reference => 'fdb8fa072be774d97a95')
  product_2 = Elibri::XmlMocks::Examples.book_example(:title => 'title_2', :isbn_value => '9788324799993', :record_reference => 'fdb8fa072be774d97a98')
  Elibri::XmlMocks::Examples.book_example(:record_reference => 'fdb8fa072be774d97a99', :isbn_value => '9788324799990', :facsimiles => [product_1, product_2], :similar_products => [])
end

#review_mock(options = {}) ⇒ Object



632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 632

def review_mock(options = {})
  attributes = {
    :artificial_id => 137,
    :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
    :text => 'Recenzja książki',
    :text_author => 'Jan Kowalski', 
    :updated_at => Date.new(2011, 12, 03).to_time + 19.hours + 5.minutes + 28.seconds,
    :exportable? => true,
    :is_a_review? => true,
    :resource_link => 'http://example'
  }.merge(options)
  stub_everything('OtherText', attributes)
end

#supply_detail_mock(options = {}) ⇒ Object



646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/elibri_onix_mocks/mocks/xml_mocks.rb', line 646

def supply_detail_mock(options = {})
  attributes = {
    :supplier_identifier => 'GILD-123',
    :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
    :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
    :supplier => stub('Supplier',
                      :name => 'Gildia.pl',
                      :nip => '521-33-59-408',
                      :phone => '22 631 40 83',
                      :email => '[email protected]',
                      :website => 'http://gildia.pl'
                     ),
                       :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
                       :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
  }.merge(options)
  stub_everything('ProductAvailability', attributes)
end