nilify 0.0.6

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: 2464a11209f5b634ed9d3ad40e4f9e58d5f001f6
4
+ data.tar.gz: 650a71e4bffa4db1484cf28c51c71aec559518d1
5
+ SHA512:
6
+ metadata.gz: 032969bde5f952a394aa5f3f611584a1bda118cf090f2cb77177d2e2fdaf2ac1fdbcfad375b13d64d3149cbedf4c42f83a88fd51a6ab09f44424ff8c101dd04a
7
+ data.tar.gz: 7cdbfea987c27c9cf6affd035c18c0ca4c2872618b31cc4f30a19ee6b5a73967cd9e69aee29f2c45e0e83022f5ad227e86f0ed488dbe2eddd82b4380c603371f
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rubixware
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,89 @@
1
+ # Nilify
2
+ [![Gem Version](https://badge.fury.io/rb/nilify.svg)](http://badge.fury.io/rb/nilify)
3
+ [![CodeClimate](https://codeclimate.com/github/rubixware/nilify/badges/gpa.svg)](https://codeclimate.com/github/rubixware/nilify)
4
+
5
+
6
+ A gem for null object pattern easy implementation on Ruby objects.
7
+
8
+ ## Getting started
9
+
10
+ Nilify works with Ruby 1.9.3 onwards. Install this gem with:
11
+
12
+ ```ruby
13
+ gem install 'nilify'
14
+ ```
15
+
16
+ ##Example
17
+
18
+ Let's check an example for the next Item class.
19
+
20
+ ```ruby
21
+ class Item
22
+ attr_accessor :sku, :title
23
+ end
24
+ ```
25
+
26
+ To create a class with mock methods there are two options:
27
+
28
+ ```ruby
29
+ # Option 1
30
+ # on the nil class specify the methods to mock
31
+ class NilItem
32
+ extend Nilify
33
+ nilify [:sku, :title]
34
+ end
35
+
36
+ # Option 2
37
+ # Pass the Item class to mock all the defined methods inside that class.
38
+ class NilItem
39
+ extend Nilify
40
+ nilify_from Item
41
+ end
42
+ ```
43
+
44
+ Then you can use the mocked methods like this:
45
+
46
+ ```ruby
47
+ > item = Item.new
48
+ > item.id
49
+ => nil
50
+ > item = NilItem.new
51
+ > item.id
52
+ => "id is a mock method"
53
+ ```
54
+
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
63
+
64
+ ### Devs
65
+
66
+ * Everardo Medina (https://github.com/everblut)
67
+
68
+ ### Future
69
+
70
+ * Add better examples
71
+ * Add support for ActiveRecord
72
+ * Add conditional mocking
73
+ * Add expected return value
74
+ * Add custom response for mocked methods
75
+ * Add wiki
76
+
77
+
78
+ ## Credits
79
+ Rubixware - hello@rubixware.com
80
+
81
+ [Follow us](http://twitter.com/rubixware "Follow us")
82
+
83
+
84
+ [Like us on Facebook](https://www.facebook.com/rubixware "Like us on Facebook")
85
+
86
+
87
+ ### License
88
+
89
+ MIT License. Copyright 2015 Rubixware. http://www.rubixware.com
@@ -0,0 +1,21 @@
1
+ module Nilify
2
+
3
+
4
+ def nilify(methods)
5
+ nilify_methods(methods)
6
+ end
7
+
8
+ def nilify_from(class_param)
9
+ nilify_methods(class_param.instance_methods(false))
10
+ end
11
+
12
+ def nilify_methods(methods)
13
+ methods.each do |method|
14
+ define_method(method) do
15
+ "#{method} is a mock method"
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module Nilify
2
+ VERSION = "0.0.6"
3
+ end
@@ -0,0 +1,15 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nilify/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'nilify'
8
+ s.version = Nilify::VERSION
9
+ s.summary = %q{Provides methods for null object pattern implementation }
10
+ s.description = %q{A ruby gem to simply add mocked methods into a ruby class}
11
+ s.authors = ["Everardo Medina"]
12
+ s.email = 'emedina@rubixware.com'
13
+ s.files = `git ls-files`.split($/)
14
+ s.license = 'MIT'
15
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nilify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Everardo Medina
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A ruby gem to simply add mocked methods into a ruby class
14
+ email: emedina@rubixware.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - LICENSE
21
+ - README.md
22
+ - lib/nilify.rb
23
+ - lib/nilify/version.rb
24
+ - nilify.gemspec
25
+ homepage:
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.4.6
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Provides methods for null object pattern implementation
49
+ test_files: []