databound 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +63 -0
  7. data/Rakefile +2 -0
  8. data/config.ru +7 -0
  9. data/databound.gemspec +31 -0
  10. data/lib/databound.rb +83 -0
  11. data/lib/databound/data.rb +51 -0
  12. data/lib/databound/manager.rb +60 -0
  13. data/lib/databound/rails/routes.rb +17 -0
  14. data/lib/databound/version.rb +3 -0
  15. data/spec/controllers/databound_spec.rb +138 -0
  16. data/spec/controllers/dsl_controller_spec.rb +177 -0
  17. data/spec/controllers/loose_dsl_controller_spec.rb +127 -0
  18. data/spec/controllers/no_model_controller_spec.rb +9 -0
  19. data/spec/controllers/permitted_columns_controller_spec.rb +104 -0
  20. data/spec/internal/app/controllers/application_controller.rb +5 -0
  21. data/spec/internal/app/controllers/dsl_controller.rb +17 -0
  22. data/spec/internal/app/controllers/loose_dsl_controller.rb +13 -0
  23. data/spec/internal/app/controllers/no_model_controller.rb +3 -0
  24. data/spec/internal/app/controllers/permitted_columns_controller.rb +13 -0
  25. data/spec/internal/app/controllers/users_controller.rb +9 -0
  26. data/spec/internal/app/models/user.rb +2 -0
  27. data/spec/internal/config/database.yml +3 -0
  28. data/spec/internal/config/routes.rb +7 -0
  29. data/spec/internal/db/combustion_test.sqlite +0 -0
  30. data/spec/internal/db/schema.rb +7 -0
  31. data/spec/internal/log/.gitignore +1 -0
  32. data/spec/internal/public/favicon.ico +0 -0
  33. data/spec/spec_helper.rb +36 -0
  34. data/spec/support/rails_test_app/.gitignore +16 -0
  35. data/spec/support/rails_test_app/Gemfile +40 -0
  36. data/spec/support/rails_test_app/Gemfile.lock +120 -0
  37. data/spec/support/rails_test_app/README.rdoc +28 -0
  38. data/spec/support/rails_test_app/Rakefile +6 -0
  39. data/spec/support/rails_test_app/app/assets/images/.keep +0 -0
  40. data/spec/support/rails_test_app/app/assets/javascripts/application.js +16 -0
  41. data/spec/support/rails_test_app/app/assets/stylesheets/application.css +15 -0
  42. data/spec/support/rails_test_app/app/controllers/application_controller.rb +5 -0
  43. data/spec/support/rails_test_app/app/controllers/concerns/.keep +0 -0
  44. data/spec/support/rails_test_app/app/helpers/application_helper.rb +2 -0
  45. data/spec/support/rails_test_app/app/mailers/.keep +0 -0
  46. data/spec/support/rails_test_app/app/models/.keep +0 -0
  47. data/spec/support/rails_test_app/app/models/concerns/.keep +0 -0
  48. data/spec/support/rails_test_app/app/views/layouts/application.html.erb +14 -0
  49. data/spec/support/rails_test_app/bin/bundle +3 -0
  50. data/spec/support/rails_test_app/bin/rails +8 -0
  51. data/spec/support/rails_test_app/bin/rake +8 -0
  52. data/spec/support/rails_test_app/bin/spring +18 -0
  53. data/spec/support/rails_test_app/config.ru +4 -0
  54. data/spec/support/rails_test_app/config/application.rb +30 -0
  55. data/spec/support/rails_test_app/config/boot.rb +4 -0
  56. data/spec/support/rails_test_app/config/database.yml +25 -0
  57. data/spec/support/rails_test_app/config/environment.rb +5 -0
  58. data/spec/support/rails_test_app/config/environments/development.rb +37 -0
  59. data/spec/support/rails_test_app/config/environments/production.rb +78 -0
  60. data/spec/support/rails_test_app/config/environments/test.rb +39 -0
  61. data/spec/support/rails_test_app/config/initializers/assets.rb +8 -0
  62. data/spec/support/rails_test_app/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/support/rails_test_app/config/initializers/cookies_serializer.rb +3 -0
  64. data/spec/support/rails_test_app/config/initializers/filter_parameter_logging.rb +4 -0
  65. data/spec/support/rails_test_app/config/initializers/inflections.rb +16 -0
  66. data/spec/support/rails_test_app/config/initializers/mime_types.rb +4 -0
  67. data/spec/support/rails_test_app/config/initializers/session_store.rb +3 -0
  68. data/spec/support/rails_test_app/config/initializers/wrap_parameters.rb +14 -0
  69. data/spec/support/rails_test_app/config/locales/en.yml +23 -0
  70. data/spec/support/rails_test_app/config/routes.rb +56 -0
  71. data/spec/support/rails_test_app/config/secrets.yml +22 -0
  72. data/spec/support/rails_test_app/db/seeds.rb +7 -0
  73. data/spec/support/rails_test_app/lib/assets/.keep +0 -0
  74. data/spec/support/rails_test_app/lib/tasks/.keep +0 -0
  75. data/spec/support/rails_test_app/log/.keep +0 -0
  76. data/spec/support/rails_test_app/public/404.html +67 -0
  77. data/spec/support/rails_test_app/public/422.html +67 -0
  78. data/spec/support/rails_test_app/public/500.html +66 -0
  79. data/spec/support/rails_test_app/public/favicon.ico +0 -0
  80. data/spec/support/rails_test_app/public/robots.txt +5 -0
  81. data/spec/support/rails_test_app/vendor/assets/javascripts/.keep +0 -0
  82. data/spec/support/rails_test_app/vendor/assets/stylesheets/.keep +0 -0
  83. metadata +320 -0
