selfies 1.2.3 → 1.3.1

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
- SHA1:
3
- metadata.gz: 542d2ed712992bff31b812fe7f1fce625e603cca
4
- data.tar.gz: 731f48a656f0d3817792c5751581555f5cf6d4b4
2
+ SHA256:
3
+ metadata.gz: 92bb0cfe1c9dbf12fb8733a58406d642155d40af435d4ea219bc899cdb35a2e2
4
+ data.tar.gz: 3f8d67ea68f9e0c053cfd702a0ac3043ad238c54d4e17160ed01ce64379eb1e2
5
5
  SHA512:
6
- metadata.gz: de4fc0461686a7f5ea01b802288193c29a1fd5f5ba5eee929661ff062ae6db2456b02a726d5ea1cab9cd6726baa68c7465deea6c530f81c706d86aeae074919e
7
- data.tar.gz: 5124a761f0f2760eaca91e593cf764e0a2ec36800aa1218adb0e705b398c1ccb98d90588f1fc16cbd487c7b087e58ae222b63b76270c5adb1711a10df9e62bac
6
+ metadata.gz: 6bbb05419580715a3b7e000adc19f47c5b606d9887982687ef9700232fbda48835238d3db71e2e3d14739ccc614292befafd55407bc832f54ef7238f6bdbbf39
7
+ data.tar.gz: a1a3c25a6f166095800510d18b6b8ae33a749c0c3f2a45892fd779bf18a74b513dd306b8c380f2354b94e47e5076fe68a0be30dae6f57a3cbec1fd027297495c
data/.gitignore CHANGED
@@ -1,10 +1,3 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
1
  /pkg/
8
- /spec/reports/
9
2
  /tmp/
10
3
  .rspec_status
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,18 @@
1
+ image: "ruby:2.5.1"
2
+
3
+ cache:
4
+ paths:
5
+ - vendor/ruby
6
+
7
+ before_script:
8
+ - ruby -v
9
+ - gem install bundler --no-ri --no-rdoc
10
+ - bundle install -j $(nproc) --path vendor
11
+
12
+ rspec:
13
+ script:
14
+ - rspec spec
15
+
16
+ rubocop:
17
+ script:
18
+ - bundle exec rubocop
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ Exclude:
4
+ - bin/**/*
5
+ - vendor/**/*
6
+ TargetRubyVersion: 2.5.1
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - '**/*_spec.rb'
11
+
12
+ Metrics/MethodLength:
13
+ Max: 15
14
+
15
+ Metrics/LineLength:
16
+ Max: 100
17
+
18
+ Metrics/ModuleLength:
19
+ Exclude:
20
+ - '**/*_spec.rb'
21
+
22
+ Style/FrozenStringLiteralComment:
23
+ Exclude:
24
+ - '**/*_spec.rb'
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
4
+ ruby '2.5.1'
5
+
6
+ Encoding.default_external = Encoding::UTF_8
7
+ Encoding.default_internal = Encoding::UTF_8
2
8
 
