rspec-storage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 76c128b4e4f8211fe9116887d23d6a79ce795c9e
4
+ data.tar.gz: 5c5f8008dce4ef1f2a8e2806b3f434957e7d12dc
5
+ SHA512:
6
+ metadata.gz: f3f8115b407f013648b436a57256566f2a9ab563702215fdea03f99d64202b62728fa164d72963292eafcbbf005a6fcb22704d32fb38645269ec98921e9b5161
7
+ data.tar.gz: dbea80fcee25b3c0bdaf280f90fd20c161457ec90070fecb76756a22f7c0813a9e51f50a992db15de3356853ab4ffab155ae807bdb8891854092167778ee1b18
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-storage.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 joker1007
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.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # rspec-storage
2
+
3
+ RSpec output test report to any stroage
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rspec-storage'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rspec-storage
20
+
21
+ # Support Storages
22
+
23
+ - S3 (s3://)
24
+ - GCS (gs://)
25
+
26
+ ## Usage
27
+
28
+ ```
29
+ $ rspec -r rspec/storage spec/example_spec.rb -f doc -f json s3://your-bucket/spec_result.json
30
+ ```
31
+
32
+ You need to require `rspec/storage` before rspec init process
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/joker1007/rspec-storage.
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
48
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/storage"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ require "rspec/storage/version"
2
+ require "rspec/storage/monkey_patch"
3
+
4
+ module RSpec
5
+ module Storage
6
+ class << self
7
+ def providers
8
+ @providers ||= {}
9
+ end
10
+
11
+ def register(scheme, klass)
12
+ self.providers[scheme] = klass
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ require "rspec/storage/s3"
19
+ require "rspec/storage/gcs"
@@ -0,0 +1,15 @@
1
+ require "forwardable"
2
+
3
+ module RSpec
4
+ module Storage
5
+ class FakeIO < IO
6
+ extend Forwardable
7
+
8
+ def initialize(obj)
9
+ @obj = obj
10
+ end
11
+
12
+ def_delegators :@obj, *IO.public_instance_methods(false)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ begin
2
+
3
+ require "googleauth"
4
+ require "google/apis/storage_v1"
5
+ require "tempfile"
6
+ require "delegate"
7
+
8
+ require "rspec/storage/fake_io"
9
+
10
+ module RSpec
11
+ module Storage
12
+ module GCS
13
+ RSpec::Storage.register("gs", self)
14
+
15
+ SCOPES = ["https://www.googleapis.com/auth/devstorage.read_write"].freeze
16
+
17
+ class << self
18
+ def handle_location(uri)
19
+ client = Google::Apis::StorageV1::StorageService.new
20
+ auth = Google::Auth.get_application_default(SCOPES)
21
+ client.authorization = auth
22
+ FakeIO.new(Uploader.new(client, uri))
23
+ end
24
+ end
25
+
26
+ class Uploader < Delegator
27
+ def initialize(gcs_client, uri)
28
+ @tempfile = Tempfile.new("rspec-storage-gcs")
29
+ @gcs_client = gcs_client
30
+ @uri = uri
31
+ @bucket = uri.host
32
+ @key = uri.path[1..-1]
33
+ end
34
+
35
+ def __getobj__
36
+ @tempfile
37
+ end
38
+
39
+ def close
40
+ @tempfile.flush
41
+ @tempfile.rewind
42
+ object = Google::Apis::StorageV1::Object.new(name: @key)
43
+ @gcs_client.insert_object(@bucket, object, upload_source: @tempfile)
44
+ $stdout.puts "Upload to #{@uri.to_s}"
45
+ ensure
46
+ @tempfile.close
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ rescue LoadError
54
+ end
@@ -0,0 +1,27 @@
1
+ require "rspec/core/formatters"
2
+ require "rspec/core/formatters/base_formatter"
3
+ require "rspec/core/formatters/base_text_formatter"
4
+ require "uri"
5
+
6
+ module RSpec
7
+ module Storage
8
+ class UnknownSchemeProvider < StandardError; end
9
+
10
+ module FormattersLoaderExtension
11
+ def file_at(path)
12
+ uri = URI.parse(path)
13
+ if uri.scheme
14
+ if provider = RSpec::Storage.providers[uri.scheme]
15
+ provider.handle_location(uri)
16
+ else
17
+ raise UnknownSchemeProvider
18
+ end
19
+ else
20
+ super
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ RSpec::Core::Formatters::Loader.prepend(RSpec::Storage::FormattersLoaderExtension)
@@ -0,0 +1,49 @@
1
+ begin
2
+
3
+ require "aws-sdk"
4
+ require "tempfile"
5
+ require "delegate"
6
+
7
+ require "rspec/storage/fake_io"
8
+
9
+ module RSpec
10
+ module Storage
11
+ module S3
12
+ RSpec::Storage.register("s3", self)
13
+
14
+ class << self
15
+ def handle_location(uri)
16
+ options = uri.query ? URI.decode_www_form(uri.query).map { |pair| pair.tap { |_p| _p[0] = _p[0].to_sym } }.to_h : {}
17
+ client = Aws::S3::Client.new(options)
18
+ FakeIO.new(Uploader.new(client, uri))
19
+ end
20
+ end
21
+
22
+ class Uploader < Delegator
23
+ def initialize(s3_client, uri)
24
+ @tempfile = Tempfile.new("rspec-storage-s3")
25
+ @s3_client = s3_client
26
+ @uri = uri
27
+ @bucket = uri.host
28
+ @key = uri.path[1..-1]
29
+ end
30
+
31
+ def __getobj__
32
+ @tempfile
33
+ end
34
+
35
+ def close
36
+ @tempfile.flush
37
+ @tempfile.rewind
38
+ @s3_client.put_object(bucket: @bucket, key: @key, body: @tempfile)
39
+ $stdout.puts "Upload to #{@uri.to_s}"
40
+ ensure
41
+ @tempfile.close
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ rescue LoadError
49
+ end
@@ -0,0 +1,5 @@
1
+ module Rspec
2
+ module Storage
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/storage/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-storage"
8
+ spec.version = Rspec::Storage::VERSION
9
+ spec.authors = ["joker1007"]
10
+ spec.email = ["kakyoin.hierophant@gmail.com"]
11
+
12
+ spec.summary = %q{RSpec output test report to any stroage}
13
+ spec.description = %q{RSpec output test report to any stroage}
14
+ spec.homepage = "https://github.com/joker1007/rspec-storage"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_runtime_dependency "rspec", "~> 3.3"
25
+
26
+ spec.add_development_dependency "aws-sdk", ">= 2.0"
27
+ spec.add_development_dependency "google-api-client", ">= 0.9"
28
+ spec.add_development_dependency "bundler", "~> 1.13"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-storage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - joker1007
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
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'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: google-api-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
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.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.0'
97
+ description: RSpec output test report to any stroage
98
+ email:
99
+ - kakyoin.hierophant@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/rspec/storage.rb
114
+ - lib/rspec/storage/fake_io.rb
115
+ - lib/rspec/storage/gcs.rb
116
+ - lib/rspec/storage/monkey_patch.rb
117
+ - lib/rspec/storage/s3.rb
118
+ - lib/rspec/storage/version.rb
119
+ - rspec-storage.gemspec
120
+ homepage: https://github.com/joker1007/rspec-storage
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.6.8
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: RSpec output test report to any stroage
144
+ test_files: []