fourteeninch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/fourteeninch.rb +20 -0
- data/fourteeninch.gemspec +32 -0
- data/lib/fourteeninch.rb +40 -0
- data/lib/fourteeninch/auth.rb +41 -0
- data/lib/fourteeninch/client.rb +48 -0
- data/lib/fourteeninch/core.rb +60 -0
- data/lib/fourteeninch/customers.rb +146 -0
- data/lib/fourteeninch/main_menu.rb +22 -0
- data/lib/fourteeninch/screens.rb +65 -0
- data/lib/fourteeninch/version.rb +3 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d9969640a7abcccd0535b1ec2788384b63c2a81
|
4
|
+
data.tar.gz: b527d0ba02a58a5404c0c36baf1fc6d53e57a538
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eee50d93c3c5d294c100217b2536603b276baee626b4ca8092d7ec2279a7b93184022a19396fb9a0f8766408b469073bfdf50803bd45c1743db60a27b7533b37
|
7
|
+
data.tar.gz: 9a6b4f036c3a17afc9eac041f97b945b45a5b7077c16ea44e1ddb7f94e3882041481eb8d78c048a1a118a0879eb299522e600176f068dc263b5b739eaecb8ad4
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Aly Badawy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# 14inch
|
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/14inch`. 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 '14inch'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install 14inch
|
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 `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` to 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
|
+
1. Fork it ( https://github.com/[my-github-username]/14inch/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "14inch"
|
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
|
data/bin/setup
ADDED
data/exe/fourteeninch.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fourteeninch'
|
4
|
+
|
5
|
+
|
6
|
+
case ARGV[0]
|
7
|
+
when '-v', '--version', 'version'
|
8
|
+
puts Fourteeninch::VERSION
|
9
|
+
when '-h', '--help', 'help'
|
10
|
+
puts Fourteeninch::Screens.uses
|
11
|
+
when 'login'
|
12
|
+
Fourteeninch::Auth.auth(true)
|
13
|
+
when 'logout'
|
14
|
+
Fourteeninch::Auth.logout
|
15
|
+
when 'core'
|
16
|
+
Fourteeninch::Core.core
|
17
|
+
else
|
18
|
+
puts "`#{ARGV[0]}` command not found.\n" if ARGV[0]
|
19
|
+
puts Fourteeninch::Screens.uses
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fourteeninch/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fourteeninch"
|
8
|
+
spec.version = Fourteeninch::VERSION
|
9
|
+
spec.authors = ["Fourteen Inch LLC"]
|
10
|
+
spec.email = ["info@fourteeninch.com"]
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.summary = %q{The Gem for managing Fourteen Inch LLC core data.}
|
17
|
+
spec.description = %q{The Gem for managing Fourteen Inch LLC core data.}
|
18
|
+
spec.homepage = "https://fourteeninch.com"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.add_dependency 'httparty', '<= 0.11'
|
22
|
+
spec.add_dependency 'httmultiparty', '<= 0.3.12'
|
23
|
+
spec.add_dependency 'rack'
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
end
|
data/lib/fourteeninch.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'digest/md5'
|
4
|
+
|
5
|
+
require "fourteeninch/version"
|
6
|
+
require "fourteeninch/client"
|
7
|
+
require "fourteeninch/screens"
|
8
|
+
require "fourteeninch/auth"
|
9
|
+
require "fourteeninch/core"
|
10
|
+
require "fourteeninch/main_menu"
|
11
|
+
require "fourteeninch/customers"
|
12
|
+
|
13
|
+
|
14
|
+
module Fourteeninch
|
15
|
+
|
16
|
+
@api_base = 'https://api.fourteeninch.com/api/v1'
|
17
|
+
|
18
|
+
class << self
|
19
|
+
attr_accessor :api_key, :api_secret, :api_base
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.api_url(url='')
|
23
|
+
"#{@api_base}/#{url}"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def self.settings_file
|
28
|
+
File.expand_path('~/.fourteeninch')
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.load_settings
|
32
|
+
if File.exist?(self.settings_file)
|
33
|
+
config = File.open(self.settings_file) do|file|
|
34
|
+
Marshal.load(file)
|
35
|
+
end
|
36
|
+
self.api_key = config[:api_key] if config.has_key?(:api_key)
|
37
|
+
self.api_secret = config[:api_secret] if config.has_key?(:api_secret)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fourteeninch
|
2
|
+
class Auth
|
3
|
+
|
4
|
+
def self.auth(re_auth = false)
|
5
|
+
Fourteeninch.load_settings if !re_auth
|
6
|
+
|
7
|
+
if re_auth || !(Fourteeninch.api_key && Fourteeninch.api_secret)
|
8
|
+
print 'Enter your fourteeninch e-mail: '
|
9
|
+
email = $stdin.gets.chomp
|
10
|
+
|
11
|
+
print 'Enter your fourteeninch password: '
|
12
|
+
system 'stty -echo'
|
13
|
+
password = $stdin.gets.chomp
|
14
|
+
system 'stty echo'
|
15
|
+
|
16
|
+
puts "\nAuthorizing..."
|
17
|
+
|
18
|
+
if (auth = Fourteeninch::Client.auth(email, password)) && (auth.is_a?(Hash)) && (auth.has_key?('api_key')) && (auth.has_key?('api_secret'))
|
19
|
+
File.open(Fourteeninch.settings_file,'w') do|file|
|
20
|
+
Marshal.dump({:api_key => auth['api_key'], :api_secret => auth['api_secret']}, file)
|
21
|
+
end
|
22
|
+
puts "=> You have been authorized. Make sure you log out after finished" if re_auth
|
23
|
+
return true
|
24
|
+
else
|
25
|
+
puts auth['error'] || "Could not authorize, check your e-mail or password."
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
else
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def self.logout
|
35
|
+
File.delete(Fourteeninch.settings_file) if File.exist?(Fourteeninch.settings_file)
|
36
|
+
puts ""
|
37
|
+
puts "You have been logged out."
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'httmultiparty'
|
2
|
+
|
3
|
+
module Fourteeninch
|
4
|
+
class Client
|
5
|
+
def self.auth(email, password)
|
6
|
+
begin
|
7
|
+
request = HTTParty.post(Fourteeninch.api_url('auth'), {query: {email: email, password: password}})
|
8
|
+
return request.parsed_response # parse JSON
|
9
|
+
rescue => e
|
10
|
+
return 'error' => e.message # error
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get(path, params = nil)
|
15
|
+
self.execute(:get, path, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.post(path, params)
|
19
|
+
self.execute(:post, path, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.put(path, params)
|
23
|
+
self.execute(:put, path, params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.delete(path, params = nil)
|
27
|
+
self.execute(:delete, path, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.execute(method, path, params = nil)
|
31
|
+
Fourteeninch.load_settings if !Fourteeninch.api_key
|
32
|
+
begin
|
33
|
+
request = HTTMultiParty.send(method, Fourteeninch.api_url(path), {
|
34
|
+
:query => params,
|
35
|
+
:basic_auth => {:username => Fourteeninch.api_key, :password => Fourteeninch.api_secret},
|
36
|
+
:timeout => 300
|
37
|
+
})
|
38
|
+
if request.respond_to?('parsed_response')
|
39
|
+
return request.parsed_response # parse JSON
|
40
|
+
else
|
41
|
+
return request # raw
|
42
|
+
end
|
43
|
+
rescue => e
|
44
|
+
return 'error' => e.message # error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fourteeninch
|
2
|
+
class Core
|
3
|
+
|
4
|
+
def self.press_a_key
|
5
|
+
print "Please press any key to continue..."
|
6
|
+
begin
|
7
|
+
system("stty raw -echo")
|
8
|
+
STDIN.getc
|
9
|
+
ensure
|
10
|
+
system("stty -raw echo")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.clear
|
15
|
+
system("clear") || system("cls")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.core
|
19
|
+
Fourteeninch.load_settings
|
20
|
+
if Fourteeninch::Auth.auth != false
|
21
|
+
menu = Fourteeninch::Core.do_core(0)
|
22
|
+
while menu != -1
|
23
|
+
menu = Fourteeninch::Core.do_core(menu)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
puts "You are not logged in. Run `fourteeninch login` now to access fourteeninch core."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
def self.do_core(menu = 0)
|
33
|
+
clear
|
34
|
+
case menu
|
35
|
+
when 0
|
36
|
+
return Fourteeninch::MainMenu.intro
|
37
|
+
when 1
|
38
|
+
return Fourteeninch::Customers.customers_menu
|
39
|
+
when 11
|
40
|
+
return Fourteeninch::Customers.list_customers
|
41
|
+
when 12
|
42
|
+
return Fourteeninch::Customers.new_customer
|
43
|
+
when 2
|
44
|
+
# Show invoices menu
|
45
|
+
when 3
|
46
|
+
#show Admin Users Menu
|
47
|
+
when 9
|
48
|
+
Fourteeninch::Auth.logout
|
49
|
+
puts "Good bye..."
|
50
|
+
return -1
|
51
|
+
when 0
|
52
|
+
puts "Good bye..."
|
53
|
+
return -1
|
54
|
+
else
|
55
|
+
return 0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module Fourteeninch
|
2
|
+
class Customers
|
3
|
+
def self.get_params
|
4
|
+
print "Email: "
|
5
|
+
new_email = $stdin.gets.chomp
|
6
|
+
print "Name: "
|
7
|
+
new_name = $stdin.gets.chomp
|
8
|
+
print "Company: : "
|
9
|
+
new_company = $stdin.gets.chomp
|
10
|
+
print "Phone: "
|
11
|
+
new_phone = $stdin.gets.chomp
|
12
|
+
print "Address 1: "
|
13
|
+
new_address1 = $stdin.gets.chomp
|
14
|
+
print "Address 2: "
|
15
|
+
new_address2 = $stdin.gets.chomp
|
16
|
+
print "City: "
|
17
|
+
new_city = $stdin.gets.chomp
|
18
|
+
print "State: "
|
19
|
+
new_state = $stdin.gets.chomp
|
20
|
+
print "Country: "
|
21
|
+
new_country = $stdin.gets.chomp
|
22
|
+
print "Zip Code: "
|
23
|
+
new_zip = $stdin.gets.chomp
|
24
|
+
params = {}
|
25
|
+
params.merge!(email: new_email) if new_email != ""
|
26
|
+
params.merge!(name: new_name) if new_name != ""
|
27
|
+
params.merge!(company: new_company) if new_company != ""
|
28
|
+
params.merge!(phone: new_phone) if new_phone != ""
|
29
|
+
params.merge!(address1: new_address1) if new_address1 != ""
|
30
|
+
params.merge!(address2: new_address2) if new_address2 != ""
|
31
|
+
params.merge!(city: new_city) if new_city != ""
|
32
|
+
params.merge!(state: new_state) if new_state != ""
|
33
|
+
params.merge!(country: new_country) if new_country != ""
|
34
|
+
params.merge!(zip: new_zip) if new_zip != ""
|
35
|
+
return params
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.edit_customer(customer)
|
39
|
+
puts "\n\n Edit Customer Information\n=================\n\n"
|
40
|
+
puts "LEAVE A FIELD BLANK FOR NO CHANGES\n"
|
41
|
+
params = get_params
|
42
|
+
puts "\n\nUpdating customer ...."
|
43
|
+
customer = Fourteeninch::Client.put('customers/' + customer['id'].to_s, params)
|
44
|
+
if customer && customer.is_a?(Hash) & customer.has_key?('id')
|
45
|
+
puts "done"
|
46
|
+
else
|
47
|
+
puts "Some error happend!! please try again"
|
48
|
+
end
|
49
|
+
Fourteeninch::Core.press_a_key
|
50
|
+
return 11
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.new_customer
|
54
|
+
puts "\n\n Create a new Customer\n==================="
|
55
|
+
params = get_params
|
56
|
+
customer = Fourteeninch::Client.post('customers', params)
|
57
|
+
if customer && customer.is_a?(Hash) && customer.has_key?('id')
|
58
|
+
puts "Customer created"
|
59
|
+
Fourteeninch::Core.press_a_key
|
60
|
+
return show_customer(customer)
|
61
|
+
else
|
62
|
+
puts "Some error happend!! please try again"
|
63
|
+
Fourteeninch::Core.press_a_key
|
64
|
+
return 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.show_customer(customer)
|
69
|
+
Fourteeninch::Core.clear
|
70
|
+
puts "\n\n Customer Information\n================="
|
71
|
+
puts " ID: #{customer['id']}"
|
72
|
+
puts " Email: #{customer['email']}"
|
73
|
+
puts " Name: #{customer['name']}"
|
74
|
+
puts " Company: #{customer['company']}"
|
75
|
+
puts " Phone: #{customer['phone']}"
|
76
|
+
puts " Address 1: #{customer['address1']}"
|
77
|
+
puts " Address 2: #{customer['address2']}"
|
78
|
+
puts " City: #{customer['city']}"
|
79
|
+
puts " State: #{customer['state']}"
|
80
|
+
puts " Country: #{customer['country']}"
|
81
|
+
puts " ZIP code: #{customer['zip']}"
|
82
|
+
puts "\n\n"
|
83
|
+
puts "Do you want to edit this customer?[Yes/No]"
|
84
|
+
edit_choice = $stdin.gets.chomp
|
85
|
+
while !(edit_choice == "Yes" || edit_choice == "No" || edit_choice == "yes" || edit_choice == "no")
|
86
|
+
puts "Do you want to edit this customer?[Yes/No]"
|
87
|
+
edit_choice = $stdin.gets.chomp
|
88
|
+
end
|
89
|
+
if edit_choice == "No" || edit_choice == "no"
|
90
|
+
return 11
|
91
|
+
elsif edit_choice == "Yes" || edit_choice == "yes"
|
92
|
+
edit_customer(customer)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.list_customers
|
97
|
+
puts "Retrieving customers....\n\n"
|
98
|
+
customers = Fourteeninch::Client.get('customers')
|
99
|
+
puts"\nAll Customers:\n=================\n\n"
|
100
|
+
if customers && customers.is_a?(Array) && customers.count > 0
|
101
|
+
customers.each do |c|
|
102
|
+
puts (" " * (5 - c['id'].to_s.length)) + c['id'].to_s + ". " + c['name'].to_s
|
103
|
+
end
|
104
|
+
else
|
105
|
+
puts "No Customers found!"
|
106
|
+
end
|
107
|
+
print "\n\nTo view, edit, or delete a customer, enter thier ID now. (Or enter `0` to exit): "
|
108
|
+
customer_choice = $stdin.gets.chomp
|
109
|
+
if customer_choice == "0"
|
110
|
+
return 1
|
111
|
+
elsif customer_choice == ""
|
112
|
+
return 11
|
113
|
+
else
|
114
|
+
customer = Fourteeninch::Client.get('customers/' + customer_choice)
|
115
|
+
if customer && customer.is_a?(Hash) && customer.has_key?('id')
|
116
|
+
self.show_customer(customer)
|
117
|
+
return 11
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.customers_menu
|
123
|
+
puts Fourteeninch::Screens.customer_intro
|
124
|
+
print 'Enter command number: '
|
125
|
+
customer_choice = $stdin.gets.chomp
|
126
|
+
case customer_choice
|
127
|
+
when '1'
|
128
|
+
return 11
|
129
|
+
when '2'
|
130
|
+
return 12
|
131
|
+
when '0'
|
132
|
+
return 0
|
133
|
+
else
|
134
|
+
return 1
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
def self.invoices
|
141
|
+
clear
|
142
|
+
puts "Invoices"
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "fourteeninch/screens"
|
2
|
+
module Fourteeninch
|
3
|
+
class MainMenu
|
4
|
+
def self.intro
|
5
|
+
puts Fourteeninch::Screens.intro
|
6
|
+
print 'Enter command number: '
|
7
|
+
menu = $stdin.gets.chomp
|
8
|
+
case menu
|
9
|
+
when '1'
|
10
|
+
return 1
|
11
|
+
when '2'
|
12
|
+
return 2
|
13
|
+
when '9'
|
14
|
+
return 9
|
15
|
+
when '0'
|
16
|
+
return -1
|
17
|
+
else
|
18
|
+
return 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Fourteeninch
|
2
|
+
class Screens
|
3
|
+
|
4
|
+
def self.intro
|
5
|
+
%Q(
|
6
|
+
|
7
|
+
============================================================================
|
8
|
+
|
9
|
+
F O U R T E E N I N C H L L C
|
10
|
+
|
11
|
+
ALERT! You are entering into a secured area! Your IP, Login Time,
|
12
|
+
HAVE been noted and has been sent to the server administrator!
|
13
|
+
This service is restricted to authorized users only. All activities on
|
14
|
+
this system are logged. Unauthorized access will be fully investigated and
|
15
|
+
reported to the appropriate law enforcement agencies.
|
16
|
+
|
17
|
+
============================================================================
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
Please type the number of the desired command:
|
22
|
+
|
23
|
+
1 : Customers
|
24
|
+
2 : Invoices
|
25
|
+
3 : Admin Users
|
26
|
+
9 : Logout
|
27
|
+
0 : Exit (Without logout)
|
28
|
+
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def self.customer_intro
|
35
|
+
%Q(
|
36
|
+
|
37
|
+
Please type the number of the desired command:
|
38
|
+
|
39
|
+
1 : List All customer
|
40
|
+
2 : Create a new customer
|
41
|
+
0 : Exit
|
42
|
+
|
43
|
+
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.uses
|
48
|
+
%Q(
|
49
|
+
Usage: fourteeninch [COMMAND] [OPTIONS]
|
50
|
+
Commands:
|
51
|
+
login Login in with your credentials
|
52
|
+
logout Logout from fourteeninch
|
53
|
+
core Access the core of fourteeninch
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
Options:
|
58
|
+
-h, --help Prints this help document
|
59
|
+
-v, --version Prints the fourteeninch gem version
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fourteeninch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fourteen Inch LLC
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "<="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.11'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "<="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httmultiparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "<="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.12
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "<="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.3.12
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack
|
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: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description: The Gem for managing Fourteen Inch LLC core data.
|
84
|
+
email:
|
85
|
+
- info@fourteeninch.com
|
86
|
+
executables:
|
87
|
+
- fourteeninch.rb
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- exe/fourteeninch.rb
|
100
|
+
- fourteeninch.gemspec
|
101
|
+
- lib/fourteeninch.rb
|
102
|
+
- lib/fourteeninch/auth.rb
|
103
|
+
- lib/fourteeninch/client.rb
|
104
|
+
- lib/fourteeninch/core.rb
|
105
|
+
- lib/fourteeninch/customers.rb
|
106
|
+
- lib/fourteeninch/main_menu.rb
|
107
|
+
- lib/fourteeninch/screens.rb
|
108
|
+
- lib/fourteeninch/version.rb
|
109
|
+
homepage: https://fourteeninch.com
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.4.5
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: The Gem for managing Fourteen Inch LLC core data.
|
133
|
+
test_files: []
|