Skip to content

Commit 9c8e9c7

Browse files
author
Ruslan Tolstov
committed
v.0.1.1
1 parent 4dfd166 commit 9c8e9c7

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
load File.expand_path("../tasks/rswag.rake", __FILE__)
1+
load File.expand_path("tasks/rswag.rake", __dir__)

lib/rswag_schema_export/schema_import.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
module RswagSchemaExport
44
class Import
5-
def run
5+
def run(stage = "develop")
66
abort("RSWAG_SCHEMA_PATH is not defined. Example: tmp/swagger/swagger.json") unless ENV["RSWAG_SCHEMA_PATH"]
77
abort("RSWAG_ACCESS_KEY_ID is not defined") unless ENV["RSWAG_ACCESS_KEY_ID"]
88
abort("RSWAG_SECRET_ACCESS_KEY is not defined") unless ENV["RSWAG_SECRET_ACCESS_KEY"]
99
abort("RSWAG_REGION is not defined") unless ENV["RSWAG_REGION"]
1010
abort("RSWAG_BUCKET is not defined") unless ENV["RSWAG_BUCKET"]
11-
12-
stage = ENV["STAGE"] || "develop"
1311
app_name = ENV["APP_NAME"] || "app"
1412

1513
begin
@@ -22,7 +20,8 @@ def run
2220
versions = bucket.objects(prefix: "schemas/#{app_name}/#{stage}_schemas/versions").collect(&:key)
2321

2422
last_schema_key = versions.max
25-
bucket.object(last_schema_key).copy_to("#{ENV['RSWAG_BUCKET']}/schemas/#{app_name}/#{stage}_schemas/schema.json")
23+
bucket.object(last_schema_key)
24+
.copy_to("#{ENV['RSWAG_BUCKET']}/schemas/#{app_name}/#{stage}_schemas/schema.json")
2625
# Download schema.json
2726
if block_given?
2827
bucket.object("schemas/#{app_name}/#{stage}_schemas/schema.json").download_file("schema.json")

lib/rswag_schema_export/tasks/rswag.rake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
require 'rswag_schema_export/schema_import'
1+
require "rswag_schema_export/schema_import"
22

33
namespace :rswag do
44
desc "Import latest schema.json to app"
55
task :schema_import do
66
on roles(:all) do
7-
RswagSchemaExport::Import.new.run do
7+
stage = ENV["STAGE"] || fetch(:stage, "develop")
8+
RswagSchemaExport::Import.new.run(stage) do
89
upload!("schema.json", "#{current_path}/#{ENV['RSWAG_SCHEMA_PATH']}")
910
end
1011
end

lib/rswag_schema_export/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RswagSchemaExport
2-
VERSION = "0.1.0".freeze
2+
VERSION = "0.1.1".freeze
33
end

0 commit comments

Comments
 (0)