hash-tweaks 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +36 -0
- data/README.md +35 -0
- data/Rakefile +8 -0
- data/hash-tweaks.gemspec +24 -0
- data/lib/hash-tweaks/version.rb +6 -0
- data/lib/hash-tweaks.rb +26 -0
- data/test/test-hash-tweaks.rb +13 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ded40e1fbddfb884c7437c48a72fd9c4fe226a96
|
4
|
+
data.tar.gz: eefa3120e45f4ed5301389a6205cdac0755445ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3da87dc74cd56b8f52d2fe99c122506b34bc97efd67bf28b9763722f5ba90615a45d229c4611bc70e1bc2810312abce84ddda19f8366b0c0a489daec1bbd5c4
|
7
|
+
data.tar.gz: 30540ef9e501779d18e7fec704345d9d7f5fd15a78d00bbf78b7f932bea98f97565bbaf67fbd79d042806b388e97b64c42598388989917efcb6a4eebc7b71819
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hash-tweaks (1.0.0)
|
5
|
+
activesupport (>= 3.0, < 6.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (5.0.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
concurrent-ruby (1.0.5)
|
16
|
+
i18n (0.8.1)
|
17
|
+
minitest (5.10.1)
|
18
|
+
power_assert (1.0.1)
|
19
|
+
rake (12.0.0)
|
20
|
+
test-unit (3.2.3)
|
21
|
+
power_assert
|
22
|
+
thread_safe (0.3.6)
|
23
|
+
tzinfo (1.2.2)
|
24
|
+
thread_safe (~> 0.1)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
bundler (~> 1.7)
|
31
|
+
hash-tweaks!
|
32
|
+
rake (~> 12.0)
|
33
|
+
test-unit (~> 3.2)
|
34
|
+
|
35
|
+
BUNDLED WITH
|
36
|
+
1.14.3
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## Responsibly extends Ruby's Hash with simple and predictable utilities.
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/hash-tweaks.svg)](https://badge.fury.io/rb/hash-tweaks)
|
4
|
+
[![Build Status](https://travis-ci.org/yivo/hash-tweaks.svg?branch=master)](https://travis-ci.org/yivo/hash-tweaks)
|
5
|
+
|
6
|
+
## Current features
|
7
|
+
* `camelize`
|
8
|
+
* `camelize!`
|
9
|
+
|
10
|
+
## Installing gem
|
11
|
+
Add to your Gemfile:
|
12
|
+
```ruby
|
13
|
+
gem 'hash-tweaks', '~> 1.0'
|
14
|
+
```
|
15
|
+
|
16
|
+
If you are using Ruby < 2.4 please add:
|
17
|
+
```ruby
|
18
|
+
gem 'regexp-match-polyfill', '~> 1.0'
|
19
|
+
```
|
20
|
+
|
21
|
+
## Running tests
|
22
|
+
Install bundler:
|
23
|
+
```bash
|
24
|
+
gem install bundler
|
25
|
+
```
|
26
|
+
|
27
|
+
Install dependencies:
|
28
|
+
```bash
|
29
|
+
cd hash-tweaks && bundle
|
30
|
+
```
|
31
|
+
|
32
|
+
Run tests:
|
33
|
+
```bash
|
34
|
+
cd hash-tweaks && bundle exec rake test
|
35
|
+
```
|
data/Rakefile
ADDED
data/hash-tweaks.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require File.expand_path('../lib/hash-tweaks/version', __FILE__)
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'hash-tweaks'
|
8
|
+
s.version = HashTweaks::VERSION
|
9
|
+
s.author = 'Yaroslav Konoplov'
|
10
|
+
s.email = 'eahome00@gmail.com'
|
11
|
+
s.summary = "Responsibly extends Ruby's Hash with simple and predictable utilities."
|
12
|
+
s.description = "Responsibly extends Ruby's Hash with simple and predictable utilities."
|
13
|
+
s.homepage = 'https://github.com/yivo/hash-tweaks'
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_dependency 'activesupport', '>= 3.0', '< 6.0'
|
21
|
+
s.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
s.add_development_dependency 'rake', '~> 12.0'
|
23
|
+
s.add_development_dependency 'test-unit', '~> 3.2'
|
24
|
+
end
|
data/lib/hash-tweaks.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'regexp-match-polyfill' if RUBY_VERSION < '2.4'
|
5
|
+
require 'active_support/core_ext/string/inflections'
|
6
|
+
|
7
|
+
module HashTweaks
|
8
|
+
module Camelize
|
9
|
+
def camelize(first_letter = :upper)
|
10
|
+
dup.camelize!(first_letter)
|
11
|
+
end
|
12
|
+
|
13
|
+
def camelize!(first_letter = :upper)
|
14
|
+
keys.each do |key|
|
15
|
+
# Check if key is symbol or string and if it is not CONSTANT_VARIABLE.
|
16
|
+
if (Symbol === key || String === key) && !key.match?(/\A[A-Z_][A-Z_0-9]*\z/)
|
17
|
+
new_key = (Symbol === key ? key.to_s : key).camelize(first_letter)
|
18
|
+
self[Symbol === key ? new_key.to_sym : new_key] = self.delete(key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Hash.include HashTweaks::Camelize
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.require :default, :development, :test
|
6
|
+
|
7
|
+
class HashTweaksTest < Test::Unit::TestCase
|
8
|
+
def test_camelize
|
9
|
+
assert_equal({fooBarBaz: 'qux'}, {foo_bar_baz: 'qux'}.camelize(:lower))
|
10
|
+
assert_equal({FooBarBaz: 'qux'}, {foo_bar_baz: 'qux'}.camelize(:upper))
|
11
|
+
assert_equal({FOO_BAZ_BAZ: 'qux'}, {FOO_BAZ_BAZ: 'qux'}.camelize(:upper))
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hash-tweaks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yaroslav Konoplov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.7'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.7'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '12.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '12.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: test-unit
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.2'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.2'
|
75
|
+
description: Responsibly extends Ruby's Hash with simple and predictable utilities.
|
76
|
+
email: eahome00@gmail.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- ".gitignore"
|
82
|
+
- ".travis.yml"
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- hash-tweaks.gemspec
|
88
|
+
- lib/hash-tweaks.rb
|
89
|
+
- lib/hash-tweaks/version.rb
|
90
|
+
- test/test-hash-tweaks.rb
|
91
|
+
homepage: https://github.com/yivo/hash-tweaks
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.6.8
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Responsibly extends Ruby's Hash with simple and predictable utilities.
|
115
|
+
test_files:
|
116
|
+
- test/test-hash-tweaks.rb
|