factory_girl_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bec3be4b446e4a19fdcb19a1e0b48dfec7134466
4
+ data.tar.gz: 510599782aa7708d2c363b46fc9bc3fa792ccc54
5
+ SHA512:
6
+ metadata.gz: ae1b548cd0840323098c6d5c0d2cce7aae1f1e93ad969919ec0c5846ba2def6f953a2751c1b188fec6635224338314468f02a8a744b4e7bf77b54d265efd22b2
7
+ data.tar.gz: 6468bddc394122e519508c98151bb9cf785276d60a03d133e120bca123d0f62445ba5a8b98d7580ad77df6074762af8bba92183629dce675c748010ed6d95b9d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Alexis King
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,37 @@
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
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'FactoryGirlApi'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'spec'
32
+ t.pattern = 'spec/**/*_spec.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,4 @@
1
+ module FactoryGirlApi
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ require 'database_cleaner'
2
+
3
+ module FactoryGirlApi
4
+ class DatabasesController < FactoryGirlApi::ApplicationController
5
+ def create
6
+ DatabaseCleaner.strategy = :truncation
7
+ DatabaseCleaner.start
8
+ render json: {}
9
+ end
10
+
11
+ def destroy
12
+ DatabaseCleaner.clean
13
+ render json: {}
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ module FactoryGirlApi
2
+ class FactoriesController < FactoryGirlApi::ApplicationController
3
+ def create
4
+ model = FactoryGirl.create(factory_name, *traits, attributes)
5
+ render json: model, status: :created
6
+ end
7
+
8
+ private
9
+
10
+ def factory_params
11
+ @factory_params ||= params.require(:factory).permit!
12
+ end
13
+
14
+ def factory_name
15
+ @factory_name ||= factory_params.require(:name)
16
+ end
17
+
18
+ def traits
19
+ @traits ||= begin
20
+ strings = factory_params[:traits] || []
21
+ strings.map(&:to_sym)
22
+ end
23
+ end
24
+
25
+ def attributes
26
+ @attributes ||= factory_params.fetch(:attributes, {})
27
+ end
28
+ end
29
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ FactoryGirlApi::Engine.routes.draw do
2
+ resource :database, only: [:create, :destroy]
3
+ resources :factories, only: [:create]
4
+ end
@@ -0,0 +1,5 @@
1
+ module FactoryGirlApi
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace FactoryGirlApi
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module FactoryGirlApi
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'factory_girl_api/engine'
2
+
3
+ module FactoryGirlApi
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :factory_girl_api do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: factory_girl_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexis King
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: database_cleaner
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: factory_girl_rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ description:
98
+ email:
99
+ - lexi.lambda@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - MIT-LICENSE
105
+ - Rakefile
106
+ - app/controllers/factory_girl_api/application_controller.rb
107
+ - app/controllers/factory_girl_api/databases_controller.rb
108
+ - app/controllers/factory_girl_api/factories_controller.rb
109
+ - config/routes.rb
110
+ - lib/factory_girl_api.rb
111
+ - lib/factory_girl_api/engine.rb
112
+ - lib/factory_girl_api/version.rb
113
+ - lib/tasks/factory_girl_api_tasks.rake
114
+ homepage: https://github.com/philosophie/factory_girl_api
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.4.5
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: A Rails engine for mainpulating factories via API
138
+ test_files: []