random_giphy_image_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
+ SHA1:
3
+ metadata.gz: c1f108d696ebbfa4aaeea05649688ac192445e69
4
+ data.tar.gz: 7dffafd854a874ffb2ea106e37a877bd53be9789
5
+ SHA512:
6
+ metadata.gz: f0d4972f6f6332c7cec38ddf3db49f81ec3ea49520b9f1d45ea1b8b6a8dd6f96381e80bd3d3b7e73fd1b1ca3f71da4eb39d165c950e1f2e916d57f773af27c30
7
+ data.tar.gz: c4d0e6da21fdad9eb912b23be744799f9ab163c6aff03563a30027a96425f2fa07b2622fe7bc5fa902d82a707657727b77b5d8ac81860e5d8709216586d10991
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.2.2
4
+ before_install: gem install bundler -v 1.10.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in random_giphy_image_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ivan Gonzalez
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,73 @@
1
+ ## About
2
+
3
+ RandomGiphyImageRails is an absolute silly gem with the only purpose of put some random Giphy images on your HTML.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'random_giphy_image_rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install random_giphy_image_rails
20
+
21
+ ## Usage
22
+
23
+ After install the gem, the only thing you should do in your Rails application is add some lines into your assets files. Add this into your `application.js` file:
24
+
25
+ ```ruby
26
+ //= require random_giphy_image_rails
27
+ ```
28
+
29
+ and this line into you `application.css` file:
30
+
31
+ ```ruby
32
+ *= require random_giphy_image_rails
33
+ ```
34
+
35
+ Now you're ready to put Giphy images on your site. You only have to do something like this on your JS:
36
+
37
+ ```javascript
38
+ $(document).ready(function(){
39
+ // Set debug mode (for console logs)
40
+ RandomGiphyImageRails.debug = true;
41
+
42
+ // Testing api key by default if you don't specify one
43
+ RandomGiphyImageRails.data.api_key = 'YOUR_GIPHY_API_KEY';
44
+
45
+ // Class of the HTML element where you want to put the gif
46
+ RandomGiphyImageRails.data.element_class = 'giphyme';
47
+
48
+ // Query or tag of your random gif
49
+ RandomGiphyImageRails.data.query = 'nintendo';
50
+
51
+ // Executes the random gif thing
52
+ RandomGiphyImageRails.giphyme();
53
+ });
54
+ ```
55
+ And then put one or more HTML elements in your view:
56
+
57
+ ```html
58
+ <body>
59
+ <div class="giphyme"> </div>
60
+ </body>
61
+ ```
62
+
63
+ Refresh you page and... voila! :)
64
+
65
+ **Important: this gem uses jQuery to work.**
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dreamingechoes/random_giphy_image_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "random_giphy_image_rails"
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,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,8 @@
1
+ require "random_giphy_image_rails/version"
2
+
3
+ module RandomGiphyImageRails
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module RandomGiphyImageRails
2
+ VERSION = "0.1.0"
3
+ end
@@ -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 'random_giphy_image_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "random_giphy_image_rails"
8
+ spec.version = RandomGiphyImageRails::VERSION
9
+ spec.authors = ["Ivan Gonzalez"]
10
+ spec.email = ["xixon.sound@gmail.com"]
11
+
12
+ spec.summary = "Rails gem to add random Giphy images into your HTML"
13
+ spec.description = "Rails gem to add random Giphy images into your HTML. A silly gem with no specific purpose."
14
+ spec.homepage = "https://github.com/dreamingechoes/random_giphy_image_rails"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Core and general tools
3
+ */
4
+ (function($, undefined) {
5
+ 'use strict';
6
+
7
+ // Singleton
8
+ if (typeof window.RandomGiphyImageRails !== 'undefined') {
9
+ return;
10
+ }
11
+
12
+ //
13
+ // Module general vars
14
+ //
15
+ var
16
+ v = '1.00 beta',
17
+ debug = false,
18
+ data = {
19
+ api_key: 'dc6zaTOxFJmzC',
20
+ query: 'happy',
21
+ element_class: 'giphyme'
22
+ };
23
+
24
+ //
25
+ // Methods
26
+ //
27
+
28
+ // Adds Giphy gifs into the elements with class data.element_class
29
+ function giphyme() {
30
+ var elements = $('.'+data.element_class);
31
+ $.each(elements, function(key, value) {
32
+ if (this.debug) console.info(value);
33
+ updateGiphyImage($(value));
34
+ });
35
+ }
36
+
37
+ // Return Giphy gif URL string.
38
+ function updateGiphyImage(element) {
39
+ $.ajax({
40
+ method: 'GET',
41
+ url: 'http://api.giphy.com/v1/gifs/random',
42
+ data: { api_key: data.api_key, tag: data.query },
43
+ success: function(response) {
44
+ if (this.debug) console.info(response.data.image_url);
45
+ element.html('<img src="'+response.data.image_url+'" alt="Gif via Giphy" />');
46
+ },
47
+ error: function() {
48
+ if (this.debug) console.info('Giphy Api call error.');
49
+ }
50
+ });
51
+ }
52
+
53
+ //
54
+ // Public methods / properties
55
+ //
56
+ window.RandomGiphyImageRails = {
57
+ debug: debug,
58
+ data: data,
59
+ giphyme: giphyme
60
+ };
61
+
62
+ }(jQuery));
@@ -0,0 +1,5 @@
1
+ html body .giphyme {
2
+ width: auto;
3
+ margin: 24px auto;
4
+ float: left;
5
+ }
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: random_giphy_image_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Gonzalez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-18 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
+ description: Rails gem to add random Giphy images into your HTML. A silly gem with
42
+ no specific purpose.
43
+ email:
44
+ - xixon.sound@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/random_giphy_image_rails.rb
59
+ - lib/random_giphy_image_rails/version.rb
60
+ - random_giphy_image_rails.gemspec
61
+ - vendor/assets/javascripts/random_giphy_image_rails.js
62
+ - vendor/assets/stylesheets/random_giphy_image_rails.css
63
+ homepage: https://github.com/dreamingechoes/random_giphy_image_rails
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Rails gem to add random Giphy images into your HTML
87
+ test_files: []