akabei 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +3 -0
- data/akabei.gemspec +1 -1
- data/lib/akabei/omakase/cli.rb +2 -2
- data/lib/akabei/omakase/s3.rb +19 -14
- data/lib/akabei/version.rb +1 -1
- data/spec/akabei/omakase/cli_spec.rb +18 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52604057edd7d358099dee7d00be7e1f4a82a4b0
|
4
|
+
data.tar.gz: bd75e223fcefc7464911e31b588abaa9b587858d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae4b2aa2c1894092876336e80a112cc8d801f7bc4bd977c1b40645f3f17e41f7ec78eef9bec9239c631b080e7d26a64411c52ffc70903cd2c5fdad7d42fb3c66
|
7
|
+
data.tar.gz: 935f90dd05513568b2b6709fa58b10ede079cf5318fa9b2a349cdee8d1341f405cb79b29f28977f0baaf219cd12735fefdba8999d4880ac5c2b5bde0b75d0923
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/akabei.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "libarchive"
|
23
23
|
spec.add_dependency "safe_yaml"
|
24
24
|
spec.add_dependency "thor"
|
25
|
-
spec.add_development_dependency "aws-sdk-
|
25
|
+
spec.add_development_dependency "aws-sdk-core"
|
26
26
|
spec.add_development_dependency "bundler"
|
27
27
|
spec.add_development_dependency "coveralls"
|
28
28
|
spec.add_development_dependency "rake"
|
data/lib/akabei/omakase/cli.rb
CHANGED
@@ -44,9 +44,9 @@ module Akabei
|
|
44
44
|
|
45
45
|
if options[:s3]
|
46
46
|
begin
|
47
|
-
require 'aws-sdk-
|
47
|
+
require 'aws-sdk-core'
|
48
48
|
rescue LoadError => e
|
49
|
-
say("WARNING: You don't have aws-sdk-
|
49
|
+
say("WARNING: You don't have aws-sdk-core installed. Disable S3 repository.", :yellow)
|
50
50
|
options[:s3] = false
|
51
51
|
end
|
52
52
|
end
|
data/lib/akabei/omakase/s3.rb
CHANGED
@@ -3,23 +3,24 @@ module Akabei
|
|
3
3
|
class S3
|
4
4
|
def initialize(aws_config, shell)
|
5
5
|
if aws_config
|
6
|
-
require 'aws-sdk-
|
7
|
-
@
|
6
|
+
require 'aws-sdk-core'
|
7
|
+
@s3 = Aws::S3::Client.new(
|
8
8
|
access_key_id: aws_config['access_key_id'],
|
9
9
|
secret_access_key: aws_config['secret_access_key'],
|
10
10
|
region: aws_config['region'],
|
11
|
-
)
|
11
|
+
)
|
12
|
+
@bucket_name = aws_config['bucket']
|
12
13
|
@write_options = aws_config['write_options']
|
13
14
|
@shell = shell
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
18
|
def before!(config, arch)
|
18
|
-
download_repository(config, arch) if @
|
19
|
+
download_repository(config, arch) if @s3
|
19
20
|
end
|
20
21
|
|
21
22
|
def after!(config, arch, packages)
|
22
|
-
upload_repository(config, arch, packages) if @
|
23
|
+
upload_repository(config, arch, packages) if @s3
|
23
24
|
end
|
24
25
|
|
25
26
|
def download_repository(config, arch)
|
@@ -33,11 +34,11 @@ module Akabei
|
|
33
34
|
|
34
35
|
def get(path)
|
35
36
|
@shell.say("Download #{path}", :blue)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
@s3.get_object(
|
38
|
+
bucket: @bucket_name,
|
39
|
+
key: path.to_s,
|
40
|
+
response_target: path,
|
41
|
+
)
|
41
42
|
rescue Aws::S3::Errors::NoSuchKey
|
42
43
|
@shell.say("S3: #{path} not found", :red)
|
43
44
|
FileUtils.rm_f(path)
|
@@ -65,10 +66,14 @@ module Akabei
|
|
65
66
|
def put(path, mime_type)
|
66
67
|
@shell.say("Upload #{path}", :green)
|
67
68
|
path.open do |f|
|
68
|
-
@
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
@s3.put_object(
|
70
|
+
@write_options.merge(
|
71
|
+
bucket: @bucket_name,
|
72
|
+
key: path.to_s,
|
73
|
+
body: f,
|
74
|
+
content_type: mime_type,
|
75
|
+
)
|
76
|
+
)
|
72
77
|
end
|
73
78
|
end
|
74
79
|
end
|
data/lib/akabei/version.rb
CHANGED
@@ -94,7 +94,7 @@ describe Akabei::Omakase::CLI do
|
|
94
94
|
let(:bucket_name) { 'test.bucket.name' }
|
95
95
|
let(:region) { 'ap-northeast-1' }
|
96
96
|
|
97
|
-
let(:
|
97
|
+
let(:s3_client) { double('S3::Client') }
|
98
98
|
let(:write_options) { { storage_class: 'REDUCED_REDUNDANCY' } }
|
99
99
|
|
100
100
|
before do
|
@@ -105,28 +105,38 @@ describe Akabei::Omakase::CLI do
|
|
105
105
|
c['s3']['region'] = region
|
106
106
|
c['s3']['write_options'] = write_options
|
107
107
|
open('.akabei.yml', 'w') { |f| YAML.dump(c, f) }
|
108
|
+
|
109
|
+
allow(Aws::S3::Client).to receive(:new).and_return(s3_client)
|
108
110
|
end
|
109
111
|
|
110
112
|
it 'uploads built packages and update repositories' do
|
111
113
|
%w[i686 x86_64].each do |arch|
|
112
114
|
setup_command_expectations(arch, config.package_dir('nkf'))
|
113
115
|
end
|
114
|
-
allow_any_instance_of(Aws::S3::Resource).to receive(:bucket).with(bucket_name).and_return(bucket)
|
115
116
|
|
116
117
|
%w[i686 x86_64].each do |arch|
|
117
118
|
%w[test.db test.files test.abs.tar.gz].each do |fname|
|
118
|
-
obj = double("S3::Object #{fname}")
|
119
119
|
# download and upload
|
120
|
-
|
121
|
-
expect(
|
122
|
-
|
120
|
+
key = "test/os/#{arch}/#{fname}"
|
121
|
+
expect(s3_client).to receive(:get_object).with(hash_including(
|
122
|
+
bucket: bucket_name,
|
123
|
+
key: key,
|
124
|
+
)).once
|
125
|
+
expect(s3_client).to receive(:put_object).with(hash_including(
|
126
|
+
bucket: bucket_name,
|
127
|
+
key: key,
|
128
|
+
)).once
|
123
129
|
end
|
124
130
|
|
125
131
|
# upload only
|
126
132
|
pkg = double("S3::Object built package (#{arch})")
|
127
133
|
db_name = "nkf-2.1.3-1-#{arch}.pkg.tar.xz"
|
128
|
-
expect(
|
129
|
-
|
134
|
+
expect(s3_client).to receive(:put_object).with(hash_including(
|
135
|
+
write_options.merge(
|
136
|
+
bucket: bucket_name,
|
137
|
+
key: "test/os/#{arch}/#{db_name}",
|
138
|
+
)
|
139
|
+
)).once
|
130
140
|
end
|
131
141
|
|
132
142
|
cli.invoke(:build, ['nkf'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: akabei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gpgme
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: aws-sdk-
|
70
|
+
name: aws-sdk-core
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.4.5
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Custom repository manager for ArchLinux pacman
|