sandboxy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +14 -0
  3. data/.github/pull_request_template.md +21 -0
  4. data/.gitignore +8 -0
  5. data/.travis.yml +3 -0
  6. data/CHANGELOG.md +5 -0
  7. data/CODE_OF_CONDUCT.md +46 -0
  8. data/CONTRIBUTING.md +1 -0
  9. data/DEPRECATIONS.md +3 -0
  10. data/Gemfile +9 -0
  11. data/INSTALL.md +3 -0
  12. data/LICENSE +21 -0
  13. data/README.md +175 -0
  14. data/Rakefile +16 -0
  15. data/examples/rails_example/.gitignore +23 -0
  16. data/examples/rails_example/Gemfile +53 -0
  17. data/examples/rails_example/README.md +24 -0
  18. data/examples/rails_example/Rakefile +6 -0
  19. data/examples/rails_example/app/assets/config/manifest.js +3 -0
  20. data/examples/rails_example/app/assets/images/.keep +0 -0
  21. data/examples/rails_example/app/assets/javascripts/application.js +15 -0
  22. data/examples/rails_example/app/assets/javascripts/bars.coffee +3 -0
  23. data/examples/rails_example/app/assets/javascripts/cable.js +13 -0
  24. data/examples/rails_example/app/assets/javascripts/channels/.keep +0 -0
  25. data/examples/rails_example/app/assets/javascripts/foos.coffee +3 -0
  26. data/examples/rails_example/app/assets/stylesheets/application.css +15 -0
  27. data/examples/rails_example/app/assets/stylesheets/bars.scss +3 -0
  28. data/examples/rails_example/app/assets/stylesheets/foos.scss +3 -0
  29. data/examples/rails_example/app/assets/stylesheets/scaffolds.scss +84 -0
  30. data/examples/rails_example/app/channels/application_cable/channel.rb +4 -0
  31. data/examples/rails_example/app/channels/application_cable/connection.rb +4 -0
  32. data/examples/rails_example/app/controllers/application_controller.rb +3 -0
  33. data/examples/rails_example/app/controllers/bars_controller.rb +74 -0
  34. data/examples/rails_example/app/controllers/concerns/.keep +0 -0
  35. data/examples/rails_example/app/controllers/foos_controller.rb +74 -0
  36. data/examples/rails_example/app/helpers/application_helper.rb +2 -0
  37. data/examples/rails_example/app/helpers/bars_helper.rb +2 -0
  38. data/examples/rails_example/app/helpers/foos_helper.rb +2 -0
  39. data/examples/rails_example/app/jobs/application_job.rb +2 -0
  40. data/examples/rails_example/app/mailers/application_mailer.rb +4 -0
  41. data/examples/rails_example/app/models/application_record.rb +3 -0
  42. data/examples/rails_example/app/models/bar.rb +2 -0
  43. data/examples/rails_example/app/models/concerns/.keep +0 -0
  44. data/examples/rails_example/app/models/foo.rb +2 -0
  45. data/examples/rails_example/app/models/sandbox.rb +7 -0
  46. data/examples/rails_example/app/models/shared_sandbox.rb +3 -0
  47. data/examples/rails_example/app/views/bars/_bar.json.jbuilder +2 -0
  48. data/examples/rails_example/app/views/bars/_form.html.erb +17 -0
  49. data/examples/rails_example/app/views/bars/edit.html.erb +6 -0
  50. data/examples/rails_example/app/views/bars/index.html.erb +25 -0
  51. data/examples/rails_example/app/views/bars/index.json.jbuilder +1 -0
  52. data/examples/rails_example/app/views/bars/new.html.erb +5 -0
  53. data/examples/rails_example/app/views/bars/show.html.erb +4 -0
  54. data/examples/rails_example/app/views/bars/show.json.jbuilder +1 -0
  55. data/examples/rails_example/app/views/foos/_foo.json.jbuilder +2 -0
  56. data/examples/rails_example/app/views/foos/_form.html.erb +17 -0
  57. data/examples/rails_example/app/views/foos/edit.html.erb +6 -0
  58. data/examples/rails_example/app/views/foos/index.html.erb +25 -0
  59. data/examples/rails_example/app/views/foos/index.json.jbuilder +1 -0
  60. data/examples/rails_example/app/views/foos/new.html.erb +5 -0
  61. data/examples/rails_example/app/views/foos/show.html.erb +4 -0
  62. data/examples/rails_example/app/views/foos/show.json.jbuilder +1 -0
  63. data/examples/rails_example/app/views/layouts/application.html.erb +14 -0
  64. data/examples/rails_example/app/views/layouts/mailer.html.erb +13 -0
  65. data/examples/rails_example/app/views/layouts/mailer.text.erb +1 -0
  66. data/examples/rails_example/bin/bundle +3 -0
  67. data/examples/rails_example/bin/rails +4 -0
  68. data/examples/rails_example/bin/rake +4 -0
  69. data/examples/rails_example/bin/setup +38 -0
  70. data/examples/rails_example/bin/update +29 -0
  71. data/examples/rails_example/bin/yarn +11 -0
  72. data/examples/rails_example/config/application.rb +18 -0
  73. data/examples/rails_example/config/boot.rb +3 -0
  74. data/examples/rails_example/config/cable.yml +10 -0
  75. data/examples/rails_example/config/database.yml +25 -0
  76. data/examples/rails_example/config/environment.rb +5 -0
  77. data/examples/rails_example/config/environments/development.rb +54 -0
  78. data/examples/rails_example/config/environments/production.rb +91 -0
  79. data/examples/rails_example/config/environments/test.rb +42 -0
  80. data/examples/rails_example/config/initializers/application_controller_renderer.rb +6 -0
  81. data/examples/rails_example/config/initializers/assets.rb +14 -0
  82. data/examples/rails_example/config/initializers/backtrace_silencers.rb +7 -0
  83. data/examples/rails_example/config/initializers/cookies_serializer.rb +5 -0
  84. data/examples/rails_example/config/initializers/filter_parameter_logging.rb +4 -0
  85. data/examples/rails_example/config/initializers/inflections.rb +16 -0
  86. data/examples/rails_example/config/initializers/mime_types.rb +4 -0
  87. data/examples/rails_example/config/initializers/sandboxy.rb +7 -0
  88. data/examples/rails_example/config/initializers/wrap_parameters.rb +14 -0
  89. data/examples/rails_example/config/locales/en.yml +33 -0
  90. data/examples/rails_example/config/puma.rb +56 -0
  91. data/examples/rails_example/config/routes.rb +5 -0
  92. data/examples/rails_example/config/secrets.yml +32 -0
  93. data/examples/rails_example/config.ru +5 -0
  94. data/examples/rails_example/db/migrate/20170826222427_sandboxy_migration.rb +14 -0
  95. data/examples/rails_example/db/migrate/20170826223227_create_foos.rb +8 -0
  96. data/examples/rails_example/db/migrate/20170826223243_create_bars.rb +8 -0
  97. data/examples/rails_example/db/schema.rb +24 -0
  98. data/examples/rails_example/db/seeds.rb +7 -0
  99. data/examples/rails_example/lib/assets/.keep +0 -0
  100. data/examples/rails_example/lib/tasks/.keep +0 -0
  101. data/examples/rails_example/package.json +5 -0
  102. data/examples/rails_example/public/404.html +67 -0
  103. data/examples/rails_example/public/422.html +67 -0
  104. data/examples/rails_example/public/500.html +66 -0
  105. data/examples/rails_example/public/apple-touch-icon-precomposed.png +0 -0
  106. data/examples/rails_example/public/apple-touch-icon.png +0 -0
  107. data/examples/rails_example/public/favicon.ico +0 -0
  108. data/examples/rails_example/public/robots.txt +1 -0
  109. data/examples/rails_example/test/application_system_test_case.rb +5 -0
  110. data/examples/rails_example/test/controllers/.keep +0 -0
  111. data/examples/rails_example/test/controllers/bars_controller_test.rb +48 -0
  112. data/examples/rails_example/test/controllers/foos_controller_test.rb +48 -0
  113. data/examples/rails_example/test/fixtures/.keep +0 -0
  114. data/examples/rails_example/test/fixtures/bars.yml +11 -0
  115. data/examples/rails_example/test/fixtures/files/.keep +0 -0
  116. data/examples/rails_example/test/fixtures/foos.yml +11 -0
  117. data/examples/rails_example/test/helpers/.keep +0 -0
  118. data/examples/rails_example/test/integration/.keep +0 -0
  119. data/examples/rails_example/test/mailers/.keep +0 -0
  120. data/examples/rails_example/test/models/.keep +0 -0
  121. data/examples/rails_example/test/models/bar_test.rb +7 -0
  122. data/examples/rails_example/test/models/foo_test.rb +7 -0
  123. data/examples/rails_example/test/system/.keep +0 -0
  124. data/examples/rails_example/test/system/bars_test.rb +9 -0
  125. data/examples/rails_example/test/system/foos_test.rb +9 -0
  126. data/examples/rails_example/test/test_helper.rb +9 -0
  127. data/examples/rails_example/tmp/.keep +0 -0
  128. data/examples/rails_example/vendor/.keep +0 -0
  129. data/init.rb +1 -0
  130. data/lib/generators/sandboxy_generator.rb +44 -0
  131. data/lib/generators/templates/README.md +1 -0
  132. data/lib/generators/templates/initializer.rb.erb +7 -0
  133. data/lib/generators/templates/migration.rb.erb +14 -0
  134. data/lib/generators/templates/model.rb +7 -0
  135. data/lib/sandboxy/railtie.rb +15 -0
  136. data/lib/sandboxy/sandboxed.rb +52 -0
  137. data/lib/sandboxy/version.rb +5 -0
  138. data/lib/sandboxy.rb +10 -0
  139. data/sandboxy.gemspec +30 -0
  140. data/test/dummy30/Gemfile +1 -0
  141. data/test/dummy30/Rakefile +4 -0
  142. data/test/dummy30/app/models/application_record.rb +3 -0
  143. data/test/dummy30/app/models/shared_sandbox.rb +4 -0
  144. data/test/dummy30/app/models/some.rb +3 -0
  145. data/test/dummy30/app/models/user.rb +3 -0
  146. data/test/dummy30/config/application.rb +14 -0
  147. data/test/dummy30/config/boot.rb +10 -0
  148. data/test/dummy30/config/database.yml +6 -0
  149. data/test/dummy30/config/environment.rb +5 -0
  150. data/test/dummy30/config/environments/development.rb +7 -0
  151. data/test/dummy30/config/environments/test.rb +6 -0
  152. data/test/dummy30/config/initializers/sandboxy.rb +1 -0
  153. data/test/dummy30/config/initializers/secret_token.rb +1 -0
  154. data/test/dummy30/config/initializers/session_store.rb +1 -0
  155. data/test/dummy30/config/locales/en.yml +2 -0
  156. data/test/dummy30/config/routes.rb +2 -0
  157. data/test/dummy30/config.ru +2 -0
  158. data/test/factories/somes.rb +17 -0
  159. data/test/factories/users.rb +5 -0
  160. data/test/sandbox_test.rb +41 -0
  161. data/test/sandboxed_test.rb +58 -0
  162. data/test/schema.rb +18 -0
  163. data/test/test_helper.rb +22 -0
  164. metadata +307 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44501426bdcd615cc069e3327bbd6e37cc7f1496
