Ruby-iCloud
Ruby-iCloud copied to clipboard
is this a gem?
if so whats its name?
Unlikely due to the Gem not being published to RubyGems.org and its README instructions usage saying:
Usage:
- Clone this repository and simply run
ruby icloud.rb
- You will be prompted for your iCloud username, then password.
You most likely need to clone via the following command
git clone https://github.com/jurriaan/Ruby-iCloud.git
Or download it via the following URL https://github.com/jurriaan/Ruby-iCloud/archive/master.zip
Or via the download link on the main repository page
Then navigate into the the download file directory and then follow the usage instructions, by entering the following in the command line prompt
ruby icloud.rb
@Sonna Fair enough, but does that mean I have to load the whole project into my rails application if I want to use it?
Technically you load the whole project into you rails application when you use it.
But what you are asking is, how do you include a Ruby Gem that is not listed on Ruby Gems?
Within your Ruby project, add the following line to your Gemfile
gem "ruby-icloud", github: "jurriaan/Ruby-iCloud"
For more information, please refer Bundlers documentation:
That should work, otherwise you need to specify the full URL like the following:
gem "ruby-icloud", git: "https://github.com/jurriaan/Ruby-iCloud"
However, like you suggested you can copy the contents of the project into your lib
directory or use a vendor
directory for gems; e.g. vendor/gems
and specific in your Gemfile something like the following
gem "ruby-icloud", path: "vendor/gems/Ruby-iCloud"
Reference: - ruby on rails - How do I vendorize gems for Rails3/Bundler - Stack Overflow
How you copy into the directory could be just a straight copy or a Git Submodule (but submodules are bit more involved when moving the parent level repository around or during deployment, I would only cautiously recommend it).
When I do any of those things I get a
`require': cannot load such file -- ./lib/ruby-icloud/util (LoadError)"
originating from
Ruby-iCloud-5bda330e8271/lib/ruby-icloud.rb:3:in `<top (required)>'
Really all I want from this is a way to verify if an iCloud account (email/password) is valid since they're one of the only major providers not to offer omniauth (to my knowledge), I don't want the command line interface at all. Do you have any idea how to do this?
Preemptive thank you! I'm aware I'm being difficult so thanks for trying to help even though I'm being a chore.
um... You are not going to like this answer (or at least most it).
From what I can gather the Ruby-iCloud/ruby-icloud.rb file that Bundler uses via the Gemfile is written to only work locally, because of its ./lib/ruby-icloud
file paths that are relative and so was really written to use externally.
There two ways to fix this I have found:
To fix the Gem, the Ruby-iCloud/ruby-icloud.rb file that looks this:
require 'bundler/setup'
require './lib/ruby-icloud/util'
require './lib/ruby-icloud/client'
require './lib/ruby-icloud/response'
require './lib/ruby-icloud/plistresponse'
require './lib/ruby-icloud/jsonresponse'
require './lib/ruby-icloud/protobufresponse'
require './lib/ruby-icloud/request'
require './lib/ruby-icloud/protodef/backup.rb'
require './lib/ruby-icloud/responses/accountsettingsresponse.rb'
require './lib/ruby-icloud/responses/authenticationresponse.rb'
require './lib/ruby-icloud/responses/Backup/backupdevicesresponse.rb'
require './lib/ruby-icloud/responses/Backup/backupdeviceresponse.rb'
require './lib/ruby-icloud/responses/Backup/backupfilesresponse.rb'
require './lib/ruby-icloud/responses/Backup/backupgetfilesresponse.rb'
require './lib/ruby-icloud/responses/Backup/backupkeysresponse.rb'
require './lib/ruby-icloud/responses/configurationresponse.rb'
require './lib/ruby-icloud/responses/defaultresponse.rb'
require './lib/ruby-icloud/responses/FindMyiPhone/initclientresponse.rb'
require './lib/ruby-icloud/responses/FindMyiPhone/updateclientresponse.rb'
require './lib/ruby-icloud/requests/accountsettingsrequest.rb'
require './lib/ruby-icloud/requests/authenticationrequest.rb'
require './lib/ruby-icloud/requests/Backup/backupdevicesrequest.rb'
require './lib/ruby-icloud/requests/Backup/backupdevicerequest.rb'
require './lib/ruby-icloud/requests/Backup/backupfilesrequest.rb'
require './lib/ruby-icloud/requests/Backup/backupgetfilesrequest.rb'
require './lib/ruby-icloud/requests/Backup/backupkeysrequest.rb'
require './lib/ruby-icloud/requests/configurationrequest.rb'
require './lib/ruby-icloud/requests/FindMyiPhone/initclientrequest.rb'
require './lib/ruby-icloud/requests/FindMyiPhone/updateclientrequest.rb'
Needs to be updated to look this
require 'bundler/setup'
require 'ruby-icloud/util'
require 'ruby-icloud/client'
require 'ruby-icloud/response'
require 'ruby-icloud/plistresponse'
require 'ruby-icloud/jsonresponse'
require 'ruby-icloud/protobufresponse'
require 'ruby-icloud/request'
require 'ruby-icloud/protodef/backup.rb'
require 'ruby-icloud/responses/accountsettingsresponse.rb'
require 'ruby-icloud/responses/authenticationresponse.rb'
require 'ruby-icloud/responses/Backup/backupdevicesresponse.rb'
require 'ruby-icloud/responses/Backup/backupdeviceresponse.rb'
require 'ruby-icloud/responses/Backup/backupfilesresponse.rb'
require 'ruby-icloud/responses/Backup/backupgetfilesresponse.rb'
require 'ruby-icloud/responses/Backup/backupkeysresponse.rb'
require 'ruby-icloud/responses/configurationresponse.rb'
require 'ruby-icloud/responses/defaultresponse.rb'
require 'ruby-icloud/responses/FindMyiPhone/initclientresponse.rb'
require 'ruby-icloud/responses/FindMyiPhone/updateclientresponse.rb'
require 'ruby-icloud/requests/accountsettingsrequest.rb'
require 'ruby-icloud/requests/authenticationrequest.rb'
require 'ruby-icloud/requests/Backup/backupdevicesrequest.rb'
require 'ruby-icloud/requests/Backup/backupdevicerequest.rb'
require 'ruby-icloud/requests/Backup/backupfilesrequest.rb'
require 'ruby-icloud/requests/Backup/backupgetfilesrequest.rb'
require 'ruby-icloud/requests/Backup/backupkeysrequest.rb'
require 'ruby-icloud/requests/configurationrequest.rb'
require 'ruby-icloud/requests/FindMyiPhone/initclientrequest.rb'
require 'ruby-icloud/requests/FindMyiPhone/updateclientrequest.rb'
So, no relative paths, otherwise you would get these kind of errors
~/.gems/2.3.0/bundler/gems/Ruby-iCloud-5bda330e8271/lib/ruby-icloud.rb:3:in `require': cannot load such file -- ./lib/ruby-icloud/util (LoadError)
However, we are trying to avoid altering the source without taking full ownership, so my alternative and second solution is to recreate that file within your vendor/gems
directory as ruby-icloud.rb
as follows:
require "bundler/setup"
require 'ruby-icloud/client'
require 'ruby-icloud/util'
require 'ruby-icloud/client'
require 'ruby-icloud/response'
require 'ruby-icloud/plistresponse'
require 'ruby-icloud/jsonresponse'
require 'ruby-icloud/protobufresponse'
require 'ruby-icloud/request'
require 'ruby-icloud/protodef/backup.rb'
require 'ruby-icloud/responses/accountsettingsresponse.rb'
require 'ruby-icloud/responses/authenticationresponse.rb'
require 'ruby-icloud/responses/Backup/backupdevicesresponse.rb'
require 'ruby-icloud/responses/Backup/backupdeviceresponse.rb'
require 'ruby-icloud/responses/Backup/backupfilesresponse.rb'
require 'ruby-icloud/responses/Backup/backupgetfilesresponse.rb'
require 'ruby-icloud/responses/Backup/backupkeysresponse.rb'
require 'ruby-icloud/responses/configurationresponse.rb'
require 'ruby-icloud/responses/defaultresponse.rb'
require 'ruby-icloud/responses/FindMyiPhone/initclientresponse.rb'
require 'ruby-icloud/responses/FindMyiPhone/updateclientresponse.rb'
require 'ruby-icloud/requests/accountsettingsrequest.rb'
require 'ruby-icloud/requests/authenticationrequest.rb'
require 'ruby-icloud/requests/Backup/backupdevicesrequest.rb'
require 'ruby-icloud/requests/Backup/backupdevicerequest.rb'
require 'ruby-icloud/requests/Backup/backupfilesrequest.rb'
require 'ruby-icloud/requests/Backup/backupgetfilesrequest.rb'
require 'ruby-icloud/requests/Backup/backupkeysrequest.rb'
require 'ruby-icloud/requests/configurationrequest.rb'
require 'ruby-icloud/requests/FindMyiPhone/initclientrequest.rb'
require 'ruby-icloud/requests/FindMyiPhone/updateclientrequest.rb'
Also,require "bundler/setup"
may or may not required, depending on your setup since it may have been required (but require it first and toggle it off and on after it works the first time to see if it is necessary)
So basically it is the same fix, but you would call your vendor copy locally, via:
require "vendor/gems/ruby-icloud"
Depending on where you place it and how your load paths are setup
Instead of
require "ruby-icloud"
And lastly, if are using Rails it is usually setup to require everything included in the Gem file (that varies between environments and Gem groups) so would need to add the following option require: false
to your ruby-icloud
gem within the Gemfile, like so:
gem "ruby-icloud", github: "jurriaan/Ruby-iCloud", require: false
I think that's it.
Ok got it to load in my project, but when I try to initialize a RubyiCloud::Client object it errors on line 13 in client.rb
dir = Dir.mktmpdir
this one @client.set_cookie_store("#{dir}/cookies.bin")
with the error
Errno::ENOENT: No such file or directory @ rb_sysopen - /var/folders/ss/tbk3ffkj0snff_tgm5wp0wj00000gn/T/d20170309-7719-1v6dskk/cookies.bin
I am not actually familiar with this Ruby library, I just thought I could help you with your require Gem issue.
Also, it kind of a new issue
I can get pass the initial RubyiCloud::Client.new
and authenticate myself, then print my User account details. So my guess would file / folder permissions for the user running the Rails application and writing to the temporary directory (which is usuallytmp/
).
The /var/folder
indicates you are running on OSX (or macOS); according to - What is "/var/folders"?.
The temporary folder might be aggressively flushed by the operating system, or full (somehow). However, you should be able to change it with the Rails environment setting ENV['RAILS_TMP']
to something else; e.g.
RAILS_TMP='/tmp' rails server # ...
_Just make sure the tmp
directory exists, or set to public
folder instead; e.g. RAILS_TMP='public' _
UPDATE: Sorry, I was reviewing this answer without fully understanding it.
It probably will not work.
UPDATE2:
The environment variable ENV['TMPDIR']
may/should work instead; i.e.
TMPDIR='/tmp' rails server # ...