groupdocs 0.3.11 → 1.0.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.
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
data/CHANGELOG.md ADDED
@@ -0,0 +1,150 @@
1
+ ## v1.0
2
+
3
+ **New**
4
+
5
+ * Added fully-featured Signature API
6
+ * Added API to retrieve subscription plans
7
+ * Added `Annotation#set_access!` to control annotation access: public or private
8
+ * Added `Job.get!` to retrieve job by its identifier
9
+ * Added `Job#delete_document!`
10
+ * Added `File.upload_web!` to convert webpages to documents
11
+ * Added `File#move_to_trash!`
12
+ * Added `User.users!` to retrieve my account's users
13
+
14
+ **Changes**
15
+
16
+ * `File` and `Folder` has changed the way paths are handled. Path should no longer start with `/`
17
+ * `File.upload!` now accept hash of options as argument: `:path` to upload to, `:name` to rename file, `:description` to add description to file
18
+ * `File#move!` now accept hash of options as argument: `:name` to rename file
19
+ * `File#copy!` now accept hash of options as argument: `:name` to rename file
20
+
21
+ **Removed**
22
+
23
+ * `Document.all!` is removed (slow recursive implementation)
24
+ * `Document.find!` is removed (slow recursive implementation)
25
+ * `Document.find_all!` is removed (slow recursive implementation)
26
+ * `File.all!` is removed (slow recursive implementation)
27
+ * `File.find!` is removed (slow recursive implementation)
28
+ * `File.find_all!` is removed (slow recursive implementation)
29
+ * `Folder.all!` is removed (slow recursive implementation)
30
+ * `Folder.find!` is removed (slow recursive implementation)
31
+ * `Folder.find_all!` is removed (slow recursive implementation)
32
+ * `Extensions::LookUp` is removed (slow recursive implementation)
33
+ * `File#upload!` is removed (not really needed, use `File.upload!`)
34
+ * `Folder#rename!` is removed (has some quirks due to API, use `Folder#move!` instead)
35
+
36
+ ## v0.3.11
37
+
38
+ * Fix for critical bug in `Entity#to_hash`
39
+
40
+ ## v0.3.10
41
+
42
+ * Updated `Document#metadata!`
43
+ * Fixed `Folder#move!`
44
+ * Fixed `Folder#copy!`
45
+
46
+ ## v0.3.9
47
+
48
+ * Added `File#upload!`
49
+ * Proper handling of `File#file_type`
50
+ * More annotation types
51
+ * `Document#datasource!` options are now optional
52
+
53
+ ## v0.3.8
54
+
55
+ * Updated `Datasource for new API
56
+ * Updated `Datasource::Field` for new API
57
+ * Some minor fixes
58
+
59
+ ## v0.3.7
60
+
61
+ * More flexible `Execution#owner=` and specs for it
62
+ * More flexible `Execution#executive=` and specs for it
63
+ * More flexible `Execution#approver=` and specs for it
64
+
65
+ ## v0.3.6
66
+
67
+ * `Questionnaire::Execution` now returns objects for`owner`, `executive` and `approver`
68
+
69
+ ## v0.3.5
70
+
71
+ * Methods to retrieve and update user profile information
72
+
73
+ ## v0.3
74
+
75
+ **This release breaks backwards compatibility**
76
+
77
+ New API version uses strings for job actions, access modes, statuses, file types, etc. This release reflects corresponding changes.
78
+
79
+ ## v0.2.11
80
+
81
+ * Added `Questionnaire#default_answer` and `Questionnaire#default_answer=`
82
+
83
+ ## v0.2.10
84
+
85
+ * Added `Annotation#collaborators!`
86
+
87
+ ## v0.2.9
88
+
89
+ * Added `Annotation#position`
90
+ * Added `Annotation#move!`
91
+
92
+ ## v0.2.8
93
+
94
+ * Human-readable `Annotation#access`
95
+ * Machine-readable `Annotation#access=`
96
+ * `Document#annotations!` now handles `null` in "annotations" response
97
+
98
+ ## v0.2.7
99
+
100
+ * `Job#documents!` now updates job status
101
+
102
+ ## v0.2.6
103
+
104
+ * Minor `Job` and `Document` fixes
105
+
106
+ ## v0.2.5
107
+
108
+ * `Document` now parses `outputs` to `Storage::File` object
109
+ * `Document` now has `output_formats` with corresponding parser
110
+ * `Document#convert!` URI was changed
111
+ * Job API methods were returning job documents in different format
112
+
113
+ ## v0.2.4
114
+
115
+ * `Job` has now more attributes
116
+ * `Job#documents=` should not raise error when `nil` is passed
117
+ * Timestamps are being returned in milliseconds, while we were parsing them as seconds
118
+
119
+ ## v0.2.3
120
+
121
+ * Fixed `Entity#variable_to_accessor` bugs
122
+ * Updated `Document#fields!` to always include geometry
123
+ * Added more accessors to `Rectange` (fixes `#inspect` issues)
124
+
125
+ ## v0.2.2
126
+
127
+ * Updated `Folder.list!` for response changes
128
+
129
+ ## v0.2.1
130
+
131
+ * `Sugar` namespace is now `Extensions`
132
+ * Removed `File#delete!` workaround
133
+
134
+ ## v0.2
135
+
136
+ * `File#compress!` supports only zip, so parameter was removed
137
+ * `Errors` namespace was removed
138
+ * `BadRequestError` now shows only error message
139
+ * `File#upload!` no longer uses description, so parameter was removed
140
+ * Added `File#file_type`
141
+ * Added `File::DOCUMENT_TYPES`. `File#type` now returns document type in human-readable format
142
+ * `Folder#list!` capitalizes `:order_by` option
143
+ * Introduced `URLHelper#normalize_path`. Path is now normalized before sending request.
144
+ * HTTP methods as strings are now allowed
145
+ * Workaround for `File#delete!`
146
+ * Updated gems
147
+
148
+ ## v0.1
149
+
150
+ Initial release
data/README.md CHANGED
@@ -36,8 +36,8 @@ GroupDocs.configure do |groupdocs|
36
36
  groupdocs.client_id = 'your_client_id'
