watchdocs-rails 0.10.0 → 0.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bac1e9b41646c40171505b88313de4c347fdb3ce
4
- data.tar.gz: ceb761af9b816983c4baa0605191ccd079355dbb
3
+ metadata.gz: 623cd0977c17c12f52dcb6d73669296483905b9b
4
+ data.tar.gz: 25b282a6b8cb5cb0b969e6aed7265b22b0156ec9
5
5
  SHA512:
6
- metadata.gz: afdea6aa7702019c7bf315a4e4d0b20b94cec50e3ef4360307f71719d1aa20494c31859c8ce9d0a1916715ecb6192fcb9878cf38a69c6d0d3f4d25de4b1e1e83
7
- data.tar.gz: 88b468b03a902f133b861b69e4c21c04666f7d716ec1fdeb4fd8d3b99ce54cfb6013d0697f5236ee5d82aaf08982da0c6f2c29dd0c04869812ff841c77733689
6
+ metadata.gz: 0c19e929f480150be5276579d777247c472759e68abba1ff740e25820894c482aced4af0bc2d86e63e1761723c22bcf052568cb8141d1814629fe35617a63286
7
+ data.tar.gz: f2860ed94519961867e5ec9fe329415684fe0a0d1cfaf87b347f98ed670016d2a932de6351c30bba187764612eaac13bc792e4b42a513bf192c46beb227c605e
@@ -0,0 +1,9 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ Watchdocs::Rails::Recordings.clear!
4
+ end
5
+
6
+ config.after(:suite) do
7
+ Watchdocs::Rails::Recordings.export
8
+ end
9
+ end
@@ -0,0 +1,112 @@
1
+ require 'rails/generators'
2
+ require 'colorize'
3
+
4
+ module Watchdocs
5
+ module Generators
6
+ MissingCredentialsError = Class.new(Thor::Error)
7
+
8
+ class InstallGenerator < ::Rails::Generators::Base
9
+ source_root File.expand_path('../../templates', __FILE__)
10
+
11
+ class_option :app_id, type: :string
12
+ class_option :app_secret, type: :string
13
+
14
+ def create_initializer_file
15
+ if !options['app_id'].present? || !options['app_secret'].present?
16
+ raise MissingCredentialsError, <<-ERROR.strip_heredoc
17
+ --app_id or/and --app_secret options is missing
18
+ Please specify both with credentials from Settings tab of your project.
19
+ ERROR
20
+ end
21
+
22
+ initializer 'watchdocs.rb' do
23
+ <<-END.gsub(/^\s+\|/, '')
24
+ |Watchdocs::Rails.configure do |c|
25
+ | c.app_id = '#{options['app_id']}'
26
+ | c.app_secret = '#{options['app_secret']}'
27
+ |end
28
+ END
29
+ end
30
+ end
31
+
32
+ def install_with_specs
33
+ if yes?('Do you have any request specs? Would you like to use Watchdocs with them in test environment? [y,n]')
34
+ application(nil, env: 'test') do
35
+ 'config.middleware.insert(0, Watchdocs::Rails::Middleware)'
36
+ end
37
+ if yes?(' Do you test with RSpec? [y,n]')
38
+ template 'rspec.rb', 'spec/support/watchdocs.rb'
39
+ begin
40
+ append_file 'spec/rails_helper.rb', "require 'support/watchdocs.rb'"
41
+ rescue Errno::ENOENT
42
+ warning = <<-END.gsub(/^\s+\|/, '')
43
+ | You don't have rails_helper.rb, so please add the following line
44
+ | to the file where you have your RSpec configuration.
45
+ | -------------------------------
46
+ | require 'support/watchdocs.rb'
47
+ | -------------------------------
48
+ END
49
+ puts warning.yellow
50
+ end
51
+ elsif yes?(' Ok, maybe you test with a Minitest? [y,n]')
52
+ begin
53
+ append_file 'test/test_helper.rb',
54
+ 'Minitest.after_run { Watchdocs::Rails::Recordings.export }'
55
+ rescue Errno::ENOENT
56
+ warning = <<-END.gsub(/^\s+\|/, '')
57
+ | You don't have test_helper.rb, so please add the following line
58
+ | to the file where you have your Minitest configuration.
59
+ | ----------------------------------------------------------
60
+ | Minitest.after_run { Watchdocs::Rails::Recordings.export }
61
+ | ----------------------------------------------------------
62
+ END
63
+ puts warning.yellow
64
+ end
65
+ else
66
+ warning = <<-END.gsub(/^\s+\|/, '')
67
+ | We are sorry, but we don't have auto setup for you testing framework.
68
+ | You need to manually add the following line to be executed after all your specs:
69
+ | -----------------------------------
70
+ | Watchdocs::Rails::Recordings.export
71
+ | -----------------------------------
72
+ END
73
+ puts warning.yellow
74
+ end
75
+ puts 'Watchdocs enabled for test environment!'.green
76
+
77
+ end
78
+ end
79
+
80
+ def install_with_runtime
81
+ if yes?('Do you want to record your API endpoints in developent environment? [y,n]')
82
+ application(nil, env: 'development') do
83
+ 'config.middleware.insert(0, Watchdocs::Rails::Middleware)'
84
+ end
85
+ if yes?(' Do you use Procfile to run your app? [y,n]')
86
+ append_file 'Procfile', 'watchdocs: watchdocs --every 60.seconds'
87
+ puts 'Watchdocs worker added to your Procfile!'.green
88
+ else
89
+ warning = <<-END.gsub(/^\s+\|/, '')
90
+ | To make sure we will receive all recorded request please run this worker command with your app:
91
+ | -----------------------------
92
+ | watchdocs --every 60.seconds
93
+ | -----------------------------
94
+ END
95
+ puts warning.yellow
96
+
97
+ end
98
+ info = <<-END.gsub(/^\s+\|/, '')
99
+ | If you would like to enable recording in any other environment (f.e. dev server, staging)
100
+ | just add the following line to you 'config/environments/{env}.rb':
101
+ | -----------------------------------------------------------
102
+ | config.middleware.insert(0, Watchdocs::Rails::Middleware)
103
+ | -----------------------------------------------------------
104
+ END
105
+ puts info.light_blue
106
+ end
107
+ puts 'Setup is completed. Now run your app and make some requests!
108
+ Check app.watchdocs.io after a minute or so.'.green
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,6 @@
1
+ module Watchdocs
2
+ module Rails
3
+ class Engine < Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Watchdocs
2
2
  module Rails
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.0'
4
4
  end
