ci-cache 1.0.0 → 1.1.0

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: 288ef0fe2be849cb4a5d1fbb0f48ecfae5fc62eb
4
- data.tar.gz: 46f0d3a3f1b403bf6f678e48f9e0cdfbc7b808e9
3
+ metadata.gz: 79c6f62e7140ce98a3a46c1152220de94933c108
4
+ data.tar.gz: 3c5747e523e18f4e5b2c611b9e94adbde1771fca
5
5
  SHA512:
6
- metadata.gz: b5ad74c170005c79dd259ff97441d77bbbb85dcda12ee52bf24675daf9478b9effa8fdb7735053c520be586bb5315fcb146ae34f11cfb36d60088bbfb659db07
7
- data.tar.gz: 18d7f343646cf8d6bbaa12f239a2690a6ffab84e495d8884812ec24a99b859f982c6587ad0df121b35a60923e49f58796b352da704f4c0cda7c623dc6d85565a
6
+ metadata.gz: 5b743cdac3da092db121d537c2e84ff68470bc2054303f929729d248c3c6a87a6e8d27bd676c0c2e297d4f45ec85c6337a96d4e7c01c7f4e2d8da7e603305439
7
+ data.tar.gz: 2da6f3d3b85076f74edcbddb78fa83e5fc4adfe1964882eef2df2961a68f9954330f2af68770f273e03aa5fbb764cf6a444483da8b57d1fb68dd56857dc50a12
data/.editorconfig ADDED
@@ -0,0 +1,21 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+
8
+ [*]
9
+
10
+ # Change these settings to your own preference
11
+ indent_style = space
12
+ indent_size = 2
13
+
14
+ # We recommend you to keep these unchanged
15
+ end_of_line = lf
16
+ charset = utf-8
17
+ trim_trailing_whitespace = true
18
+ insert_final_newline = true
19
+
20
+ [*.md]
21
+ trim_trailing_whitespace = false
data/.travis.yml CHANGED
@@ -6,9 +6,9 @@ rvm:
6
6
  - rbx-19mode
7
7
  deploy:
8
8
  provider: rubygems
9
- api_key:
10
- secure: XMfj0fh0v8byvY67GtTLIeJcxEpmt7WBOTF9fmsEsWv6Wq2ZYeWdlLxgK042FTB7IkFYVF6EsA4zmOFKZkMpypwROj0cwTEeoA/5DjukowVc2KwpRLXMCUBeatRD9U63A8gq3CVrS7t5emo4trxb6lH+x3HIgF5Ef4n8Sj+MWJM=
11
9
  gem: ci-cache
12
10
  on:
13
11
  tags: true
14
12
  repo: johanneswuerbach/ci-cache
13
+ api_key:
14
+ secure: AMbQe7WSmP/41Fi9XCHlTF+qxlPhbTSu9/6r7FUPK3b5lFoegdiQCyFw1QdKHtBHW8Rcjb7MyDKehlnnUhNbO6jA5ioccfLCZsvc3mh3Ce5HO0xhJiN9sZ+7Odt5Xgj1OPrMPeyt3bV5J84MwUrrRhP2EOwrfSArJnWaFdAJ/dc=
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # master
2
+
3
+ # 1.1.0
4
+
5
+ * Added support to prefix file names on S3
@@ -9,8 +9,9 @@ module CiCache
9
9
 
10
10
  def download(name, tmp_folder)
11
11
  target_file = "#{tmp_folder}/#{name}"
12
- log "Download: #{name} ~> #{target_file}"
13
- object = bucket_object(name)
12
+ prefixed_name = prefixed_name(name)
13
+ log "Download: #{prefixed_name} ~> #{target_file}"
14
+ object = bucket_object(prefixed_name)
14
15
  File.open(target_file, 'wb') do |file|
15
16
  object.read do |chunk|
16
17
  file.write(chunk)
@@ -21,13 +22,18 @@ module CiCache
21
22
  end
22
23
 
23
24
  def upload(name, content)
24
- log "Upload: #{name}"
25
- object = bucket_object(name)
25
+ prefixed_name = prefixed_name(name)
26
+ log "Upload: #{prefixed_name}"
27
+ object = bucket_object(prefixed_name)
26
28
  object.write(content)
27
29
  end
28
30
 
29
31
  private
30
32
 
33
+ def prefixed_name(name)
34
+ prefix + name
35
+ end
36
+
31
37
  def log(message)
32
38
  @context.log(message)
33
39
  end
@@ -36,6 +42,10 @@ module CiCache
36
42
  ENV["CI_CACHE_S3_BUCKET"]
37
43
  end
38
44
 
45
+ def prefix
46
+ ENV["CI_CACHE_S3_PREFIX"] || ""
47
+ end
48
+
39
49
  def configure_aws
40
50
  AWS.config(
41
51
  access_key_id: ENV["CI_CACHE_S3_KEY"],
@@ -1,3 +1,3 @@
1
1
  module CiCache
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
data/spec/storage_spec.rb CHANGED
@@ -16,8 +16,18 @@ describe CiCache::Storage do
16
16
  subject { storage.download(name, folder) }
17
17
 
18
18
  context "when the object exists" do
19
+
19
20
  it "downloads the object" do
20
- storage.should_receive(:bucket_object).and_return(object)
21
+ storage.should_receive(:bucket_object).with(name).and_return(object)
22
+ object.should_receive(:read).and_yield("chunk")
23
+ handle.should_receive(:write).with("chunk")
24
+ File.should_receive(:open).with("~/file", "wb").and_yield(handle)
25
+ subject
26
+ end
27
+
28
+ it "uses a defined prefix" do
29
+ storage.should_receive(:prefix).and_return("my-repo/")
30
+ storage.should_receive(:bucket_object).with("my-repo/" + name).and_return(object)
21
31
  object.should_receive(:read).and_yield("chunk")
22
32
  handle.should_receive(:write).with("chunk")
23
33
  File.should_receive(:open).with("~/file", "wb").and_yield(handle)
@@ -38,7 +48,14 @@ describe CiCache::Storage do
38
48
  subject { storage.upload(name, "content") }
39
49
 
40
50
  it "uploads the content" do
41
- storage.should_receive(:bucket_object).and_return(object)
51
+ storage.should_receive(:bucket_object).with(name).and_return(object)
52
+ object.should_receive(:write).with("content")
53
+ subject
54
+ end
55
+
56
+ it "uses a defined prefix" do
57
+ storage.should_receive(:prefix).and_return("my-repo/")
58
+ storage.should_receive(:bucket_object).with("my-repo/" + name).and_return(object)
42
59
  object.should_receive(:write).with("content")
43
60
  subject
44
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Würbach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-28 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -59,9 +59,11 @@ executables:
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - .editorconfig
62
63
  - .gitignore
63
64
  - .rspec
64
65
  - .travis.yml
66
+ - CHANGELOG.md
65
67
  - Gemfile
66
68
  - LICENSE
67
69
  - README.md