butternut_squash 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/bin/butternut +61 -1
- data/butternut_squash.gemspec +3 -2
- data/config.yml +5 -0
- data/lib/butternut_squash/config.rb +13 -0
- data/lib/butternut_squash/version.rb +1 -1
- data/lib/butternut_squash.rb +30 -1
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ebc34db077a1a2488f02d9b0506fb5a14c8b28b
|
4
|
+
data.tar.gz: 8a29b40ea03b300e03906c29eea05e9cc00f115d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ccf0b3932f1daa03cac30b87e30091ac82c106dde43974fda45ff8e4ba70b88f910818e40ed47d359e34b2da2c8441586034a4fbc9b8f104123353f35c0caa
|
7
|
+
data.tar.gz: 487fc3812e81677689c724fe37266db7079273fea087c2fc11e1345f4de19f1f9ea088577fd3f764daeeb4668fa8dda57f1338882d32b653477ebdebb8001432
|
data/bin/butternut
CHANGED
@@ -1,6 +1,66 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'butternut_squash'
|
4
|
+
require_relative '../lib/butternut_squash/config'
|
5
|
+
require 'optparse'
|
6
|
+
require 'ruby_cowsay'
|
7
|
+
|
8
|
+
parsed_options = {}
|
9
|
+
|
10
|
+
optparse = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: butternut [some options]"
|
12
|
+
|
13
|
+
#Random cow
|
14
|
+
opts.on('-r', '--randimal', 'Have a random animal give your advice') do
|
15
|
+
parsed_options[:randimal] = true
|
16
|
+
end
|
17
|
+
|
18
|
+
#List cows
|
19
|
+
opts.on('-l', '--list', 'List available cows') do
|
20
|
+
puts Cow.cows
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
#List faces
|
25
|
+
opts.on('-lf', '--list-faces', 'List available faces') do
|
26
|
+
puts Cow.faces
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
#Specify a cow
|
31
|
+
opts.on('-c', '--cow [COW]', 'Select a cow') do |cow|
|
32
|
+
unless Cow.cows.include? cow
|
33
|
+
puts "#{cow} is not a cow \nUse butternut -l for a list of cows"
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
parsed_options[:cow] = cow
|
37
|
+
end
|
38
|
+
|
39
|
+
#Specify a face
|
40
|
+
opts.on('-f', '--face [FACE]', 'Select a face') do |face|
|
41
|
+
unless Cow.faces.include? face
|
42
|
+
puts "#{face} is not a face \nUse butternut -lf for a list of faces"
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
parsed_options[:face] = face
|
46
|
+
end
|
47
|
+
|
48
|
+
#Set global options
|
49
|
+
opts.on("--config set key value", Array, "Set your shit") do |list|
|
50
|
+
key = ARGV[0]
|
51
|
+
value = ARGV[1]
|
52
|
+
ButternutSquash::Config::set(key, value)
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
|
56
|
+
#Get help
|
57
|
+
opts.on('-h', '--help', 'Help') do
|
58
|
+
puts opts
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
end
|
62
|
+
optparse.parse!
|
63
|
+
|
64
|
+
butternut = ButternutSquash::Client.new(parsed_options)
|
4
65
|
|
5
|
-
butternut = ButternutSquash::Client.new
|
6
66
|
puts butternut.random
|
data/butternut_squash.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'butternut_squash/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "butternut_squash"
|
8
8
|
spec.version = ButternutSquash::VERSION
|
9
|
-
spec.authors = ["James Ruston"]
|
10
|
-
spec.email = ["jruston90@gmail.com"]
|
9
|
+
spec.authors = ["James Ruston", "Dan Ellis"]
|
10
|
+
spec.email = ["jruston90@gmail.com", "danny_ellis90@hotmail.com"]
|
11
11
|
spec.summary = %q{Excellent advice}
|
12
12
|
spec.description = %q{For developer who care}
|
13
13
|
spec.homepage = ""
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_runtime_dependency "httparty"
|
24
|
+
spec.add_runtime_dependency "ruby_cowsay"
|
24
25
|
end
|
data/config.yml
ADDED
data/lib/butternut_squash.rb
CHANGED
@@ -1,12 +1,41 @@
|
|
1
1
|
require "butternut_squash/version"
|
2
2
|
require 'httparty'
|
3
|
+
require 'ruby_cowsay'
|
3
4
|
|
4
5
|
module ButternutSquash
|
5
6
|
class Client
|
6
7
|
include HTTParty
|
7
8
|
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
8
13
|
def random
|
9
|
-
self.class.get "#{base_url}random"
|
14
|
+
response = self.class.get "#{base_url}random"
|
15
|
+
output_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_response(response)
|
19
|
+
if @options[:cow]
|
20
|
+
cow = @options[:cow]
|
21
|
+
elsif @options[:randimal]
|
22
|
+
cow = Cow.cows.sample
|
23
|
+
end
|
24
|
+
if @options[:face]
|
25
|
+
face = @options[:face]
|
26
|
+
end
|
27
|
+
return say_with_cow_and_face(cow, face, response) if cow && face
|
28
|
+
return say_with_cow(cow, response) if cow
|
29
|
+
puts response
|
30
|
+
end
|
31
|
+
|
32
|
+
def say_with_cow(cow, response)
|
33
|
+
puts Cow.new({cow: cow}).say(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
def say_with_cow_and_face(cow, face, response)
|
37
|
+
puts "cow face"
|
38
|
+
puts Cow.new({cow: cow, face_type: face}).say(response)
|
10
39
|
end
|
11
40
|
|
12
41
|
def base_url
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: butternut_squash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Ruston
|
8
|
+
- Dan Ellis
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
@@ -52,9 +53,24 @@ dependencies:
|
|
52
53
|
- - '>='
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: ruby_cowsay
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
55
70
|
description: For developer who care
|
56
71
|
email:
|
57
72
|
- jruston90@gmail.com
|
73
|
+
- danny_ellis90@hotmail.com
|
58
74
|
executables:
|
59
75
|
- butternut
|
60
76
|
extensions: []
|
@@ -67,7 +83,9 @@ files:
|
|
67
83
|
- Rakefile
|
68
84
|
- bin/butternut
|
69
85
|
- butternut_squash.gemspec
|
86
|
+
- config.yml
|
70
87
|
- lib/butternut_squash.rb
|
88
|
+
- lib/butternut_squash/config.rb
|
71
89
|
- lib/butternut_squash/version.rb
|
72
90
|
homepage: ''
|
73
91
|
licenses:
|
@@ -89,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
107
|
version: '0'
|
90
108
|
requirements: []
|
91
109
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.0.3
|
93
111
|
signing_key:
|
94
112
|
specification_version: 4
|
95
113
|
summary: Excellent advice
|