brick_ftp 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a234ab93a2769cded17e32e1eb09693ba4cb488f
4
- data.tar.gz: 0c546aa7972b3138965444c8c6c35a483640b099
3
+ metadata.gz: f4ceed2165ffe939ec9fa8d08932469060f5ac76
4
+ data.tar.gz: baca3f3769711375adede57195a0d62421b3bc8c
5
5
  SHA512:
6
- metadata.gz: dbb6d3f3233ea40ed0cd5934d6b42302b02184c4dd101e7b19c342f124a054ee2c41ffaf2179d9b8e3f28d5d111969a64d969b058576541a0a3b01b9fc86568d
7
- data.tar.gz: b5027966e98cdfeed34b07b0e1446c72e9bcb972ea00d3500f7378b69e80fda3f2a5fcd63a32b81ce8386dd92a6de5cea78abe0fc0b39d6773ae267af688d204
6
+ metadata.gz: 52eb974b0c1a30f5248e7fdb394dc0fd85da3b1499202694825d5ec845eeb27851a502808073ac759a4ff092f9caa1a8ab2fa9d22a2759ba8415c874db35ef6f
7
+ data.tar.gz: 4e2bb88fe63df32dd2dd781ff3e7537caaf01d7df694189128e5838e1aeb995b19c2af439ac1f2cb4a0ad0706b2262ee58af0758ebdd05604dd55252752fa5c6
data/CHANGELOG.md CHANGED
@@ -2,20 +2,39 @@ Changelog
2
2
  ====
3
3
 
4
4
 
5
- [unreleased](https://github.com/koshigoe/brick_ftp/compare/v0.5.1...master)
5
+ [unreleased](https://github.com/koshigoe/brick_ftp/compare/v0.6.0...master)
6
6
  ----
7
7
 
8
- [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.5.1...master)
8
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.6.0...master)
9
9
 
10
10
  ### Enhancements:
11
11
 
12
12
  ### Fixed Bugs:
13
13
 
14
+ ### Breaking Changes:
15
+
16
+
17
+ [v0.6.0](https://github.com/koshigoe/brick_ftp/compare/v0.5.1...v0.6.0)
18
+ ----
19
+
20
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.5.1...v0.6.0)
21
+
22
+ ### Enhancements:
23
+
24
+ ### Fixed Bugs:
25
+
26
+ ### Breaking Changes:
27
+
28
+ - [#72](https://github.com/koshigoe/brick_ftp/pull/72) Improve accessor of API properties
29
+ - Cannot access some API properties named same as methods of Ruby's Object.
30
+ - e.g. `send` property of [File Uploading](https://brickftp.com/docs/rest-api/file-uploading/)
31
+ - Use `#properties` to access properties
32
+
14
33
 
15
34
  [v0.5.1](https://github.com/koshigoe/brick_ftp/compare/v0.5.0...v0.5.1)
16
35
  ----
17
36
 
18
- [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.5.0...master)
37
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.5.0...v0.5.1)
19
38
 
20
39
  ### Enhancements:
21
40
 
@@ -15,7 +15,7 @@ module BrickFTP
15
15
 
16
16
  def destroy
17
17
  super.tap do
18
- @id = nil
18
+ delete_property(:id)
19
19
  BrickFTP.config.session = nil
20
20
  end
21
21
  end
@@ -39,8 +39,12 @@ module BrickFTP
39
39
  new(data.symbolize_keys)
40
40
  end
41
41
 
42
+ # @return [Hash{String => Object}] Key Value pairs of API properties
43
+ attr_reader :properties
44
+
42
45
  def initialize(params = {})
43
- params.each { |k, v| instance_variable_set(:"@#{sanitize_instance_variable_name(k)}", v) }
46
+ @properties = {}
47
+ params.each { |k, v| write_property(k, v) }
44
48
  end
45
49
 
46
50
  def update(params = {})
@@ -51,7 +55,7 @@ module BrickFTP
51
55
  self.class.api_path_for(:update, self),
52
56
  params: self.class.api_component_for(:update).except_path_and_query(params)
53
57
  )
54
- data.each { |k, v| instance_variable_set(:"@#{k}", v) }
58
+ data.each { |k, v| write_property(k, v) }
55
59
 
56
60
  self
57
61
  end
@@ -69,17 +73,35 @@ module BrickFTP
69
73
  end
70
74
 
71
75
  def as_json
72
- self.class.attributes.each_with_object({}) { |name, res| res[name] = send(name) }
76
+ self.class.attributes.each_with_object({}) { |name, res| res[name] = read_property(name) }
73
77
  end
74
78
 
75
79
  def to_json
76
80
  as_json.to_json
77
81
  end
78
82
 
83
+ def write_property(key, value)
84
+ properties[key.to_s] = value
85
+ end
86
+
87
+ def read_property(key)
88
+ properties[key.to_s]
89
+ end
90
+
91
+ def delete_property(key)
92
+ properties.delete(key.to_s)
93
+ end
94
+
79
95
  private
80
96
 
81
- def sanitize_instance_variable_name(name)
82
- name.to_s.gsub(/\W/, '')
97
+ def respond_to_missing?(method_name, _include_private)
98
+ self.class.attributes.include?(method_name.to_sym)
99
+ end
100
+
101
+ def method_missing(method_name, *args)
102
+ super unless self.class.attributes.include?(method_name.to_sym)
103
+
104
+ read_property(method_name)
83
105
  end
84
106
  end
85
107
  end
@@ -14,6 +14,7 @@ module BrickFTP
14
14
  attribute :md5
15
15
  attribute :provided_mtime
16
16
  attribute :permissions
17
+ attribute :subfolders_locked?
17
18
  end
18
19
  end
19
20
  end
@@ -68,7 +68,7 @@ module BrickFTP
68
68
  when BrickFTP::API::Base
69
69
  keys = path_variables(params) + query_keys
70
70
  keys.each_with_object({}) do |key, res|
71
- res[key] = params.send(key)
71
+ res[key] = params.read_property(key)
72
72
  end
73
73
  else
74
74
  keys = path_variables(params) + query_keys
@@ -37,7 +37,6 @@ module BrickFTP
37
37
  else
38
38
  readonly_attributes << name.to_sym
39
39
  end
40
- attr_reader name.to_s.tr('-', '_')
41
40
  end
42
41
 
43
42
  # Return all attributes.
@@ -1,3 +1,3 @@
1
1
  module BrickFTP
2
- VERSION = "0.5.1"
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick_ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - koshigoe