spine-symbolize 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44f1fe8ad91d40db114519d3f3d1eb983ba6446c
4
+ data.tar.gz: 09b4909ecce12e6ef57f6d3ac369d7933fdb3f49
5
+ SHA512:
6
+ metadata.gz: df48dff0665b8dac4fbbe4fe32605978034326e693b89eea3d5204837aaf490b13d202f6c52bcb118ab59135f3dee7698a5c9ff0b4a3689b74bb503296869fea
7
+ data.tar.gz: c663b5027ef78b4c029e6cd9ee1f8c34c4e2bb705d861d66d5588c47e804065940c62654096d2832c775be75a66a25f9bb03036587ea0ca79c44de24c4740a4e
@@ -0,0 +1,36 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /bin/
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require config/default
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in spine-symbolize.gemspec
4
+ gemspec
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spine-symbolize (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rake (10.4.2)
11
+ rspec (3.2.0)
12
+ rspec-core (~> 3.2.0)
13
+ rspec-expectations (~> 3.2.0)
14
+ rspec-mocks (~> 3.2.0)
15
+ rspec-core (3.2.3)
16
+ rspec-support (~> 3.2.0)
17
+ rspec-expectations (3.2.1)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.2.0)
20
+ rspec-mocks (3.2.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.2.0)
23
+ rspec-support (3.2.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.7)
30
+ rake (~> 10.0)
31
+ rspec (~> 3.2)
32
+ spine-symbolize!
data/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2015, TOGGL LLC
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ 3. Neither the name of the TOGGL LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,25 @@
1
+ # Spine::Symbolize
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/spine-symbolize.svg)](http://badge.fury.io/rb/spine-symbolize)
4
+ [![Dependency Status](https://gemnasium.com/rspine/symbolize.svg)](https://gemnasium.com/rspine/symbolize)
5
+ [![Code Climate](https://codeclimate.com/github/rspine/symbolize/badges/gpa.svg)](https://codeclimate.com/github/rspine/symbolize)
6
+ [![Codeship Status for rspine/symbolize](https://codeship.com/projects/d3273040-e1c2-0132-945c-26b30be2f32e/status?branch=master)](https://codeship.com/projects/81263)
7
+
8
+ Symbolizes hash keys.
9
+
10
+ ## Installation
11
+
12
+ To install it, add the gem to your Gemfile:
13
+
14
+ ```ruby
15
+ gem 'spine-symbolize'
16
+ ```
17
+
18
+ Then run `bundle`. If you're not using Bundler, just `gem install spine-symbolize`.
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ Spine::Symbolize.keys({ 'abc' => '123' })
24
+ # => { abc: '123' }
25
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ module Spine
2
+ module Symbolize
3
+ extend self
4
+
5
+ def keys(hash)
6
+ hash.reduce({}) { |memo, (key, value)|
7
+ memo[convert_key(key)] = convert_value(value)
8
+ memo
9
+ }
10
+ end
11
+
12
+ private
13
+
14
+ def convert_value(value)
15
+ if value.is_a?(Hash)
16
+ Symbolize.keys(value)
17
+ else
18
+ value
19
+ end
20
+ end
21
+
22
+ def convert_key(key)
23
+ key.to_sym
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module Spine
2
+ module Symbolize
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ RSpec.configure do |config|
2
+ config.filter_run :focus
3
+ config.run_all_when_everything_filtered = true
4
+
5
+ if config.files_to_run.one?
6
+ config.default_formatter = 'doc'
7
+ end
8
+
9
+ config.order = :random
10
+
11
+ Kernel.srand config.seed
12
+
13
+ config.expect_with :rspec do |expectations|
14
+ expectations.syntax = :expect
15
+ end
16
+
17
+ config.mock_with :rspec do |mocks|
18
+ mocks.syntax = :expect
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ require 'spine/symbolize'
2
+
3
+ module Spine
4
+ describe Symbolize do
5
+ describe 'when hash is flat' do
6
+ let(:convertable) { { 'ping' => 'pong' } }
7
+
8
+ it 'symbolizes keys' do
9
+ result = Symbolize.keys(convertable)
10
+ expect(result.keys).to include(:ping)
11
+ expect(result.keys).not_to include('ping')
12
+ end
13
+ end
14
+
15
+ describe 'when hash is nested' do
16
+ let(:convertable) { { 'test' => { "nested_test" => 1 } } }
17
+
18
+ it 'symbolizes keys' do
19
+ result = Symbolize.keys(convertable)
20
+ expect(result.keys).to include(:test)
21
+ expect(result[:test].keys).to include(:nested_test)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'spine/symbolize/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "spine-symbolize"
8
+ spec.version = Spine::Symbolize::VERSION
9
+ spec.authors = ["TOGGL LLC"]
10
+ spec.email = ["support@toggl.com"]
11
+ spec.summary = 'Symbolizes hash keys.'
12
+ spec.description = ''
13
+ spec.homepage = 'https://github.com/rspine/symbolize'
14
+ spec.license = 'BSD-3-Clause'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', "~> 1.7"
22
+ spec.add_development_dependency 'rake', "~> 10.0"
23
+ spec.add_development_dependency 'rspec', "~> 3.2"
24
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spine-symbolize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TOGGL LLC
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-21 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: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ description: ''
56
+ email:
57
+ - support@toggl.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - lib/spine/symbolize.rb
70
+ - lib/spine/symbolize/version.rb
71
+ - spec/config/default.rb
72
+ - spec/spine/symbolize_spec.rb
73
+ - spine-symbolize.gemspec
74
+ homepage: https://github.com/rspine/symbolize
75
+ licenses:
76
+ - BSD-3-Clause
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Symbolizes hash keys.
98
+ test_files:
99
+ - spec/config/default.rb
100
+ - spec/spine/symbolize_spec.rb