4
+ data.tar.gz: dee2033f5deddb78dd4130b7d17f90e91f263cc0
5
+ SHA512:
6
+ metadata.gz: '071468637354c1ce9e6801f56bc8078ce8d7c7f09ac744e1a85469282c542c727302d68611a500ada44c57ef39fa0e47b077a816febf626c5441d45784147c68'
7
+ data.tar.gz: '080dc870bcf6be859c2b1e8fd238281997af4a0298ec35192f25de5b70cdbb21159009ac59ed0893f6276fe49d32f56fffca47d06d29d9a69cf0240199351e97'
@@ -0,0 +1,14 @@
1
+ ### Expected behavior
2
+ Tell us what should happen
3
+
4
+ ### Actual behavior
5
+ Tell us what happens instead
6
+
7
+ ### Steps to reproduce
8
+ Show a way to reproduce
9
+
10
+ ### System configuration
11
+
12
+ **Ruby version**:
13
+
14
+ **Rails version**:
@@ -0,0 +1,21 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request... were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+ ### Other Information
9
+
10
+ If there's anything else that's important and relevant to your pull
11
+ request, mention that information here. This could include
12
+ benchmarks, or other information.
13
+
14
+ If you are updating any of the CHANGELOG files or are asked to update the
15
+ CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.
16
+
17
+ Finally, if your pull request affects documentation or any non-code
18
+ changes, guidelines for those changes are [available
19
+ here](https://github.com/slooob/sandboxy/blob/master/CONTRIBUTING.md)
20
+
21
+ Thanks for contributing to `sandboxy`!
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ test/debug.log
2
+ coverage
3
+ rdoc
4
+ memory
5
+ *.gem
6
+ .rvmrc
7
+ Gemfile.lock
8
+ log
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ### master
4
+
5
+ * nothing yet
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at help@slooob.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1 @@
1
+ # Contributing
data/DEPRECATIONS.md ADDED
@@ -0,0 +1,3 @@
1
+ # Deprecations
2
+
3
+ No deprecations
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+
6
+ gem 'activesupport', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
7
+
8
+ # # Test Coverage
9
+ # gem 'simplecov', require: false, group: :test
data/INSTALL.md ADDED
@@ -0,0 +1,3 @@
1
+ **Thank you for installing sandboxy!**
2
+ Get started by running `rails g sandboxy`.
3
+ Learn more at https://github.com/slooob/sandboxy.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Slooob
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # Sandboxy - virtual data-oriented environments for Rails
2
+
3
+ <img src="https://travis-ci.org/slooob/sandboxy.svg?branch=master" /> [![Gem Version](https://badge.fury.io/rb/sandboxy.svg)](https://badge.fury.io/rb/sandboxy)
4
+
5
+ Sandboxy allows you to use two virtual data-oriented environments inside a Rails application with ActiveRecord while being able to switch in between at runtime.
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ * [Installation](#installation)
12
+ * [Usage](#usage)
13
+ * [Setup](#setup)
14
+ * [Sandboxed methods](#sandboxed-methods)
15
+ * [Switching environments](#switching-environments)
16
+ * [Sandbox & APIs](#sandbox--apis)
17
+ * [To Do](#to-do)
18
+ * [Contributing](#contributing)
19
+ * [Contributors](#contributors)
20
+ * [License](#license)
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ Sandboxy works with Rails 4.0 onwards. You can add it to your `Gemfile` with:
27
+
28
+ ```ruby
29
+ gem 'sandboxy'
30
+ ```
31
+
32
+ And then execute:
33
+
34
+ $ bundle
35
+
36
+ Or install it yourself as:
37
+
38
+ $ gem install sandboxy
39
+
40
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
41
+
42
+ ```ruby
43
+ gem 'sandboxy', github: 'slooob/sandboxy'
44
+ ```
45
+
46
+ Now run the generator:
47
+
48
+ $ rails g sandboxy
49
+
50
+ You can specify that your application should use the sandbox by default by passing `--default true`. Learn more about switching environments [here](#switching-environments).
51
+
52
+ To wrap things up, migrate the changes into your database:
53
+
54
+ $ rails db:migrate
55
+
56
+ **Note:** Use `rake db:migrate` instead if you run Rails < 5.
57
+
58
+ This will create an initializer as well as a migration file and the `Sandbox` model.
59
+
60
+ ## Usage
61
+
62
+ ### Setup
63
+
64
+ Add Sandboxy to the models where you want to separate live & sandbox reocrds:
65
+
66
+ ```ruby
67
+ class Foo < ApplicationRecord
68
+ sandboxy
69
+ end
70
+ ```
71
+
72
+ In most use cases you would want to add sandboxy to a lot of ActiveRecord models if not all. To simplify that you could create a new class and let all your models inherit from it:
73
+
74
+ ```ruby
75
+ class Sandboxy < ApplicationRecord
76
+ sandboxy
77
+ end
78
+
79
+ class Foo < Sandboxy
80
+ end
81
+ ```
82
+
83
+ ### Sandboxed methods
84
+
85
+ By default you can only access records belonging to the current environment (`live` or `sandbox`):
86
+
87
+ ```ruby
88
+ $sandbox = true
89
+ Foo.all # => returns all sandbox foo's
90
+ ```
91
+
92
+ Now to access the records belonging to a certain group regardless of your current environment, you can use:
93
+
94
+ ```ruby
95
+ Foo.live # => returns all live foo's
96
+ Foo.sandboxed # => returns all sandbox foo's
97
+ Foo.desandbox # => returns all foo's
98
+ ```
99
+
100
+ Let's check to which environment this `Foo` belongs:
101
+
102
+ ```ruby
103
+ foo = Foo.create!
104
+ foo.live? # => false
105
+ foo.sandboxed? # => true
106
+ ```
107
+
108
+ You should keep in mind that when you create a new record, it will automatically belong to your app's current environment.
109
+
110
+ Don't worry, you can move records between environments:
111
+
112
+ ```ruby
113
+ foo.make_live
114
+ foo.live? # => true
115
+ foo.make_sandboxed
116
+ foo.sandboxed? # => true
117
+ ```
118
+
119
+ ### Switching environments
120
+
121
+ In `config/initializers/sandboxy.rb` you define your app's default environment by setting the `$sandbox` variable.
122
+
123
+ You can override that variable anywhere in your application. That makes Sandboxy super flexible.
124
+
125
+ #### Sandbox & APIs
126
+
127
+ It's flexibility allows Sandboxy to work really well with APIs.
128
+
129
+ Typically an API provides two sets of authentication credentials for a consumer - one for live access and one for sandbox/testing.
130
+
131
+ Whenever you authenticate your API's consumer, just make sure to set the `$sandbox` variable accordingly to the credential the consumer used. From thereon, Sandboxy will make sure that your consumer only reads & updates data from the environment he is in.
132
+
133
+ ---
134
+
135
+ ## To Do
136
+
137
+ * Leave your suggestions [here](https://github.com/slooob/sandboxy/issues/new)
138
+
139
+ ---
140
+
141
+ ## Contributing
142
+
143
+ We hope that you will consider contributing to Sandboxy. Please read this short overview for some information about how to get started:
144
+
145
+ [Learn more about contributing to this repository](https://github.com/slooob/sandboxy/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/slooob/sandboxy/blob/master/CODE_OF_CONDUCT.md)
146
+
147
+ ### Contributors
148
+
149
+ Give the people some :heart: who are working on this project. See them all at:
150
+
151
+ https://github.com/slooob/sandboxy/graphs/contributors
152
+
153
+ ## License
154
+
155
+ MIT License
156
+
157
+ Copyright (c) 2017 Slooob
158
+
159
+ Permission is hereby granted, free of charge, to any person obtaining a copy
160
+ of this software and associated documentation files (the "Software"), to deal
161
+ in the Software without restriction, including without limitation the rights
162
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
163
+ copies of the Software, and to permit persons to whom the Software is
164
+ furnished to do so, subject to the following conditions:
165
+
166
+ The above copyright notice and this permission notice shall be included in all
167
+ copies or substantial portions of the Software.
168
+
169
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
170
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
171
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
172
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
173
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
174
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
175
+ SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rdoc/task'
7
+
8
+ desc 'Default: run unit tests.'
9
+ task default: :test
10
+
11
+ desc 'Test sandboxy gem.'
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'lib'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = true
16
+ end
@@ -0,0 +1,23 @@
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/*
16
+ /tmp/*
17
+ !/log/.keep
18
+ !/tmp/.keep
19
+
20
+ /node_modules
21
+ /yarn-error.log
22
+
23
+ .byebug_history
@@ -0,0 +1,53 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+
9
+ gem 'sandboxy'
10
+
11
+
12
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
13
+ gem 'rails', '~> 5.1.3'
14
+ # Use sqlite3 as the database for Active Record
15
+ gem 'sqlite3'
16
+ # Use Puma as the app server
17
+ gem 'puma', '~> 3.7'
18
+ # Use SCSS for stylesheets
19
+ gem 'sass-rails', '~> 5.0'
20
+ # Use Uglifier as compressor for JavaScript assets
21
+ gem 'uglifier', '>= 1.3.0'
22
+ # See https://github.com/rails/execjs#readme for more supported runtimes
23
+ # gem 'therubyracer', platforms: :ruby
24
+
25
+ # Use CoffeeScript for .coffee assets and views
26
+ gem 'coffee-rails', '~> 4.2'
27
+ # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
28
+ gem 'turbolinks', '~> 5'
29
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
30
+ gem 'jbuilder', '~> 2.5'
31
+ # Use Redis adapter to run Action Cable in production
32
+ # gem 'redis', '~> 3.0'
33
+ # Use ActiveModel has_secure_password
34
+ # gem 'bcrypt', '~> 3.1.7'
35
+
36
+ # Use Capistrano for deployment
37
+ # gem 'capistrano-rails', group: :development
38
+
39
+ group :development, :test do
40
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
41
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
42
+ # Adds support for Capybara system testing and selenium driver
43
+ gem 'capybara', '~> 2.13'
44
+ gem 'selenium-webdriver'
45
+ end
46
+
47
+ group :development do
48
+ # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
49
+ gem 'web-console', '>= 3.3.0'
50
+ end
51
+
52
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
53
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
@@ -0,0 +1,24 @@
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
+ * ...
@@ -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_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,15 @@
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, or any plugin's
5
+ // vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require turbolinks
15
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -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, or any plugin's
6
+ * vendor/assets/stylesheets directory 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 other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the bars controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the foos controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,84 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ margin: 33px;
5
+ font-family: verdana, arial, helvetica, sans-serif;
6
+ font-size: 13px;
7
+ line-height: 18px;
8
+ }
9
+
10
+ p, ol, ul, td {
11
+ font-family: verdana, arial, helvetica, sans-serif;
12
+ font-size: 13px;
13
+ line-height: 18px;
14
+ }
15
+
16
+ pre {
17
+ background-color: #eee;
18
+ padding: 10px;
19
+ font-size: 11px;
20
+ }
21
+
22
+ a {
23
+ color: #000;
24
+
25
+ &:visited {
26
+ color: #666;
27
+ }
28
+
29
+ &:hover {
30
+ color: #fff;
31
+ background-color: #000;
32
+ }
33
+ }
34
+
35
+ th {
36
+ padding-bottom: 5px;
37
+ }
38
+
39
+ td {
40
+ padding: 0 5px 7px;
41
+ }
42
+
43
+ div {
44
+ &.field, &.actions {
45
+ margin-bottom: 10px;
46
+ }
47
+ }
48
+
49
+ #notice {
50
+ color: green;
51
+ }
52
+
53
+ .field_with_errors {
54
+ padding: 2px;
55
+ background-color: red;
56
+ display: table;
57
+ }
58
+
59
+ #error_explanation {
60
+ width: 450px;
61
+ border: 2px solid red;
62
+ padding: 7px 7px 0;
63
+ margin-bottom: 20px;
64
+ background-color: #f0f0f0;
65
+
66
+ h2 {
67
+ text-align: left;
68
+ font-weight: bold;
69
+ padding: 5px 5px 5px 15px;
70
+ font-size: 12px;
71
+ margin: -7px -7px 0;
72
+ background-color: #c00;
73
+ color: #fff;
74
+ }
75
+
76
+ ul li {
77
+ font-size: 12px;
78
+ list-style: square;
79
+ }
80
+ }
81
+
82
+ label {
83
+ display: block;
84
+ }
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end