sillevl_temperature_library 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5e49ccd6d3536e8e0ed412b310a8184014ab7865
4
+ data.tar.gz: 4d8b867eb62e1d751182b1404c5c8383c540885d
5
+ SHA512:
6
+ metadata.gz: 73c0e897d93ca38eadcf91c0cb57f199e978d0983f314f3cacd12635570e2f69b0539247e98e7675ead9b1cd56d0f7e678ea57df9369ccd07d5ac095358f06a2
7
+ data.tar.gz: 2a6ed7532892cb1f0bd2003258015f12e78069b73cb6541b89ca31c298119da8bddf584b810a030a75b4d157e4669983c8cbff224bcdb5a9611babd573e66d7c
data/bin/temp-conv ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sillevl_temperature_library'
4
+ require 'highline'
5
+ require 'optparse'
6
+
7
+
8
+ options = {}
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: example.rb [options]"
11
+
12
+ opts.on("-i", "--interactive", "Run interactive") do |i|
13
+
14
+ cli = HighLine.new
15
+ cli.choose do |menu|
16
+ menu.prompt = "Please choose your method of input? "
17
+
18
+ menu.choice("CommandLine Interface") do
19
+ temperature = cli.ask "What is the temperature?"
20
+ temperature = Temperature.new temperature
21
+ converter.commandline_temperature temperature
22
+ cli.say(converter.to_text)
23
+ end
24
+
25
+ menu.choices("From file") do
26
+ filename = cli.ask "What is the filename?"
27
+ reader = FileReader.new filename
28
+ temperature = Temperature.new reader.temperature
29
+ converter.file_temperature filename
30
+ cli.say(converter.to_text)
31
+ end
32
+
33
+ menu.choices("From url") do
34
+ url = cli.ask "What is the url?"
35
+ reader = UrlReader.new url
36
+ temperature = Temperature.new reader.temperature
37
+ converter.url_temperature url
38
+ cli.say("Not from around here, are you?")
39
+ end
40
+
41
+ menu.choices("Using MQTT") do
42
+ cli.say("Not from around here, are you?")
43
+ end
44
+
45
+ menu.default = "CommandLine Interface"
46
+ end
47
+
48
+ end
49
+
50
+ temperature = Temperature.new 0
51
+
52
+ opts.on("-t T", "--temperature T", Float, "Temperature") do |t|
53
+ temperature = Temperature.new t
54
+ end
55
+
56
+ opts.on("-f FILE", "--file FILE", String, "Temperature") do |file|
57
+ reader = FileReader.new file
58
+ temperature = Temperature.new reader.temperature
59
+ end
60
+
61
+ opts.on("-u URL", "--url URL", String, "Temperature") do |url|
62
+ reader = UrlReader.new url
63
+ temperature = Temperature.new reader.temperature
64
+ end
65
+
66
+ opts.on("--text", "Output temperature as text") do
67
+ printer = TextPrinter.new temperature
68
+ puts printer.print
69
+ end
70
+
71
+ opts.on("--json", "Output temperature as json") do
72
+ printer = JsonPrinter.new temperature
73
+ puts printer.print
74
+ end
75
+
76
+ opts.on("--html", "Output temperature as html") do
77
+ printer = HtmlPrinter.new temperature
78
+ puts printer.print
79
+ end
80
+
81
+ opts.on_tail("-h", "--help", "Show this message") do
82
+ puts opts
83
+ exit
84
+ end
85
+ end.parse!
@@ -0,0 +1,3 @@
1
+ require './lib/temperature_reader'
2
+ require './lib/temperature_printer'
3
+ require './lib/temperature'
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sillevl_temperature_library
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sille Van Landschoot
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Library for converting temperatures and command line tool
14
+ email: info@sillevl.be
15
+ executables:
16
+ - temp-conv
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/temp-conv
21
+ - lib/sillevl_temperature_library.rb
22
+ homepage: http://rubygems.org/gems/sillevl_temperature_library
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.5.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Temperature converter library
46
+ test_files: []