art-gun 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c50a4cb236e4e9261427240896416fcfc4c0ac6
4
- data.tar.gz: 290fa8e9a240d8e2b12a3e955e8e726e9cba4038
3
+ metadata.gz: f5c5bfadf644a85610aee6810337476b02718c8c
4
+ data.tar.gz: 1767af707121de560fe02cf4b2ba6653632fc123
5
5
  SHA512:
6
- metadata.gz: 11c5ca00049fe958e2642de03aaa0f97be3ffc0ea2f276867b03ad632dc06fa8daf45e0a047d56bfdf8c0a026f00986e58e9681e1d708470afa8b7d1fd491da3
7
- data.tar.gz: 3707ed8faf59d76520f3c4dc670a54d5ee078440fc5691ef48f7039c28bf24b6f7cbfe5ae7fcb63580ddfa0369d6b5657ad4de2bfe7fe98655a3c51c0b4ad12f
6
+ metadata.gz: def45b412ef3bd3016f014c228ffa391a976d9b5131b6ad0393a09d2e6e7ef9024bdf2218485844715a639f50bf740734d54a140b9fe9691cec8811cb91316ca
7
+ data.tar.gz: 8bc9a21b91c545cbb34bf5603a63de05af511f5ed1b8677e4fd3ef8330eea669ab4335eef847bcf332203e3e6b0ac53220e10ad851324f1b29e241d3221816fc
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.10"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "dotenv"
26
+ spec.add_development_dependency "rspec", "~> 3.3"
27
+ spec.add_development_dependency "dotenv", "~> 2.0"
28
+ spec.add_development_dependency "factory_girl", "~> 4.0"
28
29
  end
@@ -22,6 +22,11 @@ module ArtGun
22
22
  length: {maximum: 15}
23
23
  validates :shipping_email, :billing_email,
24
24
  length: {maximum: 65}
25
+ validates :items,
26
+ length: {minimum: 1}
27
+ validate do
28
+ errors.add :items, "One or more items are not valid" if items and items.any? &:invalid?
29
+ end
25
30
 
26
31
 
27
32
  def type
@@ -3,20 +3,25 @@ module ArtGun
3
3
  include ActiveModel::Model
4
4
  include ActiveModel::Serializers::JSON
5
5
 
6
- @@attrs = %i(name sku quantity unit_amount subtotal_amount necklabel_binid item_attributes)
6
+ @@attrs = %i(name sku quantity unit_amount subtotal_amount necklabel_binid attrs)
7
7
  cattr_reader :attrs
8
8
  attr_accessor *attrs
9
9
 
10
10
  validates :name, :sku, :quantity, presence: true
11
11
  validates :name, length: {maximum: 64}
12
+ validates :attrs,
13
+ length: {minimum: 1}
14
+ validate do
15
+ errors.add :attrs, "One or more attributes (#attrs) are not valid" if attrs and attrs.any? &:invalid?
16
+ end
12
17
 
13
18
  def attributes
14
19
  self.class.attrs.inject({}){|h,k| h[k.to_s] = nil; h}
15
20
  end
16
21
 
17
- def as_json opts = {include: :item_attributes}
22
+ def as_json opts = {include: :attrs}
18
23
  hash = super opts
19
- hash['attributes'] = hash.delete('item_attributes') # to avoid name conflict in model
24
+ hash['attributes'] = hash.delete('attrs') # to avoid name conflict in model
20
25
  hash
21
26
  end
22
27
  end
@@ -1,5 +1,5 @@
1
1
  module ArtGun
2
- class OrderItem
2
+ class OrderItemAttribute
3
3
  include ActiveModel::Model
4
4
  include ActiveModel::Serializers::JSON
5
5
 
@@ -13,6 +13,7 @@ module ArtGun
13
13
  validates :location, inclusion: {in: %w(FNL)}, if: ->(a) { a.type == 'HeatTransfer' }
14
14
  validates :location, inclusion: {in: %w(FN)}, if: ->(a) { a.type == 'HangTag' }
15
15
  validates :file_url, :file_extension, presence: true, if: ->(a) { a.type == 'DigitalPrint' }
16
+ validates :file_extension, inclusion: {in: %w(jpg png)}, if: ->(a) { a.file_extension.present? }
16
17
 
17
18
  def attributes
18
19
  self.class.attrs.inject({}){|h,k| h[k.to_s] = nil; h}
@@ -1,3 +1,3 @@
1
1
  module ArtGun
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: art-gun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Kluge
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -56,30 +56,44 @@ dependencies:
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: dotenv
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_girl
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0'
96
+ version: '4.0'
83
97
  description: A Ruby wrapper to access Art-Gun's API.
84
98
  email:
85
99
  - l@larskluge.com