3
9
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ selfies (1.3.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ diff-lcs (1.3)
11
+ parallel (1.12.1)
12
+ parser (2.5.1.0)
13
+ ast (~> 2.4.0)
14
+ powerpack (0.1.1)
15
+ rainbow (3.0.0)
16
+ rake (12.3.1)
17
+ rspec (3.7.0)
18
+ rspec-core (~> 3.7.0)
19
+ rspec-expectations (~> 3.7.0)
20
+ rspec-mocks (~> 3.7.0)
21
+ rspec-core (3.7.1)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-expectations (3.7.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-mocks (3.7.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-support (3.7.1)
30
+ rubocop (0.55.0)
31
+ parallel (~> 1.10)
32
+ parser (>= 2.5)
33
+ powerpack (~> 0.1)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (~> 1.0, >= 1.0.1)
37
+ ruby-progressbar (1.9.0)
38
+ unicode-display_width (1.3.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 1.16)
45
+ rake (~> 12.3)
46
+ rspec (~> 3.7)
47
+ rubocop (~> 0.55)
48
+ selfies!
49
+
50
+ RUBY VERSION
51
+ ruby 2.5.1p57
52
+
53
+ BUNDLED WITH
54
+ 1.16.1
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/selfies.svg)](https://badge.fury.io/rb/selfies) [![Dependency Status](https://gemnasium.com/badges/github.com/mariodarco/selfies.svg)](https://gemnasium.com/github.com/mariodarco/selfies) [![CircleCI](https://circleci.com/gh/mariodarco/selfies/tree/master.svg?style=shield)](https://circleci.com/gh/mariodarco/selfies/tree/master) [![Maintainability](https://api.codeclimate.com/v1/badges/fe208e3abde2e2937ac7/maintainability)](https://codeclimate.com/github/mariodarco/selfies/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/fe208e3abde2e2937ac7/test_coverage)](https://codeclimate.com/github/mariodarco/selfies/test_coverage)
1
+ ![Gem Version](https://badge.fury.io/rb/selfies.svg) ![Build Status](https://gitlab.com/mariodarco/selfies/badges/master/build.svg)
2
2
 
3
3
  # Selfies
4
4
  **A collection of macros for quicker development**
@@ -52,7 +52,7 @@ You get this:
52
52
  ```
53
53
 
54
54
  ## Disclaimer
55
- In this project you will likely read me using both ```initialize``` and ```initialise```. I'm Italian, I learnt to code from American books and now live in UK, to me they both make sense. As a rule of thumb, it's the ```ize``` form in code and ```ise``` form everywhere else. But might mix them so bear with me. Thanks!
55
+ In this project you will likely read me using both ```initialize``` and ```initialise```. I'm Italian, I learnt to code from American books and now live in Ireland, to me they both make sense. As a rule of thumb, it's the ```ize``` form in code and ```ise``` form everywhere else. But might mix them so bear with me. Thanks!
56
56
 
57
57
 
58
58
  ## Installation
@@ -258,14 +258,15 @@ end
258
258
  ## Development
259
259
 
260
260
  Ruby version:
261
- ```
262
- 2.4.2
261
+ ```bash
262
+ 2.5.1
263
263
  ```
264
264
 
265
265
  Fork the project, clone the repository and bundle:
266
- ```
267
- >> git clone https://github.com/{your_account}/selfies.git
266
+ ```bash
267
+ >> git clone https://{your_fork}/selfies
268
268
  >> cd selfies
269
+ >> bundle
269
270
  ```
270
271
 
271
272
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -274,12 +275,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
274
275
 
275
276
  ## Contributing
276
277
 
277
- Bug reports and pull requests are welcome on GitHub at https://github.com/mariodarco/selfies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
278
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/mariodarco/selfies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
278
279
 
279
280
  ## License
280
281
 
281
282
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
282
283
 
283
- ## Code of Conduct
284
-
285
- Everyone interacting in the Selfies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mariodarco/selfies/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/lib/kernel.rb CHANGED
@@ -1,4 +1,6 @@
1
- # Open the Kernel modul to define methods for any class.
1
+ # frozen_string_literal: true
2
+
3
+ # Open the Kernel module to define methods for any class.
2
4
  module Kernel
3
5
  extend Gem::Deprecate
4
6
 
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Selfies
4
+ # Generates an accessor or reader for each passed variable
2
5
  class SelfInit
3
6
  def self.generate(class_name, accessor, *variables)
4
7
  return false unless variables.any?
@@ -9,17 +12,27 @@ module Selfies
9
12
  SelfInit.access_variables(class_name, accessor, variable_names)
10
13
 
11
14
  define_method(:initialize) do |*args|
12
- SelfInit.argument_guard(variables, variable_names.count, args.count)
15
+ SelfInit.argument_guard(variables, [variable_names.count, args.count])
13
16
 
14
17
  variables.each_with_index do |variable, index|
15
18
  variable_name, default = SelfInit.decouple(variable)
16
- value = variable_name == :args ? args[index..-1] : args[index]
17
- instance_variable_set("@#{variable_name}", value || default)
19
+
20
+ instance_variable_set(
21
+ "@#{variable_name}", SelfInit.get_value(variable_name, args, index) || default
22
+ )
18
23
  end
19
24
  end
20
25
  end
21
26
  end
22
27
 
28
+ def self.get_value(variable_name, args, index)
29
+ if variable_name == :args
30
+ args[index..-1]
31
+ else
32
+ args[index]
33
+ end
34
+ end
35
+
23
36
  def self.access_variables(class_name, accessor, variable_names)
24
37
  class_name.send(
25
38
  (accessor ? :attr_accessor : :attr_reader),
@@ -27,16 +40,12 @@ module Selfies
27
40
  )
28
41
  end
29
42
 
30
- def self.argument_guard(all_variables, expected, given)
31
- unless correct_argument_count?(all_variables, expected, given)
32
- raise(
33
- ArgumentError,
34
- "wrong number of arguments (given #{given}, expected #{expected})"
35
- )
36
- end
43
+ def self.argument_guard(all_variables, arguments)
44
+ raise_argumnet_for(arguments) unless correct_argument_count?(all_variables, arguments)
37
45
  end
38
46
 
39
- def self.correct_argument_count?(all_variables, expected, given)
47
+ def self.correct_argument_count?(all_variables, arguments)
48
+ expected, given = arguments
40
49
  final_variable = all_variables.last
41
50
  correct_argument_count = given == expected
42
51
  if final_variable.is_a? Hash
@@ -60,5 +69,10 @@ module Selfies
60
69
  variable.is_a?(Hash) ? variable.keys.first : variable
61
70
  end
62
71
  end
72
+
73
+ def self.raise_argumnet_for(arguments)
74
+ expected, given = arguments
75
+ raise(ArgumentError, "wrong number of arguments (given #{given}, expected #{expected})")
76
+ end
63
77
  end
64
78
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Selfies
2
4
  # Generates a class method for any described instance methods.
3
5
  class Selfie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Selfies
2
- VERSION = '1.2.3'.freeze
4
+ VERSION = '1.3.1'
3
5
  end
data/lib/selfies.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'kernel'
2
4
  require 'selfies/self_init'
3
5
  require 'selfies/selfie'
data/selfies.gemspec CHANGED
@@ -1,6 +1,7 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
 
3
- lib = File.expand_path('../lib', __FILE__)
4
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
6
  require 'selfies/version'
6
7
 
@@ -8,10 +9,10 @@ Gem::Specification.new do |spec|
8
9
  spec.name = 'selfies'
9
10
  spec.version = Selfies::VERSION
10
11
  spec.authors = ['Mario D’Arco']
11
- spec.email = ['mariodarco78@icloud.com']
12
+ spec.email = ['mario.darco.78@gmail.com']
12
13
 
13
14
  spec.summary = 'A collection of macros for quicker development.'
14
- spec.homepage = 'https://github.com/mariodarco/selfies'
15
+ spec.homepage = 'https://gitlab.com/mariodarco/selfies'
15
16
  spec.license = 'MIT'
16
17
  spec.bindir = 'exe'
17
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -23,8 +24,8 @@ Gem::Specification.new do |spec|
23
24
 
24
25
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
25
26
 
26
- spec.add_development_dependency 'bundler'
27
- spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rspec'
29
- spec.add_development_dependency 'rubocop'
27
+ spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'rake', '~> 12.3'
29
+ spec.add_development_dependency 'rspec', '~> 3.7'
30
+ spec.add_development_dependency 'rubocop', '~> 0.55'
30
31
  end
metadata CHANGED
@@ -1,82 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario D’Arco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.16'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '12.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '12.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.55'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.55'
69
69
  description:
70
70
  email:
71
- - mariodarco78@icloud.com
71
+ - mario.darco.78@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".gitlab-ci.yml"
77
78
  - ".rspec"
79
+ - ".rubocop.yml"
78
80
  - CODE_OF_CONDUCT.md
79
81
  - Gemfile
82
+ - Gemfile.lock
80
83
  - LICENSE.txt
81
84
  - README.md
82
85
  - Rakefile
@@ -88,7 +91,7 @@ files:
88
91
  - lib/selfies/selfie.rb
89
92
  - lib/selfies/version.rb
90
93
  - selfies.gemspec
91
- homepage: https://github.com/mariodarco/selfies
94
+ homepage: https://gitlab.com/mariodarco/selfies
92
95
  licenses:
93
96
  - MIT
94
97
  metadata:
@@ -109,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
112
  version: '0'
110
113
  requirements: []
111
114
  rubyforge_project:
112
- rubygems_version: 2.6.13
115
+ rubygems_version: 2.7.6
113
116
  signing_key:
114
117
  specification_version: 4
115
118
  summary: A collection of macros for quicker development.