sitemap2png 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmM5ZjIxZmUwYmJhYjRkZWU0YTdkMmY1NmVkMWRiMjJmOTgyOGM0MA==
4
+ NmJkMzIwMTM4YTE3MWUzYzEzZjVhZjczZjE1NjA1M2U3MjYzOWU3OQ==
5
5
  data.tar.gz: !binary |-
6
- YjcyMjIwZGU1ZTM4N2RhYmYyNzljYjBkY2Y2OWE3MGYwMGU3ZjdjZA==
6
+ YmZiNjhlZTAxNGU4NTMzYTY5NmEzOTdkZGMxYmNlZGJmMzA5ZjRkMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjBmNzRjNTIyZmM0MGZkYjQ3NjM2MDlmNzM0NjM3YWJhZDBjNDE2OWFjY2Qx
10
- MDJlNGRiNDg2YmQ0OTMyNmI1MWJjMGVjOWZkNmI3YmQ2NmE5MmYxM2EwMGVi
11
- YmMzZTI4NDc3MDE0NzAwMjEyZTk2YjU0NjcxNTMwOWI3MWU5Yjg=
9
+ NzI0ZTBhZjIzY2ZiZjgyOGYxMTZkNGU5OTY1ODRmNTllOTcxNWE2ZTI4ZjRi
10
+ NDI3ZTU5N2U4YWFkMWZmZmVkMWIzOTVjMTAzOWZmYWIyOTRkOTBhMjU0ODMw
11
+ ZmU4MWIwNjY3MjI2NTBjYjY3NWE3MDczMGEyNDI0NWJhODk3NGM=
12
12
  data.tar.gz: !binary |-
13
- ZGZmMTJhOWVmN2NhNjRhYzFkNDg3NTdiNmY0NWNlYTQyNzBlZTc2ZWE5NmFh
14
- ZTcyMGU3YmRlMGNiMjgwYzExMmI0ZjAyZjRjY2YwNWU5ZWYwMDk2ZTM1MGEy
15
- ZWUwYzNiMDczODM0MWE3YmZiZDU4OWNjYjQzMzEzOGQxMDNhNGU=
13
+ NDcyYjk1MGUwODcxMTRhZDljZjIyNzc0ODZhYzNjNmI4ODMyODZlY2I4OGIz
14
+ Y2I0ZjM4ZWE2YjlmZDI1MDY4MjUyMjFiMGQyNTdmMmU2NDk1MjE5Y2Q5Mjk1
15
+ YjE1ZGI5YjExYTQ0NTdlZDQ1ZDBhY2NhMGY4OWVmODdiMDBhNjA=
data/README.md CHANGED
@@ -11,12 +11,36 @@
11
11
  ```
12
12
  $ gem install sitemap2png
13
13
  ```
14
+
14
15
  ## Usage
15
16
 
16
17
  The following tasks are available trough the command line.
17
18
 
18
19
  ```
19
20
  Commands:
21
+ sitemap2png help [COMMAND] # Describe available commands or one specific command
22
+ sitemap2png load SITEMAP PATH WITH # Load sitemap.xml & save screenshots
23
+ ```
24
+
25
+ ## Commands
26
+
27
+ ### load
28
+
29
+ ```
30
+ Usage:
31
+ sitemap2png load SITEMAP PATH WITH
32
+
33
+ Options:
34
+ -w, [--with=N]
35
+ # Default: 1024
36
+ -d, [--delay=N]
37
+ # Default: 0
38
+ ```
39
+
40
+ ## Example Usage
41
+
42
+ ```
43
+ $ sitemap2png load http://mysite.com/sitemap.xml /path/to/destination -w 1900
20
44
  ```
21
45
 
22
46
  ## Development
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :default do
4
+ system "rake -T"
5
+ end
@@ -6,35 +6,46 @@ require 'fileutils'
6
6
  module Sitemap2png
7
7
  class Cli < Thor
8
8
 
9
- desc "load SITEMAP TARGET", "Load sitemap.xml and take screenshots"
9
+ desc "load SITEMAP PATH WITH", "Load sitemap.xml & save screenshots"
10
+ method_option :with, :aliases => "-w", :type => :numeric, :default => 1024
10
11
  method_option :delay, :aliases => "-d", :type => :numeric, :default => 0
11
- def load(sitemap, target)
12
- basedir = File.dirname(File.dirname(File.dirname(__FILE__)))
13
- webkit2png = "#{basedir}/vendor/webkit2png"
12
+ def load(sitemap, path)
13
+ @basedir = File.dirname(File.dirname(File.dirname(__FILE__)))
14
+ @webkit2png = "#{@basedir}/vendor/webkit2png"
14
15
 
15
- # validate target
16
- FileUtils.mkdir_p(target) unless Dir.exists?(target)
16
+ # validate path
17
+ FileUtils.mkdir_p(path) unless Dir.exists?(path)
17
18
 
19
+ load_sitemap(sitemap, path, options[:width], options[:delay])
18
20
 
19
- begin
20
- puts "Loading sitemap..."
21
- xml = Net::HTTP.get_response(URI.parse(sitemap)).body
22
- rescue Exception=>e
23
- raise Thor::Error, "Could not read sitemap!"
24
- end
21
+ end
22
+
23
+ no_tasks do
24
+
25
+ def load_sitemap(sitemap, path, width, delay)
26
+ begin
27
+ puts "Loading sitemap #{sitemap}"
28
+ xml = Net::HTTP.get_response(URI.parse(sitemap)).body
29
+ rescue Exception => error
30
+ raise Thor::Error, "Could not read sitemap!"
31
+ end
25
32
 
26
- # validate data
27
- doc = Nokogiri::XML(xml)
33
+ # validate data
34
+ doc = Nokogiri::XML(xml)
28
35
 
29
- puts "Parsing pages..."
30
- doc.css('url > loc').each do |node|
31
- url = node.text
32
- name = File.basename(url, '.*')
33
- puts "Taking shots from: #{url}..."
34
- [640, 768, 1024, 1600].each do |width|
35
- system "#{webkit2png} #{url} --thumb --dir=#{target} --width=#{width} --filename=#{name}-#{width} --delay=#{options[:delay]}"
36
+ doc.css('url > loc').each do |node|
37
+ url = node.text
38
+ name = File.basename(url, '.*')
39
+ puts "Taking shots from: #{url}"
40
+ system "#{@webkit2png} #{url} --thumb --dir=#{path} --width=#{width} --filename=#{name}-#{width} --delay=#{delay}"
36
41
  end
42
+
43
+ doc.css('sitemap > loc').each do |node|
44
+ load_sitemap(node.text, path, width, delay)
45
+ end
46
+
37
47
  end
48
+
38
49
  end
39
50
 
40
51
  end
@@ -1,3 +1,3 @@
1
1
  module Sitemap2png
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitemap2png
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - franklin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor