groupdocs 0.3.11 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGELOG.md +150 -0
  2. data/README.md +6 -58
  3. data/Rakefile +1 -1
  4. data/examples/README.md +13 -0
  5. data/examples/annotations/Gemfile +5 -0
  6. data/examples/annotations/app.rb +67 -0
  7. data/groupdocs.gemspec +3 -3
  8. data/lib/groupdocs.rb +11 -2
  9. data/lib/groupdocs/api/entity.rb +17 -1
  10. data/lib/groupdocs/api/helpers/path_helper.rb +10 -10
  11. data/lib/groupdocs/api/helpers/rest_helper.rb +7 -2
  12. data/lib/groupdocs/api/helpers/url_helper.rb +2 -4
  13. data/lib/groupdocs/api/request.rb +2 -4
  14. data/lib/groupdocs/datasource.rb +2 -2
  15. data/lib/groupdocs/datasource/field.rb +1 -1
  16. data/lib/groupdocs/document.rb +6 -18
  17. data/lib/groupdocs/document/annotation.rb +25 -2
  18. data/lib/groupdocs/document/annotation/reply.rb +6 -10
  19. data/lib/groupdocs/document/change.rb +1 -1
  20. data/lib/groupdocs/document/field.rb +1 -1
  21. data/lib/groupdocs/document/metadata.rb +1 -1
  22. data/lib/groupdocs/document/rectangle.rb +1 -1
  23. data/lib/groupdocs/document/view.rb +1 -1
  24. data/lib/groupdocs/job.rb +51 -8
  25. data/lib/groupdocs/questionnaire.rb +2 -2
  26. data/lib/groupdocs/questionnaire/execution.rb +1 -1
  27. data/lib/groupdocs/questionnaire/page.rb +1 -1
  28. data/lib/groupdocs/questionnaire/question.rb +1 -1
  29. data/lib/groupdocs/questionnaire/question/answer.rb +1 -1
  30. data/lib/groupdocs/signature.rb +134 -0
  31. data/lib/groupdocs/signature/contact.rb +141 -0
  32. data/lib/groupdocs/signature/envelope.rb +376 -0
  33. data/lib/groupdocs/signature/envelope/log.rb +22 -0
  34. data/lib/groupdocs/signature/field.rb +253 -0
  35. data/lib/groupdocs/signature/field/location.rb +72 -0
  36. data/lib/groupdocs/signature/form.rb +202 -0
  37. data/lib/groupdocs/signature/list.rb +93 -0
  38. data/lib/groupdocs/signature/recipient.rb +47 -0
  39. data/lib/groupdocs/signature/role.rb +84 -0
  40. data/lib/groupdocs/signature/shared.rb +6 -0
  41. data/lib/groupdocs/signature/shared/document_methods.rb +98 -0
  42. data/lib/groupdocs/signature/shared/entity_fields.rb +94 -0
  43. data/lib/groupdocs/signature/shared/entity_methods.rb +145 -0
  44. data/lib/groupdocs/signature/shared/field_methods.rb +282 -0
  45. data/lib/groupdocs/signature/shared/recipient_methods.rb +63 -0
  46. data/lib/groupdocs/signature/shared/resource_methods.rb +65 -0
  47. data/lib/groupdocs/signature/template.rb +104 -0
  48. data/lib/groupdocs/storage/file.rb +69 -62
  49. data/lib/groupdocs/storage/folder.rb +54 -88
  50. data/lib/groupdocs/storage/package.rb +1 -1
  51. data/lib/groupdocs/subscription.rb +113 -0
  52. data/lib/groupdocs/subscription/limit.rb +24 -0
  53. data/lib/groupdocs/user.rb +22 -2
  54. data/lib/groupdocs/version.rb +1 -1
  55. data/spec/groupdocs/api/entity_spec.rb +14 -0
  56. data/spec/groupdocs/api/helpers/path_helper_spec.rb +6 -19
  57. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +9 -0
  58. data/spec/groupdocs/api/request_spec.rb +2 -7
  59. data/spec/groupdocs/datasource_spec.rb +3 -7
  60. data/spec/groupdocs/document/annotation/reply_spec.rb +11 -20
  61. data/spec/groupdocs/document/annotation_spec.rb +35 -31
  62. data/spec/groupdocs/document/field_spec.rb +1 -4
  63. data/spec/groupdocs/document/rectangle_spec.rb +10 -22
  64. data/spec/groupdocs/document_spec.rb +7 -27
  65. data/spec/groupdocs/job_spec.rb +43 -0
  66. data/spec/groupdocs/questionnaire/question_spec.rb +2 -6
  67. data/spec/groupdocs/questionnaire_spec.rb +3 -7
  68. data/spec/groupdocs/signature/contact_spec.rb +129 -0
  69. data/spec/groupdocs/signature/envelope/log_spec.rb +23 -0
  70. data/spec/groupdocs/signature/envelope_spec.rb +296 -0
  71. data/spec/groupdocs/signature/field/location_spec.rb +73 -0
  72. data/spec/groupdocs/signature/field_spec.rb +264 -0
  73. data/spec/groupdocs/signature/form_spec.rb +174 -0
  74. data/spec/groupdocs/signature/list_spec.rb +92 -0
  75. data/spec/groupdocs/signature/recipient_spec.rb +37 -0
  76. data/spec/groupdocs/signature/role_spec.rb +100 -0
  77. data/spec/groupdocs/signature/template_spec.rb +82 -0
  78. data/spec/groupdocs/signature_spec.rb +117 -0
  79. data/spec/groupdocs/storage/file_spec.rb +76 -61
  80. data/spec/groupdocs/storage/folder_spec.rb +43 -90
  81. data/spec/groupdocs/storage/package_spec.rb +1 -2
  82. data/spec/groupdocs/subscription/limit_spec.rb +24 -0
  83. data/spec/groupdocs/subscription_spec.rb +85 -0
  84. data/spec/groupdocs/user_spec.rb +27 -18
  85. data/spec/groupdocs_spec.rb +11 -0
  86. data/spec/spec_helper.rb +10 -1
  87. data/spec/support/files/envelope.zip +0 -0
  88. data/spec/support/json/annotation_access_set.json +11 -0
  89. data/spec/support/json/contact_add.json +12 -0
  90. data/spec/support/json/contacts_get.json +19 -0
  91. data/spec/support/json/contacts_import.json +8 -0
  92. data/spec/support/json/envelope_get.json +46 -0
  93. data/spec/support/json/envelope_logs.json +16 -0
  94. data/spec/support/json/envelopes_all.json +48 -0
  95. data/spec/support/json/envelopes_resources.json +31 -0
  96. data/spec/support/json/form_get.json +21 -0
  97. data/spec/support/json/forms_all.json +23 -0
  98. data/spec/support/json/job_get.json +30 -0
  99. data/spec/support/json/list_add.json +12 -0
  100. data/spec/support/json/lists_get.json +19 -0
  101. data/spec/support/json/signature_create.json +12 -0
  102. data/spec/support/json/signature_field_add.json +25 -0
  103. data/spec/support/json/signature_fields_get.json +27 -0
  104. data/spec/support/json/signature_roles_get.json +17 -0
  105. data/spec/support/json/signatures_get.json +19 -0
  106. data/spec/support/json/subscription_plan_get.json +9 -0
  107. data/spec/support/json/subscription_plans_get.json +17 -0
  108. data/spec/support/json/template_get.json +35 -0
  109. data/spec/support/json/template_get_documents.json +15 -0
  110. data/spec/support/json/template_get_recipients.json +20 -0
  111. data/spec/support/json/templates_all.json +37 -0
  112. data/spec/support/json/user_users_get.json +27 -0
  113. data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -0
  114. data/spec/support/shared_examples/signature/shared/entity_fields.rb +89 -0
  115. data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -0
  116. data/spec/support/shared_examples/signature/shared/field_methods.rb +188 -0
  117. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +42 -0
  118. data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -0
  119. metadata +139 -29
  120. data/lib/groupdocs/extensions.rb +0 -1
  121. data/lib/groupdocs/extensions/lookup.rb +0 -52
  122. data/spec/support/shared_examples/extensions/lookup.rb +0 -57
