@@ -9,18 +9,24 @@ def self.source_root
9
9
end
10
10
11
11
def install
12
- Zip ::ZipFile . foreach ( open ( 'https://github.com/wordnik/swagger-ui/archive/master.zip' ) ) do |zip_entry |
13
- zip_entry . extract ( zip_entry . to_s . gsub ( 'swagger-ui-master/dist/' , 'public/apidoc/' ) ) if zip_entry . to_s =~ /\/ dist\/ /
12
+ install_path = 'apidoc'
13
+ swagger_ui_repo = 'https://github.com/wordnik/swagger-ui/'
14
+ api_path = 'api'
15
+
16
+ Zip ::ZipFile . foreach ( open ( "#{ swagger_ui_repo } /archive/master.zip" ) ) do |zip_entry |
17
+ zip_entry . extract ( zip_entry . to_s . gsub ( 'swagger-ui-master/dist/' , "public/#{ install_path } /" ) ) if zip_entry . to_s =~ /\/ dist\/ /
14
18
end
15
19
16
- file_name = ' public/apidoc /index.html'
20
+ file_name = " public/#{ install_path } /index.html"
17
21
text = File . read ( file_name )
18
- new_text = text . gsub ( 'css/' , '/apidoc/css/' ) . gsub ( 'lib/' , '/apidoc/lib/' ) . gsub ( 'swagger-ui.js' , '/apidoc/swagger-ui.js' ) . gsub ( 'images/' , '/apidoc/images/' ) . gsub ( 'supportHeaderParams: false' , 'supportHeaderParams: true' ) . gsub ( 'http://petstore.swagger.wordnik.com/api/api-docs.json' , '/api/swagger_doc.json' )
22
+ new_text = text .
23
+ gsub ( 'css/' , "/#{ install_path } /css/" ) .
24
+ gsub ( 'lib/' , "/#{ install_path } /lib/" ) .
25
+ gsub ( 'swagger-ui.js' , "/#{ install_path } /swagger-ui.js" ) .
26
+ gsub ( 'images/' , "/#{ install_path } /images/" ) .
27
+ gsub ( 'supportHeaderParams: false' , 'supportHeaderParams: true' ) .
28
+ gsub ( 'http://petstore.swagger.wordnik.com/api/api-docs.json' , "/#{ api_path } /swagger_doc.json" )
19
29
File . open ( file_name , 'w' ) { |file | file . puts new_text }
20
-
21
- template 'general_api.rb' , 'app/api/general_api.rb'
22
-
23
- route "mount GeneralAPI => '/'"
24
30
end
25
31
end
26
32
end
0 commit comments