scrnshots 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in scrnshots-downloader.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Greg Bell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ # ScrnShots Downloader
2
+
3
+ A Ruby Gem to download your screenshots from ScrnShots.com
4
+
5
+ ## Usage
6
+
7
+ First, install the gem
8
+
9
+ $> gem install scrnshots
10
+
11
+ Then use the scrnshots command to download your screenshots to a directory of
12
+ your choosing.
13
+
14
+ $> scrnshots YOURUSERNAME SOMEDIRECTORY
15
+
16
+ Example:
17
+
18
+ $> scrnshots gregbell ~/my-scrnshots
19
+
20
+ After some time passes... Open up ~/my-scrnshots and voila! All your
21
+ screenshots.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'scrnshots'
5
+
6
+ ScrnShots::CLI.run(ARGV.dup)
@@ -0,0 +1,64 @@
1
+ require 'fileutils'
2
+ require 'httparty'
3
+ require 'open-uri'
4
+
5
+ class ScrnShots
6
+ include HTTParty
7
+ base_uri "http://scrnshots.com"
8
+
9
+ def initialize(username)
10
+ @username = username
11
+ end
12
+
13
+ def all
14
+ page = 1
15
+
16
+ while paths = screenshots_for_page(page)
17
+ paths.each do |path|
18
+ yield path
19
+ end
20
+ page += 1
21
+ end
22
+ end
23
+
24
+ def screenshots_for_page(page)
25
+ results = self.class.get("/users/#{@username}/screenshots.json?page=#{page}")
26
+ if results.size > 0
27
+ results.collect do |result|
28
+ result["images"]["fullsize"]
29
+ end
30
+ else
31
+ false
32
+ end
33
+ end
34
+
35
+ module CLI
36
+
37
+ def self.run(args)
38
+ print_banner_and_exit unless args[0] && args[1]
39
+ download(args[0], args[1])
40
+ end
41
+
42
+ def self.download(username, directory)
43
+ FileUtils.mkdir_p(directory) unless File.exists?(directory)
44
+ puts "Starting to download screenshots. This may take a while..."
45
+
46
+ ScrnShots.new(username).all do |path|
47
+ print(".")
48
+ STDOUT.flush
49
+ filename = File.basename(path)
50
+ File.open(File.join(directory, filename), 'w+') do |f|
51
+ open(path){|image| f << image.read }
52
+ end
53
+ end
54
+ end
55
+
56
+ def self.print_banner_and_exit
57
+ puts "Usage: $ scrnshots USERNAME DIR"
58
+ exit(1)
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "scrnshots"
6
+ s.version = "1.0.0"
7
+ s.authors = ["Greg Bell"]
8
+ s.email = ["gregdbell@gmail.com"]
9
+ s.homepage = ""
10
+ s.summary = %q{Download all your Screenshots stored on ScrnShots.com}
11
+ s.description = %q{Download all your Screenshots stored on ScrnShots.com}
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+
18
+ s.add_runtime_dependency "httparty"
19
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrnshots
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Greg Bell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: &70196283842000 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70196283842000
25
+ description: Download all your Screenshots stored on ScrnShots.com
26
+ email:
27
+ - gregdbell@gmail.com
28
+ executables:
29
+ - scrnshots
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - bin/scrnshots
39
+ - lib/scrnshots.rb
40
+ - scrnshots.gemspec
41
+ homepage: ''
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.10
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Download all your Screenshots stored on ScrnShots.com
65
+ test_files: []