destroyall 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dc0d98610c2099826252a182582718770ed222df
4
+ data.tar.gz: 240cd1c8337b39f5545f25b5d61a617a5364b77a
5
+ SHA512:
6
+ metadata.gz: eb7ae60ae3502501a13307f63de93669c59477ed8c0a12ae9e7480f6187ce05e212fd6a60f24d55fba52c90e46a47422a142415980ea7cf09017d630392b81e4
7
+ data.tar.gz: 3f7ca6ac6944a66a181d40a08f79b21b4031926e429ba2ababa991780504d2931fb20682b28aec645ff122a924d449cd4abd86ec745aec385a7221f25e3fb7c8
@@ -0,0 +1,23 @@
1
+ # Ignore bundler config.
2
+ /.bundle
3
+
4
+ # Ignore the default SQLite database.
5
+ /db/*.sqlite3
6
+ /db/*.sqlite3-journal
7
+
8
+ # Ignore all logfiles and tempfiles.
9
+ /log/*.log
10
+ /tmp
11
+
12
+ # Ignore other unneeded files.
13
+ database.yml
14
+ doc/
15
+ test/
16
+ *.swp
17
+ *~
18
+ .project
19
+ .DS_Store
20
+ .idea
21
+ .rvmrc
22
+ .ruby-*
23
+ .secret
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in destroyall.gemspec
4
+ gemspec
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ destroyall (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.3.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.5)
16
+ destroyall!
17
+ rake
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Proalab
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,60 @@
1
+ # Destroyall GEM
2
+ Created by [Alexandr Basan]()
3
+ - (www.proalab.com)
4
+
5
+ TODO: Simple gem for quick add destroy all method for all models.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'destroyall'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install destroyall
20
+
21
+ ## Usage
22
+
23
+ TODO: Simple gem for quick add destroy all method for all models. This gem add simple method destroyall for all models for quick destroy all records in table.
24
+ This gem using Ruby method destroy_all:
25
+
26
+ $ Person.destroy_all("last_login < '2004-04-04'")
27
+ $ Person.destroy_all(:status => "inactive")
28
+
29
+ Gem have 2 methods:
30
+
31
+ $ destroy_all(model)
32
+ $ destroy_all_with_conditions(model, conditions, conditions_value)
33
+
34
+ Using destroy_all method you can set Model name as argument model.
35
+ Using destroy_all_with_conditions method you can set Model name as argument model, condition as condition (this argument auto convert to Symbol) and conditional_value as String value for conditions.
36
+ Example:
37
+
38
+ $ destroy_all(user)
39
+ $ destroy_all_with_conditions(user, status, inactive)
40
+
41
+ In first method gem destroy all records in table Users
42
+ In second method gem destroy all records in table Users where user status = inactive
43
+
44
+ Also you maybe need to create form for delete all records in your model
45
+
46
+ <%= form_for(destroy_all(model), :html => {:method => 'delete'}) do |f| %>
47
+ <%= f.submit "Delete" %>
48
+ <% end %>
49
+
50
+ If you need more information about methods using for gem work, please see rubydoc
51
+
52
+ $ http://apidock.com/rails/ActiveRecord/Base/destroy_all/class
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it ( http://github.com/<my-github-username>/destroyall/fork )
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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 'destroyall/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "destroyall"
8
+ spec.version = Destroyall::VERSION
9
+ spec.authors = ["Alexandr Basan"]
10
+ spec.email = ["alexandr.basan@gmail.com"]
11
+ spec.summary = %q{Simple gem for quick add destroy all method for all models.}
12
+ spec.description = %q{Simple gem for quick add destroy all method for all models. This gem add simple method destroyall for all models for quick destroy all records in table.}
13
+ spec.homepage = "https://github.com/Proalab/gem_destroy_all"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = '~> 1.0'
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,17 @@
1
+ require "destroyall/version"
2
+
3
+ module Destroyall
4
+ def self.destroy_all(model)
5
+ if model.nil?
6
+ else
7
+ model.delete_all
8
+ end
9
+ end
10
+ def self.destroy_all_with_conditions(model, conditions, conditions_value)
11
+ if model.nil? || conditions.nil? || conditions_value.nil?
12
+ else
13
+ conditions_sym = conditions.parameterize.underscore.to_sym
14
+ model.delete_all(conditions_sym => "#{conditions_value}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Destroyall
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: destroyall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexandr Basan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-24 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Simple gem for quick add destroy all method for all models. This gem
42
+ add simple method destroyall for all models for quick destroy all records in table.
43
+ email:
44
+ - alexandr.basan@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - destroyall.gemspec
56
+ - lib/destroyall.rb
57
+ - lib/destroyall/version.rb
58
+ homepage: https://github.com/Proalab/gem_destroy_all
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Simple gem for quick add destroy all method for all models.
82
+ test_files: []