-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let's use something which is made for parsing CLI and executing comma…
…nds: Nake.
- Loading branch information
botanicus
committed
Jul 6, 2012
1 parent
b119103
commit 2fd37ca
Showing
8 changed files
with
33 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
# encoding: UTF-8 | ||
#!/usr/bin/env nake | ||
# encoding: utf-8 | ||
|
||
begin | ||
require "pathname" | ||
bin_file = Pathname.new(__FILE__).realpath | ||
# Make sure symlinks to this file work. | ||
real_bin_path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ | ||
root_directory = File.expand_path(File.join(File.dirname(real_bin_path), "..")) | ||
lib_directory = File.join(root_directory, "lib") | ||
|
||
$:.unshift File.expand_path("../../lib", bin_file) | ||
|
||
require "apiary/cli" | ||
Apiary::CLI.start(*ARGV) | ||
rescue Interrupt | ||
# In development environment we want to use ./lib. | ||
unless $LOAD_PATH.include?(lib_directory) | ||
$LOAD_PATH.unshift(lib_directory) | ||
end | ||
|
||
require "apiary" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# encoding: utf-8 | ||
|
||
require "nake" | ||
|
||
require "apiary/commands/preview" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
require "apiary/commands/base" | ||
# encoding: utf-8 | ||
|
||
# Display preview of local blueprint file | ||
module Apiary | ||
module Command | ||
class Preview < Apiary::Command::Base | ||
# Preview. | ||
# | ||
# Launch web browser and display preview of local blueprint file | ||
def index | ||
api_server = ENV.fetch("APIARY_API_HOST") { "api.apiary.io" } | ||
Task.new(:preview) do |task| | ||
task.description = "Display preview of local blueprint file" | ||
|
||
require "launchy" | ||
require "rest_client" | ||
|
||
headers = {:accept => "text/html", :content_type => "text/plain"} | ||
response = RestClient.post "https://#{api_server}/blueprint/generate", IO.read("apiary.apib"), headers | ||
task.boot do | ||
require "launchy" | ||
require "rest_client" | ||
end | ||
|
||
file = File.new("/tmp/apiarypreview.html", "w") | ||
file.write(response) | ||
file.close | ||
task.define do |api_server = "api.apiary.io"| | ||
headers = {:accept => "text/html", :content_type => "text/plain"} | ||
response = RestClient.post "https://#{api_server}/blueprint/generate", IO.read("apiary.apib"), headers | ||
|
||
Launchy.open("file:///tmp/apiarypreview.html") | ||
end | ||
File.new("/tmp/apiarypreview.html", "w") do |file| | ||
file.write(response) | ||
end | ||
|
||
Launchy.open("file:///tmp/apiarypreview.html") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# encoding: utf-8 | ||
|
||
module Apiary | ||
VERSION ||= "0.0.1" | ||
end |