camel_snake_struct 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: e030119b3af6eaca6666865803895cf418913a62152decc3578af302ee62dc60
4
- data.tar.gz: 9bd9ef3d9d215900202ba1388c13b784e54207f7e11accf96a6bd23332b0bcb7
3
+ metadata.gz: 987bc380d252b4990ae2007fcf0d5d75dcb1eb56a9f680eb043a3b6e7e65fa0c
4
+ data.tar.gz: 1ac44036b2c851c8f98c3bef57c20ab3cf1e6d557b675c2a48465a6b8e3be5ee
5
5
  SHA512:
6
- metadata.gz: eca1edf5388aa041ac1c68438a2e24139f4a2e9263470f766bef1ff65c95943bd5593dd47d9ffe14d423a7ada766aedc6f8834859b142551dc8593e4c84d2ee3
7
- data.tar.gz: 0306446d56b056675a72d591ba125b7eaa1a98e507069d4cbedd76161b5983eff18d1e47de77306e8e4d44b074bb2517a08a6e1acbf0d8bd0d0a6aa2629aaa73
6
+ metadata.gz: c64e7b0995a1098f8a932fa80f6c488ab1c75ce6dbcbaeaa181981442fb147c599b49e9a4b156fcb9930ca044d34fa92b795499594f99c1cc678259185fbe103
7
+ data.tar.gz: e8f184b499b1fbff46d2d22ff86459cc7c46b8f38369d7e28fc7af4cf5b3d07caef7115bacc3daa375fa452e503cb91bb2701ec1041515eb6242a463cc50c81e
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ # 0.2.0
2
+ * Add support to check if key is set
3
+
1
4
  # 0.1.0
2
5
  * initial version
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CamelSnake
1
+ # CamelSnakeStruct
2
2
 
3
3
  Easily access camelCased hashes in a ruby_friendly_way.
4
4
  Main focus is handling responses from APIs that use camelCased keys.
@@ -8,7 +8,7 @@ Main focus is handling responses from APIs that use camelCased keys.
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'camel_snake'
11
+ gem 'camel_snake_struct'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -17,7 +17,7 @@ And then execute:
17
17
 
18
18
  Or install it yourself as:
19
19
 
20
- $ gem install camel_snake
20
+ $ gem install camel_snake_struct
21
21
 
22
22
  ## Usage
23
23
 
@@ -30,10 +30,15 @@ For once of hashes
30
30
 
31
31
  puts result.version # 1
32
32
  puts result.ruby_version # 2.5.0
33
- puts result.sites[0].url # https://duckduckgo.com
34
- puts result.sites[1].url # https://d.tube/
35
- puts result.unknown # NoMethodError
36
33
  puts result['version'] # 1
34
+
35
+ if result.sites?
36
+ puts result.sites[0].url # https://duckduckgo.com
37
+ puts result.sites[1].url # https://d.tube/
38
+ end
39
+
40
+ puts result.people? # false
41
+ puts result.people # NoMethodError
37
42
  ```
38
43
 
39
44
  Or Learning Structs
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "camel_snake_struct"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Grant Petersen-Speelman"]
5
5
  spec.email = ["grant@nexl.io"]
6
6
 
@@ -60,6 +60,9 @@ class CamelSnakeStruct
60
60
  else # no method defined for empty arrays as we don't know what it returns
61
61
  @_raw_hash[camelize_key]
62
62
  end
63
+ elsif method_name.to_s.end_with?('?')
64
+ camelize_key = __method_to_key(method_name.to_s.chop)
65
+ @_raw_hash.key?(camelize_key)
63
66
  else
64
67
  super
65
68
  end
@@ -67,7 +70,7 @@ class CamelSnakeStruct
67
70
 
68
71
  def respond_to_missing?(method_name, include_private = false)
69
72
  camelize_key = __method_to_key(method_name)
70
- !camelize_key.nil? || super
73
+ !camelize_key.nil? || method_name.to_s.end_with?('?') || super
71
74
  end
72
75
 
73
76
  def __method_to_key(method_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camel_snake_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Petersen-Speelman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,6 +44,7 @@ files:
44
44
  - README.md
45
45
  - Rakefile
46
46
  - bin/console
47
+ - bin/rake
47
48
  - bin/rspec
48
49
  - bin/rubocop
49
50
  - bin/setup
@@ -56,7 +57,7 @@ metadata:
56
57
  homepage_uri: https://github.com/NEXL-LTS/camel_snake_struct-ruby
57
58
  source_code_uri: https://github.com/NEXL-LTS/camel_snake_struct-ruby
58
59
  changelog_uri: https://github.com/NEXL-LTS/camel_snake_struct/CHANGELOG.md
59
- post_install_message:
60
+ post_install_message:
60
61
  rdoc_options: []
61
62
  require_paths:
62
63
  - lib
@@ -71,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubygems_version: 3.1.4
75
- signing_key:
75
+ rubygems_version: 3.2.22
76
+ signing_key:
76
77
  specification_version: 4
77
78
  summary: Easily access camelCased hashes in a ruby friendly way
78
79
  test_files: []