plate_api 1.1.5 → 1.2.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
  SHA256:
3
- metadata.gz: 241acd37c44f327c4a66c225d00d0d85945924a81fa8dd84b4560d3c5ec35889
4
- data.tar.gz: 5573a6e2cdb622e6aaf50126649cf6cb41d21932e3eb774693f95f6942fc8f65
3
+ metadata.gz: 251666f577ba0ea7439b6dfa90acfe15e9ac7724a827a8133f4eaf092124d109
4
+ data.tar.gz: a4e9c0676b64b4e324826864045cd09ba1b3e5ef68d4f6ed1b58821b136f54dd
5
5
  SHA512:
6
- metadata.gz: c87dab560422762e7bfcfc62f8b8622c264954e7f4d4bbfb2c8f4c275981c17ab5a0af65b144bc7b4abc6c65c1533e29eaf73af5916df3b2fffa9d4a3cc704e7
7
- data.tar.gz: 2717dc00e02a3432eea125d0ff8409c12b4a3a406fe596f549752428103764dda74636c38a8efe77a7bcfb269356842b47ff4ebe7e8656912430ae9828291b20
6
+ metadata.gz: a691fd2429453636ebb4f0c4fbe3aa1498a2550374f5eb220ba25135dc3580d95a4e34f074e4c948b6e5a326505c0a82e17fe928b2a0ac05d0cbb1556c307879
7
+ data.tar.gz: '09a484411bf28eb37862f11b514ae3e43385b904bad989fa448cb5174ef1b3ea2793c4289186d9b4b0de5eceb37a249fbcebc15d5ac885499eda6e309040b65f'
data/.travis.yml CHANGED
@@ -6,7 +6,7 @@ sudo: false
6
6
  language: ruby
7
7
  rvm:
8
8
  - 2.5.1
9
- before_install: gem install bundler -v 1.16.1
9
+ before_install: gem install bundler -v 2.1.4
10
10
  before_script:
11
11
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
12
  - chmod +x ./cc-test-reporter
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- # git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in plate_api.gemspec
6
- gemspec
5
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,88 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plate_api (1.1.5)
5
- faraday (~> 0.15.4)
6
- faraday_middleware (~> 0.13.1)
7
- mimemagic (~> 0.3.3)
4
+ plate_api (1.2.2)
5
+ faraday (~> 1.0.1)
8
6
 
9
7
  GEM
10
8
  remote: https://rubygems.org/
11
9
  specs:
12
- activesupport (5.2.2)
10
+ activesupport (6.0.3.1)
13
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
12
  i18n (>= 0.7, < 2)
15
13
  minitest (~> 5.1)
16
14
  tzinfo (~> 1.1)
17
- addressable (2.6.0)
18
- public_suffix (>= 2.0.2, < 4.0)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
+ addressable (2.7.0)
17
+ public_suffix (>= 2.0.2, < 5.0)
19
18
  ansi (1.5.0)
20
- byebug (11.0.0)
21
- concurrent-ruby (1.1.4)
19
+ byebug (11.1.3)
20
+ concurrent-ruby (1.1.6)
22
21
  crack (0.4.3)
23
22
  safe_yaml (~> 1.0.0)
24
23
  diff-lcs (1.3)
25
- docile (1.3.1)
26
- factory_bot (5.0.1)
24
+ docile (1.3.2)
25
+ factory_bot (5.0.2)
27
26
  activesupport (>= 4.2.0)
28
- faraday (0.15.4)
27
+ faraday (1.0.1)
29
28
  multipart-post (>= 1.2, < 3)
30
- faraday_middleware (0.13.1)
31
- faraday (>= 0.7.4, < 1.0)
32
- hashdiff (0.3.8)
33
- hirb (0.7.3)
34
- i18n (1.5.3)
29
+ hashdiff (1.0.1)
30
+ i18n (1.8.2)
35
31
  concurrent-ruby (~> 1.0)
36
- json (2.1.0)
37
- mimemagic (0.3.4)
38
- minitest (5.11.3)
32
+ minitest (5.14.1)
39
33
  multipart-post (2.1.1)
