hipsteripsum 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/hipsteripsum.rb +20 -10
  2. metadata +3 -3
data/lib/hipsteripsum.rb CHANGED
@@ -1,10 +1,20 @@
1
- require 'net/http'
2
- require 'json'
3
-
4
- class Hipster
5
- def beerMe(paragraphs=2, type="centric")
6
- response = Net::HTTP.get_response(URI.parse("http://hipsterjesus.com/api/?paras=" + paragraphs.to_s + "&type=hipster-" + type))
7
- obj = JSON.parse(response.body)
8
- return obj["text"]
9
- end
10
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ conn = Faraday.new(:url => 'http://hipsterjesus.com') do |builder|
7
+ builder.use Faraday::Response::Mashify
8
+ builder.use Faraday::Response::ParseJson
9
+ builder.adapter Faraday.default_adapter
10
+ end
11
+
12
+ def buildurl(paras, type = "centric")
13
+ url = "/api/?paras=#{paras}&type=hipster-#{type}"
14
+ end
15
+
16
+ response = conn.get buildurl(ARGV[0], ARGV[1])
17
+
18
+ t = response.body
19
+
20
+ puts t.text
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipsteripsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-06 00:00:00.000000000Z
12
+ date: 2011-12-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: http://hipsterjesus.com/
15
15
  email: me@shanemcd.com
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  requirements: []
40
40
  rubyforge_project:
41
- rubygems_version: 1.8.12
41
+ rubygems_version: 1.8.15
42
42
  signing_key:
43
43
  specification_version: 3
44
44
  summary: Hipster Ipsum