@@ -22,37 +22,40 @@ module Elasticsearch
22
22
module API
23
23
# Helper with file related methods for code generation
24
24
module FilesHelper
25
+
25
26
PROJECT_PATH = File . join ( File . dirname ( __FILE__ ) , '..' )
26
27
SRC_PATH = File . join ( PROJECT_PATH , '..' , '..' , '..' , 'tmp/rest-api-spec/api/' )
27
28
OUTPUT_DIR = '../../elasticsearch-api/lib/elasticsearch/api/actions' . freeze
28
29
TESTS_DIRECTORY = "#{ PROJECT_PATH } /../../../tmp/rest-api-spec/test/free" . freeze
29
30
30
- # Only get JSON files and remove hidden files
31
- def self . files
32
- json_files = Dir . entries ( SRC_PATH )
31
+ class << self
32
+ # Only get JSON files and remove hidden files
33
+ def files
34
+ json_files = Dir . entries ( SRC_PATH )
33
35
34
- json_files . reject do |file |
35
- File . extname ( file ) != '.json' ||
36
- File . basename ( file ) == '_common.json'
37
- end . map { |file | "#{ SRC_PATH } #{ file } " }
38
- end
36
+ json_files . reject do |file |
37
+ File . extname ( file ) != '.json' ||
38
+ File . basename ( file ) == '_common.json'
39
+ end . map { |file | "#{ SRC_PATH } #{ file } " }
40
+ end
39
41
40
- # Path to directory to copy generated files
41
- def self . output_dir
42
- Pathname ( OUTPUT_DIR )
43
- end
42
+ # Path to directory to copy generated files
43
+ def output_dir
44
+ Pathname ( OUTPUT_DIR )
45
+ end
44
46
45
- def self . documentation_url ( documentation_url )
46
- branch = `git rev-parse --abbrev-ref HEAD`
47
- return documentation_url . gsub ( /\/ (master|main)\/ / , "/current/" ) if branch == "main\n "
47
+ def documentation_url ( documentation_url )
48
+ branch = `git rev-parse --abbrev-ref HEAD`
49
+ return documentation_url . gsub ( /\/ (master|main)\/ / , "/current/" ) if branch == "main\n "
48
50
49
- regex = /([0-9]{1,2}\. [0-9x]{1,2})/
50
- version = Elasticsearch ::API ::VERSION . match ( regex ) [ 0 ]
51
- # TODO - How do we fix this so it doesn't depend on which branch we're running from
52
- if ENV [ 'IGNORE_VERSION' ]
53
- documentation_url . gsub ( /\/ (master|main)\/ / , "/current/" )
54
- else
55
- documentation_url . gsub ( /\/ (current|master|main)\/ / , "/#{ version } /" )
51
+ regex = /([0-9]{1,2}\. [0-9x]{1,2})/
52
+ version = Elasticsearch ::API ::VERSION . match ( regex ) [ 0 ]
53
+ # TODO - How do we fix this so it doesn't depend on which branch we're running from
54
+ if ENV [ 'IGNORE_VERSION' ]
55
+ documentation_url . gsub ( /\/ (master|main)\/ / , "/current/" )
56
+ else
57
+ documentation_url . gsub ( /\/ (current|master|main)\/ / , "/#{ version } /" )
58
+ end
56
59
end
57
60
end
58
61
0 commit comments