40
- public_suffix (3.0.3)
41
- rake (10.5.0)
42
- rspec (3.8.0)
43
- rspec-core (~> 3.8.0)
44
- rspec-expectations (~> 3.8.0)
45
- rspec-mocks (~> 3.8.0)
46
- rspec-core (3.8.0)
47
- rspec-support (~> 3.8.0)
48
- rspec-expectations (3.8.2)
34
+ public_suffix (4.0.5)
35
+ rake (13.0.1)
36
+ rspec (3.9.0)
37
+ rspec-core (~> 3.9.0)
38
+ rspec-expectations (~> 3.9.0)
39
+ rspec-mocks (~> 3.9.0)
40
+ rspec-core (3.9.2)
41
+ rspec-support (~> 3.9.3)
42
+ rspec-expectations (3.9.2)
49
43
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.8.0)
51
- rspec-mocks (3.8.0)
44
+ rspec-support (~> 3.9.0)
45
+ rspec-mocks (3.9.1)
52
46
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.8.0)
54
- rspec-support (3.8.0)
47
+ rspec-support (~> 3.9.0)
48
+ rspec-support (3.9.3)
55
49
  safe_yaml (1.0.5)
56
- simplecov (0.16.1)
50
+ simplecov (0.18.5)
57
51
  docile (~> 1.1)
58
- json (>= 1.8, < 3)
59
- simplecov-html (~> 0.10.0)
60
- simplecov-console (0.4.2)
52
+ simplecov-html (~> 0.11)
53
+ simplecov-console (0.7.2)
61
54
  ansi
62
- hirb
63
55
  simplecov
64
- simplecov-html (0.10.2)
56
+ terminal-table
57
+ simplecov-html (0.12.2)
58
+ terminal-table (1.8.0)
59
+ unicode-display_width (~> 1.1, >= 1.1.1)
65
60
  thread_safe (0.3.6)
66
- tzinfo (1.2.5)
61
+ tzinfo (1.2.7)
67
62
  thread_safe (~> 0.1)
68
- webmock (3.5.1)
63
+ unicode-display_width (1.7.0)
64
+ webmock (3.8.3)
69
65
  addressable (>= 2.3.6)
70
66
  crack (>= 0.3.2)
71
- hashdiff
67
+ hashdiff (>= 0.4.0, < 2.0.0)
68
+ zeitwerk (2.3.0)
72
69
 
73
70
  PLATFORMS
74
71
  ruby
75
72
 
76
73
  DEPENDENCIES
77
- bundler (~> 1.16)
74
+ bundler (~> 2.1.4)
78
75
  byebug
79
76
  factory_bot (~> 5.0.1)
80
77
  plate_api!
81
- rake (~> 10.0)
78
+ rake (~> 13.0)
82
79
  rspec (~> 3.0)
83
80
  simplecov
84
81
  simplecov-console
85
82
  webmock (~> 3.0)
86
83
 
87
84
  BUNDLED WITH
88
- 1.17.3
85
+ 2.1.4
data/lib/plate_api.rb CHANGED
@@ -9,6 +9,7 @@ require "plate_api/delete_request"
9
9
  require "plate_api/post_request"
10
10
  require "plate_api/post_multipart_request"
11
11
  require "plate_api/put_request"
12
+ require "plate_api/error"
12
13
 
13
14
 
14
15
  module PlateApi
@@ -44,6 +44,7 @@ module PlateApi
44
44
  rows: PlateApi::PlateObject::Row,
45
45
  columns: PlateApi::PlateObject::Column,
46
46
  elements: PlateApi::PlateObject::Element,
47
+ content_objects: PlateApi::PlateObject::ContentObject,
47
48
  attachments: PlateApi::PlateObject::Attachment
48
49
  }
49
50
  end
@@ -0,0 +1,5 @@
1
+ module Error
2
+ class Response < StandardError
3
+
4
+ end
5
+ end
@@ -5,39 +5,37 @@ module PlateApi
5
5
  attr_reader :handling_class
6
6
 
7
7
  def initialize(handling_class, api_connector)
8
- raise ArgumentError.new("`handling_class` given for #new is not valid") unless handling_class
9
- raise ArgumentError.new("`api_connector` given for #new is not valid") unless api_connector
8
+ raise ArgumentError, "`handling_class` given for #new is not valid" unless handling_class
9
+ raise ArgumentError, "`api_connector` given for #new is not valid" unless api_connector
10
10
  @handling_class = handling_class
11
11
  @api_connector = api_connector
12
12
  end
13
13
 
14
14
  def find(id)
15
- raise ArgumentError.new("`id` given for #find is not valid") unless id
15
+ raise ArgumentError, "`id` given for #find is not valid" unless id
16
16
  result = @api_connector.get(resource_path(id))
