ruby_trollem_ipsum 0.0.1
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.
- data/LICENSE +20 -0
- data/README.md +54 -0
- data/lib/ruby_trollem_ipsum.rb +1 -0
- data/lib/ruby_trollem_ipsum/trollem_ipsum.rb +49 -0
- data/lib/ruby_trollem_ipsum/version.rb +3 -0
- metadata +62 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Josh Dzielak
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
### ruby_trollem_ipsum
|
2
|
+
|
3
|
+
A simple, configurable API client for [trollemipsum.appspot.com](http://trollemipsum.appspot.com).
|
4
|
+
|
5
|
+
### Usage
|
6
|
+
|
7
|
+
One-liner:
|
8
|
+
|
9
|
+
TrollemIpsum.lorem # => "Flash sucks, during delay in getting Ice Cream Sandwich what gorgeous."
|
10
|
+
|
11
|
+
Filter options per client:
|
12
|
+
|
13
|
+
troll = TrollemIpsum.new(["confident"], ["siegler"])
|
14
|
+
troll.lorem # => "It’s not good for Google I believe fingergate finally pure bullshit..."
|
15
|
+
|
16
|
+
Filter options per call:
|
17
|
+
|
18
|
+
troll = TrollemIpsum.new
|
19
|
+
troll.lorem("gruber") # => "Steve Jobs in my opinion baseball."
|
20
|
+
|
21
|
+
### Installation
|
22
|
+
|
23
|
+
Rubygems:
|
24
|
+
|
25
|
+
gem install ruby_trollem_ipsum
|
26
|
+
|
27
|
+
Bundler:
|
28
|
+
|
29
|
+
gem 'ruby_trollem_ipsum'
|
30
|
+
|
31
|
+
### Options
|
32
|
+
|
33
|
+
The `TrollemIpsum` constructor takes 2 optional parameters - an array of allowable lengths and one of types. See the TrollemIpsum [API](http://trollemipsum.appspot.com/api.json?type=apple&length=new) for a list of allowed values.
|
34
|
+
|
35
|
+
If you pass these options, future calls to `lorem` will use them to scope the random selection of types and lengths.
|
36
|
+
|
37
|
+
Each call to `lorem` may also pass a length and a type which will override the scoping set on initialization.
|
38
|
+
|
39
|
+
### Error messages
|
40
|
+
|
41
|
+
*Reason*: All the reasons
|
42
|
+
|
43
|
+
*Message*:
|
44
|
+
|
45
|
+
trololololololololol
|
46
|
+
|
47
|
+
### Credits
|
48
|
+
|
49
|
+
Thanks to [@davidmoss](https://twitter.com/davidmoss) and [@patrickhmason](https://twitter.com/patrickhmason) for creating TrollemIpsum!
|
50
|
+
|
51
|
+
### Follow me
|
52
|
+
|
53
|
+
Follow [@dzello](https://twitter.com/dzello) on twitter for MORE updates and LESS trolling.
|
54
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require "ruby_trollem_ipsum/trollem_ipsum"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
# Copyright Josh Dzielak, 2012
|
5
|
+
# MIT License
|
6
|
+
|
7
|
+
# A simple Ruby client for http://trollemipsum.appspot.com
|
8
|
+
class TrollemIpsum
|
9
|
+
|
10
|
+
def self.lorem(type=nil, length=nil)
|
11
|
+
self.new.lorem(type, length)
|
12
|
+
end
|
13
|
+
|
14
|
+
# scope available lengths and/or types to those of your choosing
|
15
|
+
def initialize(available_lengths=nil, available_types=nil)
|
16
|
+
|
17
|
+
@options = JSON.parse(Net::HTTP.get('trollemipsum.appspot.com', '/api.json'))
|
18
|
+
@types =
|
19
|
+
(available_types ||
|
20
|
+
JSON.parse(@options["available_types"].gsub(/'/, "\"")).keys)
|
21
|
+
@lengths =
|
22
|
+
(available_lengths ||
|
23
|
+
JSON.parse(@options["available_lengths"].gsub(/'/, "\"")).keys)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
# randomly chooses type and length set in
|
28
|
+
# initializer unless you pass them
|
29
|
+
def lorem(type=nil, length=nil)
|
30
|
+
|
31
|
+
type ||= @types.sample
|
32
|
+
length ||= @lengths.sample
|
33
|
+
|
34
|
+
begin
|
35
|
+
JSON.parse(
|
36
|
+
Net::HTTP.get(
|
37
|
+
"trollemipsum.appspot.com",
|
38
|
+
"/api.json?type=#{type}&length=#{length}"))["lorem"]
|
39
|
+
rescue => e
|
40
|
+
trololol
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def trololol
|
46
|
+
"tro#{"lo"*(2...10).to_a.sample}l"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_trollem_ipsum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Dzielak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: &70364546040260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70364546040260
|
25
|
+
description: Configurable length and type for all the trollings!
|
26
|
+
email:
|
27
|
+
- github_public@dz.oib.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- lib/ruby_trollem_ipsum/trollem_ipsum.rb
|
33
|
+
- lib/ruby_trollem_ipsum/version.rb
|
34
|
+
- lib/ruby_trollem_ipsum.rb
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
homepage: http://github.com/dzello/ruby_trollem_ipsum
|
38
|
+
licenses: []
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.6
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project: ruby_trollem_ipsum
|
57
|
+
rubygems_version: 1.8.10
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: An API client for http://trollemipsum.appspot.com
|
61
|
+
test_files: []
|
62
|
+
has_rdoc:
|