init_copy 0.1.1 → 0.1.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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/Rakefile +5 -17
  4. data/init_copy.gemspec +12 -26
  5. data/lib/init_copy.rb +39 -44
  6. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7a0940cd2260200b9b8d82c9e60a764c1ade5d3dd9311340b98453da4393cad
4
- data.tar.gz: 159371837bce7bf68ccc201af9da425daeeb86ef5c8a6ae4313ea365aba42f54
3
+ metadata.gz: 334205ab1c79efe1d230625d0c8f6790624b1ad6fc7b0c4d53c398659d8accc6
4
+ data.tar.gz: 2251d54cef9fd610da58f62bfeb550f8bec0019f3f2d06811028648c7575c94b
5
5
  SHA512:
6
- metadata.gz: f7c63f7f9303cfa625a31a90f202e0eeefade8edbcd083073868b0d96e7af8038beda13bc5731b8dc774c66fcf6eec1e5e3252c03655696eb6f27de929631567
7
- data.tar.gz: 7bbd82cb056013d14222cd064761148e5014362570f43f5b82142021199585a02b91a47e4513437f4637e0cbc221b2119e1ec59251aa4fe2fb2c4c05d881de6a
6
+ metadata.gz: e78215e491c98eb64d1e3d8b8920559151ce92ba2fe23e858832f82f90da7b40d71fc2b41ee2968c35ab88835c47ac9263fd1e6cc149ed6974a3787d7d985a5d
7
+ data.tar.gz: f2cafe04cd905f0f31083e30343e73029cf5ae5fc8f1b5d28c141e1caeea4fb4575d3f77dde841da21d76f4aa667a767513e9bd93fe0f04a33b928ff53994c37
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Jonathan Bradley Whited
3
+ Copyright (c) 2020-2021 Jonathan Bradley Whited
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -1,17 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- #--
5
- # This file is part of InitCopy.
6
- # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
7
- #
8
- # InitCopy is free software: you can redistribute it and/or modify it under
9
- # the terms of the MIT License.
10
- #
11
- # You should have received a copy of the MIT License along with InitCopy.
12
- # If not, see <https://choosealicense.com/licenses/mit/>.
13
- #++
14
-
15
4
 
16
5
  require 'bundler/gem_tasks'
17
6
 
@@ -28,10 +17,9 @@ CLOBBER.include('doc/')
28
17
  task default: [:test]
29
18
 
30
19
  desc 'Generate doc (YARDoc)'
31
- task :doc => [:yard] do |task|
32
- end
20
+ task :doc,%i[] => %i[yard]
33
21
 
34
- Rake::TestTask.new() do |task|
22
+ Rake::TestTask.new do |task|
35
23
  task.libs = ['lib','test']
36
24
  task.pattern = File.join('test','**','*_test.rb')
37
25
  task.description += ": '#{task.pattern}'"
@@ -39,12 +27,12 @@ Rake::TestTask.new() do |task|
39
27
  task.warning = true
40
28
  end
41
29
 
42
- YARD::Rake::YardocTask.new() do |task|
30
+ YARD::Rake::YardocTask.new do |task|
43
31
  task.files = [File.join('lib','**','*.{rb}')]
44
-
32
+
45
33
  task.options += ['--files','CHANGELOG.md,LICENSE.txt']
46
34
  task.options += ['--readme','README.md']
47
-
35
+
48
36
  task.options << '--protected' # Show protected methods
49
37
  #task.options += ['--template-path',File.join('yard','templates')]
50
38
  task.options += ['--title',"InitCopy v#{InitCopy::VERSION} Doc"]
data/init_copy.gemspec CHANGED
@@ -1,52 +1,38 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- #--
5
- # This file is part of InitCopy.
6
- # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
7
- #
8
- # InitCopy is free software: you can redistribute it and/or modify it under
9
- # the terms of the MIT License.
10
- #
11
- # You should have received a copy of the MIT License along with InitCopy.
12
- # If not, see <https://choosealicense.com/licenses/mit/>.
13
- #++
14
4
 
