hi_cathy 0.1.0

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
+ SHA256:
3
+ metadata.gz: f558ba354ab74336ae46a3933bd837a2def414c2272c6b5797cb6421e3df2f2d
4
+ data.tar.gz: 53d196d826b38a279392c54d2754e9cf62494a7e66a26be17b954d7a74927b30
5
+ SHA512:
6
+ metadata.gz: a6c451273c2dd89f215a893dda4ac0099b21721a2fe35f7b2a7ccbaaadb00801f3bd104d5cfc3c6c8069bc1273cb615164e4115c650631a67ad942fb1383463a
7
+ data.tar.gz: 4ea3ed7095c4844e5a73d91c39be12d55f5299db8d80ef48e952a8b5b37de6025f5605b8eb32b5c18024b0a788ddb8dc3599cb8d98091936ebd1839bf423ec1c
data/.gitignore ADDED
@@ -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,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in hi_cathy.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hi_cathy (0.1.0)
5
+ pastel
6
+ tty-font
7
+ tty-prompt
8
+ tty-spinner
9
+ twilio-ruby
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ equatable (0.6.1)
15
+ faraday (0.17.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ jwt (2.2.1)
18
+ mini_portile2 (2.4.0)
19
+ multipart-post (2.1.1)
20
+ necromancer (0.5.0)
21
+ nokogiri (1.10.4)
22
+ mini_portile2 (~> 2.4.0)
23
+ pastel (0.7.3)
24
+ equatable (~> 0.6)
25
+ tty-color (~> 0.5)
26
+ rake (10.5.0)
27
+ tty-color (0.5.0)
28
+ tty-cursor (0.7.0)
29
+ tty-font (0.4.0)
30
+ tty-prompt (0.19.0)
31
+ necromancer (~> 0.5.0)
32
+ pastel (~> 0.7.0)
33
+ tty-reader (~> 0.6.0)
34
+ tty-reader (0.6.0)
35
+ tty-cursor (~> 0.7)
36
+ tty-screen (~> 0.7)
37
+ wisper (~> 2.0.0)
38
+ tty-screen (0.7.0)
39
+ tty-spinner (0.9.1)
40
+ tty-cursor (~> 0.7)
41
+ twilio-ruby (5.28.0)
42
+ faraday (~> 0.9)
43
+ jwt (>= 1.5, <= 2.5)
44
+ nokogiri (>= 1.6, < 2.0)
45
+ wisper (2.0.1)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ bundler (~> 2.0)
52
+ hi_cathy!
53
+ rake (~> 10.0)
54
+
55
+ BUNDLED WITH
56
+ 2.0.2
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # HiCathy
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/hi_cathy`. 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 'hi_cathy'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install hi_cathy
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]/hi_cathy.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'hi_cathy'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -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
data/exe/hi_cathy ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'hi_cathy/cli'
5
+
6
+ HiCathy::CLI.new.start!
data/hi_cathy.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'hi_cathy/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'hi_cathy'
9
+ spec.version = HiCathy::VERSION
10
+ spec.authors = ['Yasyf Mohamedali']
11
+ spec.email = ['yasyf@meetkaruna.com']
12
+
13
+ spec.summary = 'Hi, Cathy!'
14
+ spec.homepage = 'https://github.com/yasyf/hi_cathy'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/yasyf/hi_cathy'
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_dependency 'pastel'
29
+ spec.add_dependency 'tty-font'
30
+ spec.add_dependency 'tty-prompt'
31
+ spec.add_dependency 'tty-spinner'
32
+ spec.add_dependency 'twilio-ruby'
33
+
34
+ spec.add_development_dependency 'bundler', '~> 2.0'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ end
data/lib/hi_cathy.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hi_cathy/version'
4
+
5
+ module HiCathy
6
+ class Error < StandardError; end
7
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-prompt'
4
+ require 'tty-spinner'
5
+ require 'tty-font'
6
+ require 'pastel'
7
+
8
+ require 'hi_cathy/sms'
9
+
10
+ module HiCathy
11
+ class CLI
12
+ attr_reader :prompt, :pastel, :sms
13
+
14
+ def initialize
15
+ @prompt = TTY::Prompt.new(interrupt: :exit)
16
+ @pastel = Pastel.new
17
+ @sms = HiCathy::SMS.new
18
+ end
19
+
20
+ def start!
21
+ hero! 'Hi, Cathy!'
22
+ newline!
23
+ newline!
24
+
25
+ say! "First things first!"
26
+ say! "We can't have you forgetting my most important defining characteristic again..."
27
+ newline!
28
+ prompt.ask('Which country am I from?', color: :cyan) do |q|
29
+ q.validate /🇨🇦/, 'Nope! P.S. the answer is an emoji 😉'
30
+ end
31
+ spin_for!('Analyzing answer...') { wait! }
32
+ say! 'You got it!'
33
+ newline!
34
+
35
+ wait!
36
+
37
+ say! 'Next up: dinner plans!'
38
+ say! 'Our playbook this time is to check out Kuma at a slighly less peak time, and fall back to Tycoon 😋'
39
+ newline!
40
+
41
+ excitment = prompt.slider('How excited are you for this??', max: 10, default: 8)
42
+
43
+ say! 'Me too!' if excitment == 10
44
+ newline!
45
+
46
+ choice = prompt.select('Do any of these times work?') do |menu|
47
+ menu.choice 'Wednesday the 13th at 6pm'
48
+ menu.choice 'Saturday the 16th at noon'
49
+ menu.choice 'Nope!', :none
50
+ end
51
+
52
+ unless choice == :none
53
+ finish! choice
54
+ return
55
+ end
56
+
57
+ newline!
58
+ say! "Oh no! We'll have to wait until I'm back from Vietnam then."
59
+ say! "Let's bruteforce a date that works..."
60
+
61
+ day = Date.new(2019, 11, 27)
62
+ until choice != :none
63
+ choice = prompt.select("Do any of these times on #{format_day(day)} work?") do |menu|
64
+ menu.choice "Noon" if day.saturday? || day.sunday?
65
+ menu.choice "6pm"
66
+ menu.choice 'Nope!', :none
67
+ end
68
+ day = day.next_day(1)
69
+ end
70
+
71
+ finish! "#{format_day(day)} at #{choice}"
72
+ end
73
+
74
+ private
75
+
76
+ def format_day(day)
77
+ day.strftime '%A, %B %-e'
78
+ end
79
+
80
+ def finish!(choice)
81
+ send! "Response from Cathy: #{choice}"
82
+ say! 'Great! See you then 😄'
83
+ end
84
+
85
+ def send!(message)
86
+ sms.send! message
87
+ end
88
+
89
+ def wait!(seconds: 1)
90
+ sleep seconds
91
+ end
92
+
93
+ def newline!
94
+ prompt.say "\n"
95
+ end
96
+
97
+ def say!(message)
98
+ prompt.say message, color: :bright_cyan
99
+ end
100
+
101
+ def hero!(title)
102
+ TTY::Font.new(:starwars).tap do |font|
103
+ puts pastel.bold(font.write(title, letter_spacing: 2, color: :bold))
104
+ end
105
+ end
106
+
107
+ def spin_for!(title)
108
+ TTY::Spinner.new("[:spinner] #{title}", format: :spin_2).tap do |spinner|
109
+ spinner.auto_spin
110
+ yield
111
+ spinner.success
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'twilio-ruby'
4
+
5
+ module HiCathy
6
+ class SMS
7
+ ACCOUNT_SID = 'ACb5c843869d38af5284dbc62654912108'
8
+ AUTH_TOKEN = 'c78fee62bb4fd1eb23d4cae446a3b7b9' # oh god please don't steal this
9
+
10
+ FROM = '+14173522849'
11
+ TO = '+16176316733'
12
+
13
+ attr_reader :client
14
+
15
+ def initialize
16
+ @client = Twilio::REST::Client.new ACCOUNT_SID, AUTH_TOKEN
17
+ end
18
+
19
+ def send!(message)
20
+ client.messages.create(body: message, from: FROM, to: TO)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HiCathy
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hi_cathy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yasyf Mohamedali
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pastel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-font
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-prompt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-spinner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: twilio-ruby
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ description:
112
+ email:
113
+ - yasyf@meetkaruna.com
114
+ executables:
115
+ - hi_cathy
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - README.md
123
+ - Rakefile
124
+ - bin/console
125
+ - bin/setup
126
+ - exe/hi_cathy
127
+ - hi_cathy.gemspec
128
+ - lib/hi_cathy.rb
129
+ - lib/hi_cathy/cli.rb
130
+ - lib/hi_cathy/sms.rb
131
+ - lib/hi_cathy/version.rb
132
+ homepage: https://github.com/yasyf/hi_cathy
133
+ licenses: []
134
+ metadata:
135
+ homepage_uri: https://github.com/yasyf/hi_cathy
136
+ source_code_uri: https://github.com/yasyf/hi_cathy
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubygems_version: 3.0.4
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: Hi, Cathy!
156
+ test_files: []