rubyfy-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e3025c09ad6d27ee5e0ae94ae865eadf1c454e1b5f1e5f9f0ad9a5021986b181
4
+ data.tar.gz: 95d433beed8c2f9001e892ec9c98cb949ae93e388a9ed06aaee890baa8bdc6d6
5
+ SHA512:
6
+ metadata.gz: dcb1d720bc79305831238a285f7810acdff3422c9e3e47dfd8aaba82b80d0074930480bec646441e19cc0b4e050634805f813103bbba2bc272fc3b7be6922573
7
+ data.tar.gz: e905f34ac23822cd55dc46b1e174a6f1abcabd3bbc26cf817896d3440ab1ccaa79e1a7443f716a1a1347368372f339667b02e68d00e284e3f19f4c5b11a8282e
data/MIT-LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2019-infinity Caleb Matthiesen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Rubyfy for Rails
2
+ [Rubyfy](https://github.com/calebkm/rubyfy) brings some of the [Ruby](https://www.ruby-lang.org/en) methods you miss in JavaScript to your [Rails](https://rubyonrails.org) app.
3
+
4
+ ## Installation
5
+ Add Rubyfy to your gemfile:
6
+ ```ruby
7
+ gem 'rubyfy-rails'
8
+ ```
9
+ Inside of your `application.js` file add the line:
10
+ ```javascript
11
+ //= require rubyfy
12
+ ```
13
+ And wham-bam you can now call `[1, 2, 3].last()` in your JS code and get `3` returned to you!
14
+
15
+ ## Why?
16
+ The `rubyfy-rails` gem makes it easy to add [Rubyfy](https://github.com/calebkm/rubyfy) to your Rails app. If you're like me, you might miss some of the Ruby methods you love when coding in JavaScript.
17
+
18
+ ## Configuration + Methods
19
+ Check out config options and a full list of available methods in the [Rubyfy README](https://github.com/calebkm/rubyfy).
20
+
21
+ ## License
22
+ MIT - Free and open for all. Plz contribue!
@@ -0,0 +1 @@
1
+ require 'rubyfy-rails/engine'
@@ -0,0 +1,6 @@
1
+ module RubyfyRails
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,2 @@
1
+ // More info: https://github.com/calebkm/rubyfy
2
+ if(this.Rubyfy||(this.Rubyfy={}),Rubyfy.classes="Array Object String".split(" "),Rubyfy.Array="any compact is_empty first last".split(" "),Rubyfy.String="capitalize downcase is_blank".split(" "),Rubyfy.Object="any is_empty keys vals".split(" "),Rubyfy.compact=function(y){if(Rubyfy.defined(y,"compact"))return y.filter(y=>null!=y)},Rubyfy.first=function(y){if(Rubyfy.defined(y,"first"))return y[0]},Rubyfy.last=function(y){if(Rubyfy.defined(y,"last"))return y[y.length-1]},Rubyfy.keys=function(y){if(Rubyfy.defined(y,"keys"))return Object.keys(y)},Rubyfy.vals=function(y){if(Rubyfy.defined(y,"vals"))return Object.values(y)},Rubyfy.any=function(y){if(Rubyfy.defined(y,"any"))return!Rubyfy.is_empty(y)},Rubyfy.is_empty=function(y){if(Rubyfy.defined(y,"is_empty")){if(Rubyfy.is_array(y))return 0===Rubyfy.compact(y).length;if(Rubyfy.is_object(y))return 0===Object.keys(y).length}},Rubyfy.capitalize=function(y){if(Rubyfy.defined(y,"capitalize"))return y.charAt(0).toUpperCase()+y.slice(1).toLowerCase()},Rubyfy.downcase=function(y){if(Rubyfy.defined(y,"downcase"))return y.toLowerCase()},Rubyfy.is_blank=function(y){if(Rubyfy.defined(y,"is_blank"))return""===y.trim()},Rubyfy.defined=function(y,t){if(null!=y){const f=Rubyfy.class_of(y);if(f&&Rubyfy[f]&&Rubyfy[f].includes(t))return!0;throw new Error(`Rubyfy does not define a function \`${t}\` for ${Rubyfy.capitalize(f)}`)}throw new Error(`Cannot call Rubyfy \`${t}\` on ${y}`)},Rubyfy.class_of=function(y){return Rubyfy.is_array(y)?"Array":Rubyfy.is_string(y)?"String":Rubyfy.is_object(y)?"Object":typeof y},Rubyfy.is_array=(y=>Array.isArray(y)),Rubyfy.is_string=(y=>"string"==typeof y||y.constructor===String||"[object String]"===Object.prototype.toString.call(y)),Rubyfy.is_object=(y=>"object"==typeof y&&null!==y&&!Rubyfy.is_array(y)&&!Rubyfy.is_string(y)),Rubyfy.no_r||(void 0===this.R?(this.R=Rubyfy,this._R_IS_DEFINED_=!0):console.warn("Unable to assign Rubyfy shorthand `R` because it's already defined. You can still use `Rubyfy` explicitly.")),!Rubyfy.no_prototypes)for(let klass of Array.from(Rubyfy.classes))(klass=>Array.from(Rubyfy[klass]).map(func=>(function(func){return void 0===eval(klass).prototype[func]?Object.defineProperty(eval(klass).prototype,func,{value(){return Rubyfy[func](this)}}):console.warn(`Rubyfy attempted to define \`${klass}#${func}\` but it looks like ${klass}.prototype.${func} has already been defined. You can still use the Rubyfy version of \`${func}\` by calling it explicitly with \`${this._R_IS_DEFINED_?"R":"Rubyfy"}.${func}()\``)})(func)))(klass);
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubyfy-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Caleb Matthiesen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Adding just a touch of Ruby goodness to your JavaScript app.
14
+ email: c@calebkm.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - MIT-LICENSE
20
+ - README.md
21
+ - lib/rubyfy-rails.rb
22
+ - lib/rubyfy-rails/engine.rb
23
+ - vendor/assets/javascripts/rubyfy.js
24
+ homepage: https://github.com/calebkm/rubyfy-rails
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.0.6
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Ruby methods you miss in JavaScript.
47
+ test_files: []