loripsum-client 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8fddeb9480b35cdeac96936a06d64471fd24421d
4
+ data.tar.gz: 07ba3fdcf727d83dc5cca1e3f21d950330ade969
5
+ SHA512:
6
+ metadata.gz: 70d8fc5b879a2d89bfab67ff6901af2937ba9dd52bbc78332ea6ebd399b31fcea83d4d56c0234db59f5ffed514c529c0d15c453f3763d747eb401dd44ef2bf81
7
+ data.tar.gz: 703928b193e6480cf7a217fb09c75b06b3cde5c68df95fd052ef1344df36feef4a6465fe2a59b89d9b9d493943ddaf812a4a1d5459e1b5c8540fbb92e921127d
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in loripsum-client.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Javier L. Velasquez
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.
@@ -0,0 +1,53 @@
1
+ # lorem ipsum!
2
+
3
+ Ruby client for loripsum.net
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'loripsum-client'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install loripsum-client
20
+
21
+ ## Usage
22
+
23
+ Usage: loripsum.rb [options]
24
+ -n, --number [NUMBER] The number of paragraphs to generate
25
+ -l, --length [LENGTH] The average length of a paragraph
26
+ -p, --decorate Add bold, italic, and marked text
27
+ -a, --links Add links
28
+ -u, --unordered-lists Add unordered lists
29
+ -o, --ordered-lists Add ordered lists
30
+ -d, --description-lists Add description lists
31
+ -b, --block-quotes Add blockquotes
32
+ -c, --code-samples Add code samples
33
+ -h, --headers Add headers
34
+ -C, --all-caps Use ALL CAPS
35
+ -s, --prude Prude version
36
+ -t, --text Return plain text, no HTML
37
+
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nycjv321/loripsum-client.
48
+
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
53
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "loripsum/client"
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
@@ -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,121 @@
1
+ require_relative 'loripsum/version'
2
+ require 'rest-client'
3
+ require 'optparse'
4
+
5
+
6
+ module Loripsum
7
+
8
+ class OptionsParser
9
+ LENGTHS = %w(short medium long verylong)
10
+ def self.parse!
11
+ options = {}
12
+ options[:plaintext] = false
13
+ options[:prude] = false
14
+ options[:allcaps] = false
15
+ options[:headers] = false
16
+ options[:code] = false
17
+ options[:bq] = false
18
+ options[:dl] = false
19
+ options[:ul] = false
20
+ options[:ol] = false
21
+ options[:decorate] = false
22
+ options[:link] = false
23
+
24
+ OptionParser.new do |opts|
25
+ opts.banner = "Usage: loripsum.rb [options]"
26
+
27
+
28
+ opts.on("-n", "--number [NUMBER]", Integer, "The number of paragraphs to generate") do |number|
29
+ options[:number] = number
30
+ end
31
+ opts.on("-l", "--length [LENGTH]", String, "The average length of a paragraph") do |length|
32
+ unless LENGTHS.include?(length)
33
+ raise("#{length} was not valid length. Expected one of the following: #{LENGTHS}")
34
+ end
35
+ options[:length] = length
36
+ end
37
+ opts.on("-p", "--decorate", "Add bold, italic, and marked text") do
38
+ options[:decorate] = true
39
+ end
40
+ opts.on("-a", "--links", "Add links") do
41
+ options[:link] = true
42
+ end
43
+ opts.on("-u", "--unordered-lists", "Add unordered lists") do
44
+ options[:ul] = true
45
+ end
46
+
47
+ opts.on("-o", "--ordered-lists", "Add ordered lists") do
48
+ options[:ol] = true
49
+ end
50
+ opts.on("-d", "--description-lists", "Add description lists") do
51
+ options[:dl] = true
52
+ end
53
+ opts.on("-b", "--block-quotes", "Add blockquotes") do
54
+ options[:bq] = true
55
+ end
56
+ opts.on("-c", "--code-samples", "Add code samples") do
57
+ options[:code] = true
58
+ end
59
+ opts.on("-h", "--headers", "Add headers") do
60
+ options[:headers] = true
61
+ end
62
+ opts.on("-C", "--all-caps", "Use ALL CAPS") do
63
+ options[:allcaps] = true
64
+ end
65
+ opts.on("-s", "--prude", "Prude version") do
66
+ options[:prude] = true
67
+ end
68
+ opts.on("-t", "--text", "Return plain text, no HTML") do
69
+ options[:plaintext] = true
70
+ end
71
+
72
+ end.parse!
73
+ options
74
+ end
75
+ end
76
+
77
+ module Client
78
+ BASE_URL = 'loripsum.net/api'
79
+ def self.generate_url(options)
80
+ url = BASE_URL
81
+ enabled_options = options.select {|_, value| value }
82
+ if enabled_options.include?(:number)
83
+ url = "#{url}/#{enabled_options[:number]}"
84
+ enabled_options.delete(:number)
85
+ end
86
+ if enabled_options.include?(:length)
87
+ url = "#{url}/#{enabled_options[:length]}"
88
+ enabled_options.delete(:length)
89
+ end
90
+
91
+ enabled_options.keys.each do |key|
92
+ url = "#{url}/#{key}"
93
+ end
94
+ url
95
+ end
96
+
97
+ def self.generate
98
+ options = OptionsParser.parse!
99
+ if options[:headers]
100
+ generate_with_headers(options)
101
+ else
102
+ url = generate_url(options)
103
+ RestClient.get url
104
+ end
105
+ end
106
+
107
+ def self.generate_with_headers(options)
108
+ url = generate_url(options)
109
+ result = RestClient.get url
110
+ split = result.split("\n\n")
111
+ {header: split[0], body: split[1, split.size]}
112
+ end
113
+ def self.run!
114
+ $stdout << self.generate
115
+ end
116
+ end
117
+
118
+
119
+ end
120
+
121
+ Loripsum::Client.run! if __FILE__ == $0
@@ -0,0 +1,5 @@
1
+ module Loripsum
2
+ module Client
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: loripsum-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Javier L. Velasquez
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rest-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Generate lorem ipsum using loripsum.net's api
98
+ email:
99
+ - nycjv321@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/setup
112
+ - lib/loripsum.rb
113
+ - lib/loripsum/version.rb
114
+ homepage: https://github.com/nycjv321/loripsum-client
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.4.5
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Ruby client for loripsum.net
138
+ test_files: []