37
37
  groupdocs.private_key = 'your_private_key'
38
38
  # optionally specify API server and version
39
- groupdocs.api_server = 'https://dev-api.groupdocs.com'
40
- groupdocs.api_version = '2.0'
39
+ groupdocs.api_server = 'https://dev-api.groupdocs.com' # default is 'https://api.groupdocs.com'
40
+ groupdocs.api_version = '3.0' # default is '2.0'
41
41
  end
42
42
 
43
43
  GroupDocs::Storage::Folder.create!('/folder')
@@ -49,11 +49,12 @@ You can also pass access credentials to particular requests
49
49
  ```ruby
50
50
  GroupDocs::Storage::Folder.create!('/folder', client_id: 'your_client_id', private_key: 'your_private_key')
51
51
  #=> #<GroupDocs::Storage::Folder:0x0000000171f432 @id=1, @name="folder", @url="http://groupdocs.com">
52
-
53
- GroupDocs::Document.find!(:name, 'CV.doc', client_id: 'your_client_id', private_key: 'your_private_key')
54
- #=> #<GroupDocs::Storage::Folder:0x0000000171f432 @id=1, @name="Folder1", @url="http://groupdocs.com">
55
52
  ```
56
53
 
54
+ ### Documentation
55
+
56
+ Reference to [this page](http://rubydoc.info/gems/groupdocs) for docs
57
+
57
58
  ### Entities
58
59
 
59
60
  All entities can be initialized in several ways.
@@ -83,59 +84,6 @@ end
83
84
  #=> #<GroupDocs::Storage::Folder:0x0000000171f432 @name="Folder">
84
85
  ```
85
86
 
86
- ### Find entities
87
-
88
- Some entities support `#all!`, `#find!` and `#find_all!` methods. You can pass any attribute that object responds to and its value to find with.
89
-
90
- * List all files
91
-
92
- ```ruby
93
- GroupDocs::Storage::File.all!
94
- #=> [#<GroupDocs::Storage::File:0x0000000171f432 @id=123, @guid="uhfsa9dry29rhfodn", @name="resume.pdf", @url="http://groupdocs.com">, #<GroupDocs::Storage::File:0x0000000171f498 @id=456, @guid="soif97sr9u24bfosd9", @name="CV.doc", @url="http://groupdocs.com">]
95
- ```
96
-
97
- * Find folder with name `Folder1`
98
-
99
- ```ruby
100
- GroupDocs::Storage::Folder.find!(:name, 'Folder1')
101
- #=> #<GroupDocs::Storage::Folder:0x0000000171f432 @id=1, @name="Folder1", @url="http://groupdocs.com">
102
- ```
103
-
104
- * Find all folders which name starts with `Folder`
105
-
106
- ```ruby
107
- GroupDocs::Storage::Folder.find_all!(:name, /^Folder/)
108
- #=> [#<GroupDocs::Storage::Folder:0x0000000171f432 @id=1, @name="Folder1", @url="http://groupdocs.com">, #<GroupDocs::Storage::Folder:0x0000000171f467 @id=2, @name="Folder2", @url="http://groupdocs.com">]
109
- ```
110
-
111
- ### Annotation API
112
-
113
- Read more about examples of using Annotation API on [wiki](https://github.com/p0deje/groupdocs-ruby/wiki/Annotation-API).
114
-
115
- ### Assembly API
116
-
117
- Read more about examples of using Assembly API on [wiki](https://github.com/p0deje/groupdocs-ruby/wiki/Assembly-API).
118
-
119
- ### Comparison API
120
-
121
- Read more about examples of using Comparison API on [wiki](https://github.com/p0deje/groupdocs-ruby/wiki/Comparison-API).
122
-
123
- ### Document API
124
-
125
- Read more about examples of using Document API on [wiki](https://github.com/p0deje/groupdocs-ruby/wiki/Document-API).
126
-
127
- ### Job API
128
-
129
- Read more about examples of using Job API on [wiki](https://github.com/p0deje/groupdocs-ruby/wiki/Job-API).
130
-
131
- ### Signature API
132
-
133
- Not yet implemented.
134
-
135
- ### Storage API
136
-
137
- Read more about examples of using Storage API on [wiki](https://github.com/p0deje/groupdocs-ruby/wiki/Storage-API).
138
-
139
87
  ### Copyright
140
88
 
141
89
  Copyright (c) 2012 Aspose Inc.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new do |spec|
5
- spec.rspec_opts = %w(--color)
5
+ spec.rspec_opts = %w(--color --require fuubar --format Fuubar)
6
6
  spec.pattern = 'spec/**/*_spec.rb'
7
7
  end
8
8
 
@@ -0,0 +1,13 @@
1
+ ## Examples
2
+
3
+ ### Annotations
4
+
5
+ Grab the copy of examples
6
+
7
+ gem install bundler # unless it's already installed
8
+ git clone git@github.com:groupdocs/groupdocs-ruby.git
9
+ cd groupdocs-ruby/examples/annotations
10
+ bundle install --path vendor/bundle
11
+ bundle exec ruby app.rb
12
+
13
+ Now open `http://localhost:4567` and try it!
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'groupdocs'
5
+ gem 'haml'
@@ -0,0 +1,67 @@
1
+ require 'sinatra'
2
+ require 'groupdocs'
3
+ require 'haml'
4
+
5
+ GroupDocs.api_version = '2.0'
6
+
7
+ get '/' do
8
+ haml :upload
9
+ end
10
+
11
+ post '/upload' do
12
+ set :client_id, params[:client_id]
13
+ set :private_key, params[:private_key]
14
+ filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
15
+ File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
16
+ @@file = GroupDocs::Storage::File.upload!(filepath, '/', client_id: options.client_id, private_key: options.private_key)
17
+
18
+ haml :annotations
19
+ end
20
+
21
+ get '/annotations' do
22
+ annotations = @@file.to_document.annotations!(client_id: options.client_id, private_key: options.private_key)
23
+ annotations.map { |annotation| "Annotation Type: #{annotation.type} -- Replies: #{annotation.replies.map { |reply| "'#{reply.user_name}':'#{reply.text}'" }}" }.join "<br />"
24
+ end
25
+
26
+
27
+ __END__
28
+
29
+ @@layout
30
+ %html
31
+ %head
32
+ %title GroupDocs Ruby SDK Annotations Sample App
33
+ %script{ src: "http://rightjs.org/hotlink/right.js" }
34
+ :javascript
35
+ "#annotations".onClick(function(event) {
36
+ event.stop();
37
+ $('annotations_list').load("/annotations");
38
+ });
39
+ %body
40
+ = yield
41
+
42
+ @@upload
43
+ %h4 Upload file
44
+ %form{ action: '/upload', method: 'post', enctype: 'multipart/form-data' }
45
+ %label{ for: 'client_id' } GroupDocs Client ID
46
+ %br
47
+ %input{ type: 'text', name: 'client_id' }
48
+ %br
49
+ %label{ for: 'private_key' } GroupDocs Private Key
50
+ %br
51
+ %input{ type: 'text', name: 'private_key' }
52
+ %br
53
+ %label{ for: 'file' } File
54
+ %br
55
+ %input{ type: 'file', name: 'file' }
56
+ %br
57
+ %br
58
+ %input{ type: 'submit', value: 'Upload' }
59
+
60
+ @@annotations
61
+ %iframe{ src: "https://apps.groupdocs.com/document-annotation/Embed/#{@@file.guid}", frameborder: 0, width: 720, height: 600 }
62
+ %br
63
+ %br
64
+ %button#annotations Poll annotations
65
+ %br
66
+ %br
67
+ #annotations_list
data/groupdocs.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
2
- require "groupdocs/version"
2
+ require 'groupdocs/version'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'groupdocs'
@@ -17,9 +17,9 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_runtime_dependency 'rest-client', '~> 1.6'
19
19
  s.add_runtime_dependency 'json' , '~> 1.7'
20
- s.add_runtime_dependency 'ruby-hmac' , '~> 0.4'
21
20
 
22
- s.add_development_dependency 'rspec' , '~> 2.9'
21
+ s.add_development_dependency 'rspec' , '~> 2.11'
22
+ s.add_development_dependency 'fuubar' , '~> 1.1'
23
23
  s.add_development_dependency 'rake' , '~> 0.9'
24
24
  s.add_development_dependency 'simplecov', '~> 0.6'
25
25
  s.add_development_dependency 'yard' , '~> 0.8'
data/lib/groupdocs.rb CHANGED
@@ -1,13 +1,13 @@
1
- require 'rest-client'
2
1
  require 'groupdocs/version'
3
2
  require 'groupdocs/errors'
4
3
  require 'groupdocs/api'
5
- require 'groupdocs/extensions'
6
4
  require 'groupdocs/datasource'
7
5
  require 'groupdocs/document'
8
6
  require 'groupdocs/job'
9
7
  require 'groupdocs/questionnaire'
8
+ require 'groupdocs/signature'
10
9
  require 'groupdocs/storage'
10
+ require 'groupdocs/subscription'
11
11
  require 'groupdocs/user'
12
12
 
13
13
  module GroupDocs
@@ -34,6 +34,15 @@ module GroupDocs
34
34
  @api_server || 'https://api.groupdocs.com'
35
35
  end
36
36
 
37
+ #
38
+ # Returns version of API.
39
+ #
40
+ # @return [String] API version. Default one if it has not been explicitly set
41
+ #
42
+ def api_version
43
+ @api_version || '2.0'
44
+ end
45
+
37
46
  #
38
47
  # Calls block for configuration of GroupDocs.
39
48
  #
@@ -47,7 +47,7 @@ module GroupDocs
47
47
  def to_hash
48
48
  hash = {}
49
49
  instance_variables.each do |variable|
50
- key = variable_to_accessor(variable)
50
+ key = variable.to_s.delete(?@).to_sym
51
51
  value = instance_variable_get(variable)
52
52
 
53
53
  hash[key] = case value
@@ -121,6 +121,22 @@ module GroupDocs
121
121
  "@#{word}".to_sym
122
122
  end
123
123
 
124
+ #
125
+ # Returns class name.
126
+ # @api private
127
+ #
128
+ def class_name
129
+ self.class.name.split('::').last.downcase
130
+ end
131
+
132
+ #
133
+ # Returns pluralized class name.
134
+ # @api private
135
+ #
136
+ def pluralized_class_name
137
+ "#{class_name}s"
138
+ end
139
+
124
140
  end # Entity
125
141
  end # Api
126
142
  end # GroupDocs
@@ -4,22 +4,22 @@ module GroupDocs
4
4
  module Path
5
5
 
6
6
  #
7
- # Verifies path starts with root.
7
+ # Make helper methods accessible as class methods as well
8
8
  #
9
- # @raise [ArgumentError] If path does not start with /
10
- # @api private
11
- #
12
- def self.verify_starts_with_root(path)
13
- path.chars.first == '/' or raise ArgumentError, "Path should start with /: #{path.inspect}"
9
+ def self.included(klass)
10
+ klass.extend self
14
11
  end
15
12
 
13
+ private
14
+
16
15
  #
17
- # Appends file name to path if it's not present.
18
- #
16
+ # Prepares path.
17
+ # @param [String] path
18
+ # @return [String]
19
19
  # @api private
20
20
  #
21
- def self.append_file_name(path, name)
22
- path << "/#{Object::File.basename(name)}" unless /\.(\w){3,4}$/ === path
21
+ def prepare_path(path)
22
+ path.sub(%r(^/), '').gsub(%r(//+), '/')
23
23
  end
24
24
 
25
25
  end # Path