coffee_enhancer 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57edec0e1d1e4eadfdec61343f329cb79366b61c
4
+ data.tar.gz: 53f8462cc18adae4fcce00ff08f8421df424d579
5
+ SHA512:
6
+ metadata.gz: 280b08c79641133d7d8d336c811ea853011654a2e975f2d89426ab2829346cf4985b9a24fa61d00a81c2f6c713b8dd468cd3abdf0e003485c505bd920840bec2
7
+ data.tar.gz: 956be4c455591ece63badcd5e1463c02d8dfb833876ae327c3b651357933683a45fbcdd8079ed79f3a5d09a55660eec7064cf9f9bd3eb5c02eddaea97f3a88f7
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at TODO: Write your email address. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in coffee_enhancer.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ coffeescript_options = {
2
+ input: 'spec',
3
+ output: 'public/javascripts/compiled_specs',
4
+ patterns: [%r{^spec/(.+\.(?:coffee|coffee\.md|litcoffee))$}]
5
+ }
6
+
7
+ guard 'coffeescript', coffeescript_options do
8
+ coffeescript_options[:patterns].each { |pattern| watch(pattern) }
9
+ end
10
+
11
+ coffeescript_options = {
12
+ input: 'lib/assets/javascripts',
13
+ output: 'public/javascripts/compiled_src',
14
+ patterns: [%r{^lib/assets/javascripts/(.+\.(?:coffee|coffee\.md|litcoffee))$}]
15
+ }
16
+
17
+ guard 'coffeescript', coffeescript_options do
18
+ coffeescript_options[:patterns].each { |pattern| watch(pattern) }
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Daniel Fugere
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.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # CoffeeEnhancer
2
+
3
+ A gem to make coffeescript even more fun to use.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'coffee_enhancer'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install coffee_enhancer
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/coffee_enhancer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
35
+
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
41
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
11
+ require 'jasmine'
12
+ load 'jasmine/tasks/jasmine.rake'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coffee_enhancer"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'coffee_enhancer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "coffee_enhancer"
8
+ spec.version = CoffeeEnhancer::VERSION
9
+ spec.authors = ["Daniel Fugere"]
10
+ spec.email = ["danielfugere28@gmail.com"]
11
+
12
+ spec.summary = %q{A simple package that emhances the amazing experience that is of using coffeescript.}
13
+ spec.description = %q{A simple package that emhances the amazing experience that is of using coffeescript.}
14
+ spec.homepage = "https://github.com/dafuga/coffee_enhancer"
15
+ spec.license = "MIT"
16
+
17
+ spec.add_dependency 'coffee-script', '~> 2.4'
18
+ spec.add_dependency 'jasmine', '~> 2.4'
19
+ spec.add_dependency 'guard', '~> 2.13'
20
+ spec.add_dependency 'guard-coffeescript', '~> 2.0'
21
+
22
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
23
+ # delete this section to allow pushing this gem to any host.
24
+ if spec.respond_to?(:metadata)
25
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
26
+ else
27
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
28
+ end
29
+
30
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.11"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "minitest", "~> 5.0"
38
+ end
Binary file
@@ -0,0 +1,11 @@
1
+ ## Checks if array or string element is present
2
+ Array::present = ->
3
+ @.length > 0
4
+
5
+ ## Checks if array element is empty
6
+ Array::empty = ->
7
+ @.length == 0
8
+
9
+ ## Checks if array element is empty
10
+ Array::any = ->
11
+ @.present()
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,62 @@
1
+ monthNames = [
2
+ "January", "February", "March",
3
+ "April", "May", "June", "July",
4
+ "August", "September", "October",
5
+ "November", "December"
6
+ ]
7
+
8
+ year_in_seconds = 31536000
9
+ month_in_seconds = 2420000
10
+ week_in_seconds = 604800
11
+ day_in_seconds = 86400
12
+ hour_in_seconds = 3600
13
+ minute_in_seconds = 60
14
+
15
+ ## Formats time to 12 hour clock time
16
+ Date::formatted_time_with_pm = ->
17
+ hour = @getHours()
18
+ minute = @getMinutes()
19
+ prepand = if hour >= 12 then 'p.m.' else 'a.m.'
20
+ hour = if hour >= 12 then hour - 12 else hour
21
+ "#{hour}:#{minute} #{prepand}"
22
+
23
+ ## Formats time to 24 hour clock time
24
+ Date::formatted_time = ->
25
+ hour = @getHours()
26
+ minute = @getMinutes()
27
+ "#{hour}:#{minute}"
28
+
29
+ ## Formats date to 24 hour clock time
30
+ Date::formatted_date = ->
31
+ day = @getDate()
32
+ monthIndex = @getMonth()
33
+ year = @getFullYear()
34
+ "#{monthNames[monthIndex]} #{day}, #{year}"
35
+
36
+ ## Gives a string with time since timestamp
37
+ Date::time_ago_in_words = ->
38
+ time_now = new Date()
39
+ seconds = Math.floor((time_now - @) / 1000)
40
+ if seconds > 2*year_in_seconds
41
+ "over #{Math.floor(seconds/year_in_seconds)} years ago"
42
+ else if seconds > year_in_seconds + month_in_seconds
43
+ "over a year ago"
44
+ else if seconds > year_in_seconds - month_in_seconds
45
+ "about a year ago"
46
+ else if seconds > 2*month_in_seconds
47
+ "over #{Math.floor(seconds/month_in_seconds)} months ago"
48
+ else if seconds > 2*week_in_seconds
49
+ "about #{Math.floor(seconds/week_in_seconds)} weeks ago"
50
+ else if seconds > 2*day_in_seconds
51
+ "about #{Math.floor(seconds/day_in_seconds)} days ago"
52
+ else if seconds > 2*hour_in_seconds - 20*minute_in_seconds
53
+ "about #{Math.floor(seconds/hour_in_seconds)} hours ago"
54
+ else if seconds > day_in_seconds - 10*minute_in_seconds
55
+ "about an hour ago"
56
+ else if seconds > minute_in_seconds + 30
57
+ "about #{Math.floor(seconds/minute_in_seconds)} minutes ago"
58
+ else if seconds > minute_in_seconds - 1
59
+ "about #{Math.floor(seconds/minute_in_seconds)} minutes ago"
60
+ else if seconds > 0
61
+ "less than a minute ago"
62
+ else "hasn't occured yet"
@@ -0,0 +1,19 @@
1
+ # Method that checks if a certain variable is undefined or null
2
+ window.non_existent = (variable) ->
3
+ variable == undefined || variable == null
4
+
5
+ # Method that checks if a certain variable is defined and not null
6
+ window.exists = (variable) ->
7
+ not non_existent(variable)
8
+
9
+ # Method that checks if a certain variable is defined
10
+ window.defined = (variable) ->
11
+ variable != undefined
12
+
13
+ # Method that checks if a certain variable is undefined
14
+ window.not_defined = (variable) ->
15
+ variable == undefined
16
+
17
+ # Method that checks if a certain variable is loaded (used in ReactJs mostly)
18
+ window.loaded = (variable) ->
19
+ defined(variable)
@@ -0,0 +1,27 @@
1
+ ## Checks if number is positive or equal to zero
2
+ Number::is_positive = ->
3
+ @ >= 0
4
+
5
+ ## Checks if number is equal to zero
6
+ Number::is_zero = ->
7
+ -0.00000000001 <= @ <= 0.00000000001
8
+
9
+ ## Checks if number is smaller or equal to zero
10
+ Number::is_negative = ->
11
+ @ <= 0
12
+
13
+ ## Converts to currency
14
+ Number::to_currency = ->
15
+ @.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
16
+
17
+ ## Converts to string
18
+ Number::to_s = ->
19
+ @.toString()
20
+
21
+ ## Converts to integer
22
+ Number::to_i = ->
23
+ parseInt(@)
24
+
25
+ ## Converts to float
26
+ Number::to_f = ->
27
+ parseFloat(@)
@@ -0,0 +1,31 @@
1
+ ## Checks if string element is blank
2
+ String::blank = ->
3
+ not @.replace(/^\s+|\s+|\n+$/g, '')?.length
4
+
5
+ String::empty = ->
6
+ not @.replace(/^\s+|\s+|\n+$/g, '')?.length
7
+
8
+ String::present = ->
9
+ not not @.replace(/^\s+|\s+|\n+$/g, '')?.length
10
+
11
+ ## Converts to integer
12
+ String::to_i = ->
13
+ parseInt(@)
14
+
15
+ ## Converts to float
16
+ String::to_f = ->
17
+ parseFloat(@)
18
+
19
+ ## Converts the first character of string to uppercase
20
+ String::capitalize = ->
21
+ "#{@.charAt(0).toUpperCase()}#{@.substr(1)}"
22
+
23
+ String::trim = ->
24
+ @.replace /^\s+|\s+$/g, ''
25
+
26
+ ## Converts the first character of each word to uppercase
27
+ String::titleize = ->
28
+ title = ''
29
+ for word in @.toLowerCase().split(' ')
30
+ title += "#{word.capitalize()} "
31
+ title.trim()
@@ -0,0 +1,6 @@
1
+ require "coffee_enhancer/version"
2
+ require "coffee_enhancer/engine"
3
+
4
+ module CoffeeEnhancer
5
+
6
+ end
@@ -0,0 +1,4 @@
1
+ module CoffeeEnhancer
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module CoffeeEnhancer
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,16 @@
1
+ (function() {
2
+ describe('Array', function() {
3
+ var empty_array, filled_array;
4
+ filled_array = [1, 2, 3, 4];
5
+ empty_array = [];
6
+ it('should respond correctly to empty', function() {
7
+ expect(filled_array.empty()).toBe(false);
8
+ return expect(empty_array.empty()).toBe(true);
9
+ });
10
+ return it('should respond correctly to present', function() {
11
+ expect(filled_array.present()).toBe(true);
12
+ return expect(empty_array.present()).toBe(false);
13
+ });
14
+ });
15
+
16
+ }).call(this);
@@ -0,0 +1,31 @@
1
+ (function() {
2
+ describe('Datetime', function() {
3
+ var a_year_ago, that_morning, three_minutes_ago, three_months_ago, three_months_ago_then, time_then;
4
+ three_months_ago = new Date();
5
+ three_months_ago.setMonth(three_months_ago.getMonth() - 3);
6
+ a_year_ago = new Date();
7
+ a_year_ago.setYear(a_year_ago.getFullYear() - 1);
8
+ three_minutes_ago = new Date();
9
+ three_minutes_ago.setMinutes(three_minutes_ago.getMinutes() - 3);
10
+ time_then = new Date(2016, 4, 12, 19, 15);
11
+ that_morning = new Date(2016, 4, 12, 7, 15);
12
+ three_months_ago_then = new Date(2016, 1, 12, 7, 15);
13
+ it('should time_then correctly to formatted_time_with_pm', function() {
14
+ expect(time_then.formatted_time_with_pm()).toBe('7:15 p.m.');
15
+ return expect(that_morning.formatted_time_with_pm()).toBe('7:15 a.m.');
16
+ });
17
+ it('should respond correctly to formatted_time', function() {
18
+ return expect(time_then.formatted_time()).toBe('19:15');
19
+ });
20
+ it('should respond correctly to formatted_date', function() {
21
+ expect(time_then.formatted_date()).toBe('May 12, 2016');
22
+ return expect(three_months_ago_then.formatted_date()).toBe('February 12, 2016');
23
+ });
24
+ return it('should respond correctly to time_ago_in_words', function() {
25
+ expect(three_months_ago.time_ago_in_words()).toBe('over 3 months ago');
26
+ expect(a_year_ago.time_ago_in_words()).toBe('about a year ago');
27
+ return expect(three_minutes_ago.time_ago_in_words()).toBe('about 3 minutes ago');
28
+ });
29
+ });
30
+
31
+ }).call(this);
@@ -0,0 +1,33 @@
1
+ (function() {
2
+ describe('Helpers', function() {
3
+ var null_var, random_var;
4
+ null_var = null;
5
+ random_var = '';
6
+ it('should respond correctly to exists', function() {
7
+ expect(exists(void 0)).toBe(false);
8
+ expect(exists(null_var)).toBe(false);
9
+ return expect(exists(random_var)).toBe(true);
10
+ });
11
+ it('should respond correctly to non_existent', function() {
12
+ expect(non_existent(void 0)).toBe(true);
13
+ expect(non_existent(null_var)).toBe(true);
14
+ return expect(non_existent(random_var)).toBe(false);
15
+ });
16
+ it('should respond correctly to defined', function() {
17
+ expect(defined(void 0)).toBe(false);
18
+ expect(defined(null_var)).toBe(true);
19
+ return expect(defined(random_var)).toBe(true);
20
+ });
21
+ it('should respond correctly to not_defined', function() {
22
+ expect(not_defined(void 0)).toBe(true);
23
+ expect(not_defined(null_var)).toBe(false);
24
+ return expect(not_defined(random_var)).toBe(false);
25
+ });
26
+ return it('should respond correctly to loaded', function() {
27
+ expect(loaded(void 0)).toBe(false);
28
+ expect(loaded(null_var)).toBe(true);
29
+ return expect(loaded(random_var)).toBe(true);
30
+ });
31
+ });
32
+
33
+ }).call(this);
@@ -0,0 +1,4 @@
1
+ (function() {
2
+
3
+
4
+ }).call(this);
@@ -0,0 +1,34 @@
1
+ (function() {
2
+ describe('Number', function() {
3
+ var integer, long_digit_number, negative_integer, zero;
4
+ integer = 12;
5
+ negative_integer = -10;
6
+ zero = 0;
7
+ long_digit_number = 12121212.1212133;
8
+ it('should respond correctly to is_positive', function() {
9
+ expect(integer.is_positive()).toBe(true);
10
+ return expect(negative_integer.is_positive()).toBe(false);
11
+ });
12
+ it('should respond correctly to is_negative', function() {
13
+ expect(integer.is_negative()).toBe(false);
14
+ return expect(negative_integer.is_negative()).toBe(true);
15
+ });
16
+ it('should respond correctly to is_zero', function() {
17
+ expect(integer.is_zero()).toBe(false);
18
+ return expect(zero.is_zero()).toBe(true);
19
+ });
20
+ it('should respond correctly to to_currency', function() {
21
+ return expect(long_digit_number.to_currency()).toBe('12,121,212.12');
22
+ });
23
+ it('should respond correctly to to_s', function() {
24
+ return expect(integer.to_s()).toBe('12');
25
+ });
26
+ it('should respond correctly to to_i', function() {
27
+ return expect(long_digit_number.to_i()).toBe(12121212);
28
+ });
29
+ return it('should respond correctly to to_f', function() {
30
+ return expect(zero.to_f()).toBe(0.00);
31
+ });
32
+ });
33
+
34
+ }).call(this);
@@ -0,0 +1,42 @@
1
+ (function() {
2
+ describe('String', function() {
3
+ var empty_string, random_string, string_number;
4
+ random_string = 'random string';
5
+ empty_string = '';
6
+ string_number = '12.12';
7
+ it('should respond correctly to blank', function() {
8
+ expect('random string'.blank()).toBe(false);
9
+ expect(' '.blank()).toBe(true);
10
+ expect('\n'.blank()).toBe(true);
11
+ return expect(''.blank()).toBe(true);
12
+ });
13
+ it('should respond correctly to empty', function() {
14
+ expect('random string'.empty()).toBe(false);
15
+ expect(' '.empty()).toBe(true);
16
+ return expect(''.empty()).toBe(true);
17
+ });
18
+ it('should respond correctly to present', function() {
19
+ expect(''.present()).toBe(false);
20
+ return expect('random string'.present()).toBe(true);
21
+ });
22
+ it('should respond correctly to present', function() {
23
+ return expect('12.12'.to_f()).toBe(12.12);
24
+ });
25
+ it('should respond correctly to to_i', function() {
26
+ return expect('12.12'.to_i()).toBe(12);
27
+ });
28
+ it('should respond correctly to to_f', function() {
29
+ return expect('12.12'.to_f()).toBe(12.12);
30
+ });
31
+ it('should respond correctly to capitalize', function() {
32
+ return expect('a title'.capitalize()).toBe('A title');
33
+ });
34
+ it('should respond correctly to trim', function() {
35
+ return expect(' A title '.trim()).toBe('A title');
36
+ });
37
+ return it('should respond correctly to titleize', function() {
38
+ return expect('A TITLE'.titleize()).toBe('A Title');
39
+ });
40
+ });
41
+
42
+ }).call(this);
@@ -0,0 +1,10 @@
1
+ (function() {
2
+ Array.prototype.present = function() {
3
+ return this.length > 0;
4
+ };
5
+
6
+ Array.prototype.empty = function() {
7
+ return this.length === 0;
8
+ };
9
+
10
+ }).call(this);
@@ -0,0 +1,73 @@
1
+ (function() {
2
+ var day_in_seconds, hour_in_seconds, minute_in_seconds, monthNames, month_in_seconds, week_in_seconds, year_in_seconds;
3
+
4
+ monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
5
+
6
+ year_in_seconds = 31536000;
7
+
8
+ month_in_seconds = 2420000;
9
+
10
+ week_in_seconds = 604800;
11
+
12
+ day_in_seconds = 86400;
13
+
14
+ hour_in_seconds = 3600;
15
+
16
+ minute_in_seconds = 60;
17
+
18
+ Date.prototype.formatted_time_with_pm = function() {
19
+ var hour, minute, prepand;
20
+ hour = this.getHours();
21
+ minute = this.getMinutes();
22
+ prepand = hour >= 12 ? 'p.m.' : 'a.m.';
23
+ hour = hour >= 12 ? hour - 12 : hour;
24
+ return hour + ":" + minute + " " + prepand;
25
+ };
26
+
27
+ Date.prototype.formatted_time = function() {
28
+ var hour, minute;
29
+ hour = this.getHours();
30
+ minute = this.getMinutes();
31
+ return hour + ":" + minute;
32
+ };
33
+
34
+ Date.prototype.formatted_date = function() {
35
+ var day, monthIndex, year;
36
+ day = this.getDate();
37
+ monthIndex = this.getMonth();
38
+ year = this.getFullYear();
39
+ return monthNames[monthIndex] + " " + day + ", " + year;
40
+ };
41
+
42
+ Date.prototype.time_ago_in_words = function() {
43
+ var seconds, time_now;
44
+ time_now = new Date();
45
+ seconds = Math.floor((time_now - this) / 1000);
46
+ if (seconds > 2 * year_in_seconds) {
47
+ return "over " + (Math.floor(seconds / year_in_seconds)) + " years ago";
48
+ } else if (seconds > year_in_seconds + month_in_seconds) {
49
+ return "over a year ago";
50
+ } else if (seconds > year_in_seconds - month_in_seconds) {
51
+ return "about a year ago";
52
+ } else if (seconds > 2 * month_in_seconds) {
53
+ return "over " + (Math.floor(seconds / month_in_seconds)) + " months ago";
54
+ } else if (seconds > 2 * week_in_seconds) {
55
+ return "about " + (Math.floor(seconds / week_in_seconds)) + " weeks ago";
56
+ } else if (seconds > 2 * day_in_seconds) {
57
+ return "about " + (Math.floor(seconds / day_in_seconds)) + " days ago";
58
+ } else if (seconds > 2 * hour_in_seconds - 20 * minute_in_seconds) {
59
+ return "about " + (Math.floor(seconds / hour_in_seconds)) + " hours ago";
60
+ } else if (seconds > day_in_seconds - 10 * minute_in_seconds) {
61
+ return "about an hour ago";
62
+ } else if (seconds > minute_in_seconds + 30) {
63
+ return "about " + (Math.floor(seconds / minute_in_seconds)) + " minutes ago";
64
+ } else if (seconds > minute_in_seconds - 1) {
65
+ return "about " + (Math.floor(seconds / minute_in_seconds)) + " minutes ago";
66
+ } else if (seconds > 0) {
67
+ return "less than a minute ago";
68
+ } else {
69
+ return "hasn't occured yet";
70
+ }
71
+ };
72
+
73
+ }).call(this);
@@ -0,0 +1,22 @@
1
+ (function() {
2
+ window.non_existent = function(variable) {
3
+ return variable === void 0 || variable === null;
4
+ };
5
+
6
+ window.exists = function(variable) {
7
+ return !non_existent(variable);
8
+ };
9
+
10
+ window.defined = function(variable) {
11
+ return variable !== void 0;
12
+ };
13
+
14
+ window.not_defined = function(variable) {
15
+ return variable === void 0;
16
+ };
17
+
18
+ window.loaded = function(variable) {
19
+ return defined(variable);
20
+ };
21
+
22
+ }).call(this);
@@ -0,0 +1,30 @@
1
+ (function() {
2
+ Number.prototype.is_positive = function() {
3
+ return this >= 0;
4
+ };
5
+
6
+ Number.prototype.is_zero = function() {
7
+ return (-0.00000000001 <= this && this <= 0.00000000001);
8
+ };
9
+
10
+ Number.prototype.is_negative = function() {
11
+ return this <= 0;
12
+ };
13
+
14
+ Number.prototype.to_currency = function() {
15
+ return this.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
16
+ };
17
+
18
+ Number.prototype.to_s = function() {
19
+ return this.toString();
20
+ };
21
+
22
+ Number.prototype.to_i = function() {
23
+ return parseInt(this);
24
+ };
25
+
26
+ Number.prototype.to_f = function() {
27
+ return parseFloat(this);
28
+ };
29
+
30
+ }).call(this);
@@ -0,0 +1,44 @@
1
+ (function() {
2
+ String.prototype.blank = function() {
3
+ var ref;
4
+ return !((ref = this.replace(/^\s+|\s+|\n+$/g, '')) != null ? ref.length : void 0);
5
+ };
6
+
7
+ String.prototype.empty = function() {
8
+ var ref;
9
+ return !((ref = this.replace(/^\s+|\s+|\n+$/g, '')) != null ? ref.length : void 0);
10
+ };
11
+
12
+ String.prototype.present = function() {
13
+ var ref;
14
+ return !!((ref = this.replace(/^\s+|\s+|\n+$/g, '')) != null ? ref.length : void 0);
15
+ };
16
+
17
+ String.prototype.to_i = function() {
18
+ return parseInt(this);
19
+ };
20
+
21
+ String.prototype.to_f = function() {
22
+ return parseFloat(this);
23
+ };
24
+
25
+ String.prototype.capitalize = function() {
26
+ return "" + (this.charAt(0).toUpperCase()) + (this.substr(1));
27
+ };
28
+
29
+ String.prototype.trim = function() {
30
+ return this.replace(/^\s+|\s+$/g, '');
31
+ };
32
+
33
+ String.prototype.titleize = function() {
34
+ var i, len, ref, title, word;
35
+ title = '';
36
+ ref = this.toLowerCase().split(' ');
37
+ for (i = 0, len = ref.length; i < len; i++) {
38
+ word = ref[i];
39
+ title += (word.capitalize()) + " ";
40
+ }
41
+ return title.trim();
42
+ };
43
+
44
+ }).call(this);
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coffee_enhancer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Fugere
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coffee-script
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jasmine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.13'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-coffeescript
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ description: A simple package that emhances the amazing experience that is of using
112
+ coffeescript.
113
+ email:
114
+ - danielfugere28@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".DS_Store"
120
+ - ".gitignore"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - Guardfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - coffee_enhancer.gemspec
131
+ - lib/assets/.DS_Store
132
+ - lib/assets/javascripts/array.coffee
133
+ - lib/assets/javascripts/coffee_enhancer.js
134
+ - lib/assets/javascripts/datetime.coffee
135
+ - lib/assets/javascripts/helpers.coffee
136
+ - lib/assets/javascripts/number.coffee
137
+ - lib/assets/javascripts/string.coffee
138
+ - lib/coffee_enhancer.rb
139
+ - lib/coffee_enhancer/engine.rb
140
+ - lib/coffee_enhancer/version.rb
141
+ - public/javascripts/compiled_specs/array_spec.js
142
+ - public/javascripts/compiled_specs/datetime_spec.js
143
+ - public/javascripts/compiled_specs/helpers_spec.js
144
+ - public/javascripts/compiled_specs/javascripts/datetime.js
145
+ - public/javascripts/compiled_specs/number_spec.js
146
+ - public/javascripts/compiled_specs/string_spec.js
147
+ - public/javascripts/compiled_src/array.js
148
+ - public/javascripts/compiled_src/datetime.js
149
+ - public/javascripts/compiled_src/helpers.js
150
+ - public/javascripts/compiled_src/number.js
151
+ - public/javascripts/compiled_src/string.js
152
+ homepage: https://github.com/dafuga/coffee_enhancer
153
+ licenses:
154
+ - MIT
155
+ metadata:
156
+ allowed_push_host: https://rubygems.org
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.5.0
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: A simple package that emhances the amazing experience that is of using coffeescript.
177
+ test_files: []