fuelcli 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b4990477d6a5287f154e67b6ec9d46a607e0bbd034a6dc70fc2e62d7ac871965
4
+ data.tar.gz: a3b0da0c9493654286b750b15089541cb1bd55105a91faedf0d17cd1a06679b9
5
+ SHA512:
6
+ metadata.gz: 263f5ad3bcb2b38c05722719d94889b82725158ed64883c3c7d230b030274d39d210068cf3c2198764198ef5bc01ebe64a9f1a548fc2370202aa2d9bd873f21a
7
+ data.tar.gz: 1a52cc8c83430a8e648f7c88f21e5c97f8ef6b594c38346a12be6a4cc4edd10f9225494d230054a27a4e06c3d551c8c75e8548812eb99532dce82da8ac176b0e
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fuel.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec"
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fuel (0.1.2)
5
+ thor (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.4.4)
11
+ rake (12.3.3)
12
+ rspec (3.10.0)
13
+ rspec-core (~> 3.10.0)
14
+ rspec-expectations (~> 3.10.0)
15
+ rspec-mocks (~> 3.10.0)
16
+ rspec-core (3.10.0)
17
+ rspec-support (~> 3.10.0)
18
+ rspec-expectations (3.10.0)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.10.0)
21
+ rspec-mocks (3.10.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-support (3.10.0)
25
+ thor (1.0.1)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ fuel!
32
+ rake (~> 12.0)
33
+ rspec
34
+
35
+ BUNDLED WITH
36
+ 2.1.4
@@ -0,0 +1,36 @@
1
+ # Fuel
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fuel`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'fuel'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install fuel
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fuel.
36
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fuel"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ require 'bundler/setup'
5
+ Bundler.setup(:default)
6
+
7
+ require 'uri'
8
+ require 'fuel'
9
+ require 'thor'
10
+ require 'json'
11
+ require 'net/http'
12
+
13
+
14
+
15
+ module Fuel
16
+
17
+ class Cli < Thor
18
+
19
+ desc "burn LEG", "burn LEG"
20
+
21
+ def burn(leg)
22
+ begin
23
+ say ""
24
+ say "#{get_name(leg)}"
25
+ say ""
26
+ burn_fuel
27
+ if( yes? "leg #{get_name(leg)} flown?")
28
+ update_flight_plan(leg,true)
29
+ else
30
+ update_flight_plan(leg,false)
31
+ refuel
32
+ burn leg if yes? "burn more fuel on #{get_name(leg)}?"
33
+ end
34
+ rescue Interrupt => e
35
+ begin
36
+ say ""
37
+ if @progressbar.title == "Fuel - burning"
38
+ if yes?("Flown leg?")
39
+ update_flight_plan(leg,true)
40
+ end
41
+ end
42
+ if @progressbar.title == "Fuel - refueling"
43
+ burn leg if yes? "burn more fuel on #{get_name(leg)}?"
44
+ end
45
+
46
+ rescue Interrupt => exception
47
+
48
+ end
49
+
50
+
51
+ end
52
+
53
+ end
54
+
55
+ private
56
+
57
+ def get_name(leg)
58
+ url = URI("http://flightplanapp.herokuapp.com/api/fuel/#{leg}")
59
+ http = Net::HTTP.new(url.host, url.port)
60
+ request = Net::HTTP::Get.new(url)
61
+ response = http.request(request)
62
+ waypoint = JSON.parse(response.read_body)
63
+ waypoint["description"]
64
+ end
65
+ def update_flight_plan(leg,flown)
66
+ url = URI("http://flightplanapp.herokuapp.com/api/fuel")
67
+ http = Net::HTTP.new(url.host, url.port)
68
+ request = Net::HTTP::Post.new(url)
69
+ request["Content-Type"] = 'multipart/form-data'
70
+ request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
71
+ request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"uid\"\r\n\r\n#{leg}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"flown\"\r\n\r\n#{flown}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"
72
+ response = http.request(request)
73
+ end
74
+
75
+ def burn_fuel
76
+ invoke_progress title: "Fuel - burning", total: Fuel.configuration.burn_time
77
+ end
78
+
79
+ def refuel
80
+ invoke_progress title: "Fuel - refueling", total: Fuel.configuration.refuel_time
81
+ end
82
+
83
+ def invoke_progress title:,total:
84
+ @progressbar = ProgressBar.create title: title, total: total, :format => '%t | %b>>%i | %p%% | %e | '
85
+ loop do
86
+ break if @progressbar.finished?
87
+ @progressbar.increment
88
+ sleep 1
89
+ end
90
+ end
91
+
92
+
93
+ end
94
+ end
95
+
96
+ Fuel::Cli.start(ARGV)
@@ -0,0 +1,20 @@
1
+ require_relative 'lib/fuel/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "fuelcli"
5
+ spec.version = Fuel::VERSION
6
+ spec.authors = ["dsofadog"]
7
+ spec.email = ["delaney@so.fa.dog"]
8
+
9
+ spec.summary = %q{Fuel Gauge}
10
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
12
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
13
+ end
14
+ spec.bindir = "exe"
15
+ spec.executables.push("fuel")
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency 'thor', '~> 1.0'
19
+
20
+ end
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bundler'
4
+ Bundler.setup(:default)
5
+ require 'ostruct'
6
+
7
+ module Fuel
8
+ BURN_TIME=480
9
+ REFUEL_TIME=120
10
+ class Error < StandardError; end
11
+ # Your code goes here...
12
+
13
+ ##################### Config #####################
14
+
15
+ def self.configuration
16
+ @configuration ||= OpenStruct.new(
17
+ {
18
+ burn_time: ENV.fetch("FUEL_BURN_TIME",BURN_TIME).to_i,
19
+ refuel_time: ENV.fetch("FUEL_REFUEL_TIME",REFUEL_TIME).to_i
20
+ }
21
+ )
22
+ end
23
+
24
+ def self.configure
25
+ yield(configuration)
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Fuel
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuelcli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - dsofadog
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description:
28
+ email:
29
+ - delaney@so.fa.dog
30
+ executables:
31
+ - fuel
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - exe/fuel
43
+ - fuelcli.gemspec
44
+ - lib/fuel.rb
45
+ - lib/fuel/version.rb
46
+ homepage:
47
+ licenses: []
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.3.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.1.4
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Fuel Gauge
68
+ test_files: []