5
+ require_relative 'lib/init_copy'
15
6
 
16
- lib = File.expand_path(File.join('..','lib'),__FILE__)
17
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
18
7
 
19
- require 'init_copy'
20
-
21
-
22
- Gem::Specification.new() do |spec|
8
+ Gem::Specification.new do |spec|
23
9
  spec.name = 'init_copy'
24
10
  spec.version = InitCopy::VERSION
25
- spec.authors = ['Jonathan Bradley Whited (@esotericpig)']
26
- spec.email = ['bradley@esotericpig.com']
11
+ spec.authors = ['Jonathan Bradley Whited']
12
+ spec.email = ['code@esotericpig.com']
27
13
  spec.licenses = ['MIT']
28
14
  spec.homepage = 'https://github.com/esotericpig/init_copy'
29
15
  spec.summary = 'Easily use the appropriate clone/dup method in initialize_copy.'
30
16
  spec.description = spec.summary
31
-
17
+
32
18
  spec.metadata = {
33
19
  'bug_tracker_uri' => 'https://github.com/esotericpig/init_copy/issues',
34
20
  'changelog_uri' => 'https://github.com/esotericpig/init_copy/blob/master/CHANGELOG.md',
35
21
  'homepage_uri' => 'https://github.com/esotericpig/init_copy',
36
22
  'source_code_uri' => 'https://github.com/esotericpig/init_copy'
37
23
  }
38
-
24
+
39
25
  spec.require_paths = ['lib']
40
-
26
+
41
27
  spec.files = Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{rb}')) +
