snatch 0.0.3 → 0.0.4

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/snatch.rb +26 -20
  3. data/snatch.gemspec +2 -2
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/lib/snatch.rb CHANGED
@@ -4,6 +4,18 @@ require "#{File.dirname(__FILE__)}/extensions"
4
4
  require 'snatch/clean'
5
5
 
6
6
  class Snatch
7
+ RAILS_PUBLIC_ASSETS = [
8
+ '404.html',
9
+ '422.html',
10
+ '500.html',
11
+ 'favicon.ico',
12
+ 'iepngfix.htc',
13
+ 'images',
14
+ 'javascripts',
15
+ 'open-flash-chart.swf',
16
+ 'robots.txt',
17
+ 'stylesheets'
18
+ ].map { |file_name| File.expand_path("#{RAILS_ROOT}/public/#{file_name}") }
7
19
  PUBLIC_PATH = File.expand_path("#{Dir.pwd}/public")
8
20
 
9
21
  def initialize(url = nil)
@@ -27,6 +39,7 @@ class Snatch
27
39
  end
28
40
 
29
41
  def fetch
42
+ remove_cms_files &&
30
43
  download_files &&
31
44
  convert_dynamic_stylesheets &&
32
45
  git_push
@@ -36,29 +49,27 @@ private
36
49
 
37
50
  def log(message)
38
51
  bang = "\e[36;40;1m=>\e[0m"
39
- puts "#{bang} #{message}"
40
- end
41
-
42
- def which(name)
43
- @which ||= {}
44
- return @which[name] unless @which[name].nil?
45
- path = `which #{name}`.strip
46
- @which[name] = path
52
+ puts "#{bang} #{message[0..50]}..."
47
53
  end
48
54
 
49
55
  def wget(arguments = nil)
50
- wget_path = which :wget
51
- log "#{wget_path} #{arguments}"
52
- %x{#{wget_path} #{arguments}}
56
+ log "wget #{arguments}"
57
+ %x{wget #{arguments}}
53
58
  end
54
59
 
55
60
  def git(command, *args)
56
61
  options = args.last.is_a?(Hash) ? args.pop : {}
57
62
  arguments = args.join(' ')
58
63
  redirect = ' > /dev/null' if options[:silent]
59
- git_path = which :git
60
- log "#{git_path} #{command} #{arguments}#{redirect}"
61
- %x(#{git_path} #{command} #{arguments}#{redirect})
64
+ log "git #{command} #{arguments}#{redirect}"
65
+ %x(git #{command} #{arguments}#{redirect})
66
+ end
67
+
68
+ def remove_cms_files
69
+ glob_path = File.expand_path("#{RAILS_ROOT}/public") + '/*'
70
+ Pathname.glob(glob_path) do |pathname|
71
+ pathname.rm_rf unless RAILS_PUBLIC_ASSETS.include?(pathname.expand_path('public').to_s)
72
+ end
62
73
  end
63
74
 
64
75
  def download_files
@@ -72,13 +83,8 @@ private
72
83
  end
73
84
  end
74
85
 
75
- def files_to_remove
76
- Dir.glob(File.join(PUBLIC_PATH, '**/*')).reject { |path| path =~ %r{public/packaged/} }
77
- end
78
-
79
86
  def git_push
80
- git :rm, "-rq --cached #{files_to_remove}"
81
- git :add, "public"
87
+ git :add, "-A public"
82
88
  git :commit, "-q -m 'Automatic snatch'"
83
89
  git :push, :silent => true
84
90
  end
data/snatch.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{snatch}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Conroy-Finn"]
12
- s.date = %q{2010-02-02}
12
+ s.date = %q{2010-02-04}
13
13
  s.description = %q{Simple site downloaded that wraps wget and converts PHP CSS files in to regular CSS files.}
14
14
  s.email = %q{james@logi.cl}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Conroy-Finn
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-02 00:00:00 +00:00
12
+ date: 2010-02-04 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency