veye 0.0.2 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDYwMzRlOWM5ZTI0MDI5OTMyNTIzYTVjMDhmYjRlYWJhYjE0YzM3OA==
4
+ MDJmMzFkNDk1NGJlMGI0MTgzZGY5NzcyMzQ3MDRhYjE5MDI3OWFjYQ==
5
5
  data.tar.gz: !binary |-
6
- N2QyYWE5NmZjMzgwODg1MDlkMjNjM2Q5YjgxZWE1ZjI0OTc4YjIwOQ==
6
+ ZDFiOWUxMWYyZjFjODZhMWRhMGQzNzJkNjZiMDFmZmJhNTc2MzkyOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWI3ZmZlYWY4YmY0YzY1MTUzMzUxYjkwOWY1OTllODhhZjZjYTMzOTE1MDJl
10
- NDRmOWQ2NjA3OWY1N2E5YWY5NzJjY2YyOTRhNjY4YmQyMTVkYmI3MTVhZmUx
11
- NDdkNmUyMGE0MGI1YjBkMTNhMmM0Njk5MDE3MTA2ODk3ODhhYTc=
9
+ ZjA1MGI5ZTI0OWQ0ZjVjNDQyNDIwMWFjMzRmY2MwMGRjZGU4MTU1NGJlYWE0
10
+ NTJiYTQ3ZjNkMTBhMTk0MWMxY2FmMjA3NTg0NWU1YmViNmM0ZGQ5YTU2MTA0
11
+ ZjBlYmY1M2Y3NGZmZjNjZWI3NGMzNmI2OTExMzY5MzgwNTg4ZmE=
12
12
  data.tar.gz: !binary |-
13
- YzZjYWVmZTIyMGU2ZjI4NGY4Y2JkNGFkZGQ1NzIzOTMyMWU2OTU5MDg4NGMy
14
- NDRiNDNjYzkxNmUyYzNjZmMwM2FhMzc2ODg0ZTA3YzM0YWM5MjExMzRkMjk1
15
- NTg3NWI2YTAwNjQ1YTEyYTM5YmQzZGE5ZTVlZmFlYWE2ZjM1MmM=
13
+ MDQxZGY3Y2JlMzY1ZGU5MGIzMTRhOTMyNWRmYjI2ZmVlYjZkNjRhMjVhOWZm
14
+ Y2EyNDllNWE4MDRmMGNlMmU3MThmYmU2Mjc3YWNmYTI5ZGQ4ZDNhOWVjZjNj
15
+ Y2U0ZGUxNGEzNzAzYzE2NjNjY2QyNmVkMDYxMzMxMDVkM2M0NjY=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- veye (0.0.2)
4
+ veye (0.0.3)
5
5
  awesome_print (= 1.2.0)
6
6
  gli (= 2.8.0)
7
7
  rainbow
data/bin/veye CHANGED
@@ -32,11 +32,15 @@ flag :path, :default_value => "api/v2"
32
32
  desc 'set connection protocol'
33
33
  flag :protocol, :default_value => "http"
34
34
 
35
+ desc 'set folder of veye_cert.pem'
36
+ flag :ssl_path, :default_value => "~/keys"
37
+
35
38
  desc "don't use colors"
36
39
  switch 'color', :default_value => true, :negetable => true
37
40
 
38
41
  pre do |global_options, options, args|
39
- $global_options = init_environment #global_options
42
+ check_config_file
43
+ $global_options = init_environment
40
44
  $global_options.merge!(global_options)
41
45
  check_configs($global_options)
42
46
  $global_options[:url] = Veye::API::Resource.build_url($global_options)
data/lib/veye.rb CHANGED
@@ -21,15 +21,22 @@ def config_exists?
21
21
  File.exists?(filepath)
22
22
  end
23
23
 
24
- def self.check_configs(global_opts)
24
+ def check_config_file
25
25
  unless config_exists?
26
26
  msg = sprintf("%s: %s\n",
27
27
  "config file doesnt exist. ".foreground(:red),
28
28
  "Use `veye initconfig` to initialize settings file.")
29
29
  exit_now!(msg)
30
30
  end
31
+ end
32
+
33
+ def self.check_configs(global_opts)
34
+ check_config_file
31
35
  check_api_key(global_opts)
32
36
 
37
+ unless ssl_key_exists?(global_opts)
38
+ generate_ssl_keys(global_opts)
39
+ end
33
40
  true
34
41
  end
35
42
 
@@ -57,6 +64,36 @@ def check_api_key(global_opts)
57
64
  result
58
65
  end
59
66
 
67
+ def ssl_key_exists?(global_opts)
68
+ fullpath = File.expand_path(global_opts[:ssl_path])
69
+ return File.exists?("#{fullpath}/veye_cert.pem")
70
+ end
71
+
72
+ def generate_ssl_keys(global_opts)
73
+ result = false
74
+ key_command = %Q[
75
+ openssl req -x509 -newkey rsa:2048 -keyout veye_key.pem -out veye_cert.pem -nodes
76
+ ]
77
+
78
+ Dir.chdir(Dir.home)
79
+ ssl_path = File.expand_path(global_opts[:ssl_path])
80
+ unless Dir.exists?(ssl_path)
81
+ p "Creating folder for ssl keys: `#{ssl_path}`"
82
+ Dir.makedir(ssl_path)
83
+ end
84
+
85
+ Dir.chdir(ssl_path)
86
+ if system(key_command)
87
+ print "Key is generated.\n"
88
+ result = true
89
+ else
90
+ print "Cant generate SSL keys. Do you have openssl installed?\n"
91
+ end
92
+
93
+ Dir.chdir(Dir.home)
94
+ result
95
+ end
96
+
60
97
  def update_api_key
61
98
  user_key = gets.chomp.to_s.strip
62
99
  if user_key =~ /No/i
@@ -9,10 +9,13 @@ module Veye
9
9
  class Resource < BaseResource
10
10
  def initialize(path = nil)
11
11
  super(path)
12
+ ssl_path = File.expand_path($global_options[:ssl_path])
12
13
  @resource = RestClient::Resource.new(
13
14
  @full_path,
14
- :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
15
- :ssl_client_key => OpenSSL::PKey::RSA.new(File.read("key.pem"), "passphrase, if any"),
15
+ :ssl_client_cert => OpenSSL::X509::Certificate.new(
16
+ File.read("#{ssl_path}/veye_cert.pem")),
17
+ :ssl_client_key => OpenSSL::PKey::RSA.new(
18
+ File.read("#{ssl_path}/veye_key.pem"), "passphrase, if any"),
16
19
  :ssl_ca_file => "ca_certificate.pem",
17
20
  :verify_ssl => OpenSSL::SSL::VERIFY_PEER
18
21
  )
data/lib/veye/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Veye
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  BIGEYE = %q{
4
4
 
5
5
  _ __ _ ______
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - VersionEye GMBH
@@ -124,9 +124,9 @@ dependencies:
124
124
  - - '='
125
125
  - !ruby/object:Gem::Version
126
126
  version: 1.4.5
127
- description: ! " Veye is commandline tool like Heroku has own ToolBelt, \n and
127
+ description: ! "\n Veye is commandline tool like Heroku has own ToolBelt, \n and
128
128
  purpose of this tool is to make developer's life even\n more simpler and keep
129
- you up-to-date with freshest packages.\n"
129
+ you up-to-date with freshest packages.\n "
130
130
  email: contact@versioneye.com
131
131
  executables:
132
132
  - veye