giphy 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzI1NDkwMDYxMzc3YzFkMjU4OTI3YjYzYjVjYTc4M2RiZGEwNzM5Nw==
4
+ Y2I1Njc2ZTE2YjhiNWQ2YmI4YWI1MWI1Y2E5Yzg1MjEzMzc0MWQ3Nw==
5
5
  data.tar.gz: !binary |-
6
- NDMyYTFlNzU1YzljZjFhNjY5MDE2OGIyZTZjYzlkYzdjYjkwZjBjYg==
6
+ OGRkMzcwMDZlYjgwYjMwMDhmZGQ5NjI4ZmVkNGY2MzhmOGI3NjAyNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTYyZjNmODMwYmRhMTljYzNlOTVmMDg2ZTEyNzg2M2NiNTRiM2MyNWI1ZWYx
10
- ODBmZWZkOWU5MWY5MjBiNTVlZmYyYzMxM2VhMWJlOTU1ODhiYzdlYTQ4OTlj
11
- NzdhNzk0YmExMzJkYzljNTNiYTY1MDUxZjM5YWNhZGVmZGRlNDA=
9
+ ZTA0MTE2ZDk4MDlhZmI0YjZlN2YwN2E3OTZjNmNmZjY4NmUyNjdmZWJkYTE1
10
+ NWU5Y2QzYjJmNWY0Njk3MzI3ZjkwZjU5YzVmZjE3ZGI1NTNlMDQ2NWFhYWY1
11
+ MTRmZjVmMThhZGYwN2Q2MWM4NWZmOTAwOWFiZjUxOGUyY2I5MTg=
12
12
  data.tar.gz: !binary |-
13
- NDExMmM1Yjg1OGFjNThiNWYyYjgyN2ExNTlkNmJjMzEwNDFmMTJhZDUzYzdk
14
- NmU2ZjU3YjZkYTY2ZjhiNDRmNWIyZDYzMTJmMDNkNjFlNTMxODE5MmZmOWIz
15
- MzlkMTE1MzJiM2M2MTZiNjMyYWZhODgyMjQxZTBhNGMzZDJhMWM=
13
+ MzA5Y2Q1MGYxNmY2MjkwZDQ1ZGVmNmFjNGE4MjQwNmM2Zjk2ZTJkM2ZjMjcz
14
+ NDdkOWYwZTdlZDhkZGJmYThjZDQyZDQyMjYzMzI2MDE1MWE5NjAwODIyOTU2
15
+ OGUwMmJlOTJjODBjYTdkZTY5ZDU4ZDRkYWE2M2VhMzI0MTMwZTY=
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Giphy
2
2
 
3
+ [![Build Status](https://travis-ci.org/sebasoga/giphy.png?branch=master)](https://travis-ci.org/sebasoga/giphy)
4
+
3
5
  Because GIFs make life fun! Use [Giphy API](http://api.giphy.com) from your Ruby programs and
4
6
  command line. Check out [Giphy Labs](http://labs.giphy.com/) for inspiration.
5
7
 
@@ -106,7 +108,7 @@ command line and opens it on your browser. Just for fun.
106
108
  *Currently only supported for Mac.*
107
109
 
108
110
  ## Supported Ruby Versions
109
- This library aims to support and is [tested against][travis] the following Ruby
111
+ This library aims to support and is tested against the following Ruby
110
112
  implementations:
111
113
 
112
114
  * Ruby 1.9.3
data/lib/giphy/cli.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  module Giphy
2
2
  class CLI
3
+ def self.run(keyword)
4
+ new(keyword).search
5
+ end
6
+
3
7
  def initialize(keyword)
4
8
  @keyword = keyword
5
9
  end
@@ -18,6 +22,10 @@ module Giphy
18
22
 
19
23
  def result
20
24
  Giphy.screensaver(keyword)
25
+ rescue Giphy::Errors::API
26
+ GifNotFound.new('YyKPbc5OOTSQE')
21
27
  end
22
28
  end
29
+
30
+ GifNotFound = Struct.new(:id)
23
31
  end
data/lib/giphy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Giphy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,17 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Giphy::CLI do
4
+ describe ".run" do
5
+ it "creates a new instance and sends 'run'" do
6
+ instance = double
7
+ Giphy::CLI.stub(:new).with('keyword').and_return(instance)
8
+ instance.stub(search: 'shell command')
9
+ expect(Giphy::CLI.run('keyword')).to eq 'shell command'
10
+ end
11
+ end
12
+
4
13
  describe "#search" do
5
14
  subject { Giphy::CLI.new('horse') }
6
15
 
7
- before { Giphy.stub(screensaver: double(id: 'OoFJ7iMGUBpiE')) }
16
+ context "when a gif is found" do
17
+ it "echoes a message to the console and opens the url using Kernel#system" do
18
+ Giphy.stub(screensaver: double(id: 'OoFJ7iMGUBpiE'))
19
+ subject.should_receive(:system).
20
+ with("echo 'Showing the GIF on your default browser: http://giphy.com/embed/OoFJ7iMGUBpiE' && open http://giphy.com/embed/OoFJ7iMGUBpiE")
21
+ subject.search
22
+ end
23
+ end
8
24
 
9
- it "echoes a message to the console and opens the url using Kernel#system" do
10
- Giphy.stub(screensaver: double(id: 'OoFJ7iMGUBpiE'))
11
- Giphy::CLI.new('horse')
12
- subject.should_receive(:system).
13
- with("echo 'Showing the GIF on your default browser: http://giphy.com/embed/OoFJ7iMGUBpiE' && open http://giphy.com/embed/OoFJ7iMGUBpiE")
14
- subject.search
25
+ context "when a Giphy::Errors:API error is raised" do
26
+ it "echoes a message to the console and opens the url using Kernel#system" do
27
+ Giphy.stub(:screensaver).and_raise(Giphy::Errors::API)
28
+ subject.should_receive(:system).
29
+ with("echo 'Showing the GIF on your default browser: http://giphy.com/embed/YyKPbc5OOTSQE' && open http://giphy.com/embed/YyKPbc5OOTSQE")
30
+ subject.search
31
+ end
15
32
  end
16
33
  end
17
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giphy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Sogamoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,6 +90,7 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - .gitignore
92
92
  - .rspec
93
+ - .travis.yml
93
94
  - Gemfile
94
95
  - LICENSE.md
95
96
  - README.md