plissken 0.1.0 → 0.2.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: 46a91e54b2563fa6efad2ec566f056afaa002355
4
+ data.tar.gz: 20e616d7f653d16fc4a370835d35d09b3eeefa2c
5
+ SHA512:
6
+ metadata.gz: c8c7979285808498f9ff68e3d8da071fa9f403d2be00993be17d6dc50acd7f07e0da70b82629842990922a8739bdc6e27ca73f4f9d705834a4f894e92ab26145
7
+ data.tar.gz: b7509676e2defc3260949904c4081e5ae5370b34159086a6802eae81f7f87fd6e431f2f86b03b5d49209394497f1a0a025b962afda542f26c707acf7403fa90c
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ Style/HashSyntax:
2
+ EnforcedStyle: hash_rockets
3
+ SupportedStyles:
4
+ - ruby19
5
+ - hash_rockets
6
+
7
+ AllCops:
8
+ Exclude:
9
+ - plissken.gemspec
10
+ - Rakefile
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
+ gem 'symbolize', '~> 4.2'
2
3
  # Add dependencies required to use your gem here.
3
4
  # Example:
4
5
  # gem "activesupport", ">= 2.3.5"
@@ -6,9 +7,9 @@ source "http://rubygems.org"
6
7
  # Add dependencies to develop your gem here.
7
8
  # Include everything needed to run rake, tests, features, etc.
8
9
  group :development do
9
- gem "debugger"
10
- gem "minitest", ">= 0", :require => 'minitest/spec'
11
- gem "rdoc", "~> 3.12"
12
- gem "bundler"
13
- gem "jeweler", "~> 1.8.4"
10
+ # gem 'debugger'
11
+ gem 'rspec', '~> 3.1'
12
+ gem 'rdoc', '~> 3.12'
13
+ gem 'bundler', '~> 1.6'
14
+ gem 'jeweler', '~> 2.0'
14
15
  end
@@ -1,32 +1,91 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- columnize (0.3.6)
5
- debugger (1.2.1)
6
- columnize (>= 0.3.1)
7
- debugger-linecache (~> 1.1.1)
8
- debugger-ruby_core_source (~> 1.1.4)
9
- debugger-linecache (1.1.2)
10
- debugger-ruby_core_source (>= 1.1.1)
11
- debugger-ruby_core_source (1.1.4)
12
- git (1.2.5)
13
- jeweler (1.8.4)
14
- bundler (~> 1.0)
4
+ activemodel (4.0.12)
5
+ activesupport (= 4.0.12)
6
+ builder (~> 3.1.0)
7
+ activesupport (4.0.12)
8
+ i18n (~> 0.6, >= 0.6.9)
9
+ minitest (~> 4.2)
10
+ multi_json (~> 1.3)
11
+ thread_safe (~> 0.1)
12
+ tzinfo (~> 0.3.37)
13
+ addressable (2.3.6)
14
+ builder (3.1.4)
15
+ descendants_tracker (0.0.4)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ diff-lcs (1.2.5)
18
+ faraday (0.9.0)
19
+ multipart-post (>= 1.2, < 3)
20
+ git (1.2.8)
21
+ github_api (0.12.2)
22
+ addressable (~> 2.3)
23
+ descendants_tracker (~> 0.0.4)
24
+ faraday (~> 0.8, < 0.10)
25
+ hashie (>= 3.3)
26
+ multi_json (>= 1.7.5, < 2.0)
27
+ nokogiri (~> 1.6.3)
28
+ oauth2
29
+ hashie (3.3.2)
30
+ highline (1.6.21)
31
+ i18n (0.7.0)
32
+ jeweler (2.0.1)
33
+ builder
34
+ bundler (>= 1.0)
15
35
  git (>= 1.2.5)
36
+ github_api
37
+ highline (>= 1.6.15)
38
+ nokogiri (>= 1.5.10)
16
39
  rake
17
40
  rdoc
18
41
  json (1.7.7)
42
+ json (1.7.7-java)
43
+ jwt (1.2.0)
44
+ mini_portile (0.6.2)
19
45
  minitest (4.6.1)
20
- rake (10.0.3)
46
+ multi_json (1.10.1)
47
+ multi_xml (0.5.5)
48
+ multipart-post (2.0.0)
49
+ nokogiri (1.6.5)
50
+ mini_portile (~> 0.6.0)
51
+ nokogiri (1.6.5-java)
52
+ oauth2 (1.0.0)
53
+ faraday (>= 0.8, < 0.10)
54
+ jwt (~> 1.0)
55
+ multi_json (~> 1.3)
56
+ multi_xml (~> 0.5)
57
+ rack (~> 1.2)
58
+ rack (1.6.0)
59
+ rake (10.4.2)
21
60
  rdoc (3.12.1)
