picasaweb-backup 0.2.0 → 0.3.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.
data/README.md CHANGED
@@ -3,22 +3,26 @@
3
3
  A gem and executable to backup all your photos stored on Google's Picasaweb
4
4
  service.
5
5
 
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- gem 'picasaweb-backup'
11
-
12
- And then execute:
13
-
14
- $ bundle
6
+ The original code came from http://blog.costan.us/2010/01/automated-backup-for-picasa-web-albums.html
15
7
 
16
- Or install it yourself as:
8
+ ## Installation
17
9
 
18
10
  $ gem install picasaweb-backup
19
11
 
20
12
  ## Usage
13
+ ```
14
+ _ _ _ _
15
+ _ __(_)__ __ _ _____ ___ __ _____| |__ ___| |__ __ _ __| |___ _ _ __
16
+ | '_ \ / _/ _` (_-< _` \ V V / -_) '_ \___| '_ \ _` / _| / / || | '_ \
17
+ | .__/_\__\__,_/__\__,_|\_/\_/\___|_.__/ |_.__\__,_\__|_\_\\_,_| .__/
18
+ |_| |_|
21
19
 
20
+ version 0.2.0
21
+
22
+ Options
23
+ --dir DIR optional directory in which the download should be executed
24
+ -h, --help print this help section
25
+ ```
22
26
  Create an empty folder an place a file called `account.yml` with the following
23
27
  content:
24
28
 
@@ -18,6 +18,11 @@ opt_parser = OptionParser.new('Backing up your Picasaweb photos') do |opt|
18
18
  opt.on("--dir DIR", "optional directory in which the download should be executed") do |dir|
19
19
  opts[:dir] = dir
20
20
  end
21
+
22
+ opt.on "-l","--log", "log to a file instead of stout" do
23
+ opts[:log] = true
24
+ end
25
+
21
26
  opt.on("-h","--help", "print this help section") do
22
27
  puts opt_parser
23
28
  exit 0
@@ -25,11 +30,12 @@ opt_parser = OptionParser.new('Backing up your Picasaweb photos') do |opt|
25
30
  end
26
31
 
27
32
  opt_parser.parse!(ARGV)
33
+ cli = Picasaweb::CLI.new opts
28
34
 
29
35
  begin
30
36
 
31
37
  if opts[:dir]
32
- puts "Changing working directory to #{opts[:dir]}"
38
+ cli.print "Changing working directory to #{opts[:dir]}"
33
39
  Dir.chdir opts[:dir]
34
40
  end
35
41
 
@@ -49,11 +55,11 @@ begin
49
55
 
50
56
  if !File.directory? album[:title]
51
57
  Dir.mkdir album[:title]
52
- puts "Creating directory for album '#{album[:title]}'"
58
+ cli.print "Creating directory for album '#{album[:title]}'"
53
59
  end
54
60
 
55
61
  Dir.chdir album[:title] do
56
- puts "Checking for new files in '#{album[:title]}'"
62
+ cli.print "Checking for new files in '#{album[:title]}'"
57
63
  photos = nil
58
64
  until photos
59
65
  begin
@@ -66,7 +72,7 @@ begin
66
72
  downloaded_photos = 0
67
73
  photos.each do |photo|
68
74
  if !File.exists? photo[:title]
69
- puts " ==> #{photo[:title]}"
75
+ cli.print " ==> #{photo[:title]}"
70
76
  response = nil
71
77
  until response
72
78
  begin
@@ -81,13 +87,13 @@ begin
81
87
  end
82
88
  end
83
89
  if downloaded_photos == 0
84
- puts "==> no new photos found"
90
+ cli.print "==> no new photos found"
85
91
  end
86
92
  end
87
93
  end
88
94
  rescue => e
89
- puts "ERROR: #{e.message}".red
90
- puts ""
91
- puts opt_parser
95
+ cli.print "ERROR: #{e.message}".red
96
+ cli.print ""
97
+ cli.print opt_parser
92
98
  end
93
99
 
@@ -3,18 +3,34 @@
3
3
  # The script downloads the original version of the photos, and is not limited to
4
4
  # 1600x1200 thumbnails.
5
5
  #
6
- # Author:: Victor Costan
7
- # Copyright:: Copyright (C) 2010 Victor Costan
6
+ # Authors:: Victor Costan, Leonard Ehrenfried
8
7
  # License:: MIT
9
8
 
10
- require "picasaweb-backup/version"
11
- require 'yaml'
12
- require 'rubygems'
13
- require 'gdata'
9
+ require "version"
10
+ require "yaml"
11
+ require "rubygems"
12
+ require "gdata"
13
+ require "logger"
14
14
 
15
15
  module Picasaweb
16
- module Backup
17
- # Your code goes here...
16
+ class CLI
17
+
18
+ def initialize opts
19
+ @opts = opts
20
+ if @opts[:log]
21
+ @logger = Logger.new "picasaweb-backup.log", shift_age = "monthly"
22
+ @logger.datetime_format = "%Y-%m-%d %H:%M"
23
+ end
24
+ end
25
+
26
+ def print msg
27
+ if @logger
28
+ @logger.info msg
29
+ else
30
+ puts msg
31
+ end
32
+ end
33
+
18
34
  end
19
35
  end
20
36
 
@@ -1,5 +1,5 @@
1
1
  module Picasaweb
2
2
  module Backup
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/picasaweb-backup/version', __FILE__)
2
+ require File.expand_path('../lib/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Leonard Ehrenfried"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picasaweb-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2012-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gdata_19
@@ -76,7 +76,7 @@ files:
76
76
  - Rakefile
77
77
  - bin/picasaweb-backup
78
78
  - lib/picasaweb-backup.rb
79
- - lib/picasaweb-backup/version.rb
79
+ - lib/version.rb
80
80
  - picasaweb-backup.gemspec
81
81
  homepage: http://github.com/lenniboy/picasaweb-backup
82
82
  licenses: []