fuck_off 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8649ab8a8f56f1e2818c73694a629c81c8a915beea08a3180115b866beba0eb8
4
- data.tar.gz: 17025b87eac26345c7b30d1c1a0bef23553d3d0c78350629b66a3863c7bbeac5
3
+ metadata.gz: 6a67207419febceae48c360ec1b4238cfd0dfebe73cdec3f900edd7bcd64dceb
4
+ data.tar.gz: 7f828dabfe4af21804686614ab5d6b40e16c5c78c8c69411479790dfb55d9ff0
5
5
  SHA512:
6
- metadata.gz: 050c129e67b8c61cfc09949f7ef57ae8242acaab5aabca7757c3cc567916154406a41489f3bbabbabb48c991ebef5b75f449b0ec43855af083aed32b675799a6
7
- data.tar.gz: 5a08591539f3067a680ab3e62cabc54d4ddbcb08c324983aaecffcdc0c483cb8613f71c0b581d2ce6bd5fd1c51e98edf484f1d3eeb2d6cd9c39736279e324c04
6
+ metadata.gz: bf7026868c4f279df6d2503368de40888986607390c059054073aefdf8d032ce91e8f6105fbd61b93e4ea1a43bcbc016f91c8e422738adf1958204b2dfe898f4
7
+ data.tar.gz: b814c7b794811f180ed73229ded453b710b0363c979ab94c599b4eff87738a34f6bb1f70d4b70510e2c35d9c8beace275a3541898dd16c7a45350320b113154f
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # FuckOff
1
+ To prevent use of your private API, this gem allow you to mark methods as being `fucking_private` and/or `fucking_final`.
2
+
2
3
  ```ruby
3
4
  class Example
4
5
  include FuckOff
@@ -11,45 +12,22 @@ class Example
11
12
  "Bar"
12
13
  end
13
14
  end
14
-
15
- Example.new.send(:foo) # raises a FuckOff::NoMethodError
16
- Example.define_method(:bar) { "New bar" } # raises a FuckOff::NameError
17
15
  ```
18
16
 
19
- ## Installation
20
-
21
- Add this line to your application's Gemfile:
17
+ If you try to call a `fucking_private` method anyway, it will raise a `NoMethodError`.
22
18
 
23
19
  ```ruby
24
- gem 'fuck_off'
20
+ Example.new.send(:foo) # raises a FuckOff::NoMethodError
25
21
  ```
26
22
 
27
- And then execute:
28
-
29
- $ bundle install
30
-
31
- Or install it yourself as:
32
-
33
- $ gem install fuck_off
34
-
35
- ## Usage
23
+ If you try to redefine a `fucking_final` method, it will raise a `NameError`.
36
24
 
37
- TODO: Write usage instructions here
38
-
39
- ## Development
40
-
41
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
-
43
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
-
45
- ## Contributing
46
-
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fuck_off. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/fuck_off/blob/master/CODE_OF_CONDUCT.md).
48
-
49
- ## License
25
+ ```ruby
26
+ Example.define_method(:bar) { "New bar" } # raises a FuckOff::NameError
27
+ ```
50
28
 
51
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
29
+ Yes, this is a joke. But it also kind of [works](https://github.com/joeldrapper/fuck_off/blob/main/test/fuck_off_test.rb).
52
30
 
53
- ## Code of Conduct
31
+ ## Prior art
54
32
 
55
- Everyone interacting in the FuckOff project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fuck_off/blob/master/CODE_OF_CONDUCT.md).
33
+ [I told you it was private](https://github.com/fxn/i-told-you-it-was-private)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FuckOff
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/fuck_off.rb CHANGED
@@ -11,11 +11,23 @@ module FuckOff
11
11
  def fucking_private_methods
12
12
  if defined? @fucking_private_methods
13
13
  @fucking_private_methods
14
+ elsif superclass.respond_to? :fucking_private_methods
15
+ @fucking_private_methods = superclass.fucking_private_methods
14
16
  else
15
17
  @fucking_private_methods = {}
16
18
  end
17
19
  end
18
20
 
21
+ def fucking_final_methods
22
+ if defined? @fucking_final_methods
23
+ @fucking_final_methods
24
+ elsif superclass.respond_to? :fucking_final_methods
25
+ @fucking_final_methods = superclass.fucking_final_methods
26
+ else
27
+ @fucking_final_methods = {}
28
+ end
29
+ end
30
+
19
31
  def fucking_private(method_name)
20
32
  fucking_private_methods[method_name] = true
21
33
  private method_name
@@ -23,13 +35,13 @@ module FuckOff
23
35
  end
24
36
 
25
37
  def fucking_final(method_name)
26
- (@@fucking_final_methods ||= {})[method_name] = true
38
+ fucking_final_methods[method_name] = true
27
39
  method_name
28
40
  end
29
41
 
30
42
  def method_added(method_name)
31
- if (@@fucking_final_methods ||= {})[method_name]
32
- raise FuckOff::NameError, "Fuck you"
43
+ if fucking_final_methods[method_name]
44
+ raise FuckOff::NameError, "Fuck you!"
33
45
  else
34
46
  super
35
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuck_off
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper