reqres_rspec 0.1.21 → 0.2.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: 2f09fd8a0a3dff25a77e5fb829707d5f2e6b53ee
4
- data.tar.gz: de79917ba0b2a861f5f3b05a3cb834e2a5c36d8a
3
+ metadata.gz: 7de6b872bc84d101f1a6cef2274042aaffd44b76
4
+ data.tar.gz: 71a541d777f098c2a61f622e834c11e23f483ccb
5
5
  SHA512:
6
- metadata.gz: ae42a02b34f8e7a887b28182351bb0605bb9dc7957d9a8ca56739c05b285ed57c45ad1a25676a90d78900330a21ad8fa0cc0a56252bdf3f2bebb7f54f5abc21e
7
- data.tar.gz: fd663f93a02aa4fab5a8abc96e11da11c6637d8c74a4b71da3b3bc736b10f913dd5270dc7e337f420d8c09404b443140672c66327dd81551b8f0982edca563fc
6
+ metadata.gz: 6a8cd452ebe2245ed9810bbb617d12d3ccce879e2be05de4a19b2c71d45c46338dd52dbdeab54c0272aa29006a3562b6eeda60ddd2ba00d936143b674279a670
7
+ data.tar.gz: b657d0dce186f87cfabc3d95506bcc198fbedd5a91250ea7d9cf1a07fe9c2e1b134cbc09de7da3af27cbcabddbfcd19c43310780dc4b1891661bd2f68d5d3c16
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.2
data/CHANGELOG.txt CHANGED
@@ -1,3 +1,7 @@
1
+ version 0.2.1
2
+
3
+ Added GoogleDrive uploader. Please review README how to use it.
4
+
1
5
  version 0.1.21
2
6
 
3
7
  generate `./doc` dir if it does not exist in host codebase
data/README.md CHANGED
@@ -26,9 +26,9 @@ If necessary, add `require "reqres_rspec"` to your `spec/spec_helper.rb` file
26
26
  Install `prince` http://www.princexml.com/download/ . For MacOS installation commands are
27
27
 
28
28
  ```
29
- wget http://www.princexml.com/download/prince-9.0r2-macosx.tar.gz
30
- tar -xvf prince-9.0r2-macosx.tar.gz
31
- cd prince-9.0r2-macosx
29
+ wget http://www.princexml.com/download/prince-10r3-macosx.tar.gz
30
+ tar -xvf prince-10r3-macosx.tar.gz
31
+ cd prince-10r3-macosx
32
32
  ./install.sh
33
33
  ```
34
34
 
@@ -40,11 +40,35 @@ by default `reqres_rspec` is not active (this may be configured!). To activate i
40
40
 
41
41
  Documentation will be put into your application's `/doc` folder
42
42
 
43
- ## Upload to S3
43
+ ## Upload to Amazon S3
44
44
 
45
- By default ReqRes will use `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION` and `AWS_REQRES_BUCKET` environment variables. But you can alter that in configuration, see below.
45
+ Set up following environment variables
46
46
 
