Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3eaf6bf
Showing
56 changed files
with
10,532 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "autotest/growl" | ||
require "autotest/fsevent" | ||
|
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,6 @@ | ||
.bundle/ | ||
log/*.log | ||
pkg/ | ||
test/dummy/db/*.sqlite3 | ||
test/dummy/log/*.log | ||
test/dummy/tmp/ |
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,2 @@ | ||
--color | ||
--format documentation |
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,14 @@ | ||
source "http://rubygems.org" | ||
|
||
gem "rails", "3.0.11" | ||
gem "capybara", ">= 0.4.0" | ||
gem "sqlite3" | ||
|
||
group :development, :test do | ||
gem "rspec-rails" | ||
gem "ZenTest" | ||
end | ||
|
||
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+) | ||
# gem 'ruby-debug' | ||
gem 'ruby-debug19' |
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,131 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
ZenTest (4.6.2) | ||
abstract (1.0.0) | ||
actionmailer (3.0.11) | ||
actionpack (= 3.0.11) | ||
mail (~> 2.2.19) | ||
actionpack (3.0.11) | ||
activemodel (= 3.0.11) | ||
activesupport (= 3.0.11) | ||
builder (~> 2.1.2) | ||
erubis (~> 2.6.6) | ||
i18n (~> 0.5.0) | ||
rack (~> 1.2.1) | ||
rack-mount (~> 0.6.14) | ||
rack-test (~> 0.5.7) | ||
tzinfo (~> 0.3.23) | ||
activemodel (3.0.11) | ||
activesupport (= 3.0.11) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.5.0) | ||
activerecord (3.0.11) | ||
activemodel (= 3.0.11) | ||
activesupport (= 3.0.11) | ||
arel (~> 2.0.10) | ||
tzinfo (~> 0.3.23) | ||
activeresource (3.0.11) | ||
activemodel (= 3.0.11) | ||
activesupport (= 3.0.11) | ||
activesupport (3.0.11) | ||
archive-tar-minitar (0.5.2) | ||
arel (2.0.10) | ||
builder (2.1.2) | ||
capybara (1.1.2) | ||
mime-types (>= 1.16) | ||
nokogiri (>= 1.3.3) | ||
rack (>= 1.0.0) | ||
rack-test (>= 0.5.4) | ||
selenium-webdriver (~> 2.0) | ||
xpath (~> 0.1.4) | ||
childprocess (0.2.3) | ||
ffi (~> 1.0.6) | ||
columnize (0.3.4) | ||
diff-lcs (1.1.3) | ||
erubis (2.6.6) | ||
abstract (>= 1.0.0) | ||
ffi (1.0.11) | ||
i18n (0.5.0) | ||
json (1.6.2) | ||
linecache19 (0.5.12) | ||
ruby_core_source (>= 0.1.4) | ||
mail (2.2.19) | ||
activesupport (>= 2.3.6) | ||
i18n (>= 0.4.0) | ||
mime-types (~> 1.16) | ||
treetop (~> 1.4.8) | ||
mime-types (1.17.2) | ||
multi_json (1.0.4) | ||
nokogiri (1.5.0) | ||
polyglot (0.3.3) | ||
rack (1.2.4) | ||
rack-mount (0.6.14) | ||
rack (>= 1.0.0) | ||
rack-test (0.5.7) | ||
rack (>= 1.0) | ||
rails (3.0.11) | ||
actionmailer (= 3.0.11) | ||
actionpack (= 3.0.11) | ||
activerecord (= 3.0.11) | ||
activeresource (= 3.0.11) | ||
activesupport (= 3.0.11) | ||
bundler (~> 1.0) | ||
railties (= 3.0.11) | ||
railties (3.0.11) | ||
actionpack (= 3.0.11) | ||
activesupport (= 3.0.11) | ||
rake (>= 0.8.7) | ||
rdoc (~> 3.4) | ||
thor (~> 0.14.4) | ||
rake (0.9.2.2) | ||
rdoc (3.11) | ||
json (~> 1.4) | ||
rspec (2.7.0) | ||
rspec-core (~> 2.7.0) | ||
rspec-expectations (~> 2.7.0) | ||
rspec-mocks (~> 2.7.0) | ||
rspec-core (2.7.1) | ||
rspec-expectations (2.7.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.7.0) | ||
rspec-rails (2.7.0) | ||
actionpack (~> 3.0) | ||
activesupport (~> 3.0) | ||
railties (~> 3.0) | ||
rspec (~> 2.7.0) | ||
ruby-debug-base19 (0.11.25) | ||
columnize (>= 0.3.1) | ||
linecache19 (>= 0.5.11) | ||
ruby_core_source (>= 0.1.4) | ||
ruby-debug19 (0.11.6) | ||
columnize (>= 0.3.1) | ||
linecache19 (>= 0.5.11) | ||
ruby-debug-base19 (>= 0.11.19) | ||
ruby_core_source (0.1.5) | ||
archive-tar-minitar (>= 0.5.2) | ||
rubyzip (0.9.5) | ||
selenium-webdriver (2.14.0) | ||
childprocess (>= 0.2.1) | ||
ffi (~> 1.0.9) | ||
multi_json (~> 1.0.4) | ||
rubyzip | ||
sqlite3 (1.3.4) | ||
thor (0.14.6) | ||
treetop (1.4.10) | ||
polyglot | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.31) | ||
xpath (0.1.4) | ||
nokogiri (~> 1.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
ZenTest | ||
capybara (>= 0.4.0) | ||
rails (= 3.0.11) | ||
rspec-rails | ||
ruby-debug19 | ||
sqlite3 |
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,20 @@ | ||
Copyright 2011 YOURNAME | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,3 @@ | ||
= Restapi | ||
|
||
This project rocks. Real readme comes before Christmass. |
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,13 @@ | ||
require "bundler/gem_tasks" | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
desc 'Default: run specs.' | ||
task :default => :spec | ||
|
||
desc "Generate code coverage" | ||
RSpec::Core::RakeTask.new(:coverage) do |t| | ||
t.rcov = true | ||
t.rcov_opts = ['--exclude', 'spec'] | ||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "restapi/version" | ||
|
||
require "restapi/restapi_module" | ||
require "restapi/api" | ||
require "restapi/dsl_definition" | ||
require "restapi/api_manager" | ||
require "restapi/railtie" | ||
require "restapi/application" |
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,26 @@ | ||
module Restapi | ||
|
||
class Api | ||
|
||
# attr_reader :short_description | ||
attr_reader :errors, :api_args, :params, :full_description, :method_name | ||
|
||
def initialize(method_name, app) | ||
@method_name = method_name | ||
@full_description = app.get_description | ||
@errors = app.get_errors | ||
@api_args = app.get_api_args | ||
@params = app.get_params | ||
end | ||
|
||
# Restapi module methods | ||
class << self | ||
|
||
def define_api(method_name) | ||
Restapi.application.define_api(self, method_name) | ||
end | ||
|
||
end | ||
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
module Restapi | ||
|
||
module ApiManager | ||
|
||
attr_accessor :last_api_args | ||
attr_accessor :last_errors | ||
attr_accessor :last_params | ||
attr_accessor :last_description | ||
|
||
def initialize | ||
|
||
super | ||
@apis = Hash.new | ||
|
||
@last_api_args = nil | ||
@last_errors = Array.new | ||
@last_params = Hash.new | ||
@last_description = nil | ||
end | ||
|
||
def define_api(api_class, method_name) | ||
|
||
puts "defining api for method " + method_name.to_s + " hash: " + method_name.hash.to_s | ||
|
||
# create new or get existing api | ||
@apis[method_name] ||= api_class.new(method_name, self) | ||
|
||
end | ||
|
||
def restapi_provided? | ||
true if last_description | ||
end | ||
|
||
# List of all defined apis in this application. | ||
def apis | ||
@apis | ||
end | ||
|
||
# List of all the apis defined in the given scope (and its sub-scopes). | ||
def apis_for_controller(controller_name) | ||
@apis.select { |t| controller_name == t.method_name.first } | ||
end | ||
|
||
# get api for given controoler and method name | ||
def get_api(controller, method_name) | ||
id = [controller, method_name] | ||
|
||
api = @apis[id] | ||
|
||
api or fail "Don't know api for '#{method_name}'" | ||
end | ||
alias :[] :get_api | ||
|
||
# Clear all apis in this application. | ||
def clear | ||
@apis.clear | ||
end | ||
|
||
# Return the current description, clearing it in the process. | ||
def get_description | ||
desc = @last_description | ||
@last_description = nil | ||
desc | ||
end | ||
|
||
def get_errors | ||
errors = @last_errors.clone | ||
@last_errors.clear | ||
errors | ||
end | ||
|
||
def get_api_args | ||
api_args = @last_api_args | ||
api_args | ||
end | ||
|
||
def get_params | ||
params = @last_params.clone | ||
@last_params.clear | ||
params | ||
end | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "restapi/api_manager" | ||
|
||
module Restapi | ||
|
||
class Application | ||
|
||
include ApiManager | ||
|
||
def initialize | ||
puts "initialize Restapi" | ||
super | ||
end | ||
|
||
def options | ||
@options ||= OpenStruct.new | ||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.