aztro_cli 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
+ SHA256:
3
+ metadata.gz: 7f074469a35f199c6d17a670c5e927f16fd53a27ddbb5fad550541033f1e468d
4
+ data.tar.gz: 1321d55f0b579da2b7d1de69b7a7faba5fd4cb28048daf429f9ffa83534a6751
5
+ SHA512:
6
+ metadata.gz: 57093ba68e082be455a55635e8bd98733d087f8e85c61f93ca96452247a220156c9ade5026b6c1558cb19542d869fce6a910ec2465a5786ee844420fc779cb29
7
+ data.tar.gz: 25b9541666655fc9fcd3789e13073917591d3140550cf76786ba2f0385dee5d7401350eceb04bc8bb96caaf064c7c2bcadc4fb4234fbec1c1e86409e2f4cbb9b
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in aztro_cli.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,37 @@
1
+ # AztroCli
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/aztro_cli`. 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 'aztro_cli'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install aztro_cli
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. Then, run `rake spec` to run the tests. 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/<github username>/aztro_cli.
36
+
37
+ # aztro_cli
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/aztro_cli/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "aztro_cli"
5
+ spec.version = AztroCli::VERSION
6
+ spec.authors = ["lg00d"]
7
+ spec.email = ["egoodman1180@icloud.com"]
8
+
9
+ spec.summary = "This CLI project is for those who want to learn about sun signs."
10
+ spec.description = "This CLI project is for those who want to learn about sun signs."
11
+ spec.homepage = "https://github.com/lg00d/aztro_cli"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/lg00d/aztro_cli"
17
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
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('..', __FILE__)) 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
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "aztro_cli"
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,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/aztro_cli'
4
+
5
+ AztroCli::CLI.new
@@ -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,9 @@
1
+ require_relative "./aztro_cli/version"
2
+
3
+ require_relative './aztro_cli/api'
4
+ require_relative './aztro_cli/cli'
5
+ require_relative './aztro_cli/sunsign'
6
+
7
+
8
+ require 'rest-client'
9
+ require 'json'
@@ -0,0 +1,8 @@
1
+ class API
2
+
3
+ def self.get_data(sign)
4
+ response = RestClient.post("https://aztro.sameerkumar.website/?sign=#{sign}&day=today", {})
5
+ aztro_data = JSON.parse(response.body)
6
+ return aztro_data
7
+ end
8
+ end
@@ -0,0 +1,137 @@
1
+ class AztroCli::CLI
2
+ attr_accessor :user_sign, :user_object
3
+ attr_reader :api_data, :sun_signs
4
+
5
+ def initialize
6
+ @sun_signs = ["aquarius", "pisces", "aries", "taurus", "gemini", "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius", "capricorn"]
7
+ @api_data = []
8
+ sun_signs.each do |sign|
9
+ data = API.get_data(sign)
10
+ sunsign_object = SunSign.new(sign, data)
11
+ @api_data << sunsign_object
12
+ end
13
+ call
14
+ end
15
+
16
+ def call
17
+ puts "Welcome!"
18
+ puts "To learn more about your sun sign, please enter 'start'"
19
+ puts "To find your sun sign, please enter 'list'"
20
+ puts "To exit, please enter 'exit'"
21
+ menu
22
+ end
23
+
24
+ def menu
25
+ input = gets.strip.downcase
26
+ if input == "start"
27
+ get_horoscope
28
+ elsif input == "list"
29
+ list_signs
30
+ elsif input == "exit"
31
+ goodbye
32
+ else
33
+ invalid_entry
34
+ end
35
+ end
36
+
37
+ def features
38
+ puts "To learn more about your sign, please enter: 'mood', 'compatibility', 'color', 'lucky number, 'lucky time', or 'exit'"
39
+
40
+ input = gets.strip.downcase
41
+
42
+ if input == "compatibility"
43
+ compatibility
44
+ elsif input == "mood"
45
+ mood
46
+ elsif input == "color"
47
+ color
48
+ elsif input == "lucky number"
49
+ lucky_number
50
+ elsif input == "lucky time"
51
+ lucky_time
52
+ elsif input == "exit"
53
+ goodbye
54
+ elsif
55
+ invalid
56
+ else
57
+ menu
58
+ end
59
+ end
60
+
61
+ def get_horoscope
62
+ puts "please enter your sign"
63
+ input = gets.strip.downcase
64
+
65
+ if (sun_signs.include?(input))
66
+ puts "That's a valid sign"
67
+ @user_sign = input
68
+ selected_sign = api_data.select do |sign|
69
+ sign.sign_name == user_sign
70
+ end
71
+ puts selected_sign
72
+ @user_object = selected_sign.first
73
+ puts "#{user_object.date_range}, #{user_object.description}"
74
+ features
75
+ else
76
+ puts "sorry, that's not a valid sign"
77
+ get_horoscope()
78
+ end
79
+
80
+ end
81
+
82
+ def current_date
83
+ puts "#{user_object.current_date}"
84
+ menu
85
+ end
86
+
87
+ def compatibility
88
+ puts "#{user_object.compatibility}"
89
+ features
90
+ end
91
+
92
+ def mood
93
+ puts "#{user_object.mood}"
94
+ features
95
+ end
96
+
97
+ def color
98
+ puts "#{user_object.color}"
99
+ features
100
+ end
101
+
102
+ def lucky_number
103
+ puts "#{user_object.lucky_number}"
104
+ features
105
+ end
106
+
107
+ def lucky_time
108
+ puts "#{user_object.lucky_time}"
109
+ features
110
+ end
111
+
112
+ def list_signs
113
+ api_data.each do |sign|
114
+
115
+ puts "#{sign.sign_name} , #{sign.date_range}"
116
+
117
+ end
118
+ puts "===================================="
119
+ puts "please enter 'start' to learn about your sign!"
120
+ menu
121
+ end
122
+
123
+ def goodbye
124
+ puts "Goodbye!"
125
+ exit!
126
+ end
127
+
128
+ def invalid_entry
129
+ puts "Invalid entry. Please try again."
130
+ menu
131
+ end
132
+
133
+ def invalid
134
+ puts "Invalid entry. Please try again."
135
+ features
136
+ end
137
+ end
@@ -0,0 +1,15 @@
1
+ class SunSign
2
+ attr_accessor :sign_name, :mood, :compatibility, :color, :lucky_number, :lucky_time, :current_date, :date_range, :description
3
+
4
+ def initialize(name, data)
5
+ @sign_name = name
6
+ @mood = data["mood"]
7
+ @compatibility = data["compatibility"]
8
+ @color = data["color"]
9
+ @lucky_number = data["lucky_number"]
10
+ @lucky_time = data["lucky_time"]
11
+ @current_date = data["current_date"]
12
+ @date_range = data["date_range"]
13
+ @description = data["description"]
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module AztroCli
2
+ VERSION = "0.1.0"
3
+ end
data/notes ADDED
@@ -0,0 +1,13 @@
1
+ Theres no way for the program to infer all of the sun signs
2
+ hard coding was necessary
3
+
4
+ .new = the class will create a new instance of itself. It will then, internally,
5
+ call the method initialize on the new object. Doing so it will simply pass all
6
+ the arguments that you passed to .new on to the method initialize.
7
+
8
+ Require_relative = referring to a file that is relative to the current file you are working
9
+ on (basically, within the same project directory)
10
+
11
+ Require = Is a method that is used when you want to reference and execute code that is not written in your current file
12
+
13
+ select = returns a new object (e.g. array) filled with only those original items where the block you gave it returned true
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aztro_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - lg00d
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-12-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This CLI project is for those who want to learn about sun signs.
14
+ email:
15
+ - egoodman1180@icloud.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - Gemfile
24
+ - README.md
25
+ - Rakefile
26
+ - aztro_cli.gemspec
27
+ - bin/console
28
+ - bin/executable.rb
29
+ - bin/setup
30
+ - lib/aztro_cli.rb
31
+ - lib/aztro_cli/api.rb
32
+ - lib/aztro_cli/cli.rb
33
+ - lib/aztro_cli/sunsign.rb
34
+ - lib/aztro_cli/version.rb
35
+ - notes
36
+ homepage: https://github.com/lg00d/aztro_cli
37
+ licenses: []
38
+ metadata:
39
+ homepage_uri: https://github.com/lg00d/aztro_cli
40
+ source_code_uri: https://github.com/lg00d/aztro_cli
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.3.0
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubygems_version: 3.1.4
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: This CLI project is for those who want to learn about sun signs.
60
+ test_files: []