core_augmentations 0.0.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: 39894b68545032f569e10049ef6a33ab68f4cdc9
4
+ data.tar.gz: 5f752fa1c5f441d0c87f8661a737a8ef4c8943d0
5
+ SHA512:
6
+ metadata.gz: 3e3cbd00b0b18a061d4a95c88a0ba2e9a4d5db59644e079e20ea9468c43493c6251cb6ae95f3733b781e8dd93a47bd22c46f4a67f3d513ac47c57fcec3399d8c
7
+ data.tar.gz: c5f3fede02adec87b7e29c1364ec59073781d1c14b8beae117731dbeadec05e65118584a7ba3d93424be8422d762d88fd802ea2ee2feb7b3161cd53364003e60
@@ -0,0 +1,24 @@
1
+ .idea
2
+
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ *.bundle
21
+ *.so
22
+ *.o
23
+ *.a
24
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in core_augmentations.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ernie Brodeur
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # CoreAugmentations
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'core_augmentations'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install core_augmentations
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/core_augmentations/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -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 'core_augmentations/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "core_augmentations"
8
+ spec.version = CoreAugmentations::VERSION
9
+ spec.authors = ["Ernie Brodeur"]
10
+ spec.email = ["ebrodeur@ujami.net"]
11
+ spec.summary = "Methods to augment the core classes in ruby."
12
+ spec.description = "A collection of methods that can be used to extend the basic ruby classes."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
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.6"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,14 @@
1
+ class Array
2
+ def index_by(position)
3
+ index = {}
4
+ self.each do |entry|
5
+ if entry.kind_of?(Array) || entry.kind_of?(Hash)
6
+ raise "No Entry: #{position} in entry." unless entry[position]
7
+ raise "Duplicate Index: #{entry[position]}" if index[entry[position]]
8
+ index[entry[position]] = entry
9
+ end
10
+ end
11
+
12
+ return index
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ class Numeric
2
+ # return the percentage of a number, rounded to 2 places by default.
3
+ def percentage_of(n, round = 2)
4
+ return (self.to_f / n.to_f * 100.0).round(round)
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ class String
2
+ # take a CamelCase or under_scored string and convert it to a human readable string (useful for output).
3
+ def to_human
4
+ return self.split("_").map {|word| word[0] + word[1..-1]}.join(" ").capitalize if self.include?("_")
5
+
6
+ return self.split(/(?=[A-Z])/).join(" ").capitalize
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module CoreAugmentations
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: core_augmentations
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ernie Brodeur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-26 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A collection of methods that can be used to extend the basic ruby classes.
42
+ email:
43
+ - ebrodeur@ujami.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - core_augmentations.gemspec
54
+ - lib/core_augmentations/Array/index_by.rb
55
+ - lib/core_augmentations/Numeric/percentage_of.rb
56
+ - lib/core_augmentations/String/to_human.rb
57
+ - lib/core_augmentations/version.rb
58
+ - spec/lib/core_extensions/Array/index_by_spec.rb
59
+ - spec/lib/core_extensions/Numeric/percentage_of_spec.rb
60
+ - spec/lib/core_extensions/String/to_human_spec.rb
61
+ homepage: ''
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.0.14
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Methods to augment the core classes in ruby.
85
+ test_files:
86
+ - spec/lib/core_extensions/Array/index_by_spec.rb
87
+ - spec/lib/core_extensions/Numeric/percentage_of_spec.rb
88
+ - spec/lib/core_extensions/String/to_human_spec.rb