Class: Backdrop::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/backdrop/extractor.rb

Instance Method Summary collapse

Instance Method Details

#build_apis(project, rad_json, output_dir) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/backdrop/extractor.rb', line 15

def build_apis(project, rad_json, output_dir)
  rad_json.each do |json_file|
    json = JSON.parse File.read(json_file)
    method = json['http_method']
    builder  = Backdrop.configuration.http.send(method.downcase)
    builder.new.build output_dir, project, json
  end
end

#load_docs(project_path) ⇒ Object



9
10
11
12
13
# File 'lib/backdrop/extractor.rb', line 9

def load_docs(project_path)
  docs_dir = File.join(File.expand_path(project_path), 'doc/api')
  Dir["#{docs_dir}/**/*.json"]
    .reject { |filename| filename =~ /index\.json$/ }
end

#project_name(path) ⇒ Object



5
6
7
# File 'lib/backdrop/extractor.rb', line 5

def project_name(path)
  path.gsub('/workspace', '').match(/\/(\w+)$/).captures.first
end