Skip to content

Commit 0bb2955

Browse files
committed
initial commit
0 parents  commit 0bb2955

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1510
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.bundle/
2+
log/*.log
3+
pkg/
4+
test/dummy/db/*.sqlite3
5+
test/dummy/db/*.sqlite3-journal
6+
test/dummy/log/*.log
7+
test/dummy/tmp/
8+
test/dummy/.sass-cache

.ruby-gemset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
formbuilder-rb

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.0.0

Gemfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
source "https://rubygems.org"
2+
3+
# Declare your gem's dependencies in formbuilder.gemspec.
4+
# Bundler will treat runtime dependencies like base dependencies, and
5+
# development dependencies will be added by default to the :development group.
6+
gemspec
7+
8+
# Declare any dependencies that are still in development here instead of in
9+
# your gemspec. These might include edge Rails or gems from your path or
10+
# Git. Remember to move these dependencies to your gemspec before releasing
11+
# your gem to rubygems.org.
12+
13+
# To use debugger
14+
# gem 'debugger'

Gemfile.lock

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
PATH
2+
remote: .
3+
specs:
4+
formbuilder (0.0.1)
5+
pg
6+
rails (~> 4.0.0)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
actionmailer (4.0.0)
12+
actionpack (= 4.0.0)
13+
mail (~> 2.5.3)
14+
actionpack (4.0.0)
15+
activesupport (= 4.0.0)
16+
builder (~> 3.1.0)
17+
erubis (~> 2.7.0)
18+
rack (~> 1.5.2)
19+
rack-test (~> 0.6.2)
20+
activemodel (4.0.0)
21+
activesupport (= 4.0.0)
22+
builder (~> 3.1.0)
23+
activerecord (4.0.0)
24+
activemodel (= 4.0.0)
25+
activerecord-deprecated_finders (~> 1.0.2)
26+
activesupport (= 4.0.0)
27+
arel (~> 4.0.0)
28+
activerecord-deprecated_finders (1.0.3)
29+
activesupport (4.0.0)
30+
i18n (~> 0.6, >= 0.6.4)
31+
minitest (~> 4.2)
32+
multi_json (~> 1.3)
33+
thread_safe (~> 0.1)
34+
tzinfo (~> 0.3.37)
35+
arel (4.0.0)
36+
atomic (1.1.14)
37+
builder (3.1.4)
38+
erubis (2.7.0)
39+
hike (1.2.3)
40+
i18n (0.6.5)
41+
mail (2.5.4)
42+
mime-types (~> 1.16)
43+
treetop (~> 1.4.8)
44+
mime-types (1.25)
45+
minitest (4.7.5)
46+
multi_json (1.8.0)
47+
pg (0.17.0)
48+
polyglot (0.3.3)
49+
rack (1.5.2)
50+
rack-test (0.6.2)
51+
rack (>= 1.0)
52+
rails (4.0.0)
53+
actionmailer (= 4.0.0)
54+
actionpack (= 4.0.0)
55+
activerecord (= 4.0.0)
56+
activesupport (= 4.0.0)
57+
bundler (>= 1.3.0, < 2.0)
58+
railties (= 4.0.0)
59+
sprockets-rails (~> 2.0.0)
60+
railties (4.0.0)
61+
actionpack (= 4.0.0)
62+
activesupport (= 4.0.0)
63+
rake (>= 0.8.7)
64+
thor (>= 0.18.1, < 2.0)
65+
rake (10.1.0)
66+
sprockets (2.10.0)
67+
hike (~> 1.2)
68+
multi_json (~> 1.0)
69+
rack (~> 1.0)
70+
tilt (~> 1.1, != 1.3.0)
71+
sprockets-rails (2.0.0)
72+
actionpack (>= 3.0)
73+
activesupport (>= 3.0)
74+
sprockets (~> 2.8)
75+
thor (0.18.1)
76+
thread_safe (0.1.3)
77+
atomic
78+
tilt (1.4.1)
79+
treetop (1.4.15)
80+
polyglot
81+
polyglot (>= 0.3.1)
82+
tzinfo (0.3.37)
83+
84+
PLATFORMS
85+
ruby
86+
87+
DEPENDENCIES
88+
formbuilder!

MIT-LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2013 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.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Formbuilder
2+
========
3+
4+
## The `Form` model
5+
```ruby
6+
# formable_id :integer
7+
# formable_type :string(255)
8+
9+
class Form < ActiveRecord::Base
10+
11+
include Formbuilder::Form
12+
13+
end
14+
```
15+
16+
## The `Entry` model
17+
```ruby
18+
# responses :hstore
19+
# responses_text :text
20+
21+
class Entry < ActiveRecord::Base
22+
23+
include Formbuilder::Entry
24+
25+
end
26+
```
27+
28+
## The `ResponseField` model
29+
```ruby
30+
# label :text
31+
# type :string(255)
32+
# field_options :text
33+
# sort_order :integer
34+
# required :boolean default(FALSE)
35+
# blind :boolean default(FALSE)
36+
# admin_only :boolean default(FALSE)
37+
38+
class ResponseField < ActiveRecord::Base
39+
40+
include Formbuilder::ResponseFields::Base
41+
42+
end
43+
```
44+
45+
#### License
46+
47+
MIT

Rakefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 = 'Formbuilder'
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("../test/dummy/Rakefile", __FILE__)
18+
load 'rails/tasks/engine.rake'
19+
20+
21+
22+
Bundler::GemHelper.install_tasks
23+
24+
require 'rake/testtask'
25+
26+
Rake::TestTask.new(:test) do |t|
27+
t.libs << 'lib'
28+
t.libs << 'test'
29+
t.pattern = 'test/**/*_test.rb'
30+
t.verbose = false
31+
end
32+
33+
34+
task default: :test
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Formbuilder
2+
class FormsController < ApplicationController
3+
4+
before_filter :load_form
5+
6+
def update
7+
existing_response_field_ids = []
8+
9+
(params[:fields] || []).each_with_index do |field_params, i|
10+
response_field = field_params[:id].present? ?
11+
@form.response_fields.find { |rf| rf.id == field_params[:id].to_i } :
12+
@form.response_fields.build
13+
14+
response_field.update_attributes(pick(field_params, *ResponseField::ALLOWED_PARAMS).merge(sort_order: i, type: "ResponseFields::#{field_params[:field_type].camelize}"))
15+
response_field.cid = field_params[:cid]
16+
existing_response_field_ids.push response_field.id
17+
end
18+
19+
# destroy fields that no longer exist
20+
@form.response_fields.each do |response_field|
21+
response_field.destroy unless response_field.id.in?(existing_response_field_ids)
22+
end
23+
24+
render json: @form.response_fields.reload
25+
end
26+
27+
private
28+
def load_form
29+
@form = Form.find(params[:id])
30+
end
31+
32+
end
33+
end

bin/rails

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3+
4+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
5+
ENGINE_PATH = File.expand_path('../../lib/formbuilder/engine', __FILE__)
6+
7+
require 'rails/all'
8+
require 'rails/engine/commands'

0 commit comments

Comments
 (0)