42
- %W( Gemfile #{spec.name}.gemspec Rakefile ) +
43
- %w( LICENSE.txt )
44
-
28
+ %W[ Gemfile #{spec.name}.gemspec Rakefile ] +
29
+ %w[ LICENSE.txt ]
30
+
45
31
  # Lowest version that isn't eol (end-of-life).
46
32
  # - https://www.ruby-lang.org/en/downloads/branches/
47
33
  spec.required_ruby_version = '>= 2.4'
48
-
49
- spec.add_development_dependency 'bundler' ,'~> 2.1'
34
+
35
+ spec.add_development_dependency 'bundler' ,'~> 2.2'
50
36
  spec.add_development_dependency 'minitest','~> 5.14'
51
37
  spec.add_development_dependency 'rake' ,'~> 13.0'
52
38
  spec.add_development_dependency 'yard' ,'~> 0.9' # For doc
data/lib/init_copy.rb CHANGED
@@ -1,85 +1,80 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # This file is part of InitCopy.
7
- # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
8
- #
9
- # InitCopy is free software: you can redistribute it and/or modify it under
10
- # the terms of the MIT License.
11
- #
12
- # You should have received a copy of the MIT License along with InitCopy.
13
- # If not, see <https://choosealicense.com/licenses/mit/>.
6
+ # Copyright (c) 2020-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: MIT
14
9
  #++
15
10
 
16
11
 
17
12
  ###
18
- # @author Jonathan Bradley Whited (@esotericpig)
13
+ # @author Jonathan Bradley Whited
19
14
  # @since 0.1.0
20
15
  ###
21
16
  module InitCopy
22
- VERSION = '0.1.1'
23
-
24
- DEFAULT_COPY_NAME=:dup
25
-
17
+ VERSION = '0.1.2'
18
+
19
+ DEFAULT_COPY_NAME = :dup
20
+
26
21
  def self.new(default_name=DEFAULT_COPY_NAME)
27
22
  return Copier.new(default_name)
28
23
  end
29
-
24
+
30
25
  def self.find_copy_name(default_name=DEFAULT_COPY_NAME)
31
26
  copy_name = default_name
32
-
33
- caller.each() do |name|
34
- if name.end_with?(%q(clone'))
27
+
28
+ caller.each do |name|
29
+ if name.end_with?("clone'")
35
30
  copy_name = :clone
36
31
  break
37
32
  end
38
-
39
- if name.end_with?(%q(dup'))
33
+
34
+ if name.end_with?("dup'")
40
35
  copy_name = :dup
41
36
  break
42
37
  end
43
38
  end
44
-
39
+
45
40
  return copy_name
46
41
  end
47
-
42
+
48
43
  ###
49
- # @author Jonathan Bradley Whited (@esotericpig)
44
+ # @author Jonathan Bradley Whited
50
45
  # @since 0.1.0
51
46
  ###
52
47
  class Copier
53
48
  attr_accessor :default_name
54
49
  attr_accessor :name
55
-
50
+
56
51
  def initialize(default_name=DEFAULT_COPY_NAME)
57
52
  super()
58
-
53
+
59
54
  @default_name = default_name
60
-
61
- update_name()
55
+
56
+ update_name
62
57
  end
63
-
58
+
64
59
  def copy(var)
65
60
  return var.__send__(@name)
66
61
  end
67
-
62
+
68
63
  def safe_copy(var)
69
64
  return var.respond_to?(@name) ? var.__send__(@name) : var
70
65
  end
71
-
72
- def update_name()
66
+
67
+ def update_name
73
68
  @name = InitCopy.find_copy_name(@default_name)
74
69
  end
75
70
  end
76
-
71
+
77
72
  Copyer = Copier # Alias
78
-
73
+
79
74
  ###
80
75
  # The instance variable name is long and obnoxious to reduce conflicts.
81
- #
82
- # @author Jonathan Bradley Whited (@esotericpig)
76
+ #
77
+ # @author Jonathan Bradley Whited
83
78
  # @since 0.1.0
84
79
  ###
85
80
  module Copyable
@@ -88,40 +83,40 @@ module InitCopy
88
83
  super
89
84
  @init_copy_method_name = DEFAULT_COPY_NAME
90
85
  end
91
-
86
+
92
87
  def initialize_clone(*)
93
88
  @init_copy_method_name = :clone
94
89
  super
95
90
  end
96
-
91
+
97
92
  def initialize_dup(*)
98
93
  @init_copy_method_name = :dup
99
94
  super
100
95
  end
101
-
96
+
102
97
  def clone(*)
103
98
  @init_copy_method_name = :clone
104
99
  super
105
100
  end
106
-
101
+
107
102
  def dup(*)
108
103
  @init_copy_method_name = :dup
109
104
  super
110
105
  end
111
-
106
+
112
107
  private
113
-
108
+
114
109
  def copy(var)
115
110
  return var.__send__(@init_copy_method_name)
116
111
  end
117
-
112
+
118
113
  def safe_copy(var)
119
- @init_copy_method_name = DEFAULT_COPY_NAME if @init_copy_method_name.nil?()
120
-
114
+ @init_copy_method_name = DEFAULT_COPY_NAME if @init_copy_method_name.nil?
115
+
121
116
  return var.respond_to?(@init_copy_method_name) ?
122
117
  var.__send__(@init_copy_method_name) : var
123
118
  end
124
119
  end
125
-
120
+
126
121
  Copiable = Copyable # Alias
127
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: init_copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
- - Jonathan Bradley Whited (@esotericpig)
8
- autorequire:
7
+ - Jonathan Bradley Whited
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-07 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: '2.2'
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: '2.1'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '0.9'
69
69
  description: Easily use the appropriate clone/dup method in initialize_copy.
70
70
  email:
71
- - bradley@esotericpig.com
71
+ - code@esotericpig.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -86,7 +86,7 @@ metadata:
86
86
  changelog_uri: https://github.com/esotericpig/init_copy/blob/master/CHANGELOG.md
87
87
  homepage_uri: https://github.com/esotericpig/init_copy
88
88
  source_code_uri: https://github.com/esotericpig/init_copy
89
- post_install_message:
89
+ post_install_message:
90
90
  rdoc_options: []
91
91
  require_paths:
92
92
  - lib
@@ -101,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.1.2
105
- signing_key:
104
+ rubygems_version: 3.2.15
105
+ signing_key:
106
106
  specification_version: 4
107
107
  summary: Easily use the appropriate clone/dup method in initialize_copy.
108
108
  test_files: []