Skip to content

Commit

Permalink
bump the rails requirement down and see what happens!
Browse files Browse the repository at this point in the history
  • Loading branch information
randym committed Oct 1, 2013
1 parent 198f520 commit 1bfe48d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,4 +7,5 @@ spec/dummy/log/*.log
spec/dummy/tmp/
spec/dummy/.sass-cache
*.un~
*.gem

44 changes: 43 additions & 1 deletion README.md
@@ -1,3 +1,45 @@
= Apic

This project rocks and uses MIT-LICENSE.
[![Build Status](https://secure.travis-ci.org/hsbt/whispered.png)](https://travis-ci.org/hsbt/whispered) [![Coverage Status](https://coveralls.io/repos/randym/apic/badge.png?branch=master)](https://coveralls.io/r/randym/apic) [![Dependency Status](https://gemnasium.com/randym/apic.png)](https://gemnasium.com/randym/apic) [![Code Climate](https://codeclimate.com/github/randym/apic.png)](https://codeclimate.com/github/randym/apic)


What you need to do?

add the gem to your Gemfile

```
gem 'apic'
```

require the gem in your application.rb

```
require 'apic'
```

mount the gem in your routes.rb

```
mount Apic::Engine => "/apic"
```

## and some groovy stuff too

Filter routes on a regex match


```
Apic.routes_matcher = /\/api\//
```

Tell us what your authorization filter is!

```
Apic.authorization_filter = :authenticate
```


git remote add origin https://github.com/randym/apic.git


This project rocks and uses MIT-LICENSE.
12 changes: 0 additions & 12 deletions Rakefile
Expand Up @@ -4,20 +4,8 @@ rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end

require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Apic'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'



Bundler::GemHelper.install_tasks

4 changes: 2 additions & 2 deletions apic.gemspec
Expand Up @@ -14,9 +14,9 @@ Gem::Specification.new do |s|
s.description = s.summary
s.license = "MIT"

s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

s.add_dependency "rails", "~> 4.0.0"
s.add_dependency "rails", "~> 3.2.0"
s.add_dependency "slim-rails", "~>2.0.1"
s.add_dependency "sass-rails", ">= 3.2"
s.add_dependency "bootstrap-sass", "~>2.3.2.2"
Expand Down
7 changes: 6 additions & 1 deletion lib/apic.rb
Expand Up @@ -7,9 +7,14 @@ module Apic
mattr_accessor :authorization_filter
@@authorization_filter = nil

mattr_accessor :route_matcher
@@route_matcher = /\/api\//



def self.endpoints
@endpoints ||= Rails.application.routes.routes.reduce({}) do |hash, route|
if route.path.spec.to_s =~ /\/api\//
if route.path.spec.to_s =~ @@route_matcher
route_spec = {
path: route.path.spec.to_s.gsub("(.:format)",".json"),
parts: route.parts - [:format],
Expand Down

0 comments on commit 1bfe48d

Please sign in to comment.