@@ -1 +0,0 @@
1
- require 'groupdocs/extensions/lookup'
@@ -1,52 +0,0 @@
1
- module GroupDocs
2
- module Extensions
3
- #
4
- # Extends classes providing them with .find! and .find_all! class methods
5
- # which is a bit of sugar for working with files, folder and documents,
6
- #
7
- # It's not that flexible because requires extending class to implement
8
- # .all! class method.
9
- #
10
- # This module is a subject to modifications.
11
- #
12
- module Lookup
13
-
14
- #
15
- # Returns first object matching given options.
16
- #
17
- # @param [Symbol] attribute
18
- # @param [Integer, String, Regexp] value
19
- # @param [Hash] access Access credentials
20
- # @option access [String] :client_id
21
- # @option access [String] :private_key
22
- # @return [GroupDocs::Api::Entity] Matching entity
23
- #
24
- def find!(attribute, value, access = {})
25
- find_all!(attribute, value, access).first
26
- end
27
-
28
- #
29
- # Returns all objects matching given options.
30
- #
31
- # Each entity has to implement #all! method for this to work.
32
- #
33
- # @param [Symbol] attribute
34
- # @param [Integer, String, Regexp] value
35
- # @param [Hash] access Access credentials
36
- # @option access [String] :client_id
37
- # @option access [String] :private_key
38
- # @return [Array] Array of matching entities
39
- #
40
- # @raise [NoMethodError] if extending class does not implement .all! class method.
41
- #
42
- def find_all!(attribute, value, access = {})
43
- respond_to?(:all!) or raise NoMethodError, "#{self}.all! is not implemented - aborting."
44
-
45
- all!('/', access).select do |object|
46
- value === object.send(attribute)
47
- end
48
- end
49
-
50
- end # Lookup
51
- end # Extensions
52
- end # GroupDocs
@@ -1,57 +0,0 @@
1
- shared_examples_for GroupDocs::Extensions::Lookup do
2
- before(:each) do
3
- # make sure `name` attribute exists
4
- described_class.class_eval('attr_accessor :name')
5
- end
6
-
7
- let(:found) do
8
- if described_class == GroupDocs::Document
9
- described_class.new(id: 1, file: GroupDocs::Storage::File.new)
10
- else
11
- described_class.new(id: 1)
12
- end
13
- end
14
-
15
- describe '.find!' do
16
- it 'calls #find_all! and return its first result' do
17
- described_class.should_receive(:find_all!).with(:id, 1, {}).and_return([found])
18
- described_class.find!(:id, 1).should == found
19
- end
20
- end
21
-
22
- describe '.find_all!' do
23
- before(:each) do
24
- folder1 = stub(list!: [], id: 1, name: 'Test')
25
- folder2 = stub(list!: [folder1], id: 2, name: 'Test2')
26
- described_class.stub(all!: [folder1, folder2])
27
- end
28
-
29
- it 'raises error if class does not implement #all!' do
30
- described_class.stub(:respond_to?).with(:all!).and_return(false)
31
- lambda do
32
- described_class.find_all!(:id, 1)
33
- end.should raise_error(NoMethodError, "#{described_class}.all! is not implemented - aborting.")
34
- end
35
-
36
- it 'allows passing attribute and its value' do
37
- -> { described_class.find_all!(:id, 1) }.should_not raise_error(ArgumentError)
38
- end
39
-
40
- it 'calls #all! and search within it' do
41
- described_class.should_receive(:all!).and_return([found])
42
- described_class.find_all!(:name, 'Test')
43
- end
44
-
45
- it 'returns an array' do
46
- described_class.find_all!(:id, 1).should be_an(Array)
47
- end
48
-
49
- it 'finds by exact match' do
50
- described_class.find_all!(:name, 'Test').length.should == 1
51
- end
52
-
53
- it 'finds by regexp match' do
54
- described_class.find_all!(:name, /Test/).length.should == 2
55
- end
56
- end
57
- end