lipsum-api 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/lipsum +4 -31
- data/lib/lipsum.rb +0 -1
- data/lib/lipsum_app.rb +47 -0
- metadata +26 -11
data/Rakefile
CHANGED
data/bin/lipsum
CHANGED
@@ -1,34 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Usage: $ lipsum words 5
|
4
|
-
# $ lipsum paragraphs 5
|
5
|
-
# $ lipsum lists 10
|
6
|
-
# $ lipsum bytes 120
|
7
|
-
# $ lipsum w|p|l|b number
|
8
|
-
#
|
9
|
-
require 'rubygems'
|
10
|
-
require 'lipsum'
|
11
|
-
|
12
|
-
def print_usage
|
13
|
-
STDERR.puts "Usage: "
|
14
|
-
STDERR.puts "lipsum what amount"
|
15
|
-
STDERR.puts " Where 'what' can be 'words', 'paragraphs', 'lists', or 'bytes'"
|
16
|
-
STDOUT.puts " 'amount' is the number of words, paragraphs, lists or bytes to retrieve"
|
17
|
-
puts ARGV.inspect
|
18
|
-
exit(1)
|
19
|
-
end
|
20
|
-
|
2
|
+
# -*- mode: ruby -*-
|
21
3
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
command = ARGV[0]
|
26
|
-
amount = ARGV[1].to_i
|
27
|
-
start_with_lorem = ARGV.include?('--start-with-lorem') || ARGV.include?('-s')
|
28
|
-
|
29
|
-
if !['words', 'paragraphs', 'lists', 'bytes'].include?(command)
|
30
|
-
print_usage
|
31
|
-
end
|
4
|
+
require 'rubygems'
|
5
|
+
require 'lipsum_app'
|
32
6
|
|
33
|
-
|
34
|
-
STDOUT.puts amount.send("lipsum_#{command}", opts)
|
7
|
+
LipsumApp.start(ARGV, :debug => true)
|
data/lib/lipsum.rb
CHANGED
data/lib/lipsum_app.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'lipsum'
|
3
|
+
|
4
|
+
class LipsumApp < Thor
|
5
|
+
map 'p' => :paragraphs
|
6
|
+
map 'w' => :words
|
7
|
+
map 'l' => :lists
|
8
|
+
map 'b' => :bytes
|
9
|
+
|
10
|
+
desc "paragraphs AMOUNT", "Downloads an AMOUNT of paragraphs from Lipsum.com"
|
11
|
+
method_options :start_with_lorem => :boolean
|
12
|
+
def paragraphs(amount=0)
|
13
|
+
amount = amount.to_i
|
14
|
+
opts = do_config
|
15
|
+
STDOUT.puts amount.lipsum_paragraphs opts if amount.to_i > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "words AMOUNT", "Downloads an AMOUNT of words from Lipsum.com"
|
19
|
+
method_options :start_with_lorem => :boolean
|
20
|
+
def words(amount=0)
|
21
|
+
amount = amount.to_i
|
22
|
+
opts = do_config
|
23
|
+
STDOUT.puts amount.lipsum_words if amount.to_i > 0
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "lists AMOUNT", "Downloads an AMOUNT of lists from Lipsum.com"
|
27
|
+
method_options :start_with_lorem => :boolean
|
28
|
+
def lists(amount=0)
|
29
|
+
amount = amount.to_i
|
30
|
+
opts = do_config
|
31
|
+
STDOUT.puts amount.lipsum_lists if amount.to_i > 0
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "bytes AMOUNT", "Downloads an AMOUNT of bytes from Lipsum.com"
|
35
|
+
method_options :start_with_lorem => :boolean
|
36
|
+
def bytes(amount=0)
|
37
|
+
amount = amount.to_i
|
38
|
+
opts = do_config
|
39
|
+
STDOUT.puts amount.lipsum_bytes if amount.to_i > 0
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def do_config
|
44
|
+
options.start_with_lorem? ? {:start_with_lorem => true}:{}
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lipsum-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 5
|
9
|
+
version: "0.5"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Vicente Reig Rinc\xC3\xB3n de Arellano"
|
@@ -14,11 +14,11 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-23 00:00:00 +02:00
|
18
18
|
default_executable: lipsum
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: thor
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: nokogiri
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: rest-client
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
segments:
|
58
58
|
- 0
|
59
59
|
version: "0"
|
60
|
-
type: :
|
60
|
+
type: :runtime
|
61
61
|
version_requirements: *id003
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: rake
|
64
64
|
prerelease: false
|
65
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
@@ -73,7 +73,21 @@ dependencies:
|
|
73
73
|
version: "0"
|
74
74
|
type: :development
|
75
75
|
version_requirements: *id004
|
76
|
-
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: bundler
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :development
|
89
|
+
version_requirements: *id005
|
90
|
+
description: A library and command line client to interface Lipsum.com
|
77
91
|
email: vicente.reig@gmail.com
|
78
92
|
executables:
|
79
93
|
- lipsum
|
@@ -84,6 +98,7 @@ extra_rdoc_files: []
|
|
84
98
|
files:
|
85
99
|
- bin/lipsum
|
86
100
|
- lib/lipsum.rb
|
101
|
+
- lib/lipsum_app.rb
|
87
102
|
- test/fixtures/lipsum_bytes.html
|
88
103
|
- test/fixtures/lipsum_words.html
|
89
104
|
- test/fixtures/lipsum_lists.html
|
@@ -126,6 +141,6 @@ rubyforge_project:
|
|
126
141
|
rubygems_version: 1.3.7
|
127
142
|
signing_key:
|
128
143
|
specification_version: 3
|
129
|
-
summary:
|
144
|
+
summary: A Ruby interface to Lipsum.com
|
130
145
|
test_files: []
|
131
146
|
|