s3repo 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5575094474d0415e12cdd36b75d9cbb6a09af19f
4
+ data.tar.gz: 77e89871b806a7f07dc1c152c13cb3b4942fdc2a
5
+ SHA512:
6
+ metadata.gz: c999c20619aa6407b3a143c212c2413198f23558c4515f0e3ec9a17418ea1285936901b4a8cd76faa539d60d547b16cd0416b8baffc106961aecdd329facae5e
7
+ data.tar.gz: 370965115705922b94325879ec7baf2a3eb25188921946032ae66ca58c75031ed9c1f1f0a742556f709ebb907f5c82eb5e78610db2bdc4d5aadbe6ba5691673f
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ pkg/*.gem
2
+ coverage/
3
+ .coveralls.yml
4
+ .bundle
5
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Encoding:
2
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ rvm:
5
+ - 2.1.0
6
+ - 2.0.0
7
+ - 1.9.3
8
+ notifications:
9
+ email: false
10
+ irc:
11
+ channels:
12
+ - ircs://irc.oftc.net#akerl,ysalamir
13
+ template:
14
+ - '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Les Aker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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.
22
+
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ s3repo
2
+ =========
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/s3repo.svg)](https://rubygems.org/gems/s3repo)
5
+ [![Dependency Status](https://img.shields.io/gemnasium/amylum/s3repo.svg)](https://gemnasium.com/amylum/s3repo)
6
+ [![Code Climate](https://img.shields.io/codeclimate/github/amylum/s3repo.svg)](https://codeclimate.com/github/amylum/s3repo)
7
+ [![Coverage Status](https://img.shields.io/coveralls/amylum/s3repo.svg)](https://coveralls.io/r/amylum/s3repo)
8
+ [![Build Status](https://img.shields.io/travis/amylum/s3repo.svg)](https://travis-ci.org/amylum/s3repo)
9
+ [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
10
+
11
+ Simple library for interacting with an Archlinux repo stored in S3
12
+
13
+ ## Usage
14
+
15
+ ## Installation
16
+
17
+ gem install s3repo
18
+
19
+ ## License
20
+
21
+ s3repo is released under the MIT License. See the bundled LICENSE file for details.
22
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ desc 'Run tests'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc 'Run Rubocop on the gem'
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb', 'bin/*']
11
+ task.fail_on_error = true
12
+ end
13
+
14
+ task default: [:spec, :rubocop, :build, :install]
data/bin/s3repo ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 's3repo'
4
+ require 'mercenary'
data/lib/s3repo.rb ADDED
@@ -0,0 +1,18 @@
1
+ ##
2
+ # This module provides a simple library for Archlinux repos in S3
3
+ module S3Repo
4
+ class << self
5
+ ##
6
+ # Insert a helper .new() method for creating a new Repo object
7
+
8
+ def new(*args)
9
+ self::Repo.new(*args)
10
+ end
11
+ end
12
+ end
13
+
14
+ require 's3repo/base'
15
+ require 's3repo/client'
16
+ require 's3repo/package'
17
+ require 's3repo/metadata'
18
+ require 's3repo/repo'
@@ -0,0 +1,21 @@
1
+ module S3Repo
2
+ ##
3
+ # Base object, used to provide common attributes
4
+ class Base
5
+ def initialize(params = {})
6
+ @options = params
7
+ end
8
+
9
+ private
10
+
11
+ def bucket
12
+ @bucket ||= @options[:bucket] || ENV['S3_BUCKET']
13
+ return @bucket if @bucket
14
+ fail('No bucket given')
15
+ end
16
+
17
+ def client
18
+ @client ||= @options[:client] || Client.new(bucket: bucket)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'aws-sdk'
2
+
3
+ module S3Repo
4
+ ##
5
+ # AWS API client
6
+ class Client
7
+ def initialize(params = {})
8
+ @api = Aws::S3::Client.new
9
+ @defaults = params
10
+ end
11
+
12
+ def respond_to?(method, include_all = false)
13
+ @api.respond_to?(method, include_all) || super
14
+ end
15
+
16
+ private
17
+
18
+ def method_missing(method, *args, &block)
19
+ if @api.respond_to?(method) && args.size == 1 && args.first.is_a?(Hash)
20
+ define_singleton_method(method) do |*a|
21
+ @api.send(method, @defaults.dup.merge!(a.first))
22
+ end
23
+ send(method, args.first)
24
+ else
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module S3Repo
2
+ ##
3
+ # Metadata object, represents a package DB
4
+ class Metadata < Base
5
+ def add_package(package)
6
+ puts "Adding #{package}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module S3Repo
2
+ ##
3
+ # Package object, represents a single package tarball
4
+ class Package < Base
5
+ private
6
+
7
+ def info
8
+ lines = `tar xOf #{@options[:file]} .PKGINFO`.split("\n")
9
+ lines.reject! { |x| x.match(/^#/) }
10
+ lines.map { |x| x.split(' = ', 2) }.to_h
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ module S3Repo
2
+ ##
3
+ # Repo object, represents an Arch repo inside an S3 bucket
4
+ class Repo < Base
5
+ def add_package(file)
6
+ upload!(file)
7
+ package = Package.new(client: client, key: file)
8
+ metadata.add_package(package)
9
+ package
10
+ end
11
+
12
+ def packages(cache = true)
13
+ @packages = nil unless cache
14
+ @packages ||= parse_packages
15
+ end
16
+
17
+ def metadata
18
+ @metadata ||= Metadata.new(client: client)
19
+ end
20
+
21
+ private
22
+
23
+ def upload!(file)
24
+ client.put_object(
25
+ bucket: bucket,
26
+ key: file,
27
+ body: File.open(file) { |fh| fh.read }
28
+ )
29
+ end
30
+
31
+ def parse_packages
32
+ resp = client.list_objects(bucket: bucket).contents.map(&:key)
33
+ resp.select! { |x| x.match(/.*\.pkg\.tar\.xz$/) }
34
+ resp.map { |x| Package.new(client: client, key: x) }
35
+ end
36
+ end
37
+ end
data/s3repo.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 's3repo'
3
+ s.version = '0.0.1'
4
+ s.date = Time.now.strftime('%Y-%m-%d')
5
+
6
+ s.summary = 'S3 Archlinux repo library'
7
+ s.description = "Simple library for interacting with Archlinux repos in S3"
8
+ s.authors = ['Les Aker']
9
+ s.email = 'me@lesaker.org'
10
+ s.homepage = 'https://github.com/amylum/s3repo'
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files`.split
14
+ s.test_files = `git ls-files spec/*`.split
15
+ s.executables = ['s3repo']
16
+
17
+ s.add_dependency 'mercenary', '~> 0.3.4'
18
+ s.add_dependency 'aws-sdk', '~> 2.0.0'
19
+
20
+ s.add_development_dependency 'rubocop', '~> 0.28.0'
21
+ s.add_development_dependency 'rake', '~> 10.4.0'
22
+ s.add_development_dependency 'coveralls', '~> 0.7.1'
23
+ s.add_development_dependency 'rspec', '~> 3.1.0'
24
+ s.add_development_dependency 'fuubar', '~> 2.0.0'
25
+ end
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.start do
6
+ add_filter '/spec/'
7
+ end
8
+
9
+ require 'rspec'
10
+ require 's3repo'
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: s3repo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Les Aker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mercenary
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.28.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.28.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 10.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 10.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: fuubar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.0
111
+ description: Simple library for interacting with Archlinux repos in S3
112
+ email: me@lesaker.org
113
+ executables:
114
+ - s3repo
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - bin/s3repo
127
+ - lib/s3repo.rb
128
+ - lib/s3repo/base.rb
129
+ - lib/s3repo/client.rb
130
+ - lib/s3repo/metadata.rb
131
+ - lib/s3repo/package.rb
132
+ - lib/s3repo/repo.rb
133
+ - s3repo.gemspec
134
+ - spec/s3repo_spec.rb
135
+ - spec/spec_helper.rb
136
+ homepage: https://github.com/amylum/s3repo
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: S3 Archlinux repo library
160
+ test_files:
161
+ - spec/s3repo_spec.rb
162
+ - spec/spec_helper.rb