birdie 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/birdie.gemspec +30 -0
- data/lib/birdie.rb +12 -0
- data/lib/birdie/application.rb +33 -0
- data/lib/birdie/controller.rb +65 -0
- data/lib/birdie/version.rb +3 -0
- data/spec/dummy/app/builders/root_collection_builder.rb +7 -0
- data/spec/dummy/app/controllers/root_controller.rb +5 -0
- data/spec/dummy/config/application.rb +9 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/integration/root_controller_spec.rb +20 -0
- data/spec/spec_helper.rb +37 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b62455c3396652229b0b3927393d8d31d9443b43
|
4
|
+
data.tar.gz: 94fdaa5c394d8e95f5d3a60f5312c69a88924c08
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61652a892786eae067d29c5edf2e0ed8bb0815b580052010264f466369dffba6f1c76c3daafdbd6c72fbe70294546781181d8480087a359f522f4dc0fa5d36e4
|
7
|
+
data.tar.gz: 9994172664892e300456570c3192f7f189598b5b1200f725e72b91be0e0dcfef1eb15d6d22ce89cb13d9844abd16de81a2c070dd77e3848851728a20ed8c5802
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pom
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Emily Dobervich, Justin Kim
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Birdie
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'birdie'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install birdie
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/birdie/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/birdie.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'birdie/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "birdie"
|
8
|
+
spec.version = Birdie::VERSION
|
9
|
+
spec.authors = ["Emily Dobervich", "Justin Kim"]
|
10
|
+
spec.email = ["birdie@narwhunderful.com"]
|
11
|
+
spec.summary = %q{Unfinished (aka Pre-Release) Ruby Web API Framework}
|
12
|
+
spec.description = %q{A Ruby Web API Framework for CollectionJSON (and maybe more in the future).}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'lotus-controller'
|
22
|
+
spec.add_dependency 'lotus-router'
|
23
|
+
spec.add_dependency 'conglomerate'
|
24
|
+
spec.add_dependency 'activesupport'
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
end
|
data/lib/birdie.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'active_support/dependencies'
|
2
|
+
require 'birdie'
|
3
|
+
|
4
|
+
module Birdie
|
5
|
+
module Application
|
6
|
+
class << self
|
7
|
+
attr_accessor :root, :app
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.extended(subclass)
|
11
|
+
self.app = subclass
|
12
|
+
call_stack = caller_locations.map(&:path)
|
13
|
+
|
14
|
+
class << subclass
|
15
|
+
attr_accessor :root
|
16
|
+
end
|
17
|
+
|
18
|
+
subclass.root = File.expand_path('../..', call_stack.find { |call| call !~ %r{lib/birdie} })
|
19
|
+
|
20
|
+
relative_load_paths = %w[controllers builders]
|
21
|
+
relative_load_paths = relative_load_paths.map do |path|
|
22
|
+
File.expand_path("app/#{path}", subclass.root)
|
23
|
+
end
|
24
|
+
ActiveSupport::Dependencies.autoload_paths += relative_load_paths
|
25
|
+
|
26
|
+
require File.join(subclass.root, 'config', 'routes.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
def router(&block)
|
30
|
+
@router ||= Lotus::Router.new(&block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
if ENV['BIRDIE_DEBUG']
|
2
|
+
Lotus::Controller.configure do
|
3
|
+
handle_exceptions false
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Birdie
|
8
|
+
module Controller
|
9
|
+
def self.extended(base)
|
10
|
+
base.send(:include, Lotus::Controller)
|
11
|
+
end
|
12
|
+
|
13
|
+
def builder(klass)
|
14
|
+
@builder_klass = klass
|
15
|
+
end
|
16
|
+
|
17
|
+
def index_action(&block)
|
18
|
+
define_action('Index', &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def show_action(&block)
|
22
|
+
define_action('Show', &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_action(&block)
|
26
|
+
define_action('Create', &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_action(&block)
|
30
|
+
define_action('Update', &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy_action(&block)
|
34
|
+
define_action('Destroy', &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def define_action(name, &block)
|
40
|
+
block ||= Proc.new{ [] }
|
41
|
+
action(name, &action_block)
|
42
|
+
const = self.const_get(name)
|
43
|
+
const.exec_block = block
|
44
|
+
const.builder_klass = @builder_klass
|
45
|
+
end
|
46
|
+
|
47
|
+
def action_block
|
48
|
+
Proc.new do
|
49
|
+
class << self
|
50
|
+
attr_accessor :builder_klass, :exec_block
|
51
|
+
end
|
52
|
+
|
53
|
+
def call(params)
|
54
|
+
items = instance_eval(&self.class.exec_block)
|
55
|
+
collection = self.class.builder_klass.new(items, context: self).serialize
|
56
|
+
self.body = JSON.dump(collection)
|
57
|
+
end
|
58
|
+
|
59
|
+
def path_for(*args)
|
60
|
+
Birdie::Application.app.router.path(*args)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../dummy/config/application'
|
3
|
+
|
4
|
+
describe RootController do
|
5
|
+
describe "index" do
|
6
|
+
let(:action) { RootController::Index.new }
|
7
|
+
|
8
|
+
it "returns a collection-json collection" do
|
9
|
+
call_action(action, {})
|
10
|
+
expect(response.collection.class).to eq(Conglomerate::Collection)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "links to root" do
|
14
|
+
call_action(action, {})
|
15
|
+
expect(
|
16
|
+
response.collection.links.find{ |l| l.rel == "root" }.href
|
17
|
+
).to eq(path_for(:root))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
ENV['BIRDIE_DEBUG'] = 'true'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.order = "random"
|
7
|
+
end
|
8
|
+
|
9
|
+
class CollectionResponse
|
10
|
+
attr_accessor :status, :collection, :headers
|
11
|
+
|
12
|
+
def initialize(status, headers, body)
|
13
|
+
self.status = status
|
14
|
+
self.headers = headers
|
15
|
+
self.collection = parse_body(body.first)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def parse_body(body)
|
21
|
+
deserializer = Conglomerate::TreeDeserializer.new(JSON.parse(body))
|
22
|
+
deserializer.deserialize
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def call_action(action, params)
|
27
|
+
raw_response = action.call(params)
|
28
|
+
@collection_response = CollectionResponse.new(*raw_response)
|
29
|
+
end
|
30
|
+
|
31
|
+
def response
|
32
|
+
@collection_response
|
33
|
+
end
|
34
|
+
|
35
|
+
def path_for(*args)
|
36
|
+
Birdie::Application.app.router.path(*args)
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: birdie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emily Dobervich
|
8
|
+
- Justin Kim
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: lotus-controller
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: lotus-router
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: conglomerate
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: activesupport
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.6'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.6'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: pry
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rake
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rspec
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: A Ruby Web API Framework for CollectionJSON (and maybe more in the future).
|
127
|
+
email:
|
128
|
+
- birdie@narwhunderful.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".ruby-gemset"
|
135
|
+
- ".ruby-version"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- birdie.gemspec
|
141
|
+
- lib/birdie.rb
|
142
|
+
- lib/birdie/application.rb
|
143
|
+
- lib/birdie/controller.rb
|
144
|
+
- lib/birdie/version.rb
|
145
|
+
- spec/dummy/app/builders/root_collection_builder.rb
|
146
|
+
- spec/dummy/app/controllers/root_controller.rb
|
147
|
+
- spec/dummy/config/application.rb
|
148
|
+
- spec/dummy/config/routes.rb
|
149
|
+
- spec/integration/root_controller_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
homepage: ''
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.2.2
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: Unfinished (aka Pre-Release) Ruby Web API Framework
|
175
|
+
test_files:
|
176
|
+
- spec/dummy/app/builders/root_collection_builder.rb
|
177
|
+
- spec/dummy/app/controllers/root_controller.rb
|
178
|
+
- spec/dummy/config/application.rb
|
179
|
+
- spec/dummy/config/routes.rb
|
180
|
+
- spec/integration/root_controller_spec.rb
|
181
|
+
- spec/spec_helper.rb
|