fuelcli 0.1.3 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad1469e92b2a48947081d0e133ce6f394c24f0cd2c857a246aa92f58bfe4f4bd
4
- data.tar.gz: da040b3ce78756394fb64f72abea239ab574a4a376dd5c698af62b815cc51845
3
+ metadata.gz: 0af234ec55592c3bf0aa8f12b8903d5d51c5204a3bf8af65044cb3b066b734b9
4
+ data.tar.gz: 117f336f56634be05b836975dc3f45e5f89f48579066494e9892240179e69d72
5
5
  SHA512:
6
- metadata.gz: b0ee20eef634da66a0f0b0fc07fbafc00a7c464b356661fbde863dea2d9fcf1b3f1a16e82c598934215c61cfecbb190673176a7917f7b498513c9fa7214caf98
7
- data.tar.gz: 2794f79d662dfa1bc727f6dab22c71a8f7e0ffc146577a7929507ebb62d938eeeac4098e24e87c8588c48bd620b36022616226a1170e4101caa808dc09ae812d
6
+ metadata.gz: 3678e1f13a5a382c3ee5e08d3cee53b16c67e299a262b574ecea0db76067626c467b35f1698e772c72755ed065f7c42db5c4dde5ddc0c662656aafc834b00537
7
+ data.tar.gz: 9eda743d9be1520e0a490c9b3fdfc2b62a477e31c96297f68d5a15f8f65255a7f7de703b7f81c61f4fdad0031b8c1ef7dd480066fff57ba2fa38c485fece5ad5
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
data/.idea/fuel.iml ADDED
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="chruby: ruby-2.7.2" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, chruby: ruby-2.7.2) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, chruby: ruby-2.7.2) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="notifier (v0.5.2, chruby: ruby-2.7.2) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="rake (v12.3.3, chruby: ruby-2.7.2) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, chruby: ruby-2.7.2) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.0, chruby: ruby-2.7.2) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.0, chruby: ruby-2.7.2) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.0, chruby: ruby-2.7.2) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.0, chruby: ruby-2.7.2) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, chruby: ruby-2.7.2) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="terminal-notifier (v2.0.0, chruby: ruby-2.7.2) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="thor (v1.1.0, chruby: ruby-2.7.2) [gem]" level="application" />
26
+ </component>
27
+ <component name="RakeTasksCache">
28
+ <option name="myRootTask">
29
+ <RakeTaskImpl id="rake">
30
+ <subtasks>
31
+ <RakeTaskImpl description="Build fuelcli-0.1.8.gem into the pkg directory" fullCommand="build" id="build" />
32
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
33
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
34
+ <RakeTaskImpl description="Build and install fuelcli-0.1.8.gem into system gems" fullCommand="install" id="install" />
35
+ <RakeTaskImpl id="install">
36
+ <subtasks>
37
+ <RakeTaskImpl description="Build and install fuelcli-0.1.8.gem into system gems without network access" fullCommand="install:local" id="local" />
38
+ </subtasks>
39
+ </RakeTaskImpl>
40
+ <RakeTaskImpl description="Create tag v0.1.8 and build and push fuelcli-0.1.8.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
41
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
42
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
43
+ <RakeTaskImpl id="release">
44
+ <subtasks>
45
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
46
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
47
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
48
+ </subtasks>
49
+ </RakeTaskImpl>
50
+ </subtasks>
51
+ </RakeTaskImpl>
52
+ </option>
53
+ </component>
54
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="chruby: ruby-2.7.1" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/fuel.iml" filepath="$PROJECT_DIR$/.idea/fuel.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/Gemfile.lock CHANGED
@@ -1,13 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuel (0.1.2)
4
+ fuelcli (0.2.0)
5
+ notifier (~> 0.5.2)
6
+ ruby-progressbar (~> 1.11)
7
+ terminal-notifier (~> 2.0)
5
8
  thor (~> 1.0)
6
9
 
7
10
  GEM
8
11
  remote: https://rubygems.org/
9
12
  specs:
10
13
  diff-lcs (1.4.4)
14
+ notifier (0.5.2)
11
15
  rake (12.3.3)
12
16
  rspec (3.10.0)
13
17
  rspec-core (~> 3.10.0)
@@ -22,13 +26,15 @@ GEM
22
26
  diff-lcs (>= 1.2.0, < 2.0)
23
27
  rspec-support (~> 3.10.0)
24
28
  rspec-support (3.10.0)
25
- thor (1.0.1)
29
+ ruby-progressbar (1.11.0)
30
+ terminal-notifier (2.0.0)
31
+ thor (1.1.0)
26
32
 
27
33
  PLATFORMS
28
34
  ruby
29
35
 
30
36
  DEPENDENCIES
31
- fuel!
37
+ fuelcli!
32
38
  rake (~> 12.0)
33
39
  rspec
34
40
 
data/exe/fuel CHANGED
@@ -4,6 +4,7 @@ require 'uri'
4
4
  require 'fuel'
5
5
  require 'thor'
6
6
  require 'json'
7
+ require 'notifier'
7
8
  require 'net/http'
8
9
 
9
10
 
@@ -16,34 +17,35 @@ module Fuel
16
17
 
17
18
  def burn(leg)
18
19
  begin
19
- say ""
20
20
  say "#{get_name(leg)}"
21
- say ""
21
+ say "#{get_note_url(leg)}"
22
22
  burn_fuel
23
+ send_notification "fuel burned"
23
24
  if( yes? "leg #{get_name(leg)} flown?")
