simple-masker 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  simple-masker
2
2
  =============
3
3
 
4
+ {<img src="https://travis-ci.org/more-ron/simple-masker.png" />}[https://travis-ci.org/more-ron/simple-masker]
5
+
4
6
  An implementation of presenter pattern.
5
7
 
6
8
  == Contributing to simple-masker
data/lib/simple-masker.rb CHANGED
@@ -1,9 +1,42 @@
1
1
  require "forwardable"
2
2
 
3
- # A simple implementation of a presenter pattern.
3
+ # A simple implementation of a presenter / masker pattern.
4
4
  # Acts like a SimpleDelegator implementing a decorator pattern except that
5
5
  # it hides the object's methods instead of delegating them by default.
6
6
  # Useful for hiding the ugly beast behind the mask.
7
+ #
8
+ # Usage:
9
+ #
10
+ # require "simple-masker"
11
+ #
12
+ # class Beast
13
+ # def presentable
14
+ # puts "eyes, nose, mouth"
15
+ # end
16
+ #
17
+ # def ugly
18
+ # puts "furry face"
19
+ # end
20
+ # end
21
+ #
22
+ # class MaskedMan < SimpleMasker
23
+ # masks :beast
24
+ # reveal_method :presentable
25
+ #
26
+ # def decoration
27
+ # puts "sparkles"
28
+ # end
29
+ # end
30
+ #
31
+ # beast = Beast.new
32
+ # masked_man = MaskedMan.new( beast )
33
+ #
34
+ # beast.respond_to? :presentable # => true
35
+ # beast.respond_to? :ugly # => true
36
+ #
37
+ # masked_man.respond_to? :presentable # => true
38
+ # masked_man.respond_to? :ugly # => false
39
+ # masked_man.respond_to? :decoration # => true
7
40
 
8
41
  class SimpleMasker
9
42
  extend Forwardable
@@ -12,14 +45,18 @@ class SimpleMasker
12
45
  _set_masked_object object
13
46
  end
14
47
 
48
+ # Names the beast behind the mask
15
49
  def self.masks(masked_name)
16
50
  define_method(masked_name){ _get_masked_object }
17
51
  end
18
52
 
53
+ # Reveals the specified method(s)
19
54
  def self.reveal_method(*method_names)
20
55
  def_delegators :_get_masked_object, *method_names
21
56
  end
22
57
 
58
+ private
59
+
23
60
  def _get_masked_object
24
61
  @_masked_object
25
62
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-masker
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 25
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - MoreRon
@@ -14,69 +15,78 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2013-04-12 00:00:00 +08:00
18
- default_executable:
18
+ date: 2013-04-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- prerelease: false
22
21
  type: :development
23
- name: rdoc
24
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
25
24
  requirements:
26
25
  - - ">="
27
26
  - !ruby/object:Gem::Version
27
+ hash: 3
28
28
  segments:
29
29
  - 0
30
30
  version: "0"
31
31
  requirement: *id001
32
- - !ruby/object:Gem::Dependency
33
32
  prerelease: false
33
+ name: rdoc
34
+ - !ruby/object:Gem::Dependency
34
35
  type: :development
35
- name: bundler
36
36
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ none: false
37
38
  requirements:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
41
+ hash: 3
40
42
  segments:
41
43
  - 0
42
44
  version: "0"
43
45
  requirement: *id002
44
- - !ruby/object:Gem::Dependency
45
46
  prerelease: false
47
+ name: bundler
48
+ - !ruby/object:Gem::Dependency
46
49
  type: :development
47
- name: jeweler
48
50
  version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ none: false
49
52
  requirements:
50
53
  - - ">="
51
54
  - !ruby/object:Gem::Version
55
+ hash: 3
52
56
  segments:
53
57
  - 0
54
58
  version: "0"
55
59
  requirement: *id003
56
- - !ruby/object:Gem::Dependency
57
60
  prerelease: false
61
+ name: jeweler
62
+ - !ruby/object:Gem::Dependency
58
63
  type: :development
59
- name: rspec
60
64
  version_requirements: &id004 !ruby/object:Gem::Requirement
65
+ none: false
61
66
  requirements:
62
67
  - - ">="
63
68
  - !ruby/object:Gem::Version
69
+ hash: 3
64
70
  segments:
65
71
  - 0
66
72
  version: "0"
67
73
  requirement: *id004
68
- - !ruby/object:Gem::Dependency
69
74
  prerelease: false
75
+ name: rspec
76
+ - !ruby/object:Gem::Dependency
70
77
  type: :development
71
- name: shoulda
72
78
  version_requirements: &id005 !ruby/object:Gem::Requirement
79
+ none: false
73
80
  requirements:
74
81
  - - ">="
75
82
  - !ruby/object:Gem::Version
83
+ hash: 3
76
84
  segments:
77
85
  - 0
78
86
  version: "0"
79
87
  requirement: *id005
88
+ prerelease: false
89
+ name: shoulda
80
90
  description: Acts like a SimpleDelegator implementing a decorator pattern except that it hides the object's methods instead of delegating them by default. Useful for hiding the ugly beast behind the mask.
81
91
  email: more.ron.too@gmail.com
82
92
  executables: []
@@ -87,18 +97,9 @@ extra_rdoc_files:
87
97
  - LICENSE.txt
88
98
  - README.md
89
99
  files:
90
- - .rspec
91
- - Gemfile
92
- - Gemfile.lock
100
+ - lib/simple-masker.rb
93
101
  - LICENSE.txt
94
102
  - README.md
95
- - Rakefile
96
- - VERSION
97
- - lib/simple-masker.rb
98
- - simple-masker.gemspec
99
- - spec/simple-masker_spec.rb
100
- - spec/spec_helper.rb
101
- has_rdoc: true
102
103
  homepage: http://github.com/more-ron/simple-masker
103
104
  licenses:
104
105
  - MIT
@@ -108,23 +109,27 @@ rdoc_options: []
108
109
  require_paths:
109
110
  - lib
110
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
111
113
  requirements:
112
114
  - - ">="
113
115
  - !ruby/object:Gem::Version
116
+ hash: 3
114
117
  segments:
115
118
  - 0
116
119
  version: "0"
117
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
118
122
  requirements:
119
123
  - - ">="
120
124
  - !ruby/object:Gem::Version
125
+ hash: 3
121
126
  segments:
122
127
  - 0
123
128
  version: "0"
124
129
  requirements: []
125
130
 
126
131
  rubyforge_project:
127
- rubygems_version: 1.3.6
132
+ rubygems_version: 1.8.25
128
133
  signing_key:
129
134
  specification_version: 3
130
135
  summary: A simple implementation of a presenter pattern
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "rdoc"
10
- gem "bundler"
11
- gem "jeweler"
12
- gem "rspec"
13
- gem "shoulda"
14
- end
data/Gemfile.lock DELETED
@@ -1,49 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activesupport (3.2.13)
5
- i18n (= 0.6.1)
6
- multi_json (~> 1.0)
7
- bourne (1.4.0)
8
- mocha (~> 0.13.2)
9
- diff-lcs (1.2.3)
10
- git (1.2.5)
11
- i18n (0.6.1)
12
- jeweler (1.8.4)
13
- bundler (~> 1.0)
14
- git (>= 1.2.5)
15
- rake
16
- rdoc
17
- json (1.7.7)
18
- metaclass (0.0.1)
19
- mocha (0.13.3)
20
- metaclass (~> 0.0.1)
21
- multi_json (1.7.2)
22
- rake (10.0.4)
23
- rdoc (4.0.1)
24
- json (~> 1.4)
25
- rspec (2.13.0)
26
- rspec-core (~> 2.13.0)
27
- rspec-expectations (~> 2.13.0)
28
- rspec-mocks (~> 2.13.0)
29
- rspec-core (2.13.1)
30
- rspec-expectations (2.13.0)
31
- diff-lcs (>= 1.1.3, < 2.0)
32
- rspec-mocks (2.13.1)
33
- shoulda (3.4.0)
34
- shoulda-context (~> 1.0, >= 1.0.1)
35
- shoulda-matchers (~> 1.0, >= 1.4.1)
36
- shoulda-context (1.1.0)
37
- shoulda-matchers (1.5.6)
38
- activesupport (>= 3.0.0)
39
- bourne (~> 1.3)
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- bundler
46
- jeweler
47
- rdoc
48
- rspec
49
- shoulda
data/Rakefile DELETED
@@ -1,45 +0,0 @@
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 = "simple-masker"
18
- gem.homepage = "http://github.com/more-ron/simple-masker"
19
- gem.license = "MIT"
20
- gem.summary = %Q{A simple implementation of a presenter pattern}
21
- gem.description = %Q{Acts like a SimpleDelegator implementing a decorator pattern except that it hides the object's methods instead of delegating them by default. Useful for hiding the ugly beast behind the mask.}
22
- gem.email = "more.ron.too@gmail.com"
23
- gem.authors = ["MoreRon"]
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
- task :default => :test
36
-
37
- require 'rdoc/task'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "simple-masker #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.2
@@ -1,63 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{simple-masker}
8
- s.version = "0.0.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["MoreRon"]
12
- s.date = %q{2013-04-12}
13
- s.description = %q{Acts like a SimpleDelegator implementing a decorator pattern except that it hides the object's methods instead of delegating them by default. Useful for hiding the ugly beast behind the mask.}
14
- s.email = %q{more.ron.too@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".rspec",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/simple-masker.rb",
28
- "simple-masker.gemspec",
29
- "spec/simple-masker_spec.rb",
30
- "spec/spec_helper.rb"
31
- ]
32
- s.homepage = %q{http://github.com/more-ron/simple-masker}
33
- s.licenses = ["MIT"]
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.6}
36
- s.summary = %q{A simple implementation of a presenter pattern}
37
-
38
- if s.respond_to? :specification_version then
39
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
- s.specification_version = 3
41
-
42
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
43
- s.add_development_dependency(%q<rdoc>, [">= 0"])
44
- s.add_development_dependency(%q<bundler>, [">= 0"])
45
- s.add_development_dependency(%q<jeweler>, [">= 0"])
46
- s.add_development_dependency(%q<rspec>, [">= 0"])
47
- s.add_development_dependency(%q<shoulda>, [">= 0"])
48
- else
49
- s.add_dependency(%q<rdoc>, [">= 0"])
50
- s.add_dependency(%q<bundler>, [">= 0"])
51
- s.add_dependency(%q<jeweler>, [">= 0"])
52
- s.add_dependency(%q<rspec>, [">= 0"])
53
- s.add_dependency(%q<shoulda>, [">= 0"])
54
- end
55
- else
56
- s.add_dependency(%q<rdoc>, [">= 0"])
57
- s.add_dependency(%q<bundler>, [">= 0"])
58
- s.add_dependency(%q<jeweler>, [">= 0"])
59
- s.add_dependency(%q<rspec>, [">= 0"])
60
- s.add_dependency(%q<shoulda>, [">= 0"])
61
- end
62
- end
63
-
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module SimpleMasker::Tests
4
- describe SimpleMasker do
5
-
6
- class UglyBeast
7
- def presentable?
8
- end
9
-
10
- def ugly?
11
- end
12
- end
13
-
14
- class MaskedMan < SimpleMasker
15
- masks :ugly_beast
16
-
17
- reveal_method :presentable?
18
- end
19
-
20
- let(:ugly_beast){ UglyBeast.new }
21
-
22
- subject(:masked_man) do
23
- MaskedMan.new ugly_beast
24
- end
25
-
26
- describe ".hides" do
27
- it "identifies what's masked" do
28
- masked_man.ugly_beast == ugly_beast
29
- end
30
- end
31
-
32
- describe ".reveal_method" do
33
- it "reveals the specified method" do
34
- masked_man.should respond_to :presentable?
35
- end
36
-
37
- it "does not reveal other methods" do
38
- masked_man.should_not respond_to :ugly?
39
- end
40
- end
41
-
42
- end
43
- end
data/spec/spec_helper.rb DELETED
@@ -1,20 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
-
8
- require "simple-masker"
9
-
10
- RSpec.configure do |config|
11
- config.treat_symbols_as_metadata_keys_with_true_values = true
12
- config.run_all_when_everything_filtered = true
13
- config.filter_run :focus
14
-
15
- # Run specs in random order to surface order dependencies. If you find an
16
- # order dependency and want to debug it, you can fix the order by providing
17
- # the seed, which is printed after each run.
18
- # --seed 1234
19
- config.order = 'random'
20
- end