ostruct 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -3
  3. data/README.md +4 -4
  4. data/Rakefile +0 -7
  5. data/lib/ostruct.rb +13 -1
  6. data/ostruct.gemspec +1 -4
  7. metadata +4 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 860c3132a16e7c7e90c96f7241accad8d7f2e9e5a355fce61a2f15a3fc00943e
4
- data.tar.gz: '068a9d69d71d7fdc75b69c11eae85f6ceb70212c59185307101076c748ba7344'
3
+ metadata.gz: fe09d17a88e6e83d913e0c395ba08bbcc7c8ba375162507186c4c91dac54fcd8
4
+ data.tar.gz: e297f7776377bbee4097d9f3f48cbc56c5d5ef90f5d89899a53d81855d637965
5
5
  SHA512:
6
- metadata.gz: 63155bc6c512c8ea516eb97c44088a2236c2e040837efdb609598f0e733542cb67883a21d77a0c35ad061617a2db8141fb84e9a69ffe7b1c9bbc4b341012c02e
7
- data.tar.gz: 7cc37e85d8956426e0f89ac6f26da12d503faf40c6cc81c4743c6df6da8b9b08d56fd1cb6961b1fca4eb0700c73edc1e4f20c04c0dfbe8ceb5832f79fdefacd7
6
+ metadata.gz: ec4852aeff7dc71ac3d15698207e3fbe9ad83085cdcc1e90adbe1e990aa874f83c35b82170131fea825ff72c4d510af52442bbffab4adb2509a91d20689b972a
7
+ data.tar.gz: aeb7ef000d1d2d0b22351d4bc0e318ae7accc3a88168c4ce1fe50151e6819050da5234ebcd17d520501eb3bc54ef73bfcbd71d2db09d89853de7ee30b06211fb
data/Gemfile CHANGED
@@ -1,6 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in ostruct.gemspec
6
3
  gemspec
4
+
5
+ group :development do
6
+ gem "bundler"
7
+ gem "rake"
8
+ gem "test-unit"
9
+ gem "test-unit-ruby-core"
10
+ end
data/README.md CHANGED
@@ -8,7 +8,7 @@ The `ostruct` library comes pre-packaged with Ruby. No installation is necessary
8
8
 
9
9
  ## Usage
10
10
 
11
- ```
11
+ ```ruby
12
12
  require "ostruct"
13
13
 
14
14
  person = OpenStruct.new
@@ -22,14 +22,14 @@ The `ostruct` library comes pre-packaged with Ruby. No installation is necessary
22
22
 
23
23
  An OpenStruct employs a Hash internally to store the attributes and values and can even be initialized with one:
24
24
 
25
- ```
25
+ ```ruby
26
26
  australia = OpenStruct.new(:country => "Australia", :capital => "Canberra")
27
27
  # => #<OpenStruct country="Australia", capital="Canberra">
28
28
  ```
29
29
 
30
30
  Hash keys with spaces or characters that could normally not be used for method calls (e.g. <code>()[]*</code>) will not be immediately available on the OpenStruct object as a method for retrieval or assignment, but can still be reached through the Object#send method.
31
31
 
32
- ```
32
+ ```ruby
33
33
  measurements = OpenStruct.new("length (in inches)" => 24)
34
34
  measurements.send("length (in inches)") # => 24
35
35
 
@@ -41,7 +41,7 @@ Hash keys with spaces or characters that could normally not be used for method c
41
41
 
42
42
  Removing the presence of an attribute requires the execution of the delete_field method as setting the property value to +nil+ will not remove the attribute.
43
43
 
44
- ```
44
+ ```ruby
45
45
  first_pet = OpenStruct.new(:name => "Rowdy", :owner => "John Smith")
46
46
  second_pet = OpenStruct.new(:name => "Rowdy")
47
47
 
data/Rakefile CHANGED
@@ -15,11 +15,4 @@ Rake::TestTask.new(:test) do |t|
15
15
  t.test_files = FileList["test/**/test_*.rb"]
16
16
  end
17
17
 
18
- task :sync_tool do
19
- require 'fileutils'
20
- FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
21
- FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
22
- FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
23
- end
24
-
25
18
  task :default => [:test]
data/lib/ostruct.rb CHANGED
@@ -107,7 +107,15 @@
107
107
  # For all these reasons, consider not using OpenStruct at all.
108
108
  #
109
109
  class OpenStruct
110
- VERSION = "0.5.5"
110
+ VERSION = "0.6.0"
111
+
112
+ HAS_PERFORMANCE_WARNINGS = begin
113
+ Warning[:performance]
114
+ true
115
+ rescue NoMethodError, ArgumentError
116
+ false
117
+ end
118
+ private_constant :HAS_PERFORMANCE_WARNINGS
111
119
 
112
120
  #
113
121
  # Creates a new OpenStruct object. By default, the resulting OpenStruct
@@ -124,6 +132,10 @@ class OpenStruct
124
132
  # data # => #<OpenStruct country="Australia", capital="Canberra">
125
133
  #
126
134
  def initialize(hash=nil)
135
+ if HAS_PERFORMANCE_WARNINGS && Warning[:performance]
136
+ warn "OpenStruct use is discouraged for performance reasons", uplevel: 1, category: :performance
137
+ end
138
+
127
139
  if hash
128
140
  update_to_values!(hash)
129
141
  else
data/ostruct.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  name = File.basename(__FILE__, ".gemspec")
4
- version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
4
+ version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
5
5
  break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
6
6
  /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
7
7
  end rescue nil
@@ -21,7 +21,4 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/ostruct.rb", "ostruct.gemspec"]
23
23
  spec.require_paths = ["lib"]
24
-
25
- spec.add_development_dependency "bundler"
26
- spec.add_development_dependency "rake"
27
24
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ostruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-Andre Lafortune
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-31 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
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
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: Class to build custom data structures, similar to a Hash.
42
14
  email:
43
15
  - ruby-core@marc-andre.ca
@@ -74,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
46
  - !ruby/object:Gem::Version
75
47
  version: '0'
76
48
  requirements: []
77
- rubygems_version: 3.3.3
49
+ rubygems_version: 3.5.0.dev
78
50
  signing_key:
79
51
  specification_version: 4
80
52
  summary: Class to build custom data structures, similar to a Hash.