22
61
  json (~> 1.4)
62
+ rspec (3.1.0)
63
+ rspec-core (~> 3.1.0)
64
+ rspec-expectations (~> 3.1.0)
65
+ rspec-mocks (~> 3.1.0)
66
+ rspec-core (3.1.7)
67
+ rspec-support (~> 3.1.0)
68
+ rspec-expectations (3.1.2)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.1.0)
71
+ rspec-mocks (3.1.3)
72
+ rspec-support (~> 3.1.0)
73
+ rspec-support (3.1.2)
74
+ symbolize (4.5.2)
75
+ activemodel (>= 3.2, < 5)
76
+ activesupport (>= 3.2, < 5)
77
+ i18n
78
+ thread_safe (0.3.4)
79
+ thread_safe (0.3.4-java)
80
+ tzinfo (0.3.42)
23
81
 
24
82
  PLATFORMS
83
+ java
25
84
  ruby
26
85
 
27
86
  DEPENDENCIES
28
- bundler
29
- debugger
30
- jeweler (~> 1.8.4)
31
- minitest
87
+ bundler (~> 1.6)
88
+ jeweler (~> 2.0)
32
89
  rdoc (~> 3.12)
90
+ rspec (~> 3.1)
91
+ symbolize (~> 4.2)
data/README.md CHANGED
@@ -11,17 +11,23 @@ This gem recursively converts all camelBack or CamelCase keys in a hash structur
11
11
  ## Usage
12
12
 
13
13
  ```ruby
14
+ gem 'plissken'
14
15
  my_hash = {"firstKey" => 1, "fooBars" => [{"bazBaz" => "value"}, {"blahBlah" => "value"}]}
15
16
  snaked_hash = my_hash.to_snake_keys
16
17
  # => {"first_key" => 1, "foo_bars" => [{"baz_baz" => "value"}, {"blah_blah" => "value"}]}
17
18
  ```
18
19
 
19
- Plissken works on either string keys or symbolized keys. It has no dependencies, as has its own `underscore` method lifted out of ActiveSupport.
20
+ Plissken works on either string keys or symbolized keys. It has no dependencies, as it has its own `underscore` method lifted out of ActiveSupport.
20
21
 
21
22
  ## Limitations
22
23
 
23
24
  * Your keys must be camelBack or CamelCase. The key "Foo Bar" will output as "foo bar".
