groupdocs 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ module GroupDocs
24
24
  json = api.execute!
25
25
 
26
26
  DataSource.new(json[:datasource])
27
- rescue BadResponseError
27
+ rescue RestClient::ResourceNotFound
28
28
  nil
29
29
  end
30
30
 
@@ -1,43 +1,29 @@
1
1
  module GroupDocs
2
2
  class DataSource::Field < GroupDocs::Api::Entity
3
3
 
4
- TYPES = {
5
- text: 0,
6
- binary: 1,
7
- }
8
-
9
- # @attr [String] field
10
- attr_accessor :field
4
+ # @attr [String] name
5
+ attr_accessor :name
11
6
  # @attr [Integer] type
12
7
  attr_accessor :type
13
8
  # @attr [Array<String>] values
14
9
  attr_accessor :values
15
10
 
16
- # Compatibility with response JSON
17
- alias_method :name=, :field=
18
-
19
11
  #
20
12
  # Updates type with machine-readable format.
21
13
  #
22
14
  # @param [Symbol] type
23
- # @raise [ArgumentError] if type is unknown
24
15
  #
25
16
  def type=(type)
26
- if type.is_a?(Symbol)
27
- TYPES.keys.include?(type) or raise ArgumentError, "Unknown type: #{type.inspect}"
28
- type = TYPES[type]
29
- end
30
-
31
- @type = type
17
+ @type = type.is_a?(Symbol) ? type.to_s.capitalize : type
32
18
  end
33
19
 
34
20
  #
35
- # Returns field type in human-readable format.
21
+ # Returns type in human-readable format.
36
22
  #
37
23
  # @return [Symbol]
38
24
  #
39
25
  def type
40
- TYPES.invert[@type]
26
+ @type.downcase.to_sym
41
27
  end
42
28
 
43
29
  end # DataSource::Field
@@ -42,7 +42,7 @@ module GroupDocs
42
42
  end.execute!
43
43
 
44
44
  Questionnaire.new(json[:questionnaire])
45
- rescue RestClient::BadRequest
45
+ rescue RestClient::ResourceNotFound
46
46
  nil
47
47
  end
48
48
 
@@ -45,9 +45,9 @@ module GroupDocs
45
45
 
46
46
  %w(owner executive approver).each do |method|
47
47
  #
48
- # Converts hash of user options to GroupDocs::user object.
48
+ # Converts hash of user options to GroupDocs::User object.
49
49
  #
50
- # @param [Hash] options
50
+ # @param [GroupDocs::User, Hash] options
51
51
  #
52
52
  define_method(:"#{method}=") do |options|
53
53
  case options
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '0.3.7'
2
+ VERSION = '0.3.8'
3
3
  end # GroupDocs
@@ -4,46 +4,28 @@ describe GroupDocs::DataSource::Field do
4
4
 
5
5
  it_behaves_like GroupDocs::Api::Entity
6
6
 
7
- describe 'TYPES' do
8
- it 'contains hash of field types' do
9
- described_class::TYPES.should == {
10
- text: 0,
11
- binary: 1,
12
- }
13
- end
14
- end
15
-
16
- it { should respond_to(:field) }
17
- it { should respond_to(:field=) }
7
+ it { should respond_to(:name) }
8
+ it { should respond_to(:name=) }
18
9
  it { should respond_to(:type) }
19
10
  it { should respond_to(:type=) }
20
11
  it { should respond_to(:values) }
21
12
  it { should respond_to(:values=) }
22
13
 
23
- it 'is compatible with response JSON' do
24
- subject.should respond_to(:name=)
25
- subject.method(:name=).should == subject.method(:field=)
26
- end
27
-
28
14
  describe '#type=' do
29
15
  it 'saves type in machine readable format if symbol is passed' do
30
16
  subject.type = :binary
31
- subject.instance_variable_get(:@type).should == 1
17
+ subject.instance_variable_get(:@type).should == 'Binary'
32
18
  end
33
19
 
34
20
  it 'does nothing if parameter is not symbol' do
35
- subject.type = 1
36
- subject.instance_variable_get(:@type).should == 1
37
- end
38
-
39
- it 'raises error if type is unknown' do
40
- -> { subject.type = :unknown }.should raise_error(ArgumentError)
21
+ subject.type = 'Binary'
22
+ subject.instance_variable_get(:@type).should == 'Binary'
41
23
  end
42
24
  end
43
25
 
44
26
  describe '#type' do
45
27
  it 'returns type in human-readable format' do
46
- subject.type = 1
28
+ subject.type = 'Binary'
47
29
  subject.type.should == :binary
48
30
  end
49
31
  end
@@ -25,8 +25,8 @@ describe GroupDocs::DataSource do
25
25
  described_class.get!(1).should be_a(GroupDocs::DataSource)
26
26
  end
27
27
 
28
- it 'returns nil if datasource was not found' do
29
- mock_api_server('{"result": {"datasource": null}, "status": "Failed"}')
28
+ it 'returns nil if ResourceNotFound was raised' do
29
+ GroupDocs::Api::Request.any_instance.should_receive(:execute!).and_raise(RestClient::ResourceNotFound)
30
30
  described_class.get!(99).should be_nil
31
31
  end
32
32
  end
@@ -39,8 +39,8 @@ describe GroupDocs::Questionnaire do
39
39
  described_class.get!(1).should be_a(GroupDocs::Questionnaire)
40
40
  end
41
41
 
42
- it 'returns nil if BadRequestError was raised' do
43
- GroupDocs::Api::Request.any_instance.should_receive(:execute!).and_raise(RestClient::BadRequest)
42
+ it 'returns nil if ResourceNotFound was raised' do
43
+ GroupDocs::Api::Request.any_instance.should_receive(:execute!).and_raise(RestClient::ResourceNotFound)
44
44
  described_class.get!(1).should be_nil
45
45
  end
46
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
12
+ date: 2012-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &17627180 !ruby/object:Gem::Requirement
16
+ requirement: &18874340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *17627180
24
+ version_requirements: *18874340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &17641880 !ruby/object:Gem::Requirement
27
+ requirement: &18888780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.7'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *17641880
35
+ version_requirements: *18888780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-hmac
38
- requirement: &17640500 !ruby/object:Gem::Requirement
38
+ requirement: &18887640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *17640500
46
+ version_requirements: *18887640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &17638840 !ruby/object:Gem::Requirement
49
+ requirement: &18886060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.9'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *17638840
57
+ version_requirements: *18886060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &17637840 !ruby/object:Gem::Requirement
60
+ requirement: &18885040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0.9'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *17637840
68
+ version_requirements: *18885040
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &17636920 !ruby/object:Gem::Requirement
71
+ requirement: &18884140 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.6'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *17636920
79
+ version_requirements: *18884140
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: yard
82
- requirement: &17650020 !ruby/object:Gem::Requirement
82
+ requirement: &18897000 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0.8'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *17650020
90
+ version_requirements: *18897000
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &17647300 !ruby/object:Gem::Requirement
93
+ requirement: &18894420 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '1.8'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *17647300
101
+ version_requirements: *18894420
102
102
  description: Ruby SDK for GroupDocs REST API
103
103
  email: p0deje@gmail.com
104
104
  executables: []
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  segments:
258
258
  - 0
259
- hash: 3735999314178222013
259
+ hash: 2096644299297283301
260
260
  required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  none: false
262
262
  requirements:
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  segments:
267
267
  - 0
268
- hash: 3735999314178222013
268
+ hash: 2096644299297283301
269
269
  requirements: []
270
270
  rubyforge_project:
271
271
  rubygems_version: 1.8.10