5
5
  end
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency 'configurations', '~> 2.0'
33
33
  spec.add_runtime_dependency 'activesupport', '>4', '<6'
34
34
  spec.add_runtime_dependency 'recurrent', '~> 0.4'
35
+ spec.add_runtime_dependency 'colorize', '~> 0.8.1'
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchdocs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mazikwyry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2017-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0.4'
109
+ - !ruby/object:Gem::Dependency
110
+ name: colorize
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 0.8.1
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 0.8.1
109
123
  description: |-
110
124
  It captures every JSON response, stores request and
111
125
  response details in temporary storage.
@@ -130,6 +144,8 @@ files:
130
144
  - bin/setup
131
145
  - bin/watchdocs
132
146
  - lib/.DS_Store
147
+ - lib/generators/templates/rspec.rb
148
+ - lib/generators/watchdocs/install_generator.rb
133
149
  - lib/watchdocs-rails.rb
134
150
  - lib/watchdocs/.DS_Store
135
151
  - lib/watchdocs/rails.rb
@@ -141,6 +157,7 @@ files:
141
157
  - lib/watchdocs/rails/core_extensions/enumerable.rb
142
158
  - lib/watchdocs/rails/core_extensions/hash.rb
143
159
  - lib/watchdocs/rails/core_extensions/object.rb
160
+ - lib/watchdocs/rails/engine.rb
144
161
  - lib/watchdocs/rails/helpers.rb
145
162
  - lib/watchdocs/rails/helpers/body_helper.rb
146
163
  - lib/watchdocs/rails/helpers/query_string_helper.rb