cknife 1.1.0 → 1.1.1

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: 942e64f111eae005180fac6810e16a3edf9c3a84
4
- data.tar.gz: c4a46d9f451bb18b8799815c48a1be45d1632e49
3
+ metadata.gz: 7870ad7c8c9c58e3d5b7b74bc2e021d60a87a21a
4
+ data.tar.gz: 41c4dbed7df35ec62fbfbcdc829e7d4b4dab6965
5
5
  SHA512:
6
- metadata.gz: dbe3f929fa330740f8928de67be6b45f5ad3f3088538c79a7cd47bf0a88f4dd4492d7bfcdcd6018e86072c08228f6edf94db28c2c9366526bae39294d9dfca34
7
- data.tar.gz: 805af5ed73add5a49fc6f10c4ae97bd6f73e6230625d1becb8b33e1b6303758d55d16ed64cb9d382f3e711bb9752bc1ca8a01dedd0d624990bfd896bcde6b7c8
6
+ metadata.gz: 1ca47285a7655a8720e3b77b6cab4d567dbe69e9264496d88f80fdeaa2d228a864f5ed028aebfb557fb46f29242cc18513856d934ed1a1bbbca187afbd6f4f3c
7
+ data.tar.gz: 10d540700a6615dce43e2298650227d74425e23dec9ea66d9c15e3e1d70f299041a305031684fd248026f55cb34d7d928abf6b9f4ea6f406192ae9280958dad4
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2013 The Mike De La Loza Company
3
+ Copyright (c) 2018 Michael Rivera
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -17,9 +17,11 @@ Install ruby and possibly bundler:
17
17
 
18
18
  Create a Gemfile with cknife and its git repository.
19
19
 
20
+
20
21
  source "http://rubygems.org"
21
-
22
- gem "cknife", :git => "https://github.com/mikedll/cknife.git"
22
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
23
+
24
+ gem "cknife", '~> 1.1.0'
23
25
 
24
26
  Run bundle.
25
27
 
@@ -76,9 +78,10 @@ Setup your AWS key and secret in any of these methods, in order of priority:
76
78
  - $CWD/cknife.yml
77
79
  - $CWD/tmp/cknife.yml
78
80
  - environment variables: `KEY`, `SECRET`
79
- - environment variablse: `AMAZON_ACCESS_KEY_ID`, `AMAZON_SECRET_ACCESS_KEY`
81
+ - environment variables: `AMAZON_ACCESS_KEY_ID`, `AMAZON_SECRET_ACCESS_KEY`
80
82
 
81
- The format of your cknife.yml must be like so:
83
+ If using one of the above cknife.yml files to define your keys, the format
84
+ is as follows:
82
85
 
83
86
  ---
84
87
  key: AKIAblahblahb...
@@ -360,13 +363,19 @@ One of the following, like patch. This will create a git commit.
360
363
  bundle exec rake version:bump:minor
361
364
  bundle exec rake version:bump:patch
362
365
 
363
- Create the gem spec.
366
+ Do a git flow release. Create the gem spec and commit it:
364
367
 
365
368
  bundle exec rake gemspec:generate
366
369
  git commit -am "Generated gemspec for version 0.1.4"
367
370
 
368
- You can `rake release`... I think that deploys
369
- the gem to Rubygems.
371
+ Do a git flow finish release. Push to github. You can
372
+ then do a release to Rubygems. This command will
373
+ try to generate the gemspec, but nothing will happen
374
+ since the gemspec is already valid.
375
+
376
+ rake release
377
+
378
+ ### Building Locally (Optional)
370
379
 
371
380
  You may build a local gem:
372
381
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: cknife 1.1.0 ruby lib
5
+ # stub: cknife 1.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cknife".freeze
9
- s.version = "1.1.0"
9
+ s.version = "1.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -71,6 +71,37 @@ class CKnifeAws < Thor
71
71
  @cdn ||= Fog::CDN.new(fog_opts)
72
72
  end
73
73
 
74
+ def get_bucket(bucket_name)
75
+ d = fog_storage.directories.select { |d| d.key == bucket_name }.first
76
+
77
+ if d.nil?
78
+ say ("Found no bucket by name #{bucket_name}")
79
+ return
80
+ end
81
+ d
82
+ end
83
+
84
+ def get_file(bucket, file_name)
85
+ f = bucket.files.select { |f| f.key == file_name }.first
86
+ if f.nil?
87
+ say("Found no file in #{bucket.key} having name #{file_name}.")
88
+ return
89
+ end
90
+ f
91
+ end
92
+
93
+ def get_bucket_and_file(bucket_name, file_name)
94
+ d = get_bucket(bucket_name)
95
+ return [nil, nil] if d.nil?
96
+
97
+ f = get_file(d, file_name)
98
+ return [nil, nil] if f.nil?
99
+
100
+ [d, f]
101
+ end
102
+
103
+
104
+
74
105
  def show_buckets
75
106
  fog_storage.directories.sort { |a,b| a.key <=> b.key }.each { |b| puts "#{b.key}" }
76
107
  end
@@ -196,15 +227,26 @@ class CKnifeAws < Thor
196
227
  show_buckets
197
228
  end
198
229
 
230
+ desc "url [BUCKET_NAME] [FILE]", "Generate a temporary (15 minute) URL for a file."
231
+ method_options :region => "us-east-1"
232
+ method_options :duration => 15
233
+ def url(bucket_name, file_name)
234
+ d, f = get_bucket_and_file(bucket_name, file_name)
235
+ return if d.nil? || f.nil?
236
+
237
+ minutes = options[:duration].to_i
238
+ expiry = (Time.now + minutes.minutes).to_i
239
+ url = f.url(expiry, path_style: true)
240
+ say("URL created.")
241
+ say(url)
242
+ end
243
+
199
244
  desc "afew [BUCKET_NAME]", "Show first 5 files in bucket"
200
245
  method_options :count => "5"
201
246
  method_options :glob => "*"
202
247
  def afew(bucket_name)
203
- d = fog_storage.directories.select { |d| d.key == bucket_name }.first
204
- if d.nil?
205
- say ("Found no bucket by name #{bucket_name}")
206
- return
207
- end
248
+ d = get_bucket(bucket_name)
249
+ return if d.nil?
208
250
 
209
251
  found = n_file_heads(d, options[:glob], options[:count].to_i)
210
252
 
@@ -448,18 +490,8 @@ class CKnifeAws < Thor
448
490
  method_options :noprompt => false
449
491
  method_options :region => "us-east-1"
450
492
  def fdelete(bucket_name, file_name)
451
- d = fog_storage.directories.select { |d| d.key == bucket_name }.first
452
-
453
- if d.nil?
454
- say ("Found no bucket by name #{bucket_name}")
455
- return
456
- end
457
-
458
- f = d.files.select { |f| f.key == file_name }.first
459
- if f.nil?
460
- say("Found no file in #{d.key} having name #{file_name}.")
461
- return
462
- end
493
+ d, f = get_bucket_and_file(bucket_name, file_name)
494
+ return if d.nil? || f.nil?
463
495
 
464
496
  if options[:noprompt] || yes?("Are you sure you want to delete #{f.key} in #{d.key}?", :red)
465
497
  f.destroy
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cknife
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rivera