24
- * Unlike the original Snake Plissken in the seminal film [Escape from New York](http://en.wikipedia.org/wiki/Escape_from_New_York), the plissken gem is non-destructive. There is no Hash#to_snake_keys! form.
25
+ * Unlike the original Snake Plissken in the seminal film [Escape from New York](http://en.wikipedia.org/wiki/Escape_from_New_York), the plissken gem is non-destructive. There is no `Hash#to_snake_keys!` form.
26
+
27
+ # Going the other way
28
+
29
+ If you've already got `snake_case` and need to `CamelCase` it, you are encouraged to try
30
+ the [Awrence](http://github.com/futurechimp/awrence) gem.
25
31
 
26
32
  ## Contributing to plissken
27
33
 
data/Rakefile CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new('spec')
7
+
5
8
  begin
6
9
  Bundler.setup(:default, :development)
7
10
  rescue Bundler::BundlerError => e
@@ -28,7 +31,7 @@ Jeweler::Tasks.new do |gem|
28
31
  structure to snake_case.
29
32
  }
30
33
  gem.email = "dave.hrycyszyn@headlondon.com"
31
- gem.authors = ["Dave Hrycyszyn"]
34
+ gem.authors = ["Dave Hrycyszyn", "Michael Chrisco"]
32
35
  # dependencies defined in Gemfile
33
36
  end
34
37
  Jeweler::RubygemsDotOrgTasks.new
@@ -40,7 +43,7 @@ Rake::TestTask.new(:test) do |test|
40
43
  test.verbose = true
41
44
  end
42
45
 
43
- task :default => :test
46
+ task :default => :spec
44
47
 
45
48
  require 'rdoc/task'
46
49
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -1,5 +1,4 @@
1
1
  class Hash
2
-
3
2
  # Recursively converts CamelCase and camelBack JSON-style hash keys to
4
3
  # Rubyish snake_case, suitable for use during instantiation of Ruby
5
4
  # model attributes.
@@ -9,7 +8,7 @@ class Hash
9
8
  when Array
10
9
  value.map { |v| to_snake_keys(v) }
11
10
  when Hash
12
- Hash[value.map { |k, v| [underscore_key(k), to_snake_keys(v)] }]
11
+ Hash[value.map { |k, v| [underscore_key(k).to_sym, to_snake_keys(v)] }]
13
12
  else
14
13
  value
15
14
  end
@@ -34,5 +33,5 @@ class Hash
34
33
  tr("-", "_").
35
34
  downcase
36
35
  end
37
-
38
- end
36
+ end
37
+
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: plissken 0.2.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "plissken"
8
- s.version = "0.1.0"
9
+ s.version = "0.2.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Dave Hrycyszyn"]
12
- s.date = "2013-02-19"
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Dave Hrycyszyn", "Michael Chrisco"]
14
+ s.date = "2014-12-31"
13
15
  s.description = "\n Have you ever needed to automatically convert JSON-style camelBack or\n CamelCase hash keys into more Rubyish snake_case?\n\n Plissken to the rescue.\n\n This gem recursively converts all camelBack or CamelCase keys in a hash\n structure to snake_case.\n "
14
16
  s.email = "dave.hrycyszyn@headlondon.com"
15
17
  s.extra_rdoc_files = [
@@ -18,6 +20,8 @@ Gem::Specification.new do |s|
18
20
  ]
19
21
  s.files = [
20
22
  ".document",
23
+ ".rspec",
24
+ ".rubocop.yml",
21
25
  "Gemfile",
22
26
  "Gemfile.lock",
23
27
  "LICENSE.txt",
@@ -27,38 +31,39 @@ Gem::Specification.new do |s|
27
31
  "lib/plissken.rb",
28
32
  "lib/plissken/ext/hash/to_snake_keys.rb",
29
33
  "plissken.gemspec",
34
+ "spec/lib/to_snake_keys_spec.rb",
35
+ "spec/spec_helper.rb",
30
36
  "test/helper.rb",
31
37
  "test/plissken/ext/hash/to_snake_keys_test.rb",
32
38
  "test/test_plissken.rb"
33
39
  ]
34
40
  s.homepage = "http://github.com/futurechimp/plissken"
35
41
  s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = "1.8.24"
42
+ s.rubygems_version = "2.2.2"
38
43
  s.summary = "Snakify your camel keys when working with JSON APIs"
39
44
 
40
45
  if s.respond_to? :specification_version then
41
- s.specification_version = 3
46
+ s.specification_version = 4
42
47
 
43
48
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_development_dependency(%q<debugger>, [">= 0"])
45
- s.add_development_dependency(%q<minitest>, [">= 0"])
49
+ s.add_runtime_dependency(%q<symbolize>, ["~> 4.2"])
50
+ s.add_development_dependency(%q<rspec>, ["~> 3.1"])
46
51
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
47
- s.add_development_dependency(%q<bundler>, [">= 0"])
48
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
52
+ s.add_development_dependency(%q<bundler>, ["~> 1.6"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
49
54
  else
50
- s.add_dependency(%q<debugger>, [">= 0"])
51
- s.add_dependency(%q<minitest>, [">= 0"])
55
+ s.add_dependency(%q<symbolize>, ["~> 4.2"])
56
+ s.add_dependency(%q<rspec>, ["~> 3.1"])
52
57
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
53
- s.add_dependency(%q<bundler>, [">= 0"])
54
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
59
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
55
60
  end
56
61
  else
57
- s.add_dependency(%q<debugger>, [">= 0"])
58
- s.add_dependency(%q<minitest>, [">= 0"])
62
+ s.add_dependency(%q<symbolize>, ["~> 4.2"])
63
+ s.add_dependency(%q<rspec>, ["~> 3.1"])
59
64
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
60
- s.add_dependency(%q<bundler>, [">= 0"])
61
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
66
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
62
67
  end
63
68
  end
64
69
 
@@ -0,0 +1,179 @@
1
+ require 'spec_helper'
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/plissken')
4
+
5
+ RSpec.describe 'A Hash' do
6
+ describe 'with camelBack keys' do
7
+ describe 'which are JSON-style strings' do
8
+ describe 'in the simplest case' do
9
+
10
+ let(:hash) { [{ 'firstKey' => 'fooBar' }] }
11
+
12
+ describe 'non-destructive snakification' do
13
+ let(:snaked) { hash.map(&:to_snake_keys) }
14
+ it 'snakifies the key' do
15
+ expect(snaked.first).to have_key(:first_key)
16
+ end
17
+
18
+ it 'leaves the key as a string' do
19
+ expect(snaked.first.keys).to eq([:first_key])
20
+ end
21
+
22
+ it 'leaves the value untouched' do
23
+ expect(hash.first.values).to eq(['fooBar'])
24
+ end
25
+
26
+ it 'leaves the original hash untouched' do
27
+ expect(hash.first.keys).to eq(['firstKey'])
28
+ end
29
+ end
30
+ end
31
+
32
+ describe 'containing an array of other hashes' do
33
+ let(:hash) do {
34
+ 'appleType' => 'Granny Smith',
35
+ 'vegetableTypes' => [
36
+ { 'potatoType' => 'Golden delicious' },
37
+ { 'otherTuberType' => 'peanut' },
38
+ { 'peanutNamesAndSpouses' => [
39
+ { 'billThePeanut' => 'sallyPeanut' },
40
+ { 'sammyThePeanut' => 'jillPeanut' }
41
+ ] }
42
+ ]}
43
+ end
44
+
45
+ describe 'non-destructive snakification' do
46
+ subject(:snaked) { hash.to_snake_keys }
47
+ #
48
+ it 'recursively snakifies the keys on the top level of the hash' do
49
+ expect(snaked.include?(:apple_type)).to be_truthy
50
+ expect(snaked.include?(:vegetable_types)).to be_truthy
51
+ end
52
+
53
+ it 'leaves the values on the top level alone' do
54
+ expect(snaked[:apple_type]).to eq('Granny Smith')
55
+ end
56
+
57
+ it 'converts second-level keys' do
58
+ expect(snaked[:vegetable_types].first)
59
+ .to have_key(:potato_type)
60
+ end
61
+
62
+ it 'leaves second-level values alone' do
63
+ expect(snaked[:vegetable_types].first)
64
+ .to have_value('Golden delicious')
65
+ end
66
+
67
+ it 'converts third-level keys' do
68
+ expect(snaked[:vegetable_types].last[:peanut_names_and_spouses]
69
+ .last).to have_value('jillPeanut')
70
+ expect(snaked[:vegetable_types]
71
+ .last[:peanut_names_and_spouses]
72
+ .last).to have_key(:sammy_the_peanut)
73
+ end
74
+
75
+ it 'leaves third-level values alone' do
76
+ expect(snaked[:vegetable_types]
77
+ .last[:peanut_names_and_spouses]
78
+ .first[:bill_the_peanut]).to eq('sallyPeanut')
79
+ expect(snaked[:vegetable_types]
80
+ .last[:peanut_names_and_spouses]
81
+ .last[:sammy_the_peanut]).to eq('jillPeanut')
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ describe 'which are symbols' do
88
+ describe 'in the simplest case' do
89
+ let(:hash) { { :firstKey => 'fooBar' } }
90
+
91
+
92
+ describe 'non-destructive snakification' do
93
+ subject(:snaked) { hash.to_snake_keys }
94
+
95
+ it 'snakifies the key' do
96
+ expect(snaked).to have_key(:first_key)
97
+ end
98
+
99
+ it 'leaves the key as a symbol' do
100
+ expect(:first_key).to eq(snaked.keys.first)
101
+ end
102
+
103
+ it 'leaves the value untouched' do
104
+ expect(snaked.values.first).to eq('fooBar')
105
+ end
106
+
107
+ it 'leaves the original hash untouched' do
108
+ expect(hash).to have_key(:firstKey)
109
+ end
110
+ end
111
+ end
112
+ #
113
+ describe 'containing an array of other hashes' do
114
+ let(:hash) do {
115
+ :appleType => 'Granny Smith',
116
+ :vegetableTypes => [
117
+ { :potatoType => 'Golden delicious' },
118
+ { :otherTuberType => 'peanut' },
119
+ { :peanutNamesAndSpouses => [
120
+ { :billThePeanut => 'sallyPeanut' },
121
+ { :sammyThePeanut => 'jillPeanut' }
122
+ ] }
123
+ ]}
124
+ end
125
+ #
126
+ describe 'non-destructive snakification' do
127
+ subject(:snaked) { hash.to_snake_keys }
128
+ #
129
+ it 'recursively snakifies the keys on the top level of the hash' do
130
+ expect(snaked.include?(:apple_type)).to be_truthy
131
+ expect(snaked.include?(:vegetable_types)).to be_truthy
132
+ end
133
+
134
+ it 'leaves the values on the top level alone' do
135
+ expect(snaked[:apple_type]).to eq('Granny Smith')
136
+ end
137
+
138
+ it 'converts second-level keys' do
139
+ expect(snaked[:vegetable_types].first)
140
+ .to have_key(:potato_type)
141
+ end
142
+
143
+ it 'leaves second-level values alone' do
144
+ expect(snaked[:vegetable_types].first)
145
+ .to have_value('Golden delicious')
146
+ end
147
+
148
+ it 'converts third-level keys' do
149
+ expect(snaked[:vegetable_types].last[:peanut_names_and_spouses]
150
+ .last).to have_value('jillPeanut')
151
+ expect(snaked[:vegetable_types]
152
+ .last[:peanut_names_and_spouses]
153
+ .last).to have_key(:sammy_the_peanut)
154
+ end
155
+
156
+ it 'leaves third-level values alone' do
157
+ expect(snaked[:vegetable_types]
158
+ .last[:peanut_names_and_spouses]
159
+ .first[:bill_the_peanut]).to eq('sallyPeanut')
160
+ expect(snaked[:vegetable_types]
161
+ .last[:peanut_names_and_spouses]
162
+ .last[:sammy_the_peanut]).to eq('jillPeanut')
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+
169
+ describe 'strings with spaces in them' do
170
+
171
+ let(:hash) { { 'With Spaces' => 'FooBar' } }
172
+ subject { hash.to_snake_keys }
173
+
174
+
175
+ it "doesn't get snaked, although it does get downcased" do
176
+ is_expected.to have_key(:'with spaces')
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,90 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper`
4
+ # which will cause this file to always be loaded,
5
+ # without a need to explicitly require it in any files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec
13
+ # files that actually need it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey
54
+ patched syntax that is recommended.
55
+ # For more details, see:
56
+
57
+ config.disable_monkey_patching!
58
+
59
+ # This setting enables warnings. It's recommended, but in some cases may
60
+ # be too noisy due to issues in dependencies.
61
+ config.warnings = true
62
+
63
+ # Many RSpec users commonly either run the entire suite or an individual
64
+ # file, and it's useful to allow more verbose output when running an
65
+ # individual spec file.
66
+ if config.files_to_run.one?
67
+ # Use the documentation formatter for detailed output,
68
+ # unless a formatter has already been configured
69
+ # (e.g. via a command-line flag).
70
+ config.default_formatter = 'doc'
71
+ end
72
+
73
+ # Print the 10 slowest examples and example groups at the
74
+ # end of the spec run, to help surface which specs are running
75
+ # particularly slow.
76
+ config.profile_examples = 10
77
+
78
+ # Run specs in random order to surface order dependencies. If you find an
79
+ # order dependency and want to debug it, you can fix the order by providing
80
+ # the seed, which is printed after each run.
81
+ # --seed 1234
82
+ config.order = :random
83
+
84
+ # Seed global randomization in this process using the `--seed` CLI option.
85
+ # Setting this allows you to use `--seed` to deterministically reproduce
86
+ # test failures related to randomization by passing the same `--seed` value
87
+ # as the one that triggered the failure.
88
+ Kernel.srand config.seed
89
+ =end
90
+ end
@@ -4,11 +4,11 @@ begin
4
4
  Bundler.setup(:default, :development)
5
5
  rescue Bundler::BundlerError => e
6
6
  $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
7
+ $stderr.puts 'Run `bundle install` to install missing gems'
8
8
  exit e.status_code
9
9
  end
10
10
  require 'minitest/spec'
11
- require 'debugger'
11
+ # require 'debugger'
12
12
 
13
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -1,170 +1,184 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../../test_plissken.rb')
2
2
 
3
- describe "A Hash" do
4
- describe "with camelBack keys" do
5
- describe "which are JSON-style strings" do
6
- describe "in the simplest case" do
3
+ describe 'A Hash' do
4
+ describe 'with camelBack keys' do
5
+ describe 'which are JSON-style strings' do
6
+ describe 'in the simplest case' do
7
7
  before do
8
- @hash = { "firstKey" => "fooBar" }
8
+ @hash = { 'firstKey' => 'fooBar' }
9
9
  end
10
10
 
11
- describe "non-destructive snakification" do
11
+ describe 'non-destructive snakification' do
12
12
  before do
13
13
  @snaked = @hash.to_snake_keys
14
14
  end
15
15
 
16
- it "snakifies the key" do
17
- assert_equal(@snaked.keys.first, "first_key")
16
+ it 'snakifies the key' do
17
+ assert_equal(@snaked.keys.first, 'first_key')
18
18
  end
19
19
 
20
- it "leaves the key as a string" do
21
- assert_equal("first_key", @snaked.keys.first)
20
+ it 'leaves the key as a string' do
21
+ assert_equal('first_key', @snaked.keys.first)
22
22
  end
23
23
 
24
- it "leaves the value untouched" do
25
- assert_equal(@snaked.values.first, "fooBar")
24
+ it 'leaves the value untouched' do
25
+ assert_equal(@snaked.values.first, 'fooBar')
26
26
  end
27
27
 
28
- it "leaves the original hash untouched" do
29
- assert_equal(@hash.keys.first, "firstKey")
28
+ it 'leaves the original hash untouched' do
29
+ assert_equal(@hash.keys.first, 'firstKey')
30
30
  end
31
31
  end
32
32
  end
33
33
 
34
- describe "containing an array of other hashes" do
34
+ describe 'containing an array of other hashes' do
35
35
  before do
36
36
  @hash = {
37
- "appleType" => "Granny Smith",
38
- "vegetableTypes" => [
39
- {"potatoType" => "Golden delicious"},
40
- {"otherTuberType" => "peanut"},
41
- {"peanutNamesAndSpouses" => [
42
- {"billThePeanut" => "sallyPeanut"}, {"sammyThePeanut" => "jillPeanut"}
43
- ]}
44
- ]}
37
+ 'appleType' => 'Granny Smith',
38
+ 'vegetableTypes' => [
39
+ { 'potatoType' => 'Golden delicious' },
40
+ { 'otherTuberType' => 'peanut' },
41
+ { 'peanutNamesAndSpouses' => [
42
+ { 'billThePeanut' => 'sallyPeanut' },
43
+ { 'sammyThePeanut' => 'jillPeanut' }
44
+ ] }
45
+ ] }
45
46
  end
46
47
 
47
- describe "non-destructive snakification" do
48
+ describe 'non-destructive snakification' do
48
49
  before do
49
50
  @snaked = @hash.to_snake_keys
50
51
  end
51
52
 
52
- it "recursively snakifies the keys on the top level of the hash" do
53
- assert @snaked.keys.include?("apple_type")
54
- assert @snaked.keys.include?("vegetable_types")
53
+ it 'recursively snakifies the keys on the top level of the hash' do
54
+ assert @snaked.keys.include?('apple_type')
55
+ assert @snaked.keys.include?('vegetable_types')
55
56
  end
56
57
 
57
- it "leaves the values on the top level alone" do
58
- assert_equal(@snaked["apple_type"], "Granny Smith")
58
+ it 'leaves the values on the top level alone' do
59
+ assert_equal(@snaked['apple_type'], 'Granny Smith')
59
60
  end
60
61
 
61
- it "converts second-level keys" do
62
- assert @snaked["vegetable_types"].first.has_key? "potato_type"
62
+ it 'converts second-level keys' do
63
+ assert @snaked['vegetable_types'].first.key? 'potato_type'
63
64
  end
64
65
 
65
- it "leaves second-level values alone" do
66
- assert @snaked["vegetable_types"].first.has_value? "Golden delicious"
66
+ it 'leaves second-level values alone' do
67
+ assert @snaked['vegetable_types'].first.value? 'Golden delicious'
67
68
  end
68
69
 
69
- it "converts third-level keys" do
70
- assert @snaked["vegetable_types"].last["peanut_names_and_spouses"].first.has_key?("bill_the_peanut")
71
- assert @snaked["vegetable_types"].last["peanut_names_and_spouses"].last.has_key?("sammy_the_peanut")
70
+ it 'converts third-level keys' do
71
+ assert @snaked['vegetable_types'].last['peanut_names_and_spouses']
72
+ .first.key?('bill_the_peanut')
73
+ assert @snaked['vegetable_types'].last['peanut_names_and_spouses']
74
+ .last.key?('sammy_the_peanut')
72
75
  end
73
76
 
74
- it "leaves third-level values alone" do
75
- assert_equal "sallyPeanut", @snaked["vegetable_types"].last["peanut_names_and_spouses"].first["bill_the_peanut"]
76
- assert_equal "jillPeanut", @snaked["vegetable_types"].last["peanut_names_and_spouses"].last["sammy_the_peanut"]
77
+ it 'leaves third-level values alone' do
78
+ assert_equal 'sallyPeanut', @snaked['vegetable_types']
79
+ .last['peanut_names_and_spouses']
80
+ .first['bill_the_peanut']
81
+ assert_equal 'jillPeanut', @snaked['vegetable_types']
82
+ .last['peanut_names_and_spouses']
83
+ .last['sammy_the_peanut']
77
84
  end
78
85
  end
79
86
  end
80
87
  end
81
88
 
82
- describe "which are symbols" do
83
- describe "in the simplest case" do
89
+ describe 'which are symbols' do
90
+ describe 'in the simplest case' do
84
91
  before do
85
- @hash = { :firstKey => "fooBar" }
92
+ @hash = { :firstKey => 'fooBar' }
86
93
  end
87
94
 
88
- describe "non-destructive snakification" do
95
+ describe 'non-destructive snakification' do
89
96
  before do
90
97
  @snaked = @hash.to_snake_keys
91
98
  end
92
99
 
93
- it "snakifies the key" do
100
+ it 'snakifies the key' do
94
101
  assert_equal(@snaked.keys.first, :first_key)
95
102
  end
96
103
 
97
- it "leaves the key as a symbol" do
104
+ it 'leaves the key as a symbol' do
98
105
  assert_equal(:first_key, @snaked.keys.first)
99
106
  end
100
107
 
101
- it "leaves the value untouched" do
102
- assert_equal(@snaked.values.first, "fooBar")
108
+ it 'leaves the value untouched' do
109
+ assert_equal(@snaked.values.first, 'fooBar')
103
110
  end
104
111
 
105
- it "leaves the original hash untouched" do
112
+ it 'leaves the original hash untouched' do
106
113
  assert_equal(@hash.keys.first, :firstKey)
107
114
  end
108
115
  end
109
116
  end
110
117
 
111
- describe "containing an array of other hashes" do
118
+ describe 'containing an array of other hashes' do
112
119
  before do
113
120
  @hash = {
114
- :appleType => "Granny Smith",
121
+ :appleType => 'Granny Smith',
115
122
  :vegetableTypes => [
116
- {:potatoType => "Golden delicious"},
117
- {:otherTuberType => "peanut"},
118
- {:peanutNamesAndSpouses => [
119
- {:billThePeanut => "sallyPeanut"}, {:sammyThePeanut => "jillPeanut"}
120
- ]}
121
- ]}
123
+ { :potatoType => 'Golden delicious' },
124
+ { :otherTuberType => 'peanut' },
125
+ { :peanutNamesAndSpouses => [
126
+ { :billThePeanut => 'sallyPeanut' },
127
+ { :sammyThePeanut => 'jillPeanut' }
128
+ ] }
129
+ ] }
122
130
  end
123
131
 
124
- describe "non-destructive snakification" do
132
+ describe 'non-destructive snakification' do
125
133
  before do
126
134
  @snaked = @hash.to_snake_keys
127
135
  end
128
136
 
129
- it "recursively snakifies the keys on the top level of the hash" do
137
+ it 'recursively snakifies the keys on the top level of the hash' do
130
138
  assert @snaked.keys.include?(:apple_type)
131
139
  assert @snaked.keys.include?(:vegetable_types)
132
140
  end
133
141
 
134
- it "leaves the values on the top level alone" do
135
- assert_equal(@snaked[:apple_type], "Granny Smith")
142
+ it 'leaves the values on the top level alone' do
143
+ assert_equal(@snaked[:apple_type], 'Granny Smith')
136
144
  end
137
145
 
138
- it "converts second-level keys" do
139
- assert @snaked[:vegetable_types].first.has_key? :potato_type
146
+ it 'converts second-level keys' do
147
+ assert @snaked[:vegetable_types].first.key? :potato_type
140
148
  end
141
149
 
142
- it "leaves second-level values alone" do
143
- assert @snaked[:vegetable_types].first.has_value? "Golden delicious"
150
+ it 'leaves second-level values alone' do
151
+ assert @snaked[:vegetable_types].first.value? 'Golden delicious'
144
152
  end
145
153
 
146
- it "converts third-level keys" do
147
- assert @snaked[:vegetable_types].last[:peanut_names_and_spouses].first.has_key?(:bill_the_peanut)
148
- assert @snaked[:vegetable_types].last[:peanut_names_and_spouses].last.has_key?(:sammy_the_peanut)
154
+ it 'converts third-level keys' do
155
+ assert @snaked[:vegetable_types].last[:peanut_names_and_spouses]
156
+ .first.key?(:bill_the_peanut)
157
+ assert @snaked[:vegetable_types].last[:peanut_names_and_spouses]
158
+ .last.key?(:sammy_the_peanut)
149
159
  end
150
160
 
151
- it "leaves third-level values alone" do
152
- assert_equal "sallyPeanut", @snaked[:vegetable_types].last[:peanut_names_and_spouses].first[:bill_the_peanut]
153
- assert_equal "jillPeanut", @snaked[:vegetable_types].last[:peanut_names_and_spouses].last[:sammy_the_peanut]
161
+ it 'leaves third-level values alone' do
162
+ assert_equal 'sallyPeanut', @snaked[:vegetable_types]
163
+ .last[:peanut_names_and_spouses]
164
+ .first[:bill_the_peanut]
165
+ assert_equal 'jillPeanut', @snaked[:vegetable_types]
166
+ .last[:peanut_names_and_spouses]
167
+ .last[:sammy_the_peanut]
154
168
  end
155
169
  end
156
170
  end
157
171
  end
158
172
  end
159
173
 
160
- describe "strings with spaces in them" do
174
+ describe 'strings with spaces in them' do
161
175
  before do
162
- @hash = { "With Spaces" => "FooBar"}
176
+ @hash = { 'With Spaces' => 'FooBar' }
163
177
  @snaked = @hash.to_snake_keys
164
178
  end
165
179
 
166
180
  it "doesn't get snaked, although it does get downcased" do
167
- assert @snaked.keys.include? "with spaces"
181
+ assert @snaked.keys.include? 'with spaces'
168
182
  end
169
183
  end
170
- end
184
+ end
@@ -1,2 +1,2 @@
1
1
  require 'helper'
2
- require File.dirname(__FILE__) + '/../lib/plissken/ext/hash/to_snake_keys'
2
+ require File.dirname(__FILE__) + '/../lib/plissken/ext/hash/to_snake_keys'
metadata CHANGED
@@ -1,97 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plissken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dave Hrycyszyn
8
+ - Michael Chrisco
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-19 00:00:00.000000000 Z
12
+ date: 2014-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: debugger
15
+ name: symbolize
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ! '>='
18
+ - - "~>"
20
19
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
20
+ version: '4.2'
21
+ type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ! '>='
25
+ - - "~>"
28
26
  - !ruby/object:Gem::Version
29
- version: '0'
27
+ version: '4.2'
30
28
  - !ruby/object:Gem::Dependency
31
- name: minitest
29
+ name: rspec
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ! '>='
32
+ - - "~>"
36
33
  - !ruby/object:Gem::Version
37
- version: '0'
34
+ version: '3.1'
38
35
  type: :development
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
- - - ! '>='
39
+ - - "~>"
44
40
  - !ruby/object:Gem::Version
45
- version: '0'
41
+ version: '3.1'
46
42
  - !ruby/object:Gem::Dependency
47
43
  name: rdoc
48
44
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ~>
46
+ - - "~>"
52
47
  - !ruby/object:Gem::Version
53
48
  version: '3.12'
54
49
  type: :development
55
50
  prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
- - - ~>
53
+ - - "~>"
60
54
  - !ruby/object:Gem::Version
61
55
  version: '3.12'
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: bundler
64
58
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
59
  requirements:
67
- - - ! '>='
60
+ - - "~>"
68
61
  - !ruby/object:Gem::Version
69
- version: '0'
62
+ version: '1.6'
70
63
  type: :development
71
64
  prerelease: false
72
65
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
- - - ! '>='
67
+ - - "~>"
76
68
  - !ruby/object:Gem::Version
77
- version: '0'
69
+ version: '1.6'
78
70
  - !ruby/object:Gem::Dependency
79
71
  name: jeweler
80
72
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
73
  requirements:
83
- - - ~>
74
+ - - "~>"
84
75
  - !ruby/object:Gem::Version
85
- version: 1.8.4
76
+ version: '2.0'
86
77
  type: :development
87
78
  prerelease: false
88
79
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
80
  requirements:
91
- - - ~>
81
+ - - "~>"
92
82
  - !ruby/object:Gem::Version
93
- version: 1.8.4
94
- description: ! "\n Have you ever needed to automatically convert JSON-style camelBack
83
+ version: '2.0'
84
+ description: "\n Have you ever needed to automatically convert JSON-style camelBack
95
85
  or\n CamelCase hash keys into more Rubyish snake_case?\n\n Plissken to the
96
86
  rescue.\n\n This gem recursively converts all camelBack or CamelCase keys in
97
87
  a hash\n structure to snake_case.\n "
@@ -102,7 +92,9 @@ extra_rdoc_files:
102
92
  - LICENSE.txt
103
93
  - README.md
104
94
  files:
105
- - .document
95
+ - ".document"
96
+ - ".rspec"
97
+ - ".rubocop.yml"
106
98
  - Gemfile
107
99
  - Gemfile.lock
108
100
  - LICENSE.txt
@@ -112,35 +104,33 @@ files:
112
104
  - lib/plissken.rb
113
105
  - lib/plissken/ext/hash/to_snake_keys.rb
114
106
  - plissken.gemspec
107
+ - spec/lib/to_snake_keys_spec.rb
108
+ - spec/spec_helper.rb
115
109
  - test/helper.rb
116
110
  - test/plissken/ext/hash/to_snake_keys_test.rb
117
111
  - test/test_plissken.rb
118
112
  homepage: http://github.com/futurechimp/plissken
119
113
  licenses:
120
114
  - MIT
115
+ metadata: {}
121
116
  post_install_message:
122
117
  rdoc_options: []
123
118
  require_paths:
124
119
  - lib
125
120
  required_ruby_version: !ruby/object:Gem::Requirement
126
- none: false
127
121
  requirements:
128
- - - ! '>='
122
+ - - ">="
129
123
  - !ruby/object:Gem::Version
130
124
  version: '0'
131
- segments:
132
- - 0
133
- hash: 4152380818208412704
134
125
  required_rubygems_version: !ruby/object:Gem::Requirement
135
- none: false
136
126
  requirements:
137
- - - ! '>='
127
+ - - ">="
138
128
  - !ruby/object:Gem::Version
139
129
  version: '0'
140
130
  requirements: []
141
131
  rubyforge_project:
142
- rubygems_version: 1.8.24
132
+ rubygems_version: 2.2.2
143
133
  signing_key:
144
- specification_version: 3
134
+ specification_version: 4
145
135
  summary: Snakify your camel keys when working with JSON APIs
146
136
  test_files: []