creative_rails_utilities 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e70cd283fffd7f7397b943573fab75b9b9c55394
4
+ data.tar.gz: 57586083f99e9ff364ca15ebc5227e09b87659b3
5
+ SHA512:
6
+ metadata.gz: fd689e06491a867f35f2f402410e0bec5936907277ab93fd4e7c0e7353fcc5c34f5c521a7f304782a4971c61af8abd1bbf113aee57f5475f2f264d9f362da2a0
7
+ data.tar.gz: ecfa4dfbb28e9a3e3ede00984ab8c5fb097a84272b3e6e0f7c5200ba58bd196e49dfbaad3795390e7360dc67f89fd19869472778329e95b08ffd101a4bafc530
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Release candidate][ - - ]
6
+ ### Changed
7
+ -
8
+
9
+ ## [0.1.0] - 2015-10-16
10
+ ### Added
11
+ - Initial release with basic functionality described in README
12
+ ### Changed
13
+ - Nothing
14
+ ### Fixed
15
+ - Nothing
16
+ ### Removed
17
+ - Nothing
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in creative_rails_utilities.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Creative
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,45 @@
1
+ # CreativeRailsUtilities
2
+
3
+ Defines extensions, useful and convenient methods on Ruby and Rails base classes.
4
+
5
+ ## Installation
6
+
7
+ `gem 'creative_rails_utilities'` and `bundle`
8
+
9
+ ## Usage
10
+
11
+ Feel free to read the source under `/lib/creative_rails_utilities/`
12
+
13
+ ##### Numeric
14
+
15
+ ```ruby
16
+ # integer into letters
17
+ 1.to_s26 #=> "a"
18
+ 28.to_s26 #=> "ab"
19
+ ```
20
+
21
+ ##### String
22
+
23
+ ```ruby
24
+ # letters into integer
25
+ "z".to_i26 #=> 26
26
+ "apple".to_i26 #=> 749325
27
+ ```
28
+
29
+ ## Development
30
+
31
+ 1. Write specs
32
+ 2. Make specs fail
33
+ 3. Write feature
34
+ 4. Make tests pass
35
+ 5. Update README.md with examples
36
+ 6. Update CHANGELOG.md with changes/fixes/additions.
37
+ 7. Bump version and `rake release`
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/CreativePublisher/rails_utilities)
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "creative_rails_utilities"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'creative_rails_utilities/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "creative_rails_utilities"
8
+ spec.version = CreativeRailsUtilities::VERSION
9
+ spec.authors = ["Creative"]
10
+ spec.email = ["hi@creative.gs"]
11
+
12
+ spec.summary = %q|Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails base classes|
13
+ spec.description = %q|Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails base classes|
14
+ spec.homepage = "https://github.com/CreativePublisher/rails_utilities"
15
+ spec.license = "MIT"
16
+ spec.date = Date.today.to_s
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,7 @@
1
+ require "creative_rails_utilities/numeric"
2
+ require "creative_rails_utilities/string"
3
+ require "creative_rails_utilities/version"
4
+
5
+ module CreativeRailsUtilities
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,17 @@
1
+ class Numeric
2
+
3
+ Alpha26 = ("a".."z").to_a
4
+
5
+ def to_s26
6
+ return "" if self < 1
7
+
8
+ s, q = "", self
9
+ loop do
10
+ q, r = (q - 1).divmod(26)
11
+ s.prepend(Alpha26[r])
12
+ break if q.zero?
13
+ end
14
+ s
15
+ end
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+ class String
2
+
3
+ Alpha26 = ("a".."z").to_a
4
+
5
+ def to_i26
6
+ result = 0
7
+ downcase!
8
+ (1..length).each do |i|
9
+ char = self[-i]
10
+ result += 26**(i-1) * (Alpha26.index(char) + 1)
11
+ end
12
+ result
13
+ end
14
+
15
+ end
@@ -0,0 +1,3 @@
1
+ module CreativeRailsUtilities
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: creative_rails_utilities
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Creative
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-16 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails
56
+ base classes
57
+ email:
58
+ - hi@creative.gs
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
+ - bin/console
72
+ - bin/setup
73
+ - creative_rails_utilities.gemspec
74
+ - lib/creative_rails_utilities.rb
75
+ - lib/creative_rails_utilities/numeric.rb
76
+ - lib/creative_rails_utilities/string.rb
77
+ - lib/creative_rails_utilities/version.rb
78
+ homepage: https://github.com/CreativePublisher/rails_utilities
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.4.8
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails base
102
+ classes
103
+ test_files: []