coati 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTQ5ZDNkZTE5OGUxNGZlZDU1ZjExMGNiZjE2NjY5M2VjMWU4YmI5Ng==
5
+ data.tar.gz: !binary |-
6
+ MmJiYjg1OGU4NGU0NGVjZmVmZWY0ODE1ZDlkY2JiODc4MTQ3MzZjOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjI2Yzc1OTEwZWVjOTg2ZDMzZTM1NjE1YmUxNDU3NThlNzVhNjcwZTA0ODRj
10
+ NWU4NDRhOTRkYTQwNjg3N2IwOTRjYjliYWM2N2YwNTI5MTQ2NzdjZmY2NGFj
11
+ NTc5M2M2NGM1NTY5MjE4Y2U3YjAxOWNkNTcyOTQ3ZTRjMTU0Mzg=
12
+ data.tar.gz: !binary |-
13
+ NWIyNWM0NjI5NjY2YTcwYzhkZTUwYjRhN2NlM2JiOTAxZTI1NTBkZjJmN2U3
14
+ NmEzOTU0OWE1MjE1ZDM5NDUxMWM4OGY2MWU2YzkyZGEyNjdjMmVkNDE3MjM4
15
+ ODUyZDQwZDIyNjI5ZmJjMWYxZWZhZjZhMWRmMGQ5NTFkYzNiY2Q=
Binary file
@@ -0,0 +1,49 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ coati (0.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.4)
10
+ rspec (2.13.0)
11
+ rspec-core (~> 2.13.0)
12
+ rspec-expectations (~> 2.13.0)
13
+ rspec-mocks (~> 2.13.0)
14
+ rspec-core (2.13.1)
15
+ rspec-expectations (2.13.0)
16
+ diff-lcs (>= 1.1.3, < 2.0)
17
+ rspec-mocks (2.13.1)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ coati!
24
+ rspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Albert Bellonch Llargués
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ Coati
2
+ ======
3
+
4
+ Description
5
+ -----------
6
+
7
+ Coati hides user-defined instance variables from being show when inspecting an instance of the class.
8
+
9
+ Imagine you have a simple class like:
10
+
11
+ class TestClass
12
+ def initialize(username, password)
13
+ @username = username
14
+ @password = password
15
+ end
16
+ end
17
+
18
+ Then when you inspect the instance of the class, the output will be something like:
19
+
20
+ [1] pry(main)> instance = TestClass.new('Joe', 'supersecretpassword')
21
+ => #<TestClass:0x007f9633ca87f0 @username="Joe", @password="supersecretpassword">
22
+
23
+ ...even if we don't want the password value to be shown. This gem addresses this problem.
24
+
25
+ This gem is named after [an American mammal](https://en.wikipedia.org/wiki/Coati).
26
+
27
+ Installation
28
+ ------------
29
+
30
+ Simply do
31
+
32
+ gem install coati
33
+
34
+ Usage
35
+ ------------
36
+
37
+ Firstly require it from the file:
38
+
39
+ require 'coati'
40
+
41
+ Then use the `attr_hider` method in the class:
42
+
43
+ class TestClass
44
+ attr_hider :password
45
+
46
+ def initialize(username, password)
47
+ @username = username
48
+ @password = password
49
+ end
50
+ end
51
+
52
+ When inspecting an instance of the class, the ouput will be something like:
53
+
54
+ [1] pry(main)> instance = TestClass.new('Joe', 'supersecretpassword')
55
+ => #<TestClass:0x007f9633ca87f0 @username="Joe">
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "okapi"
18
+ gem.homepage = "http://github.com/albertbellonch/okapi"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{TODO: one-line summary of your gem}
21
+ gem.description = %Q{TODO: longer description of your gem}
22
+ gem.email = "albert@itnig.net"
23
+ gem.authors = ["Albert Bellonch Llargués"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "okapi #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "coati/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "coati"
7
+ s.version = Coati::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Albert Bellonch"]
10
+ s.email = ["albert@itnig.net"]
11
+ s.homepage = "http://github.com/albertbellonch/coati"
12
+ s.summary = %q{ A simple utility that hides instance variables inside Ruby objects }
13
+
14
+ s.rubyforge_project = "coati"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.test_files = `git ls-files -- spec/*`.split("\n")
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec"
22
+ end
@@ -0,0 +1 @@
1
+ require 'coati/core'
@@ -0,0 +1,26 @@
1
+ module Coati
2
+ module ClassMethods
3
+ def attr_hider(*attrs)
4
+ define_method :attrs_to_hide do
5
+ attrs
6
+ end
7
+ end
8
+ end
9
+
10
+ module InstanceMethods
11
+ def inspect
12
+ new_inspect = super
13
+
14
+ if self.class.instance_methods.include?(:attrs_to_hide)
15
+ attrs_to_hide.each do |attr_to_hide|
16
+ new_inspect.gsub!(/,? @#{attr_to_hide}=".+"/, '')
17
+ end
18
+ end
19
+
20
+ new_inspect
21
+ end
22
+ end
23
+ end
24
+
25
+ Object.extend Coati::ClassMethods
26
+ Object.send(:include, Coati::InstanceMethods)
@@ -0,0 +1,3 @@
1
+ module Coati
2
+ VERSION = "0.1.0"
3
+ end
Binary file
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'coati'
3
+
4
+ describe Coati do
5
+ class TestClass
6
+ attr_hider :password
7
+
8
+ def initialize(username, password)
9
+ @username = username
10
+ @password = password
11
+ end
12
+ end
13
+
14
+ before do
15
+ @instance = TestClass.new('myusername', 'mypassword')
16
+ @inspect = @instance.inspect
17
+ end
18
+
19
+ it "should show the name and value of the username" do
20
+ @inspect.should =~ /@username=\"myusername\"/
21
+ end
22
+
23
+ it "should not show the name neither the value of the username" do
24
+ @inspect.should_not =~ /@password=\"mypassword\"/
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require 'coati'
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coati
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Albert Bellonch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
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
+ description:
28
+ email:
29
+ - albert@itnig.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .DS_Store
35
+ - .gitignore
36
+ - .rspec
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - coati.gemspec
43
+ - lib/coati.rb
44
+ - lib/coati/core.rb
45
+ - lib/coati/version.rb
46
+ - spec/.DS_Store
47
+ - spec/integration/coati.rb
48
+ - spec/spec_helper.rb
49
+ homepage: http://github.com/albertbellonch/coati
50
+ licenses: []
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project: coati
68
+ rubygems_version: 2.0.3
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: A simple utility that hides instance variables inside Ruby objects
72
+ test_files:
73
+ - spec/integration/coati.rb
74
+ - spec/spec_helper.rb