24
25
  update_flight_plan(leg,true)
25
26
  else
26
27
  update_flight_plan(leg,false)
27
- refuel
28
+ refuel
29
+ send_notification "refueled"
28
30
  burn leg if yes? "burn more fuel on #{get_name(leg)}?"
29
31
  end
32
+ rescue JSON::ParserError => e
33
+ say "#{leg} is not a valid uid"
30
34
  rescue Interrupt => e
31
35
  begin
32
- say ""
33
36
  if @progressbar.title == "Fuel - burning"
34
37
  if yes?("Flown leg?")
35
38
  update_flight_plan(leg,true)
39
+ send_notification "fuel burned"
36
40
  end
37
41
  end
38
42
  if @progressbar.title == "Fuel - refueling"
39
43
  burn leg if yes? "burn more fuel on #{get_name(leg)}?"
40
44
  end
41
-
42
- rescue Interrupt => exception
45
+ rescue Interrupt
43
46
 
44
47
  end
45
48
 
46
-
47
49
  end
48
50
 
49
51
  end
@@ -51,15 +53,23 @@ module Fuel
51
53
  private
52
54
 
53
55
  def get_name(leg)
54
- url = URI("http://flightplanapp.herokuapp.com/api/fuel/#{leg}")
56
+ url = URI("http://#{ENV.fetch("FUEL_HOST","www.flightplanapp.com")}/api/fuel/#{leg}")
55
57
  http = Net::HTTP.new(url.host, url.port)
56
58
  request = Net::HTTP::Get.new(url)
57
59
  response = http.request(request)
58
60
  waypoint = JSON.parse(response.read_body)
59
61
  waypoint["description"]
60
62
  end
63
+ def get_note_url(leg)
64
+ url = URI("http://#{ENV.fetch("FUEL_HOST","www.flightplanapp.com")}/api/fuel/#{leg}")
65
+ http = Net::HTTP.new(url.host, url.port)
66
+ request = Net::HTTP::Get.new(url)
67
+ response = http.request(request)
68
+ waypoint = JSON.parse(response.read_body)
69
+ waypoint["note_url"]
70
+ end
61
71
  def update_flight_plan(leg,flown)
62
- url = URI("http://flightplanapp.herokuapp.com/api/fuel")
72
+ url = URI("http://#{ENV.fetch("FUEL_HOST","www.flightplanapp.com")}/api/fuel")
63
73
  http = Net::HTTP.new(url.host, url.port)
64
74
  request = Net::HTTP::Post.new(url)
65
75
  request["Content-Type"] = 'multipart/form-data'
@@ -71,7 +81,15 @@ module Fuel
71
81
  def burn_fuel
72
82
  invoke_progress title: "Fuel - burning", total: Fuel.configuration.burn_time
73
83
  end
74
-
84
+
85
+ def send_notification msg
86
+ Notifier.notify(
87
+ image: "../gauge.png",
88
+ title: "Fuel Gauge",
89
+ message: msg
90
+ )
91
+ end
92
+
75
93
  def refuel
76
94
  invoke_progress title: "Fuel - refueling", total: Fuel.configuration.refuel_time
77
95
  end
@@ -84,9 +102,7 @@ module Fuel
84
102
  sleep 1
85
103
  end
86
104
  end
87
-
88
-
89
- end
105
+ end
90
106
  end
91
107
 
92
- Fuel::Cli.start(ARGV)
108
+ Fuel::Cli.start(ARGV)
data/fuelcli.gemspec CHANGED
@@ -16,5 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.require_paths = ["lib"]
17
17
 
18
18
  spec.add_dependency 'thor', '~> 1.0'
19
-
20
- end
19
+ spec.add_dependency 'ruby-progressbar', '~> 1.11'
20
+ spec.add_dependency 'notifier', '~> 0.5.2'
21
+ spec.add_dependency 'terminal-notifier', '~> 2.0'
22
+ end
data/gauge.png ADDED
Binary file
data/lib/fuel.rb CHANGED
@@ -1,12 +1,10 @@
1
1
  require 'rubygems'
2
- require 'bundler/setup'
3
- require 'bundler'
4
- Bundler.setup(:default)
5
2
  require 'ostruct'
3
+ require 'ruby-progressbar'
6
4
 
7
5
  module Fuel
8
- BURN_TIME=480
9
- REFUEL_TIME=120
6
+ BURN_TIME=48
7
+ REFUEL_TIME=12
10
8
  class Error < StandardError; end
11
9
  # Your code goes here...
12
10
 
data/lib/fuel/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fuel
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuelcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dsofadog
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,6 +24,48 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-progressbar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: notifier
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: terminal-notifier
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
27
69
  description:
28
70
  email:
29
71
  - delaney@so.fa.dog
@@ -33,6 +75,11 @@ extensions: []
33
75
  extra_rdoc_files: []
34
76
  files:
35
77
  - ".gitignore"
78
+ - ".idea/.gitignore"
79
+ - ".idea/fuel.iml"
80
+ - ".idea/misc.xml"
81
+ - ".idea/modules.xml"
82
+ - ".idea/vcs.xml"
36
83
  - Gemfile
37
84
  - Gemfile.lock
38
85
  - README.md
@@ -41,6 +88,7 @@ files:
41
88
  - bin/setup
42
89
  - exe/fuel
43
90
  - fuelcli.gemspec
91
+ - gauge.png
44
92
  - lib/fuel.rb
45
93
  - lib/fuel/version.rb
46
94
  homepage: