elibri_connect 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,6 +5,10 @@
5
5
  Elibri Xml Versions: [![Build Status](https://secure.travis-ci.org/elibri/elibri_xml_versions.png?branch=master)](http://travis-ci.org/elibri/elibri_xml_versions)
6
6
  Elibri Onix Mocks: [![Build Status](https://secure.travis-ci.org/elibri/elibri_onix_mocks.png?branch=master)](http://travis-ci.org/elibri/elibri_onix_mocks)
7
7
  Acts as Elibri Product: [![Build Status](https://secure.travis-ci.org/elibri/acts_as_elibri_product.png?branch=master)](http://travis-ci.org/elibri/acts_as_elibri_product)
8
+ Elibri Onix Dict: [![Build Status](https://secure.travis-ci.org/elibri/elibri_onix_dict.png?branch=master)](http://travis-ci.org/elibri/elibri_onix_dict)
9
+ Elibri Onix: [![Build Status](https://secure.travis-ci.org/elibri/elibri_onix.png?branch=master)](http://travis-ci.org/elibri/elibri_onix)
10
+ Elibri Api Client: [![Build Status](https://secure.travis-ci.org/elibri/elibri_api_client.png?branch=master)](http://travis-ci.org/elibri/elibri_api_client)
11
+
8
12
 
9
13
  ### Elibri Connect: ###
10
14
  [![Build Status](https://secure.travis-ci.org/elibri/elibri_connect.png?branch=master)](http://travis-ci.org/elibri/elibri_connect)
@@ -13,7 +17,7 @@ Acts as Elibri Product: [![Build Status](https://secure.travis-ci.org/elibri/act
13
17
  ## Description ##
14
18
 
15
19
  Gem designed to allow easy addition of elibri based product system to your application.
16
- Currently tested and support only on REE - due to dependencies.
20
+ Currently tested and supported 1.8.7 versions of ruby (MRI, rbx, REE).
17
21
 
18
22
  ## Usage ##
19
23
 
@@ -34,6 +38,16 @@ If you need to access raw api client - you can get it by invoking `Elibri::Conne
34
38
 
35
39
  Gem has additional mode of operation called test_mode - you can get into it, by setting `test_mode=true` inside configuration file. When using it your application will not connect to elibri, instead it will use elibri_xml_mocks to mock and create product for your app.
36
40
 
41
+ Also when installed elibri_connect you will receive method to look into related products imported from elibri.
42
+ There is one to many relationship between product and related_products.
43
+ You can use it, like this:
44
+
45
+ ```ruby
46
+ product.related_products #list of related objects
47
+ product.related_products.objects #list of actual products related to our
48
+ product.related_products.first.object #actual product that is related
49
+ ```
50
+
37
51
  ## Anatomy of config file ##
38
52
 
39
53
  Config file looks like this, and needs to be in config/initializers directory (generate command can provide one for you):
@@ -1,3 +1,3 @@
1
1
  module ElibriConnect
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -25,6 +25,23 @@ module Elibri
25
25
  attr_accessible :import_id, :text, :text_type, :text_author, :source_title, :resource_link
26
26
 
27
27
  end}
28
+
29
+ create_file "app/models/related_product.rb",
30
+ %Q{class RelatedProduct < ActiveRecord::Base
31
+ attr_accessible :onix_code, :product_id, :related_record_reference
32
+
33
+ belongs_to :product
34
+
35
+ def object
36
+ Product.where(:record_reference => related_record_reference).first
37
+ end
38
+
39
+ def self.objects
40
+ joins(:product).first.product.related_products.map { |x| Product.where(:record_reference => x.related_record_reference).first }.compact
41
+ end
42
+
43
+ end}
44
+
28
45
  create_file "app/models/product.rb",
29
46
  %Q[class Product < ActiveRecord::Base
30
47
 
@@ -32,7 +49,15 @@ module Elibri
32
49
  product.has_many :contributors
33
50
  product.has_many :product_texts
34
51
  product.has_one :imprint
52
+ product.has_many :related_products
35
53
  end
54
+
55
+ HEIGHT_UNIT = 'mm'
56
+ WIDTH_UNIT = 'mm'
57
+ THICKNESS_UNIT = 'mm'
58
+ WEIGHT_UNIT = 'gr'
59
+ FILE_SIZE_UNIT = 'MB'
60
+ DURATION_UNIT = 'min'
36
61
 
37
62
  attr_accessible :isbn, :title, :full_title, :trade_title, :original_title, :publication_year,
38
63
  :publication_month, :publication_day, :number_of_pages, :width, :height,
@@ -40,7 +65,7 @@ module Elibri
40
65
  :price_amount, :vat, :current_state, :product_form, :old_xml
41
66
 
42
67
  #on left side elibri attributes, on right side our name of attribute
43
- acts_as_elibri_product :record_reference => :record_reference,
68
+ acts_as_elibri_product :record_reference => :record_reference, #very important attribute!
44
69
  :isbn13 => :isbn,
45
70
  :title => :title,
46
71
  :full_title => :full_title,
@@ -73,6 +98,12 @@ module Elibri
73
98
  :biographical_note => :biography
74
99
  }
75
100
  },
101
+ :related_products => {
102
+ :related_products => {
103
+ :record_reference => :related_record_reference,
104
+ :relation_code => :onix_code
105
+ }
106
+ },
76
107
  :text_contents => {
77
108
  :product_texts => {
78
109
  :id => :import_id,
@@ -54,6 +54,16 @@ class CreateElibriStructure < ActiveRecord::Migration
54
54
  t.text :old_xml
55
55
  t.timestamps
56
56
  end
57
+
58
+ create_table :related_products do |t|
59
+ t.integer :product_id
60
+ t.string :related_record_reference
61
+ t.string :onix_code
62
+
63
+ t.timestamps
64
+ end
65
+
66
+
57
67
 
58
68
  end
59
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibri_connect
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Piotr Szmielew
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-07 00:00:00 Z
18
+ date: 2012-05-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ name: rails
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ~>
@@ -30,12 +30,12 @@ dependencies:
30
30
  - 2
31
31
  - 0
32
32
  version: 3.2.0
33
- version_requirements: *id001
34
- name: rails
35
33
  type: :runtime
36
- - !ruby/object:Gem::Dependency
37
34
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: acts_as_elibri_product
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ">="
@@ -44,12 +44,12 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  version: "0"
47
- version_requirements: *id002
48
- name: acts_as_elibri_product
49
47
  type: :runtime
50
- - !ruby/object:Gem::Dependency
51
48
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: elibri_api_client
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ">="
@@ -58,12 +58,12 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  version: "0"
61
- version_requirements: *id003
62
- name: elibri_api_client
63
61
  type: :runtime
64
- - !ruby/object:Gem::Dependency
65
62
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
63
+ requirement: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: elibri_onix_mocks
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
69
  - - ">="
@@ -72,12 +72,12 @@ dependencies:
72
72
  segments:
73
73
  - 0
74
74
  version: "0"
75
- version_requirements: *id004
76
- name: elibri_onix_mocks
77
75
  type: :runtime
78
- - !ruby/object:Gem::Dependency
79
76
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
77
+ requirement: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: whenever
80
+ version_requirements: &id005 !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
83
  - - ">="
@@ -86,12 +86,12 @@ dependencies:
86
86
  segments:
87
87
  - 0
88
88
  version: "0"
89
- version_requirements: *id005
90
- name: whenever
91
89
  type: :runtime
92
- - !ruby/object:Gem::Dependency
93
90
  prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
91
+ requirement: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: sqlite3
94
+ version_requirements: &id006 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ">="
@@ -100,12 +100,12 @@ dependencies:
100
100
  segments:
101
101
  - 0
102
102
  version: "0"
103
- version_requirements: *id006
104
- name: sqlite3
105
103
  type: :development
106
- - !ruby/object:Gem::Dependency
107
104
  prerelease: false
108
- requirement: &id007 !ruby/object:Gem::Requirement
105
+ requirement: *id006
106
+ - !ruby/object:Gem::Dependency
107
+ name: rspec
108
+ version_requirements: &id007 !ruby/object:Gem::Requirement
109
109
  none: false
110
110
  requirements:
111
111
  - - ">="
@@ -114,12 +114,12 @@ dependencies:
114
114
  segments:
115
115
  - 0
116
116
  version: "0"
117
- version_requirements: *id007
118
- name: rspec
119
117
  type: :development
120
- - !ruby/object:Gem::Dependency
121
118
  prerelease: false
122
- requirement: &id008 !ruby/object:Gem::Requirement
119
+ requirement: *id007
120
+ - !ruby/object:Gem::Dependency
121
+ name: rspec-rails
122
+ version_requirements: &id008 !ruby/object:Gem::Requirement
123
123
  none: false
124
124
  requirements:
125
125
  - - ">="
@@ -128,9 +128,9 @@ dependencies:
128
128
  segments:
129
129
  - 0
130
130
  version: "0"
131
- version_requirements: *id008
132
- name: rspec-rails
133
131
  type: :development
132
+ prerelease: false
133
+ requirement: *id008
134
134
  description: |-
135
135
  Gem designed to allow easy addition of elibri based product system to your application.
136
136
  Currently tested and support only on REE - due to dependencies.
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  requirements: []
185
185
 
186
186
  rubyforge_project:
187
- rubygems_version: 1.8.17
187
+ rubygems_version: 1.8.21
188
188
  signing_key:
189
189
  specification_version: 3
190
190
  summary: Gem designed to allow easy addition of elibri based product system to your application.