hangar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +26 -0
- data/app/controllers/hangar/records_controller.rb +10 -0
- data/app/controllers/hangar/resources_controller.rb +25 -0
- data/config/routes.rb +8 -0
- data/lib/hangar/constraint.rb +7 -0
- data/lib/hangar/engine.rb +13 -0
- data/lib/hangar/version.rb +3 -0
- data/lib/hangar.rb +13 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 883d2389cdcdc3e0f93b86c3be4263b6bf7a555a
|
4
|
+
data.tar.gz: 6e0a4ed85f4e9fe702f8501d70522f32e2036cc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8134e1b641e36c91f212bd0ee1088212bd17f08180080aeb9d3270dbfefe5649b404dcbd9d45d2200cff3f1033553d5c3364322e122346781cfd05c2cd776d2f
|
7
|
+
data.tar.gz: e84c86638ac31875e0d138ea7ae3a228ec1df1f97002125d1ea2a1ccafd438c4a3594969c7ce3e826d5bd315a05ab45d02e7e895d128e1e3e4c87f03b2ec9791
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
8
|
+
load 'rails/tasks/engine.rake'
|
9
|
+
|
10
|
+
Bundler::GemHelper.install_tasks
|
11
|
+
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
RSpec::Core::RakeTask.new(:application_spec) do |t|
|
14
|
+
t.rspec_opts = '--tag application'
|
15
|
+
end
|
16
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
17
|
+
t.rspec_opts = '--tag ~application'
|
18
|
+
end
|
19
|
+
|
20
|
+
task :default do
|
21
|
+
old_spec = ENV['SPEC']
|
22
|
+
ENV['SPEC'] = File.expand_path('../spec/application/environment_spec.rb', __FILE__)
|
23
|
+
Rake::Task[:application_spec].execute
|
24
|
+
ENV['SPEC'] = old_spec
|
25
|
+
Rake::Task[:spec].execute
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Hangar
|
2
|
+
class ResourcesController < ActionController::Base
|
3
|
+
respond_to :json
|
4
|
+
|
5
|
+
def create
|
6
|
+
created = FactoryGirl.create resource, resource_attributes
|
7
|
+
respond_with created
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
attributes = FactoryGirl.attributes_for resource, resource_attributes
|
12
|
+
respond_with attributes
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def resource
|
18
|
+
request.path.split('/')[1].singularize.to_sym
|
19
|
+
end
|
20
|
+
|
21
|
+
def resource_attributes
|
22
|
+
params.fetch(resource, {}).permit!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
constraints Hangar::RouteConstraint.new do
|
3
|
+
FactoryGirl.factories.map(&:name).map(&:to_s).map(&:pluralize).map(&:to_sym).each do |factory|
|
4
|
+
resources factory, only: [:new, :create], controller: 'hangar/resources'
|
5
|
+
end
|
6
|
+
delete '/', to: 'hangar/records#delete'
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Hangar
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
initializer :promote_hangar_routes, after: :add_routing_paths do |app|
|
4
|
+
hangar_routes_path = File.expand_path('../../../config/routes.rb', __FILE__)
|
5
|
+
app.routes_reloader.paths.delete hangar_routes_path
|
6
|
+
app.routes_reloader.paths.unshift hangar_routes_path
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer :validate_environment do
|
10
|
+
Hangar.validate_environment
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/hangar.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "hangar/engine"
|
2
|
+
require 'hangar/constraint'
|
3
|
+
require 'database_cleaner'
|
4
|
+
|
5
|
+
module Hangar
|
6
|
+
BadEnvironmentError = Class.new(StandardError)
|
7
|
+
|
8
|
+
def validate_environment
|
9
|
+
Rails.env.test? or raise BadEnvironmentError, "Hangar should not be used in the #{Rails.env} environment"
|
10
|
+
end
|
11
|
+
module_function :validate_environment
|
12
|
+
end
|
13
|
+
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hangar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Rossmeissl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: database_cleaner
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Exposes routes (in the test environment only!) that allow your frontend
|
56
|
+
to factory objects and clear them between tests
|
57
|
+
email:
|
58
|
+
- andy@rossmeissl.net
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- MIT-LICENSE
|
64
|
+
- Rakefile
|
65
|
+
- app/controllers/hangar/records_controller.rb
|
66
|
+
- app/controllers/hangar/resources_controller.rb
|
67
|
+
- config/routes.rb
|
68
|
+
- lib/hangar.rb
|
69
|
+
- lib/hangar/constraint.rb
|
70
|
+
- lib/hangar/engine.rb
|
71
|
+
- lib/hangar/version.rb
|
72
|
+
homepage: http://github.com/faradayio/hangar
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Use Rails factories from your frontend
|
96
|
+
test_files: []
|