47
- `REQRES_UPLOAD=1 REQRES_RSPEC=1 bundle exec rspec --order=defined`
47
+ ```
48
+ AWS_ACCESS_KEY_ID
49
+ AWS_SECRET_ACCESS_KEY
50
+ AWS_REQRES_BUCKET
51
+ ```
52
+
53
+ Then run
54
+
55
+ `REQRES_RSPEC=1 REQRES_UPLOAD=AmazonS3 bundle exec rspec --order=defined`
56
+
57
+
58
+ ## Upload to Google Drive
59
+
60
+ Follow "Create a client ID and client secret" in [this page](https://developers.google.com/drive/web/auth/web-server) to get OAuth credentials.
61
+
62
+ Set environment variables
63
+
64
+ ```
65
+ GOOGLE_CLIENT_ID
66
+ GOOGLE_CLIENT_SECRET
67
+ ```
68
+
69
+ `REQRES_RSPEC=1 REQRES_UPLOAD=GoogleDrive bundle exec rspec --order=defined`
70
+
71
+ Follow instructions in console.
48
72
 
49
73
  ### Sample controller action
50
74
 
@@ -108,8 +132,8 @@ describe 'Something', reqres_section: 'Foo' do
108
132
  end
109
133
  ```
110
134
 
111
- In this case all the `reqres_sections` can be used for grouping colleced data into section, and `reqres_title` will become human readable titles:
112
- [![Cusomized titles](http://i57.tinypic.com/2581lw9.jpg)](http://i57.tinypic.com/2581lw9.jpg)
135
+ In this case all the `reqres_sections` can be used for grouping collected data into section, and `reqres_title` will become human readable titles:
136
+ [![Customized titles](http://i57.tinypic.com/2581lw9.jpg)](http://i57.tinypic.com/2581lw9.jpg)
113
137
 
114
138
  ### Generates documentation example
115
139
 
data/lib/reqres_rspec.rb CHANGED
@@ -9,6 +9,7 @@ require 'reqres_rspec/formatters/json'
9
9
  require 'reqres_rspec/formatters/pdf'
10
10
  require 'reqres_rspec/uploaders'
11
11
  require 'reqres_rspec/uploaders/amazon_s3'
12
+ require 'reqres_rspec/uploaders/google_drive'
12
13
 
13
14
  if defined?(RSpec) && ENV['REQRES_RSPEC'] == '1'
14
15
  collector = ReqresRspec::Collector.new
@@ -40,7 +41,7 @@ if defined?(RSpec) && ENV['REQRES_RSPEC'] == '1'
40
41
  if collector.records.size > 0
41
42
  collector.sort
42
43
  ReqresRspec::Formatters.process(collector.records)
43
- ReqresRspec::Uploaders.upload if ENV['REQRES_UPLOAD'] == '1'
44
+ ReqresRspec::Uploaders.upload if ENV['REQRES_UPLOAD']
44
45
  end
45
46
  end
46
47
  end
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module ReqresRspec
2
4
  extend self
3
5
 
@@ -34,7 +36,7 @@ module ReqresRspec
34
36
 
35
37
  @templates_path = File.expand_path('../templates', __FILE__)
36
38
  @output_path = File.join(@root, '/doc/reqres')
37
- Dir.mkdir(@output_path) unless Dir.exist?(@output_path)
39
+ FileUtils.mkdir_p @output_path
38
40
 
39
41
  requested_formats = (ENV['REQRES_RSPEC_FORMATTERS'].to_s).split(',')
40
42
  requested_formats.sort_by!{|fmt| [DEFAULT_FORMATTERS.index(fmt), fmt]}
@@ -10,16 +10,14 @@ module ReqresRspec
10
10
  if defined?(VCR)
11
11
  VCR.configure do |c|
12
12
  c.ignore_request do |request|
13
- URI(request.uri).host == 's3.amazonaws.com'
13
+ URI(request.uri).host == 's3.amazonaws.com' ||
14
+ URI(request.uri).host.include?('google')
14
15
  end
15
16
  end
16
17
  end
17
18
 
18
- self.constants.each do |name|
19
- klass = Object.const_get("ReqresRspec::Uploaders::#{name}")
20
- klass.upload if klass.respond_to?(:upload)
21
- end
19
+ klass = Object.const_get("ReqresRspec::Uploaders::#{ENV['REQRES_UPLOAD']}")
20
+ klass.upload if klass.respond_to?(:upload)
22
21
  end
23
-
24
22
  end
25
23
  end
@@ -0,0 +1,50 @@
1
+ require 'google/api_client'
2
+ require 'google_drive'
3
+
4
+ module ReqresRspec
5
+ module Uploader
6
+ # You can find more detailed information here https://github.com/gimite/google-drive-ruby
7
+ class GoogleDrive
8
+ def initialize
9
+ @path = ReqresRspec.configuration.output_path
10
+ @logger = ReqresRspec.logger
11
+
12
+ client = Google::APIClient.new
13
+ auth = client.authorization
14
+ auth.client_id = ENV['GOOGLE_CLIENT_ID']
15
+ auth.client_secret = ENV['GOOGLE_CLIENT_SECRET']
16
+ auth.scope = [
17
+ 'https://www.googleapis.com/auth/drive',
18
+ 'https://spreadsheets.google.com/feeds/'
19
+ ]
20
+ auth.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'
21
+ puts("\n\n1. Open this page:\n%s\n\n" % auth.authorization_uri)
22
+ puts('2. Enter the authorization code shown in the page: ')
23
+ auth.code = $stdin.gets.chomp
24
+ auth.fetch_access_token!
25
+ access_token = auth.access_token
26
+ @session = GoogleDrive::GoogleDrive.login_with_oauth(access_token)
27
+ end
28
+
29
+ attr_reader :logger, :path
30
+
31
+ def self.upload
32
+ uploader = self.new
33
+ uploader.process
34
+ end
35
+
36
+ def process
37
+ Dir["#{path}/**/*"].each { |file|
38
+ next if File.directory?(file)
39
+ local_path = file.gsub("#{@path}/", '')
40
+
41
+ start = Time.now
42
+ @session.upload_from_file(file, local_path, convert: false)
43
+ done = Time.now
44
+
45
+ puts "\n[#{local_path}] Uploaded in #{done.to_i - start.to_i}s"
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module ReqresRspec
2
- VERSION = '0.1.21'
2
+ VERSION = '0.2.1'
3
3
  end
data/reqres_rspec.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'coderay'
22
22
  spec.add_dependency 'mime-types'
23
23
  spec.add_dependency 'aws-sdk-core', '~> 2.0'
24
+ spec.add_dependency 'google_drive'
24
25
 
25
26
  spec.add_development_dependency 'bundler', '~> 1.3'
26
27
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reqres_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rilian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coderay
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: google_drive
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +124,7 @@ files:
110
124
  - lib/reqres_rspec/templates/spec.erb
111
125
  - lib/reqres_rspec/uploaders.rb
112
126
  - lib/reqres_rspec/uploaders/amazon_s3.rb
127
+ - lib/reqres_rspec/uploaders/google_drive.rb
113
128
  - lib/reqres_rspec/utils.rb
114
129
  - lib/reqres_rspec/version.rb
115
130
  - reqres_rspec.gemspec