attire 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53a76fd77e586cecce6fea04de34aea4225090d3
4
- data.tar.gz: a8e7d3b291bc0adc3845a7d893d4bca319256254
3
+ metadata.gz: 31b2df57e10b512df7cfc2dada08361ffac9c7fb
4
+ data.tar.gz: 98aacf33921ee96122ceca88893eef7e72d65ea4
5
5
  SHA512:
6
- metadata.gz: 66e94421748b69661c57680844088fee92e8474a252b7130e5c6e9918f8f6b16f015746c3b1ce51fa851ac6f561cfd53055ef74efd4e3bbfa27106f7affa8931
7
- data.tar.gz: 0efe0cdb17fc8e4903746b983ef0b039b13db70ebb783bbcb732599c9270b43dd604cb14131b9b33292368e1cfc71a48351ce245b84f91c3be209dadb90534f0
6
+ metadata.gz: 05b75852d131e69c5cf93bf5834291b3d7032a4e4fa498350948d6d004117456bb607c62a6615281f43e1bb3a681b14c159be33bd342df0ccb47414ea9821bcb
7
+ data.tar.gz: d90d695b0b7cc62339ab4a99337df6040dd2d3d4ba093e422e92882b68c0470188c2e881f8ca6b383c9af387672e5d7a2b29dd5470aa96b8976d662e022a5969
data/README.md CHANGED
@@ -38,8 +38,8 @@ class CheeseSpreader
38
38
  attr_method :spread, :cheese, crackers: Jacobs.new
39
39
 
40
40
  def spread
41
- raise CheeseError unless cheese.is_a?(Cheddar)
42
- cheese.spread_on(crackers)
41
+ raise CheeseError unless cheese.is_a?(Cheddar)
42
+ cheese.spread_on(crackers)
43
43
  end
44
44
  end
45
45
 
@@ -72,11 +72,11 @@ gem 'attire'
72
72
 
73
73
  And then execute:
74
74
 
75
- $ bundle
75
+ $ bundle
76
76
 
77
77
  Or install it yourself as:
78
78
 
79
- $ gem install attire
79
+ $ gem install attire
80
80
 
81
81
 
82
82
  ## Contributing
@@ -43,7 +43,7 @@ module Attire
43
43
  end
44
44
 
45
45
  def type_check
46
- return if args.all? {|a| [Symbol, Hash].include?(a.class) }
46
+ return if args.all? { |a| [Symbol, Hash].include?(a.class) }
47
47
  fail ArgumentError, 'Must be Symbol or Hash.'
48
48
  end
49
49
 
data/lib/attire.rb CHANGED
@@ -5,7 +5,7 @@ module Attire
5
5
  def attr_query(*names)
6
6
  names.each do |name|
7
7
  name = name.to_s
8
- fail ArgumentError, "`#{name}?`, not `#{name}`." unless name.end_with?("?")
8
+ fail ArgumentError, "`#{name}?`, not `#{name}`." unless name.end_with?('?')
9
9
  define_method(name) { !!send(name.chop) }
10
10
  end
11
11
  end
@@ -16,22 +16,22 @@ module Attire
16
16
 
17
17
  def attr_method(verb, *args, &b)
18
18
  define_singleton_method(verb) { |*a| new(*a).send(verb) }
19
- attr_init(*args, &b)
20
- end
19
+ attr_init(*args, &b)
20
+ end
21
21
 
22
- def fattr_init(*args, &b)
22
+ def fattr_init(*args, &b)
23
23
  attr_init(*args) do
24
- instance_eval(&b) if b
25
- self.freeze
24
+ instance_eval(&b) if b
25
+ freeze
26
26
  end
27
27
  end
28
28
 
29
29
  def fattr_method(verb, *args, &b)
30
30
  define_singleton_method(verb) { |*a| new(*a).send(verb) }
31
- fattr_init(*args, &b)
32
- end
31
+ fattr_init(*args, &b)
32
+ end
33
33
  end
34
34
 
35
35
  class Module
36
- include Attire
36
+ include Attire
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max White
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.1.0
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,29 +27,20 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.1.0
27
33
  description:
28
- email:
29
- - mushishi78@gmail.com
34
+ email: mushishi78@gmail.com
30
35
  executables: []
31
36
  extensions: []
32
37
  extra_rdoc_files: []
33
38
  files:
34
- - ".gitignore"
35
- - ".rspec"
36
- - Gemfile
37
39
  - LICENSE.txt
38
40
  - README.md
39
- - Rakefile
40
- - attire.gemspec
41
41
  - lib/attire.rb
42
42
  - lib/attire/attr_init.rb
43
- - lib/attire/version.rb
44
- - spec/attr_init_spec.rb
45
- - spec/attr_method_spec.rb
46
- - spec/attr_query_spec.rb
47
- - spec/fattr_spec.rb
48
- - spec/spec_helper.rb
49
- homepage: https://github.com/mushishi78/attire
43
+ homepage:
50
44
  licenses:
51
45
  - MIT
