rails_sandbox 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d3ccfc844aa225c59eeff4607fb5b6909788800
4
+ data.tar.gz: 9d4635d5fcaa3a6f79d15c27c9712aded8b516ba
5
+ SHA512:
6
+ metadata.gz: 80480d87127c02eba25eadaf9166d28d99fb2eb0ee87645239c3aeeb7a6bf8033293811afe728c767f4331953ec519eee62ef0b49bf08ddfd63a2cc7720ef3c7
7
+ data.tar.gz: 3cb67b69839e22c08c000c2bed76d86e25357fc212518fcfeb8d6eb907dd389b8ca79b8829244f4ed83d0e9cd53d960224c0842aed8698ff803a5848aaf43a07
@@ -0,0 +1,34 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /public/system
8
+ /coverage/
9
+ /spec/tmp
10
+ /pkg/*
11
+ **.orig
12
+ rerun.txt
13
+ pickle-email-*.html
14
+
15
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
16
+ config/initializers/secret_token.rb
17
+ config/secrets.yml
18
+
19
+ ## Environment normalisation:
20
+ /.bundle
21
+ /vendor/bundle
22
+
23
+ # these should all be checked in to normalise the environment:
24
+ # Gemfile.lock, .ruby-version, .ruby-gemset
25
+
26
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
27
+ .rvmrc
28
+
29
+ # if using bower-rails ignore default bower_components path bower.json files
30
+ /vendor/assets/bower_components
31
+ *.bowerrc
32
+ bower.json
33
+
34
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_sandbox.gemspec
4
+ gemspec
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_sandbox (0.0.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (4.1.6)
10
+ activesupport (= 4.1.6)
11
+ builder (~> 3.1)
12
+ activerecord (4.1.6)
13
+ activemodel (= 4.1.6)
14
+ activesupport (= 4.1.6)
15
+ arel (~> 5.0.0)
16
+ activesupport (4.1.6)
17
+ i18n (~> 0.6, >= 0.6.9)
18
+ json (~> 1.7, >= 1.7.7)
19
+ minitest (~> 5.1)
20
+ thread_safe (~> 0.1)
21
+ tzinfo (~> 1.1)
22
+ arel (5.0.1.20140414130214)
23
+ builder (3.2.2)
24
+ i18n (0.6.11)
25
+ json (1.8.1)
26
+ minitest (5.4.2)
27
+ rake (10.3.2)
28
+ thread_safe (0.3.4)
29
+ tzinfo (1.2.2)
30
+ thread_safe (~> 0.1)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ activerecord
37
+ bundler (~> 1.7)
38
+ rails_sandbox!
39
+ rake (~> 10.0)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Shou Ya
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.
22
+
@@ -0,0 +1,55 @@
1
+ [![Gem Version](https://badge.fury.io/rb/rails_sandbox.png)](https://rubygems.org/gems/rails_sandbox)
2
+
3
+ # RailsSandbox
4
+
5
+
6
+ a tiny gem that provides a protective sandbox for database transactions.
7
+
8
+ this gem is based on the magic of `ActiveRecord::Base#transaction`.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rails_sandbox'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install rails_sandbox
25
+
26
+ ## Usage Example
27
+
28
+ in your model:
29
+
30
+ ```ruby
31
+ # app/models/my_model.rb
32
+
33
+ require 'rails_sandbox'
34
+
35
+ class MyModel
36
+ def json_with_updated_attributes(params)
37
+ # the json result with updated attributes will be returned while the actual
38
+ # record keeps unchanged
39
+ ActiveRecord::Base.sandbox do
40
+ self.update_attributes(params)
41
+ self.to_json
42
+ end
43
+ end
44
+
45
+ end
46
+ ```
47
+
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/[my-github-username]/rails_sandbox/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,14 @@
1
+ require 'active_record'
2
+
3
+ require 'rails_sandbox/version'
4
+
5
+ class ActiveRecord::Base
6
+ def self.sandbox
7
+ result = nil
8
+ self.transaction do
9
+ result = yield if block_given?
10
+ raise ActiveRecord::Rollback
11
+ end
12
+ result
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module RailsSandbox
3
+ VERSION = "0.0.3"
4
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_sandbox/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_sandbox"
8
+ spec.version = RailsSandbox::VERSION
9
+ spec.authors = ["Shou Ya"]
10
+ spec.email = ["shouyatf@gmail.com"]
11
+ spec.summary = %q{set up a protective sandbox for database transactions}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/shouya/rails_sandbox"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "activerecord"
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_sandbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Shou Ya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord
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: set up a protective sandbox for database transactions
56
+ email:
57
+ - shouyatf@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - lib/rails_sandbox.rb
69
+ - lib/rails_sandbox/version.rb
70
+ - rails_sandbox.gemspec
71
+ homepage: https://github.com/shouya/rails_sandbox
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: set up a protective sandbox for database transactions
95
+ test_files: []