camel_snake 0.9.1

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: 54ebfd9d79f3d595406f5636a8e6a41b4762a085
4
+ data.tar.gz: 613413c9f93a8e810468fc590aa041f2a6263540
5
+ SHA512:
6
+ metadata.gz: 017dbdf8970313f3855d44caa92e5c98fd776a06fb224b02bfb104ce9f864d131c0ef7818a5368cd544c3eed28937fea489b8b07df7d677632a2b820a9b67f69
7
+ data.tar.gz: 6f19ba8f9d85eb76a6705441743a59345a09611ea6ecfd7c5bbd0b449b9680467e558ac5702154a1f0b0373c8d1981d340f5a181703c50933f399c9e19056a01
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.8
6
+ - 2.2.0
7
+ before_install: gem install bundler -v 1.11.2
8
+ notifications:
9
+ slack:
10
+ secure: xlgfthYwPca7j+s5bFjOdl28ENCkohq/k+l/7tsx4Ag4vIIaa4Nn7KXVwIiHpMHB5dp574Jfqwd83+uizFfgbL7CevDddKtsLjrNAXaWTR6gTNU3EdOO7177hEEMpGRX6yzAA5G/eh5UdCYVscB0uvFiIhRfo84T5jQTEMTm3niuY1hZf5/Li1xGXQsD2Feu/nUlQZC2v+Dnhz3kpSLZUDQfNrMWBZJecFTcSK3fAEC84y1TOA9r4JK7wk7kl/Qf/JrbX9t14m47hJ4GURF7bhtZwwC7UFHEtNvFOHRU106MnYMyqcD4ZbQP5ASi0mEw3lR8Bo/+WSgWhtXQB4WwW4lLXozE69ayKSwNrxn3SBnkHQhg0CwWn1vddsn1lEGep+CaqmeB3/XYF6LvSJPABUbQrdof5K6qYUeOnVMB4CWvl8nEWUk9xmqKYsR1aUCvEfLEL83Ix+c05whmLyFuAkIggHxS9DRAT/Apv/ryHyz+zSJ/LGPfz36x5XO/fqzVfFBtCQL459xUkDfIJg2Th9Oy/UjL036V0fwnlc+c+HOGiUYvFMB6atjDTtHsqGKv3mSEpF775q1laClsptkTVuIFW1okfMvNi7K7OgdKWHD40d/ayVCIaacoWqasAo9TQcMIj2Fo0wenRa92qxa73SzD5yovEPmNqX6COEuHv9Y=
@@ -0,0 +1,9 @@
1
+ ## 0.9.1 (2016/4/10)
2
+
3
+ Bug Fix:
4
+
5
+ - Method `#to_camel` was calling wrong method when capitalize first letter.
6
+
7
+ ## 0.9.0 (2016/4/4)
8
+
9
+ Initial release.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in camel_snake.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 YASUTAKE Kiyoshi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # camel\_snake
2
+ [![Gem Version](https://badge.fury.io/rb/camel_snake.svg)](https://badge.fury.io/rb/camel_snake)
3
+ [![Build Status](https://travis-ci.org/key-amb/ruby-camel_snake.svg?branch=master)](https://travis-ci.org/key-amb/ruby-camel_snake)
4
+
5
+ This package provides a Mix-in module which extends String class and adds features
6
+ to convert itself into _CamelCase_ or *snake\_case*.
7
+
8
+ ## Usage
9
+
10
+ ```ruby
11
+ require 'camel_snake'
12
+
13
+ "FooBar".extend(CamelSnake).to_snake #=> "foo_bar"
14
+ "bar_baz".extend(CamelSnake).to_camel #=> "BarBaz"
15
+
16
+ # Or you can do bellow
17
+ String.include CamelSnake
18
+
19
+ "FooBar".to_snake #=> "foo_bar"
20
+ "bar_baz".to_camel #=> "BarBaz"
21
+ ```
22
+
23
+ ## Installation
24
+
25
+ Add this line to your application's Gemfile:
26
+
27
+ ```ruby
28
+ gem 'camel_snake'
29
+ ```
30
+
31
+ And then run `bundle` command on your terminal.
32
+
33
+ Or install it yourself as:
34
+
35
+ ```
36
+ $ gem install camel_snake
37
+ ```
38
+
39
+ ## Motivation
40
+
41
+ I know there are a lot of packages which provide similar features including
42
+ ActiveSupport in Rails.
43
+ But I want a minimul package which gives only these two conversion functions
44
+ out of Rails.
45
+
46
+ With [refinements](http://ruby-doc.org/core-2.3.0/doc/syntax/refinements_rdoc.html),
47
+ Ruby's recent feature, we can safely extend classes.
48
+ Jan Lelis's [sugar_refinery](https://rubygems.org/gems/sugar_refinery) uses this
49
+ feature. But it is not usable in older Ruby versions.
50
+
51
+ This module is simple and hopefully usable in many Ruby versions.
52
+ And it meets my needs.
53
+
54
+ ## See Also
55
+
56
+ - [sugar_refinery](https://rubygems.org/gems/sugar_refinery)
57
+ - [string-cases](https://rubygems.org/gems/string-cases)
58
+
59
+ ## Contribution
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new [Pull Request](../../pull/new/master)
66
+
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
70
+
71
+ Copyright (c) 2016 YASUTAKE Kiyoshi
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+ task :default => :spec
9
+
10
+ desc 'Open an irb session preloaded with the gem library'
11
+ task :console do
12
+ sh 'irb -rubygems -I lib -r camel_snake'
13
+ end
14
+ task :c => :console
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'camel_snake/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "camel_snake"
8
+ spec.version = CamelSnake::VERSION
9
+ spec.authors = ["YASUTAKE Kiyoshi"]
10
+ spec.email = ["yasutake.kiyoshi@gmail.com"]
11
+
12
+ spec.summary = %q{Mix-in for String to convert CamelCase and snake_case.}
13
+ spec.description = %q{Mix-in module for String class which enables to convert CamelCase and snake_case}
14
+ spec.homepage = "https://github.com/key-amb/ruby-camel_snake"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.11"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+ end
@@ -0,0 +1,25 @@
1
+ require "camel_snake/version"
2
+
3
+ # Mix-in for String to convert CamelCase and snake_case.
4
+ module CamelSnake
5
+
6
+ # @return [String] PascalStyle string
7
+ def to_pascal
8
+ gsub(/(?:\b|_)([a-z])/) { $1.upcase }
9
+ end
10
+
11
+ # @param firstletter [Symbol] flag to capitalize first letter or not
12
+ # @return [String] CamelCase or camelCase string
13
+ def to_camel firstletter=:capital
14
+ if firstletter == :capital
15
+ to_pascal
16
+ else
17
+ gsub(/_([a-z])/) { $1.upcase }
18
+ end
19
+ end
20
+
21
+ # @return [String] snake_case string
22
+ def to_snake
23
+ gsub(/\b([A-Z]+)/) { $1.downcase }.gsub(/(.)([A-Z]+)/, '\1_\2').downcase
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module CamelSnake
2
+ VERSION = "0.9.1"
3
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: camel_snake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - YASUTAKE Kiyoshi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-09 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Mix-in module for String class which enables to convert CamelCase and
56
+ snake_case
57
+ email:
58
+ - yasutake.kiyoshi@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CHANGELOG.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - camel_snake.gemspec
72
+ - lib/camel_snake.rb
73
+ - lib/camel_snake/version.rb
74
+ homepage: https://github.com/key-amb/ruby-camel_snake
75
+ licenses:
76
+ - MIT
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.5.1
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Mix-in for String to convert CamelCase and snake_case.
98
+ test_files: []