17
17
  if result["data"]
18
18
  return new_object(result["data"])
19
19
  else
20
- puts "PlateApi: No success: #{result}"
21
- return nil
20
+ raise Error::Response, result
22
21
  end
23
22
  end
24
23
 
25
24
  def update(id, attributes)
26
- raise ArgumentError.new("`id` given for #update is not valid") unless id
27
- raise ArgumentError.new("`attributes` given for #update is not valid") unless attributes.is_a? Hash
25
+ raise ArgumentError, "`id` given for #update is not valid" unless id
26
+ raise ArgumentError, "`attributes` given for #update is not valid" unless attributes.is_a? Hash
28
27
  result = @api_connector.put(resource_path(id), {"data" => attributes})
29
28
 
30
29
  if result["data"]
31
30
  return new_object(result["data"])
32
31
  else
33
- puts "PlateApi: No success: #{result}"
34
- return nil
32
+ raise Error::Response, result
35
33
  end
36
34
  end
37
35
 
38
36
  def create(parent, attributes, create_method=:post)
39
- raise ArgumentError.new("`parent` given for #create is not valid") unless parent
40
- raise ArgumentError.new("`attributes` given for #create is not valid") unless attributes.is_a? Hash
37
+ raise ArgumentError, "`parent` given for #create is not valid" unless parent
38
+ raise ArgumentError, "`attributes` given for #create is not valid" unless attributes.is_a? Hash
41
39
  parameters = case create_method
42
40
  when :post
43
41
  {"data" => attributes}
@@ -50,32 +48,29 @@ module PlateApi
50
48
  if result["data"]
51
49
  return new_object(result["data"])
52
50
  else
53
- puts "PlateApi: No success: #{result}"
54
- return nil
51
+ raise Error::Response, result
55
52
  end
56
53
  end
57
54
 
58
55
  def delete(id)
59
- raise ArgumentError.new("`id` given for #find is not valid") unless id
56
+ raise ArgumentError, "`id` given for #find is not valid" unless id
60
57
  result = @api_connector.delete(resource_path(id))
61
58
  if result["data"]
62
59
  return new_object(result["data"])
63
60
  else
64
- puts "PlateApi: No success: #{result}"
65
- return nil
61
+ raise Error::Response, result
66
62
  end
67
63
  end
68
64
 
69
65
  def index(parent_class, parent_id, extra_params={})
70
- raise ArgumentError.new("`parent_id` given for #index is not valid") unless parent_id
71
- raise ArgumentError.new("`parent_class` given for #index is not valid") unless parent_class
66
+ raise ArgumentError, "`parent_id` given for #index is not valid" unless parent_id
67
+ raise ArgumentError, "`parent_class` given for #index is not valid" unless parent_class
72
68
 
73
69
  result = @api_connector.get(collection_path(parent_class, parent_id), extra_params)
74
70
  if result["data"]
75
71
  return result["data"].map{|x| new_object(x)}
76
72
  else
77
- puts "PlateApi: No success: #{result}"
78
- return nil
73
+ raise Error::Response, result
79
74
  end
80
75
  end
81
76
 
@@ -84,8 +79,7 @@ module PlateApi
84
79
  if result["meta"]
85
80
  return result["meta"]["pagination"]["total_records"]
86
81
  else
87
- puts "PlateApi: No success: #{result}"
88
- return nil
82
+ raise Error::Response, result
89
83
  end
90
84
  end
91
85
 
@@ -107,7 +101,7 @@ module PlateApi
107
101
 
108
102
  def collection_path(parent_class=nil, parent_id=nil)
109
103
  if (parent_class != nil) ^ (parent_id != nil)
110
- raise ArgumentError.new("An invalid combination `parent_class` and `parent_id` is given. Provide both or none.")
104
+ raise ArgumentError, "An invalid combination `parent_class` and `parent_id` is given. Provide both or none."
111
105
  end
112
106
 
113
107
  if parent_class
@@ -0,0 +1,15 @@
1
+ module PlateApi::PlateObject
2
+ class ContentObject < Base
3
+
4
+ has_one :site_translation, "PlateApi::PlateObject::SiteTranslation"
5
+
6
+ def self.api_name
7
+ "content_objects"
8
+ end
9
+
10
+ def self.parent_class
11
+ SiteTranslation
12
+ end
13
+
14
+ end
15
+ end
@@ -9,6 +9,7 @@ module PlateApi::PlateObject
9
9
  has_many :rows, :row, "PlateApi::PlateObject::Row"
