thaw 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d4814e3220e1643d7b83f32c4fd35065a8e3511a0bb9ffa100c3f6b1aebcff11
4
+ data.tar.gz: 3fcf3cb52b2d554733cc1531bb32900646655574cc8755a5eeae1c9e3e88a2cc
5
+ SHA512:
6
+ metadata.gz: 3a5dc69ae082317ce3bc753604d6eb9dd12e4c8a554e1c1ead27c184a59a5ffbfe751893473add827ae46e22595e01c6770edc83aeca9f098fa409fef7ec5136
7
+ data.tar.gz: e86905d9cfdb9ea54c2a8edbd621a78e846a03779150250b0a2be8329dd720463c95af99383a232cf01e2ec6def12a7f8ba2ff1134485946d8b2cd1930ac7384
@@ -0,0 +1,4 @@
1
+ # Thaw
2
+
3
+ ## 0.1.0 _(December 30, 2019)_
4
+ - Initial Release
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Dale Stevens
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ [![Version ](https://img.shields.io/gem/v/thaw.svg)](https://rubygems.org/gems/thaw)
2
+ [![Build Status ](https://travis-ci.org/TwilightCoders/thaw.svg)](https://travis-ci.org/TwilightCoders/thaw)
3
+ [![Code Climate ](https://api.codeclimate.com/v1/badges/606df1b8c3c69772a11d/maintainability)](https://codeclimate.com/github/TwilightCoders/thaw/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/606df1b8c3c69772a11d/test_coverage)](https://codeclimate.com/github/TwilightCoders/thaw/test_coverage)
5
+
6
+ ## Thaw
7
+
8
+ Flip the frozen bit on ruby objects, to unfreeze (thaw) them.
9
+
10
+ Note: You probably don't need to use this gem, you probably want to [`.dup`](https://www.rubyguides.com/2018/11/dup-vs-clone/) your objects instead.
11
+
12
+ ### Compatibility
13
+
14
+ To-date, `thaw` works in Ruby `2.0` through `2.6`<sup>1</sup>.
15
+
16
+ Check the [build status](https://travis-ci.org/TwilightCoders/thaw) for the most current compatibility.
17
+
18
+ <sup>1</sup>There seems to be a segmentation fault in Ruby `2.7` that I haven't had time to investigate.
19
+
20
+ ### Installation
21
+
22
+ The best way to install is with RubyGems:
23
+
24
+ $ [sudo] gem install thaw
25
+
26
+ Or better still, just add it to your Gemfile:
27
+
28
+ gem 'thaw'
29
+
30
+ ### Example
31
+
32
+ string = "hello"
33
+ string.frozen?
34
+ => false
35
+ string.thawed?
36
+ => true
37
+ string.freeze
38
+ string.frozen?
39
+ => true
40
+ string.thawed?
41
+ => false
42
+ string.thaw
43
+ string.frozen?
44
+ => false
45
+ string.thawed?
46
+ => true
47
+
48
+ ## Development
49
+
50
+ After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rspec` to run the tests.
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/TwilightCoders/active_record-framing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+
56
+ ## Credits
57
+
58
+ Shamelessly ripped from [ndnenkov](https://stackoverflow.com/users/2423164/ndnenkov)'s answer on [StackOverflow](https://stackoverflow.com/questions/35633367/how-to-unfreeze-an-object-in-ruby).
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ require 'fiddle'
2
+
3
+ if ENV['RUBY_ENV'] != 'test' && Gem::Requirement.new('~> 2.7') =~ Gem::Version.new(RUBY_VERSION)
4
+ warn("Object#thaw is not supported by Ruby 2.7+")
5
+ else
6
+ require 'thaw/object'
7
+ end
@@ -0,0 +1,10 @@
1
+ class Object
2
+ def thaw
3
+ Fiddle::Pointer.new(object_id * 2)[1] &= ~(1 << 3)
4
+ self
5
+ end
6
+
7
+ def thawed?
8
+ !frozen?
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Thaw
2
+ VERSION = "0.1.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thaw
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dale Stevens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-30 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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:
42
+ email: dale@twilightcoders.net
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CHANGELOG.md
48
+ - LICENSE
49
+ - README.md
50
+ - lib/thaw.rb
51
+ - lib/thaw/object.rb
52
+ - lib/thaw/version.rb
53
+ homepage: http://github.com/twilightcoders/thaw
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ allowed_push_host: https://rubygems.org
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '2.0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.0.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Unfreeze your objects
77
+ test_files: []