@@ -0,0 +1,3 @@
1
+ class NoModelController < ApplicationController
2
+ include Databound
3
+ end
@@ -0,0 +1,13 @@
1
+ class PermittedColumnsController < ApplicationController
2
+ include Databound
3
+
4
+ private
5
+
6
+ def model
7
+ User
8
+ end
9
+
10
+ def permitted_columns
11
+ %i(name)
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class UsersController < ApplicationController
2
+ include Databound
3
+
4
+ private
5
+
6
+ def model
7
+ User
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,7 @@
1
+ Rails.application.routes.draw do
2
+ databound :users
3
+ databound :no_model
4
+ databound :permitted_columns
5
+ databound :dsl
6
+ databound :loose_dsl
7
+ end
@@ -0,0 +1,7 @@
1
+ ActiveRecord::Schema.define do
2
+ create_table(:users, force: true) do |t|
3
+ t.string :name
4
+ t.string :city
5
+ t.timestamps
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'combustion'
5
+
6
+ Combustion.initialize! :all
7
+
8
+ require 'rspec/rails'
9
+ require 'pry'
10
+
11
+ RSpec.configure do |config|
12
+ config.use_transactional_fixtures = true
13
+ end
14
+
15
+ def javascriptize(ruby_obj)
16
+ ruby_obj.each_with_object({}) do |(key, val), obj|
17
+ obj[key] = JSON.dump(val)
18
+ end
19
+ end
20
+
21
+ def rubize(response)
22
+ optionize(JSON.parse(response.body))
23
+ end
24
+
25
+ def optionize(obj)
26
+ case obj
27
+ when Array
28
+ obj.map(&:to_options)
29
+ else
30
+ obj.to_options
31
+ end
32
+ end
33
+
34
+ def gather(attribute, response)
35
+ rubize(response).map { |record| record[attribute] }
36
+ end
@@ -0,0 +1,16 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
@@ -0,0 +1,40 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.1.6'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 4.0.3'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .js.coffee assets and views
13
+ gem 'coffee-rails', '~> 4.0.0'
14
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
27
+ gem 'spring', group: :development
28
+
29
+ # Use ActiveModel has_secure_password
30
+ # gem 'bcrypt', '~> 3.1.7'
31
+
32
+ # Use unicorn as the app server
33
+ # gem 'unicorn'
34
+
35
+ # Use Capistrano for deployment
36
+ # gem 'capistrano-rails', group: :development
37
+
38
+ # Use debugger
39
+ # gem 'debugger', group: [:development, :test]
40
+
@@ -0,0 +1,120 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionmailer (4.1.6)
5
+ actionpack (= 4.1.6)
6
+ actionview (= 4.1.6)
7
+ mail (~> 2.5, >= 2.5.4)
8
+ actionpack (4.1.6)
9
+ actionview (= 4.1.6)
10
+ activesupport (= 4.1.6)
11
+ rack (~> 1.5.2)
12
+ rack-test (~> 0.6.2)
13
+ actionview (4.1.6)
14
+ activesupport (= 4.1.6)
15
+ builder (~> 3.1)
16
+ erubis (~> 2.7.0)
17
+ activemodel (4.1.6)
18
+ activesupport (= 4.1.6)
19
+ builder (~> 3.1)
20
+ activerecord (4.1.6)
21
+ activemodel (= 4.1.6)
22
+ activesupport (= 4.1.6)
23
+ arel (~> 5.0.0)
24
+ activesupport (4.1.6)
25
+ i18n (~> 0.6, >= 0.6.9)
26
+ json (~> 1.7, >= 1.7.7)
27
+ minitest (~> 5.1)
28
+ thread_safe (~> 0.1)
29
+ tzinfo (~> 1.1)
30
+ arel (5.0.1.20140414130214)
31
+ builder (3.2.2)
32
+ coffee-rails (4.0.1)
33
+ coffee-script (>= 2.2.0)
34
+ railties (>= 4.0.0, < 5.0)
35
+ coffee-script (2.3.0)
36
+ coffee-script-source
37
+ execjs
38
+ coffee-script-source (1.8.0)
39
+ erubis (2.7.0)
40
+ execjs (2.2.2)
41
+ hike (1.2.3)
42
+ i18n (0.6.11)
43
+ jbuilder (2.2.2)
44
+ activesupport (>= 3.0.0, < 5)
45
+ multi_json (~> 1.2)
46
+ jquery-rails (3.1.2)
47
+ railties (>= 3.0, < 5.0)
48
+ thor (>= 0.14, < 2.0)
49
+ json (1.8.1)
50
+ mail (2.6.1)
51
+ mime-types (>= 1.16, < 3)
52
+ mime-types (2.4.1)
53
+ minitest (5.4.2)
54
+ multi_json (1.10.1)
55
+ rack (1.5.2)
56
+ rack-test (0.6.2)
57
+ rack (>= 1.0)
58
+ rails (4.1.6)
59
+ actionmailer (= 4.1.6)
60
+ actionpack (= 4.1.6)
61
+ actionview (= 4.1.6)
62
+ activemodel (= 4.1.6)
63
+ activerecord (= 4.1.6)
64
+ activesupport (= 4.1.6)
65
+ bundler (>= 1.3.0, < 2.0)
66
+ railties (= 4.1.6)
67
+ sprockets-rails (~> 2.0)
68
+ railties (4.1.6)
69
+ actionpack (= 4.1.6)
70
+ activesupport (= 4.1.6)
71
+ rake (>= 0.8.7)
72
+ thor (>= 0.18.1, < 2.0)
73
+ rake (10.3.2)
74
+ rdoc (4.1.2)
75
+ json (~> 1.4)
76
+ sass (3.2.19)
77
+ sass-rails (4.0.3)
78
+ railties (>= 4.0.0, < 5.0)
79
+ sass (~> 3.2.0)
80
+ sprockets (~> 2.8, <= 2.11.0)
81
+ sprockets-rails (~> 2.0)
82
+ sdoc (0.4.1)
83
+ json (~> 1.7, >= 1.7.7)
84
+ rdoc (~> 4.0)
85
+ spring (1.1.3)
86
+ sprockets (2.11.0)
87
+ hike (~> 1.2)
88
+ multi_json (~> 1.0)
89
+ rack (~> 1.0)
90
+ tilt (~> 1.1, != 1.3.0)
91
+ sprockets-rails (2.2.0)
92
+ actionpack (>= 3.0)
93
+ activesupport (>= 3.0)
94
+ sprockets (>= 2.8, < 4.0)
95
+ sqlite3 (1.3.9)
96
+ thor (0.19.1)
97
+ thread_safe (0.3.4)
98
+ tilt (1.4.1)
99
+ turbolinks (2.4.0)
100
+ coffee-rails
101
+ tzinfo (1.2.2)
102
+ thread_safe (~> 0.1)
103
+ uglifier (2.5.3)
104
+ execjs (>= 0.3.0)
105
+ json (>= 1.8.0)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ coffee-rails (~> 4.0.0)
112
+ jbuilder (~> 2.0)
113
+ jquery-rails
114
+ rails (= 4.1.6)
115
+ sass-rails (~> 4.0.3)
116
+ sdoc (~> 0.4.0)
117
+ spring
118
+ sqlite3
119
+ turbolinks
120
+ uglifier (>= 1.3.0)
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsTestApp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
7
+ require_relative '../config/boot'
8
+ require 'rails/commands'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ require_relative '../config/boot'
7
+ require 'rake'
8
+ Rake.application.run
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast
4
+ # It gets overwritten when you run the `spring binstub` command
5
+
6
+ unless defined?(Spring)
7
+ require "rubygems"
8
+ require "bundler"
9
+
10
+ if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11
+ ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12
+ ENV["GEM_HOME"] = ""
13
+ Gem.paths = ENV
14
+
15
+ gem "spring", match[1]
16
+ require "spring/binstub"
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,30 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_model/railtie"
5
+ require "active_record/railtie"
6
+ require "action_controller/railtie"
7
+ require "action_mailer/railtie"
8
+ require "action_view/railtie"
9
+ require "sprockets/railtie"
10
+ # require "rails/test_unit/railtie"
11
+
12
+ # Require the gems listed in Gemfile, including any gems
13
+ # you've limited to :test, :development, or :production.
14
+ Bundler.require(*Rails.groups)
15
+
16
+ module RailsTestApp
17
+ class Application < Rails::Application
18
+ # Settings in config/environments/* take precedence over those specified here.
19
+ # Application configuration should go into files in config/initializers
20
+ # -- all .rb files in that directory are automatically loaded.
21
+
22
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
23
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
24
+ # config.time_zone = 'Central Time (US & Canada)'
25
+
26
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
27
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
28
+ # config.i18n.default_locale = :de
29
+ end
30
+ end