10
10
  has_many :columns, :column, "PlateApi::PlateObject::Column"
11
11
  has_many :elements, :element, "PlateApi::PlateObject::Element"
12
+ has_many :content_objects, :content_object, "PlateApi::PlateObject::ContentObject"
12
13
  has_many :attachment_folders, :attachment_folder, "PlateApi::PlateObject::AttachmentFolder"
13
14
  has_many :attachments, :attachment, "PlateApi::PlateObject::Attachment"
14
15
 
@@ -7,6 +7,7 @@ module PlateApi::PlateObject
7
7
  has_many :rows, :row, "PlateApi::PlateObject::Row"
8
8
  has_many :columns, :column, "PlateApi::PlateObject::Column"
9
9
  has_many :elements, :element, "PlateApi::PlateObject::Element"
10
+ has_many :content_objects, :content_object, "PlateApi::PlateObject::ContentObject"
10
11
 
11
12
  def self.api_name
12
13
  "site_translations"
@@ -1,11 +1,8 @@
1
- require 'mimemagic'
2
-
3
1
  module PlateApi
4
2
  class PostMultipartRequest < Request
5
3
  HttpAdapter = :net_http
6
- MimeMagic.add('image/jpeg', extensions: "jfif")
7
4
 
8
- def initialize(public_key, secret, path, parameters={}, custom_server=nil)
5
+ def initialize(public_key, secret, path, parameters = {}, custom_server = nil)
9
6
  super(public_key, secret, "POST", path, custom_server)
10
7
 
11
8
  @post_parameters = map_parameters(parameters)
@@ -13,19 +10,23 @@ module PlateApi
13
10
 
14
11
  def extra_builder_options(builder)
15
12
  builder.request :multipart
16
- builder.request :url_encoded
13
+ builder.request :url_encoded
17
14
  end
18
15
 
19
16
  def extra_request_options(request)
20
17
  request.body = @post_parameters
21
18
  end
22
19
 
20
+ def mime_type(full_path)
21
+ IO.popen(["file", "--brief", "--mime-type", full_path], in: :close, err: :close) { |io| io.read.chomp }
22
+ end
23
+
23
24
  def map_parameters(parameters)
24
25
  parameters.keys.each do |key|
25
26
  val = parameters[key]
26
27
  if val.is_a? File
27
28
  full_path = File.expand_path(val)
28
- mime_type = MimeMagic.by_path(full_path).type
29
+ mime_type = self.mime_type(full_path)
29
30
  parameters[key] = Faraday::UploadIO.new(full_path, mime_type)
30
31
  end
31
32
  end
@@ -1,5 +1,5 @@
1
1
  require "faraday"
2
- require 'faraday_middleware'
2
+ # require 'faraday_middleware'
3
3
  require 'time'
4
4
  require "base64"
5
5
  require "openssl"
@@ -1,3 +1,3 @@
1
1
  module PlateApi
2
- VERSION = "1.1.5"
2
+ VERSION = "1.2.2"
3
3
  end
data/plate_api.gemspec CHANGED
@@ -1,20 +1,19 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "plate_api/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = 'plate_api'
8
- spec.version = PlateApi::VERSION
9
- spec.date = '2019-01-05'
10
- spec.summary = "Connector for the Plate API"
6
+ spec.name = "plate_api"
7
+ spec.version = PlateApi::VERSION
8
+ spec.date = "2019-01-05"
9
+ spec.summary = "Connector for the Plate API"
11
10
  spec.description = "This gem can be used to connect to the Plate API. It takes care
12
11
  of the authentication procedure. It also provides a basic wrapper around the Plate API,
13
12
  so objects in Plate can be manipulated as local objects."
14
- spec.authors = ["David Kortleven", "Harmen Fuite"]
15
- spec.email = ['david@getplate.com', 'harmen@getplate.com']
16
- spec.files = ["lib/plate_api.rb"]
17
- spec.license = 'MIT'
13
+ spec.authors = ["David Kortleven", "Harmen Fuite"]
14
+ spec.email = ["david@getplate.com", "harmen@getplate.com"]
15
+ spec.files = ["lib/plate_api.rb"]
16
+ spec.license = "MIT"
18
17
 
