Class: SharepointApi
- Inherits:
-
Object
- Object
- SharepointApi
- Extended by:
- Forwardable
- Includes:
- FileSystem, Items, Permissions, Users
- Defined in:
- lib/sharepoint_api.rb,
lib/sharepoint_api/items.rb,
lib/sharepoint_api/users.rb,
lib/sharepoint_api/version.rb,
lib/sharepoint_api/file_info.rb,
lib/sharepoint_api/file_system.rb,
lib/sharepoint_api/permissions.rb,
lib/sharepoint_api/filename_cleaner.rb,
lib/sharepoint_api/sharepoint_error.rb,
lib/sharepoint_api/version_converter.rb
Defined Under Namespace
Modules: FileSystem, Items, Permissions, Users Classes: FileInfo, FilenameCleaner, SharepointError, VersionConverter
Constant Summary collapse
- VERSION =
'2.4.0'.freeze
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#library_name ⇒ Object
Returns the value of attribute library_name.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Class Method Summary collapse
Instance Method Summary collapse
- #base_path ⇒ Object
- #encode_path(path, safe_quote: true) ⇒ Object
-
#initialize(library_name: '', **config) ⇒ SharepointApi
constructor
A new instance of SharepointApi.
- #login_name(*args, **kwargs) ⇒ Object
- #server_relative_path(path) ⇒ Object
- #site_path ⇒ Object
- #site_relative_path(path, safe_quote: true) ⇒ Object
Methods included from Users
#ensure_user, #fetch_user_id_from_login_name
Methods included from Permissions
#add_group, #add_role_assignment, #add_user_to_group, #break_permission_inheritance_for, #fetch_role_assignments, #find_group, #find_role, #list_item_for, #remove_group, #remove_role_assignment, #remove_user_from_group, #rename_group, #users_in_group
Methods included from FileSystem
#add_file, #add_folder, #add_library, #file_exists?, #files_in_folder, #find_file, #find_file_version, #find_folder, #find_library, #move_file, #remove_file, #remove_file_version, #remove_folder, #rename_file, #retrieve_file_content
Methods included from Items
#fetch_content_types, #validate_update_list_item
Constructor Details
#initialize(library_name: '', **config) ⇒ SharepointApi
Returns a new instance of SharepointApi.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/sharepoint_api.rb', line 52 def initialize(library_name: '', **config) @library_name = library_name @host = config.fetch(:host) @username = config.fetch(:username) @password = config.fetch(:password) @site_name = config[:site_name] || '' @ntlm = config[:ntlm] || false @verbose = config[:verbose] || false @login_name_extractor = config[:login_name_extractor] @site = build_connection end |
Class Attribute Details
.logger ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/sharepoint_api.rb', line 27 def logger @logger ||= begin logger = Logger.new($stdout) logger.level = Logger::WARN logger end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
47 48 49 |
# File 'lib/sharepoint_api.rb', line 47 def host @host end |
#library_name ⇒ Object
Returns the value of attribute library_name.
46 47 48 |
# File 'lib/sharepoint_api.rb', line 46 def library_name @library_name end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
47 48 49 |
# File 'lib/sharepoint_api.rb', line 47 def site @site end |
Class Method Details
.log_as(method, exception_or_message, level: :info) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/sharepoint_api.rb', line 35 def log_as(method, , level: :info) = if .respond_to?(:message) . else end logger.send(level, "#{name}: #{method}: #{message}") end |
Instance Method Details
#base_path ⇒ Object
80 81 82 |
# File 'lib/sharepoint_api.rb', line 80 def base_path "#{protocol}://#{host}/#{site_path}" end |
#encode_path(path, safe_quote: true) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/sharepoint_api.rb', line 84 def encode_path(path, safe_quote: true) path = Addressable::URI.encode(path) path.gsub!(/'/, '%27%27') if safe_quote path.gsub!('+', '%2B') path end |
#login_name(*args, **kwargs) ⇒ Object
91 92 93 |
# File 'lib/sharepoint_api.rb', line 91 def login_name(*args, **kwargs) @login_name_extractor.call(*args, **kwargs) end |
#server_relative_path(path) ⇒ Object
72 73 74 |
# File 'lib/sharepoint_api.rb', line 72 def server_relative_path(path) "/#{site_path}/#{site_relative_path(path)}" end |
#site_path ⇒ Object
76 77 78 |
# File 'lib/sharepoint_api.rb', line 76 def site_path @site.name end |
#site_relative_path(path, safe_quote: true) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/sharepoint_api.rb', line 65 def site_relative_path(path, safe_quote: true) file_path = [ library_name, path ].reject { |p| p.nil? || p == '' }.join('/') encode_path(file_path, safe_quote: safe_quote) end |