datapimp 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04d4793efcb122a4aa130ae1e979303970defb83
4
- data.tar.gz: 27044a2f923a7e155ca65d0173db0689f5c45119
3
+ metadata.gz: f92a9f500550b9bf611651ec9269f1f1022b50aa
4
+ data.tar.gz: 8513b18bb3c76b1ea20e3eb91d532f8f37976994
5
5
  SHA512:
6
- metadata.gz: 3d9b7739a5f9988355b4e71b9d0dec7e031d9f1d2f2c36d63d1c0d8e3adc94a5eda99393da65f8c54db5b469c865856d7544be70c4d43cb405571869bc064e28
7
- data.tar.gz: 4563f49579ceff3abb34559fc754158e1cf8c4211f949f26a6a0c063f2c992f4d35f92a3771d164281599f4d2b1297b4821897792829d54dc438d29513ced6d8
6
+ metadata.gz: c59ce1165293766f89ed019f6862e39cfc8097c39efe7e152918b512a88605197b8aaa3dcee138655bb1ba42a6f7610a13b45692f6f2ee56886bb83fba59d0ed
7
+ data.tar.gz: 761f03f731d979fdae3760884eb5954c8f4b0de1179a71d85bb3577b04abbde1693ee076c6aeda3de1159a68046a73504e816619b4994ee2c20b7a74acd66cf7
data/Rakefile CHANGED
@@ -2,9 +2,6 @@ Dir[File.join(Dir.pwd, 'tasks', '**', '*.rb')].each { |f| require f }
2
2
  Dir[File.join(Dir.pwd, 'tasks', '*.rake')].each { |f| load f }
3
3
 
4
4
  require "bundler/gem_tasks"
5
- require 'rspec/core/rake_task'
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
5
 
9
6
  Distribution.configure do |config|
10
7
  config.package_name = 'datapimp'
@@ -18,4 +15,6 @@ Distribution.configure do |config|
18
15
  ]
19
16
  end
20
17
 
21
- task :default => :spec
18
+ task :default do
19
+ puts "Sup?"
20
+ end
@@ -5,8 +5,12 @@ command 'create cache invalidations' do |c|
5
5
  Datapimp::Cli.accepts_keys_for(c, :amazon)
6
6
 
7
7
  c.option '--all-html', 'Invalidate all HTML paths in the bucket'
8
+ c.option '--verbose', 'Print extra information such as exactly what paths get invalidated'
8
9
  c.option '--previous-deploy', 'Invalidate all paths from the previous deploy'
9
- c.option '--paths PATHS', Array, 'The paths you would like to invalidate'
10
+ c.option '--paths PATHS', Array, 'List the specific paths you would like to invalidate'
11
+ c.option '--local-path FOLDER', String, 'Determine which paths to invalidate by looking at the files in this folder'
12
+ c.option '--ignore-paths PATTERN', String, 'Ignore any paths matching the supplied regex'
13
+ c.option '--match-paths PATTERN', String, 'Only invalidate paths matching the supplied regex'
10
14
 
11
15
  c.action do |args, options|
12
16
  options.defaults(:paths => [])
@@ -15,7 +19,16 @@ command 'create cache invalidations' do |c|
15
19
 
16
20
  paths = Array(options.paths)
17
21
 
18
- if options.all_html
22
+ if options.local_path
23
+ local = Pathname(options.local_path)
24
+
25
+ paths += Dir[local.join('**/*')].map do |file|
26
+ file = Pathname(file)
27
+ "/#{file.relative_path_from(local)}"
28
+ end
29
+ end
30
+
31
+ if options.local_path.to_s.length == 0 && options.all_html
19
32
  html_files = bucket.s3.files.select {|file| file.key.match(/\.html/) }
20
33
 
21
34
  paths += html_files.map {|file| file.public_url }.map do |url|
@@ -24,19 +37,39 @@ command 'create cache invalidations' do |c|
24
37
  index = "/" if index == ""
25
38
  [path, index]
26
39
  end
40
+ end
27
41
 
42
+ if options.local_path.to_s.length > 0 && options.all_html
43
+ paths.select! {|path| path.match(/\.html$/) }
44
+ paths.map! {|path| [path, path.gsub('/index.html','')] }
28
45
  paths.flatten!
46
+ paths << "/"
29
47
  end
30
48
 
49
+ paths.flatten!
50
+
51
+ # TODO
52
+ # Need to pull out paths that were previous deployed.
53
+ # We can rely on the s3 bucket deploy manifest for this.
31
54
  if options.previous_deploy
32
55
  items = bucket.deploy_manifest["uploaded"]
33
56
  items
34
57
  end
35
58
 
59
+ if options.match_paths
60
+ paths.select! {|path| path.to_s.match(options.ignore_paths) }
61
+ end
62
+
63
+ if options.ignore_paths
64
+ paths.reject! {|path| path.to_s.match(options.ignore_paths) }
65
+ end
66
+
67
+ paths.reject! {|path| path.length == 0}
68
+
36
69
  if paths.length > 0
37
70
  log "Posting invalidations for #{ paths.length } paths"
38
71
  Datapimp::Sync.amazon.cdn.post_invalidation(bucket.cloudfront.id, paths)
39
- log "Invalidated paths: #{ paths.inspect }"
72
+ log "\nInvalidated paths: #{ paths.inspect }" if options.verbose
40
73
  end
41
74
  end
42
75
  end
@@ -92,5 +125,6 @@ command 'create cloudfront distribution' do |c|
92
125
  distribution.cname = Array(options.domains)
93
126
  distribution.save
94
127
  end
128
+
95
129
  end
96
130
  end
@@ -1,3 +1,3 @@
1
1
  module Datapimp
2
- VERSION = "1.0.12"
2
+ VERSION = "1.0.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datapimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-30 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -444,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
444
  version: '0'
445
445
  requirements: []
446
446
  rubyforge_project:
447
- rubygems_version: 2.4.5
447
+ rubygems_version: 2.2.2
448
448
  signing_key:
449
449
  specification_version: 4
450
450
  summary: A collection of API development patterns that I have accumulated in my career