Sha256: b1ff07d68cde3c6db1edb3ebe981e1320336024fb20be0d06c9791fa3e35cfcc

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require 'wordnik'

RSpec::Core::RakeTask.new('spec')

# If you want to make this the default task
task :default => :spec

desc 'Download the latest swagger API docs and build out resource methods'
task :swagger do
  
  # Configure default input values..
  settings = {
    :scheme => 'http',
    :host => 'localhost:8001',
    :base_path => "/admin/api",
    :api_key => 'b39ee8d5f05d0f566a0080b4c310ceddf5dc5f7606a616f53',
  }

  # Ask user for each setting, using the defaults where user input is blank
  settings.each do |name, default_value|
    puts "\nEnter the #{name} (default is '#{default_value}'): "
    input = STDIN.gets.chomp
    settings[name.to_sym] = input unless input.blank?
  end
  
  # Configure Wordnik, but tell it not to attempt to build resources
  # (there aren't any JSON docs yet.. a chicken/egg thing.)
  Wordnik.configure(false) do |config|
    config.scheme = settings[:scheme]
    config.host = settings[:host]
    config.base_path = settings[:base_path]
    config.api_key = settings[:api_key] unless settings[:api_key].blank?
  end

  puts "\nDownloading resource descriptions"
  Wordnik.download_resource_descriptions
  
  Wordnik.instantiate_resources

  puts "\nWriting convenience methods"
  Wordnik.resources.each_pair do |name, resource|
    resource.write_convenience_methods
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wordnik-4.06.08 Rakefile
wordnik-4.06.07 Rakefile
wordnik-4.06.06 Rakefile