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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3eb09aa9bd6389e16b3f858e97653c851f779c91
4
- data.tar.gz: 101a687e2f16c2f58b7bfabc50789852a98e045f
3
+ metadata.gz: 52604057edd7d358099dee7d00be7e1f4a82a4b0
4
+ data.tar.gz: bd75e223fcefc7464911e31b588abaa9b587858d
5
5
  SHA512:
6
- metadata.gz: 3d8d0e2e2c012a44f834da8447c8307ea9d3751b833ff5ef18b0268bab9d9269082c07a36629f9513d22f6841af2af053dc90265913165dae2c65da99577e4c7
7
- data.tar.gz: 687f42c50a6ce54c338a5b6f519ee9ea1f8fb53642cc8c340a87f58f0c0922b1734cade396b47e86df13d3357e8ac6f2e7a47520885c78229d7852152de4098d
6
+ metadata.gz: ae4b2aa2c1894092876336e80a112cc8d801f7bc4bd977c1b40645f3f17e41f7ec78eef9bec9239c631b080e7d26a64411c52ffc70903cd2c5fdad7d42fb3c66
7
+ data.tar.gz: 935f90dd05513568b2b6709fa58b10ede079cf5318fa9b2a349cdee8d1341f405cb79b29f28977f0baaf219cd12735fefdba8999d4880ac5c2b5bde0b75d0923
@@ -2,11 +2,11 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.2
5
+ - 2.1
6
+ - 2.2
6
7
  - ruby-head
7
8
  before_install:
8
9
  - sudo apt-get install -y libarchive-dev
9
- - export NOKOGIRI_USE_SYSTEM_LIBRARIES=1
10
10
  matrix:
11
11
  allow_failures:
12
12
  - rvm: ruby-head
@@ -1,3 +1,6 @@
1
+ # 0.4.1 (2015-01-10)
2
+ - Do not depend on aws-sdk-resources
3
+
1
4
  # 0.4.0 (2014-11-02)
2
5
  - Switch to AWS SDK for Ruby v2
3
6
 
@@ -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-resources"
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"
@@ -44,9 +44,9 @@ module Akabei
44
44
 
45
45
  if options[:s3]
46
46
  begin
47
- require 'aws-sdk-resources'
47
+ require 'aws-sdk-core'
48
48
  rescue LoadError => e
49
- say("WARNING: You don't have aws-sdk-resources installed. Disable S3 repository.", :yellow)
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
@@ -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-resources'
7
- @bucket = Aws::S3::Resource.new(
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
- ).bucket(aws_config['bucket'])
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 @bucket
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 @bucket
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
- path.open('wb') do |f|
37
- @bucket.object(path.to_s).get do |chunk|
38
- f.write(chunk)
39
- end
40
- end
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
- @bucket.object(path.to_s).put(@write_options.merge(
69
- body: f,
70
- content_type: mime_type,
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
@@ -1,3 +1,3 @@
1
1
  module Akabei
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -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(:bucket) { double('S3::Bucket') }
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
- expect(bucket).to receive(:object).with("test/os/#{arch}/#{fname}").twice.and_return(obj)
121
- expect(obj).to receive(:get).and_yield('')
122
- expect(obj).to receive(:put)
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(bucket).to receive(:object).with("test/os/#{arch}/#{db_name}").and_return(pkg)
129
- expect(pkg).to receive(:put).with(hash_including(write_options))
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.0
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: 2014-11-02 00:00:00.000000000 Z
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-resources
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.2.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