patience_and_fortitude 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8c9c84288da4dc9b61e2cb6d36eb58c0e3298ab
4
+ data.tar.gz: a687ca49dc4407be67eab912930ae4f3698613dc
5
+ SHA512:
6
+ metadata.gz: 81c033b1d3e8103f94cfaccd820af32be554475eab1da5a4de6399d8a7ccefe320e0aaf58ffbd9879d8677f0a88d47c06fa879b7c5ad142e4ecb6de6402f574d
7
+ data.tar.gz: f072d572af994d7bee9d7b6831efe2a5dc8f09cf53a5af4d57b58b7b09120a9dcacc1c181722061b6b3e2ea07aae0e299f1d649722557a7f6976f653b668d3b6
@@ -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 @@
1
+ patience_and_fortitude
@@ -0,0 +1 @@
1
+ ruby-2.4.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in patience_and_fortitude.gemspec
4
+ gemspec
@@ -0,0 +1,80 @@
1
+ # PatienceAndFortitude
2
+
3
+ Command line access to your NYPL account.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'patience_and_fortitude'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install patience_and_fortitude
20
+
21
+ ## Example Video
22
+
23
+ This application makes (fun?) sounds.
24
+
25
+ [![Screencast Video Screenshot](resources/vimeo-screenshot.png)](https://vimeo.com/246590038)
26
+
27
+ ## Usage
28
+
29
+ ```
30
+ 17:01:46-sschor~/work/patience_and_fortitude (show-fines)$ nypl-cli
31
+ +--------------------------------------------------+
32
+ |oooooooooooooooooooooooooooooooooooooooooooooooooo| _ _ __ __ _ ____ _ _ _
33
+ |ooooooooooooooooooooooo++++ooooooooooooooooooooooo| | \ | | _____ __ \ \ / /__ _ __| | __ | _ \ _ _| |__ | (_) ___
34
+ |ooooooooooooooooo+:~. .:~~~~~~++ooooooooooooooooo| | \| |/ _ \ \ /\ / / \ V / _ \| '__| |/ / | |_) | | | | '_ \| | |/ __|
35
+ |oooooooooooooo+. .+++~.:oooo++:..:ooooooooooooooo| | |\ | __/\ V V / | | (_) | | | < | __/| |_| | |_) | | | (__
36
+ |oooooooooooo+..::++~.~+: ++ooooo+: :ooooooooooooo| |_| \_|\___| \_/\_/ |_|\___/|_| |_|\_\ |_| \__,_|_.__/|_|_|\___|
37
+ |ooooooooooo+ .:::::. ~:++::..:+oooo+. oooooooooooo|
38
+ |oooooooooo+ .::~ oooo+:.++:::+++oo. ooooooooooo|
39
+ |oooooooooo .oo: ++ ooooo+++oo+.. +oo :oooooooooo| _ _ _
40
+ |ooooooooo+ oo .+ +o. :+oooooooo+: :~oo~ oooooooooo| | | (_) |__ _ __ __ _ _ __ _ _
41
+ |ooooooooo+ o: +o oo: .+++.::::..+oo~ oooooooooo| | | | | '_ \| '__/ _` | '__| | | |
42
+ |oooooooooo +~ +o+ +oo+:. :o++. ~++ ~oooooooooo| | |___| | |_) | | | (_| | | | |_| |
43
+ |oooooooooo+ +ooo: :oooo++. :+o+ .ooooooooooo| |_____|_|_.__/|_| \__,_|_| \__, |
44
+ |ooooooooooo+ ~ooooo~ .+ooooo: .ooo..oooooooooooo| |___/
45
+ |oooooooooooo+. :oooooo~ :oooooo~ . ~ooooooooooooo|
46
+ |oooooooooooooo+~.~+++oo+ .ooo+:~.:ooooooooooooooo|
47
+ |ooooooooooooooooo+:~~~~~ ...:++ooooooooooooooooo|
48
+ |oooooooooooooooooooooo++o+oooooooooooooooooooooooo|
49
+ |oooooooooooooooooooooooooooooooooooooooooooooooooo|
50
+ +--------------------------------------------------+
51
+
52
+
53
+ Enter your barcode: *****************
54
+ Enter your pin: ****
55
+
56
+ ▒ connecting..
57
+
58
+ 1. See My Holds
59
+ 2. See My Fines
60
+ 3. Exit
61
+
62
+ What would you like to do?
63
+ 2
64
+ +-------+----------------------------------------------------------------------------------+
65
+ | FINE | TITLE |
66
+ +-------+----------------------------------------------------------------------------------+
67
+ | $0.20 | Zog and the flying doctors / by Julia Donaldson & illustrated by Axel Scheffler. |
68
+ | $0.10 | Stick Man / by Julia Donaldson ; illustrated by Axel Scheffler. |
69
+ +-------+----------------------------------------------------------------------------------+
70
+ ```
71
+
72
+ ## Development
73
+
74
+ 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.
75
+
76
+ 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).
77
+
78
+ ## Contributing
79
+
80
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nodanaonlyzuul/patience_and_fortitude.
@@ -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 "patience_and_fortitude"
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,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,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "patience_and_fortitude"
5
+ require "patience_and_fortitude/audio_player"
6
+ require "patience_and_fortitude/response_formatter"
7
+ require 'highline'
8
+ require 'whirly'
9
+ require 'nypl_site_scraper/scraper'
10
+
11
+ @highline = HighLine.new
12
+
13
+ Whirly.start spinner: "random_dots" do
14
+ puts Rainbow(File.read(File.join(File.dirname(__FILE__), '..', 'resources', 'banner-ascii.txt'))).green
15
+ PatienceAndFortitude::AudioPlayer.play('tone-and-notes')
16
+ end
17
+
18
+ @barcode = @highline.ask("Enter your barcode: ") { |q| q.echo = "*" }
19
+ @pin = @highline.ask("Enter your pin: ") { |q| q.echo = "*" }
20
+
21
+ Whirly.start spinner: "noise", status: "connecting" do
22
+ PatienceAndFortitude::AudioPlayer.play('modem-connection')
23
+ @client = NyplSiteScraper::Client.new(barcode: @barcode, pin: @pin)
24
+ @client.login!
25
+ end
26
+
27
+ def fetch_holds
28
+ puts "\n#{PatienceAndFortitude::ResponseFormatter.holds_response_to_sentence(@client.get_holds)}\n\n"
29
+ main_menu
30
+ end
31
+
32
+ def leave_app
33
+ PatienceAndFortitude::AudioPlayer.play('goodbye')
34
+ exit 0
35
+ end
36
+
37
+ def fetch_fines
38
+ puts "\n#{PatienceAndFortitude::ResponseFormatter.fines_response_to_sentence(@client.get_fines)}\n\n"
39
+ main_menu
40
+ end
41
+
42
+ def main_menu
43
+ @highline.choose do |menu|
44
+ menu.prompt = "What would you like to do?"
45
+ menu.choice("See My Holds") { fetch_holds }
46
+ menu.choice("See My Fines") { fetch_fines }
47
+ menu.choice("Exit") { leave_app }
48
+ end
49
+ end
50
+
51
+ PatienceAndFortitude::AudioPlayer.play('welcome')
52
+ main_menu
@@ -0,0 +1,5 @@
1
+ require "patience_and_fortitude/version"
2
+
3
+ module PatienceAndFortitude
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,16 @@
1
+ module PatienceAndFortitude
2
+ class AudioPlayer
3
+ # For osx, ubuntu, raspbian respectively
4
+ COMMANDS_TO_TRY = %w[afplay play omxplayer]
5
+
6
+ def self.play(file_name)
7
+ COMMANDS_TO_TRY.each do |command|
8
+ if !`which #{command}`.empty?
9
+ `#{command} #{File.join(File.dirname(__FILE__), '..', '..', 'resources', "#{file_name}.wav")} &`
10
+ break
11
+ end
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,46 @@
1
+ module PatienceAndFortitude
2
+ class ResponseFormatter
3
+ require 'rainbow'
4
+ require 'formatador'
5
+
6
+ def self.holds_response_to_sentence(holds_response)
7
+ holds_array = holds_response[:holds]
8
+
9
+ table_data = []
10
+ holds_array.each do |hold|
11
+ table_row = {
12
+ :STATUS => hold[:statusString],
13
+ :TITLE => hold[:title],
14
+ :PICKUP_LOCATION => hold[:pickupLocation]
15
+ }
16
+ table_data << table_row
17
+ end
18
+
19
+ if table_data.empty?
20
+ "Sorry. You have no holds."
21
+ else
22
+ Formatador.display_compact_table(table_data, [:STATUS, :TITLE, :PICKUP_LOCATION])
23
+ end
24
+
25
+ end
26
+
27
+ def self.fines_response_to_sentence(fines_response)
28
+ fines_array = fines_response[:fines]
29
+
30
+ table_data = []
31
+ fines_array.each do |fine|
32
+ table_row = {
33
+ FINE: fine[:fineAmount],
34
+ TITLE: fine[:title]
35
+ }
36
+ table_data << table_row
37
+ end
38
+
39
+ if table_data.empty?
40
+ "Mazel! You have no fines. You ARE fine. You're better than fine. Is...is this love?"
41
+ else
42
+ Formatador.display_compact_table(table_data, [:FINE, :TITLE])
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module PatienceAndFortitude
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'patience_and_fortitude/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "patience_and_fortitude"
8
+ spec.version = PatienceAndFortitude::VERSION
9
+ spec.authors = ["nodanaonlyzuul"]
10
+ spec.email = ["beholdthepanda@gmail.com"]
11
+
12
+ spec.summary = %q{Menu driven, command line access to your NYPL account}
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/nodanaonlyzuul/patience_and_fortitude"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'highline', '~> 1.7'
33
+ spec.add_dependency 'whirly', '~> 0.2.6'
34
+ spec.add_dependency 'nypl-site-scraper', '0.1.1'
35
+ spec.add_dependency 'rainbow', '~> 3.0'
36
+ spec.add_dependency 'paint', '~> 2.0'
37
+ spec.add_dependency 'formatador', '~> 0.2.5'
38
+
39
+ spec.add_development_dependency "pry", '~> 0.11.3'
40
+ spec.add_development_dependency "bundler", "~> 1.13"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ end
@@ -0,0 +1,20 @@
1
+ +--------------------------------------------------+
2
+ |oooooooooooooooooooooooooooooooooooooooooooooooooo| _ _ __ __ _ ____ _ _ _
3
+ |ooooooooooooooooooooooo++++ooooooooooooooooooooooo| | \ | | _____ __ \ \ / /__ _ __| | __ | _ \ _ _| |__ | (_) ___
4
+ |ooooooooooooooooo+:~. .:~~~~~~++ooooooooooooooooo| | \| |/ _ \ \ /\ / / \ V / _ \| '__| |/ / | |_) | | | | '_ \| | |/ __|
5
+ |oooooooooooooo+. .+++~.:oooo++:..:ooooooooooooooo| | |\ | __/\ V V / | | (_) | | | < | __/| |_| | |_) | | | (__
6
+ |oooooooooooo+..::++~.~+: ++ooooo+: :ooooooooooooo| |_| \_|\___| \_/\_/ |_|\___/|_| |_|\_\ |_| \__,_|_.__/|_|_|\___|
7
+ |ooooooooooo+ .:::::. ~:++::..:+oooo+. oooooooooooo|
8
+ |oooooooooo+ .::~ oooo+:.++:::+++oo. ooooooooooo|
9
+ |oooooooooo .oo: ++ ooooo+++oo+.. +oo :oooooooooo| _ _ _
10
+ |ooooooooo+ oo .+ +o. :+oooooooo+: :~oo~ oooooooooo| | | (_) |__ _ __ __ _ _ __ _ _
11
+ |ooooooooo+ o: +o oo: .+++.::::..+oo~ oooooooooo| | | | | '_ \| '__/ _` | '__| | | |
12
+ |oooooooooo +~ +o+ +oo+:. :o++. ~++ ~oooooooooo| | |___| | |_) | | | (_| | | | |_| |
13
+ |oooooooooo+ +ooo: :oooo++. :+o+ .ooooooooooo| |_____|_|_.__/|_| \__,_|_| \__, |
14
+ |ooooooooooo+ ~ooooo~ .+ooooo: .ooo..oooooooooooo| |___/
15
+ |oooooooooooo+. :oooooo~ :oooooo~ . ~ooooooooooooo|
16
+ |oooooooooooooo+~.~+++oo+ .ooo+:~.:ooooooooooooooo|
17
+ |ooooooooooooooooo+:~~~~~ ...:++ooooooooooooooooo|
18
+ |oooooooooooooooooooooo++o+oooooooooooooooooooooooo|
19
+ |oooooooooooooooooooooooooooooooooooooooooooooooooo|
20
+ +--------------------------------------------------+
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: patience_and_fortitude
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nodanaonlyzuul
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: whirly
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: nypl-site-scraper
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rainbow
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: paint
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: formatador
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.2.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.11.3
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.11.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.13'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.13'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '10.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ description:
140
+ email:
141
+ - beholdthepanda@gmail.com
142
+ executables:
143
+ - nypl-cli
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".ruby-gemset"
149
+ - ".ruby-version"
150
+ - Gemfile
151
+ - README.md
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/setup
155
+ - exe/nypl-cli
156
+ - lib/patience_and_fortitude.rb
157
+ - lib/patience_and_fortitude/audio_player.rb
158
+ - lib/patience_and_fortitude/response_formatter.rb
159
+ - lib/patience_and_fortitude/version.rb
160
+ - patience_and_fortitude.gemspec
161
+ - resources/banner-ascii.txt
162
+ - resources/goodbye.wav
163
+ - resources/modem-connection.wav
164
+ - resources/tone-and-notes.wav
165
+ - resources/vimeo-screenshot.png
166
+ - resources/welcome.wav
167
+ homepage: https://github.com/nodanaonlyzuul/patience_and_fortitude
168
+ licenses: []
169
+ metadata:
170
+ allowed_push_host: https://rubygems.org
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubyforge_project:
187
+ rubygems_version: 2.6.14
188
+ signing_key:
189
+ specification_version: 4
190
+ summary: Menu driven, command line access to your NYPL account
191
+ test_files: []