52
46
  metadata: {}
@@ -70,9 +64,4 @@ rubygems_version: 2.2.2
70
64
  signing_key:
71
65
  specification_version: 4
72
66
  summary: Convenience methods to remove some boiler plate in defining classes.
73
- test_files:
74
- - spec/attr_init_spec.rb
75
- - spec/attr_method_spec.rb
76
- - spec/attr_query_spec.rb
77
- - spec/fattr_spec.rb
78
- - spec/spec_helper.rb
67
+ test_files: []
data/.gitignore DELETED
@@ -1,15 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
15
- *.gem
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --require spec_helper
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in attire.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
data/attire.gemspec DELETED
@@ -1,21 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'attire/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "attire"
8
- spec.version = Attire::VERSION
9
- spec.authors = ["Max White"]
10
- spec.email = ["mushishi78@gmail.com"]
11
- spec.summary = %q{Convenience methods to remove some boiler plate in defining classes.}
12
- spec.homepage = "https://github.com/mushishi78/attire"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency 'rspec', '~> 3.1'
21
- end
@@ -1,3 +0,0 @@
1
- module Attire
2
- VERSION = "0.0.1"
3
- end
@@ -1,47 +0,0 @@
1
- describe '#attr_init' do
2
- let(:instance) { define_class(inside).new(1, 2, option1: 54) }
3
- let(:inside) do
4
- Proc.new { attr_init :argument1, :argument2, option1: 23, option2: 'default', option3: nil }
5
- end
6
-
7
- it 'assigns arguments to private methods' do
8
- expect(instance.send(:argument1)).to eq(1)
9
- expect(instance.send(:argument2)).to eq(2)
10
- expect(instance.send(:option1)).to eq(54)
11
- expect(instance.send(:option2)).to eq('default')
12
- expect(instance.send(:option3)).to eq(nil)
13
- end
14
-
15
- context 'with optional hash missing' do
16
- let(:instance) { define_class(inside).new(1, 2) }
17
-
18
- it 'still assigns arguments to private methods using default' do
19
- expect(instance.send(:option1)).to eq(23)
20
- end
21
- end
22
-
23
- context 'with input of wrong type' do
24
- let(:inside) { Proc.new { attr_init 'Strings bad' } }
25
- it { expect { define_class(inside) }.to raise_error(ArgumentError) }
26
- end
27
-
28
- context 'with too many arguments' do
29
- let(:instance) { define_class(inside).new(1, 2, {}, 4, 5) }
30
- it { expect { instance }.to raise_error(ArgumentError) }
31
- end
32
-
33
- context 'with too few arguments' do
34
- let(:instance) { define_class(inside).new(1) }
35
- it { expect { instance }.to raise_error(ArgumentError) }
36
- end
37
-
38
- context 'with block' do
39
- let(:instance) { define_class(inside).new(1) }
40
- let(:inside) { Proc.new { attr_init :foo do @foo = 5 end } }
41
-
42
- it 'calls block' do
43
- expect(instance.send(:foo)).to eq(5)
44
- end
45
- end
46
- end
47
-
@@ -1,16 +0,0 @@
1
- describe '#attr_method' do
2
- let(:klass) do
3
- klass = Class.new do
4
- attr_method :select, :child, toy: 5
5
-
6
- def select
7
- toy * child
8
- end
9
- end
10
- end
11
-
12
- it 'creates a class method that initializes and calls instance method' do
13
- expect(klass.select(3)).to eq(15)
14
- expect(klass.select(3, toy: 2)).to eq(6)
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- describe '#attr_query' do
2
- context 'with correct arguments' do
3
- let(:instance) { define_class(inside).new }
4
- let(:inside) do
5
- Proc.new { attr_accessor :foo; attr_query :foo? }
6
- end
7
-
8
- it 'creates a query method' do
9
- expect(instance.foo?).to be(false)
10
- instance.foo = 'rah'
11
- expect(instance.foo?).to be(true)
12
- end
13
- end
14
-
15
- context 'without a tailing questionmark' do
16
- let(:inside) { Proc.new { attr_query :bar } }
17
- it { expect { define_class(inside) }.to raise_error }
18
- end
19
- end
data/spec/fattr_spec.rb DELETED
@@ -1,17 +0,0 @@
1
- describe '#fattr_init' do
2
- let(:instance) { define_class(inside).new(5) }
3
- let(:inside) { Proc.new { fattr_init :chick } }
4
-
5
- it 'freezes class after initializing' do
6
- expect(instance.send(:chick)).to eq(5)
7
- expect { instance.instance_variable_set('@chick', 12) }.to raise_error
8
- end
9
-
10
- context 'with block' do
11
- let(:inside) { Proc.new { fattr_init :chick do @chick = 15 end } }
12
- it 'still evaluates block' do
13
- expect(instance.send(:chick)).to eq(15)
14
- end
15
- end
16
- end
17
-
data/spec/spec_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'attire'
2
-
3
- def define_class(proc)
4
- Class.new { instance_eval(&proc) }
5
- end