Class: DribbbleBucketSync
- Inherits:
-
Object
- Object
- DribbbleBucketSync
- Defined in:
- lib/dribbble_bucket_sync.rb,
lib/dribbble_bucket_sync/folder.rb,
lib/dribbble_bucket_sync/version.rb
Defined Under Namespace
Classes: Folder
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username) ⇒ DribbbleBucketSync
constructor
A new instance of DribbbleBucketSync.
- #sync_to(directory) ⇒ Object
Constructor Details
#initialize(username) ⇒ DribbbleBucketSync
Returns a new instance of DribbbleBucketSync.
9 10 11 |
# File 'lib/dribbble_bucket_sync.rb', line 9 def initialize(username) @username = username end |
Instance Attribute Details
#username ⇒ Object (readonly)
Returns the value of attribute username.
7 8 9 |
# File 'lib/dribbble_bucket_sync.rb', line 7 def username @username end |
Instance Method Details
#sync_to(directory) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dribbble_bucket_sync.rb', line 13 def sync_to(directory) # ensure the directory exists unless File.directory?(directory) raise ArgumentError, "Sync destination must be a valid directory:\n#{directory}" end # get the first page response = connection.buckets(page: 1) # load the total pages total_pages = response.total_pages # return if total pages is none return if total_pages < 1 # print how many buckets there are puts "#{@username} has #{response.total_entries} buckets." # loop through each page 1.upto(total_pages) do |page| # load the buckets for this page buckets = connection.buckets(page: page) # sync each bucket buckets.each do |bucket| sync_bucket(bucket, directory) end # being nice to Dribbble site # sleep for 1 - 3 seconds every 5 buckets sleep(3) + 1 end end |