19
18
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -22,27 +21,26 @@ Gem::Specification.new do |spec|
22
21
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
23
22
  else
24
23
  raise "RubyGems 2.0 or newer is required to protect against " \
25
- "public gem pushes."
24
+ "public gem pushes."
26
25
  end
27
26
 
28
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
28
  f.match(%r{^(test|spec|features)/})
30
29
  end
31
- spec.bindir = "exe"
32
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
32
  spec.require_paths = ["lib"]
34
33
 
35
- spec.add_dependency "faraday", "~> 0.15.4"
36
- spec.add_dependency "faraday_middleware", "~> 0.13.1"
37
- spec.add_dependency "mimemagic", "~> 0.3.3"
34
+ spec.add_dependency "faraday", "~> 1.0.1"
35
+ # spec.add_dependency "faraday_middleware", "~> 0.13.1"
36
+ # spec.add_dependency "mimemagic", "~> 0.3.10"
38
37
 
39
- spec.add_development_dependency "bundler", "~> 1.16"
40
- spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "bundler", "~> 2.1.4"
39
+ spec.add_development_dependency "rake", "~> 13.0"
41
40
  spec.add_development_dependency "rspec", "~> 3.0"
42
41
  spec.add_development_dependency "webmock", "~> 3.0"
43
42
  spec.add_development_dependency "factory_bot", "~> 5.0.1"
44
43
  spec.add_development_dependency "simplecov"
45
44
  spec.add_development_dependency "simplecov-console"
46
45
  spec.add_development_dependency "byebug"
47
-
48
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plate_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Kortleven
@@ -17,70 +17,42 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.15.4
20
+ version: 1.0.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.15.4
28
- - !ruby/object:Gem::Dependency
29
- name: faraday_middleware
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: 0.13.1
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: 0.13.1
42
- - !ruby/object:Gem::Dependency
43
- name: mimemagic
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: 0.3.3
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: 0.3.3
27
+ version: 1.0.1
56
28
  - !ruby/object:Gem::Dependency
57
29
  name: bundler
58
30
  requirement: !ruby/object:Gem::Requirement
59
31
  requirements:
60
32
  - - "~>"
61
33
  - !ruby/object:Gem::Version
62
- version: '1.16'
34
+ version: 2.1.4
63
35
  type: :development
64
36
  prerelease: false
65
37
  version_requirements: !ruby/object:Gem::Requirement
66
38
  requirements:
67
39
  - - "~>"
68
40
  - !ruby/object:Gem::Version
69
- version: '1.16'
41
+ version: 2.1.4
70
42
  - !ruby/object:Gem::Dependency
71
43
  name: rake
72
44
  requirement: !ruby/object:Gem::Requirement
73
45
  requirements:
74
46
  - - "~>"
75
47
  - !ruby/object:Gem::Version
76
- version: '10.0'
48
+ version: '13.0'
77
49
  type: :development
78
50
  prerelease: false
79
51
  version_requirements: !ruby/object:Gem::Requirement
80
52
  requirements:
81
53
  - - "~>"
82
54
  - !ruby/object:Gem::Version
83
- version: '10.0'
55
+ version: '13.0'
84
56
  - !ruby/object:Gem::Dependency
85
57
  name: rspec
86
58
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +161,7 @@ files:
189
161
  - lib/plate_api.rb
190
162
  - lib/plate_api/connector.rb
191
163
  - lib/plate_api/delete_request.rb
164
+ - lib/plate_api/error.rb
192
165
  - lib/plate_api/get_request.rb
193
166
  - lib/plate_api/object_handler.rb
194
167
  - lib/plate_api/plate_object/attachment.rb
@@ -196,6 +169,7 @@ files:
196
169
  - lib/plate_api/plate_object/base.rb
197
170
  - lib/plate_api/plate_object/column.rb
198
171
  - lib/plate_api/plate_object/company.rb
172
+ - lib/plate_api/plate_object/content_object.rb
199
173
  - lib/plate_api/plate_object/element.rb
200
174
  - lib/plate_api/plate_object/partner.rb
201
175
  - lib/plate_api/plate_object/post.rb
@@ -230,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
204
  - !ruby/object:Gem::Version
231
205
  version: '0'
232
206
  requirements: []
233
- rubygems_version: 3.0.6
207
+ rubygems_version: 3.1.2
234
208
  signing_key:
235
209
  specification_version: 4
236
210
  summary: Connector for the Plate API