vikingio 0.0.4 → 0.0.5

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.
@@ -1,110 +1,115 @@
1
- module VikingIO
2
- module CLI
3
- NETRC_PATH = File.join(Dir.home, ".netrc")
4
- NETRC_ENTRY_RX = /machine\s+vikingio.com\s+login\s+(.*)\s+password\s+(.*)[\s+]?/i
5
- APP_DATA_FILENAME = ".vikingio"
6
- NODE_DATA_FILENAME = "Nodefile"
7
-
8
- def self.node_data_path
9
- File.join(Dir.pwd, "Assets", "VikingIO", NODE_DATA_FILENAME)
10
- end
11
-
12
- def self.get_node_data
13
- return unless File.exist?(self.node_data_path)
14
- d = File.read(self.node_data_path)
15
- return JSON.parse(d)
16
- end
17
-
18
- def self.save_node_data(data)
19
- File.open(self.node_data_path, 'w') do |f|
20
- f << data.to_json
21
- end
22
- end
23
-
24
- def self.get_app_data
25
- return unless File.exist?(self.app_data_path)
26
- d = File.read(self.app_data_path)
27
- return JSON.parse(d)
28
- end
29
-
30
- def self.link_app(app)
31
- File.open(self.app_data_path, 'w') do |f|
32
- f << app.to_json
33
- end
34
- end
35
-
36
- def self.unlink_app
37
- return unless File.exist?(self.app_data_path)
38
- FileUtils.rm_rf(app_data_path)
39
- end
40
-
41
- def self.linked?
42
- File.exist?(self.app_data_path)
43
- end
44
-
45
- def self.authenticated?
46
- return true if VikingIO::CLI.netrc_exist? && VikingIO::CLI.in_netrc?
47
- return false
48
- end
49
-
50
- def self.app_data_path
51
- File.join(Dir.pwd, APP_DATA_FILENAME)
52
- end
53
-
54
- def self.netrc_contents
55
- File.read(NETRC_PATH)
56
- end
57
-
58
- def self.netrc_exist?()
59
- File.exist?(NETRC_PATH)
60
- end
61
-
62
- def self.in_netrc?()
63
- netrc_contents =~ /machine\s+vikingio.com/i
64
- end
65
-
66
- def self.get_netrc_key
67
- data = NETRC_ENTRY_RX.match(netrc_contents)
68
-
69
- email = data[1]
70
- key = data[2]
71
-
72
- return key
73
- end
74
-
75
- def self.update_netrc_key(new_password)
76
- netrc = netrc_contents
77
-
78
- data = NETRC_ENTRY_RX.match(netrc)
79
-
80
- existing_email = data[1]
81
- existing_password = data[2]
82
-
83
- netrc.gsub!(existing_password, new_password)
84
-
85
- save_netrc(netrc)
86
- end
87
-
88
- def self.add_netrc_key(email, key)
89
- netrc = netrc_contents
90
-
91
- netrc += "machine vikingio.com\n login " + email + "\n password " + key + "\n"
92
-
93
- save_netrc(netrc)
94
- end
95
-
96
- def self.remove_netrc_key
97
- netrc = netrc_contents
98
-
99
- netrc.gsub!(NETRC_ENTRY_RX, "")
100
-
101
- save_netrc(netrc)
102
- end
103
-
104
- def self.save_netrc(netrc_contents)
105
- File.open(NETRC_PATH, 'w') { |file| file.write(netrc_contents) }
106
- end
107
-
108
- end
109
-
110
- end
1
+ module VikingIO
2
+ module CLI
3
+ NETRC_PATH = File.join(Dir.home, ".netrc")
4
+ NETRC_ENTRY_RX = /machine\s+vikingio.com\s+login\s+(.*)\s+password\s+(.*)[\s+]?/i
5
+ APP_DATA_FILENAME = ".vikingio"
6
+ NODE_DATA_FILENAME = "Nodefile"
7
+
8
+ def self.node_data_path
9
+ File.join(Dir.pwd, "Assets", "VikingIO", NODE_DATA_FILENAME)
10
+ end
11
+
12
+ def self.get_node_data
13
+ return unless File.exist?(self.node_data_path)
14
+ d = File.read(self.node_data_path)
15
+ return JSON.parse(d)
16
+ end
17
+
18
+ def self.save_node_data(data)
19
+ File.open(self.node_data_path, 'w') do |f|
20
+ f << data.to_json
21
+ end
22
+ end
23
+
24
+ def self.get_app_data
25
+ return unless File.exist?(self.app_data_path)
26
+ d = File.read(self.app_data_path)
27
+ return JSON.parse(d)
28
+ end
29
+
30
+ def self.link_app(app)
31
+ File.open(self.app_data_path, 'w') do |f|
32
+ f << app.to_json
33
+ end
34
+ end
35
+
36
+ def self.unlink_app
37
+ return unless File.exist?(self.app_data_path)
38
+ FileUtils.rm_rf(app_data_path)
39
+ end
40
+
41
+ def self.linked?
42
+ File.exist?(self.app_data_path)
43
+ end
44
+
45
+ def self.authenticated?
46
+ return true if VikingIO::CLI.netrc_exist? && VikingIO::CLI.in_netrc?
47
+ return false
48
+ end
49
+
50
+ def self.app_data_path
51
+ File.join(Dir.pwd, APP_DATA_FILENAME)
52
+ end
53
+
54
+ def self.netrc_contents
55
+ File.read(NETRC_PATH)
56
+ end
57
+
58
+ def self.netrc_exist?()
59
+ File.exist?(NETRC_PATH)
60
+ end
61
+
62
+ def self.in_netrc?()
63
+ netrc_contents =~ /machine\s+vikingio.com/i
64
+ end
65
+
66
+ def self.get_netrc_key
67
+ data = NETRC_ENTRY_RX.match(netrc_contents)
68
+
69
+ email = data[1]
70
+ key = data[2]
71
+
72
+ return key
73
+ end
74
+
75
+ def self.update_netrc_key(new_password)
76
+ netrc = netrc_contents
77
+
78
+ data = NETRC_ENTRY_RX.match(netrc)
79
+
80
+ existing_email = data[1]
81
+ existing_password = data[2]
82
+
83
+ netrc.gsub!(existing_password, new_password)
84
+
85
+ save_netrc(netrc)
86
+ end
87
+
88
+ def self.add_netrc_key(email, key)
89
+ netrc = netrc_contents
90
+
91
+ netrc += "machine vikingio.com\n login " + email + "\n password " + key + "\n"
92
+
93
+ save_netrc(netrc)
94
+ end
95
+
96
+ def self.create_netrc(email, key)
97
+ netrc = "machine vikingio.com\n login " + email + "\n password " + key + "\n"
98
+ save_netrc(netrc)
99
+ end
100
+
101
+ def self.remove_netrc_key
102
+ netrc = netrc_contents
103
+
104
+ netrc.gsub!(NETRC_ENTRY_RX, "")
105
+
106
+ save_netrc(netrc)
107
+ end
108
+
109
+ def self.save_netrc(netrc_contents)
110
+ File.open(NETRC_PATH, 'w') { |file| file.write(netrc_contents) }
111
+ end
112
+
113
+ end
114
+
115
+ end
@@ -1,5 +1,5 @@
1
- module VikingIO
2
- module CLI
3
- VERSION = "0.0.4"
4
- end
5
- end
1
+ module VikingIO
2
+ module CLI
3
+ VERSION = "0.0.5"
4
+ end
5
+ end
data/lib/vikingio/cli.rb CHANGED
@@ -1,44 +1,49 @@
1
- require 'net/http'
2
- require 'uri'
3
- require 'io/console'
4
- require 'json'
5
- require 'fileutils'
6
- require 'yaml'
7
- require 'tmpdir'
8
- require 'open3'
9
- require 'net/http/post/multipart'
10
-
11
- lib = File.dirname(File.expand_path(__FILE__))
12
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
13
-
14
- require "vikingio/cli/version"
15
- require "vikingio/cli/helpers"
16
- require "vikingio/cli/client"
17
- require "vikingio/cli/commands"
18
-
19
- module VikingIO
20
- module CLI
21
-
22
- def self.start(*args)
23
- begin
24
- if $stdin.isatty
25
- $stdin.sync = true
26
- end
27
- if $stdout.isatty
28
- $stdout.sync = true
29
- end
30
-
31
- command = args.shift.strip rescue "help"
32
- args.flatten!
33
-
34
- VikingIO::CLI::Commands.run(command, args)
35
-
36
- rescue Interrupt
37
- puts "Command cancelled."
38
- rescue => error
39
- puts error
40
- end
41
- end
42
-
43
- end
44
- end
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'io/console'
4
+ require 'json'
5
+ require 'fileutils'
6
+ require 'yaml'
7
+ require 'tmpdir'
8
+ require 'open3'
9
+ require 'net/http/post/multipart'
10
+ require 'openssl'
11
+ require 'rbconfig'
12
+
13
+ IS_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
14
+
15
+ lib = File.dirname(File.expand_path(__FILE__))
16
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
17
+
18
+ require "vikingio/cli/version"
19
+ require "vikingio/cli/helpers"
20
+ require "vikingio/cli/client"
21
+ require "vikingio/cli/commands"
22
+
23
+
24
+ module VikingIO
25
+ module CLI
26
+
27
+ def self.start(*args)
28
+ begin
29
+ if $stdin.isatty
30
+ $stdin.sync = true
31
+ end
32
+ if $stdout.isatty
33
+ $stdout.sync = true
34
+ end
35
+
36
+ command = args.shift.strip rescue "help"
37
+ args.flatten!
38
+
39
+ VikingIO::CLI::Commands.run(command, args)
40
+
41
+ rescue Interrupt
42
+ puts "Command cancelled."
43
+ rescue => error
44
+ puts error
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -1,25 +1,25 @@
1
- using System.Collections;
2
-
3
- using VikingIO.Network;
4
- using VikingIO.Network.Messaging;
5
-
6
- public class [MESSAGE_NAME] : BaseNetworkMessage
7
- {
8
-
9
- public [MESSAGE_NAME]()
10
- {
11
-
12
- }
13
-
14
- public override void Deserialize(INetIncomingMessage serializedMessage)
15
- {
16
- GetMessageInformation(serializedMessage);
17
- // Deserialize your message data here
18
- }
19
-
20
- public override void Serialize(INetOutgoingMessage message)
21
- {
22
- // Serialize your message data here
23
- }
24
-
25
- }
1
+ using System.Collections;
2
+
3
+ using VikingIO.Network;
4
+ using VikingIO.Network.Messaging;
5
+
6
+ public class [MESSAGE_NAME] : BaseNetworkMessage
7
+ {
8
+
9
+ public [MESSAGE_NAME]()
10
+ {
11
+
12
+ }
13
+
14
+ public override void Deserialize(INetIncomingMessage serializedMessage)
15
+ {
16
+ GetMessageInformation(serializedMessage);
17
+ // Deserialize your message data here
18
+ }
19
+
20
+ public override void Serialize(INetOutgoingMessage message)
21
+ {
22
+ // Serialize your message data here
23
+ }
24
+
25
+ }
@@ -1,34 +1,34 @@
1
- using UnityEngine;
2
- using System;
3
- using System.Collections;
4
-
5
- using VikingIO.Network;
6
- using VikingIO.Network.Messaging;
7
-
8
- public class NetworkManager : VikingSingleton<NetworkManager>
9
- {
10
- protected NetworkManager()
11
- {
12
- }
13
-
14
- private VikingClient m_NetClient;
15
-
16
- public VikingClient Client
17
- {
18
- get { return m_NetClient; }
19
- }
20
-
21
- void Awake()
22
- {
23
- m_NetClient = new VikingClient(VikingIOConfig.APP_NAME, VikingIOConfig.APP_ID);
24
-
25
- Instance.Client.Start(true);
26
-
27
- Debug.LogWarning("VikingIO NetworkManager started");
28
- }
29
-
30
- void Update()
31
- {
32
- Instance.Client.Update();
33
- }
1
+ using UnityEngine;
2
+ using System;
3
+ using System.Collections;
4
+
5
+ using VikingIO.Network;
6
+ using VikingIO.Network.Messaging;
7
+
8
+ public class NetworkManager : VikingSingleton<NetworkManager>
9
+ {
10
+ protected NetworkManager()
11
+ {
12
+ }
13
+
14
+ private VikingClient m_NetClient;
15
+
16
+ public VikingClient Client
17
+ {
18
+ get { return m_NetClient; }
19
+ }
20
+
21
+ void Awake()
22
+ {
23
+ m_NetClient = new VikingClient(VikingIOConfig.APP_NAME, VikingIOConfig.APP_ID);
24
+
25
+ Instance.Client.Start(true);
26
+
27
+ Debug.LogWarning("VikingIO NetworkManager started");
28
+ }
29
+
30
+ void Update()
31
+ {
32
+ Instance.Client.Update();
33
+ }
34
34
  }
data/templates/Program.cs CHANGED
@@ -1,22 +1,22 @@
1
- using System;
2
- using System.Collections.Generic;
3
- using System.Text;
4
-
5
- using VikingIO.Network;
6
-
7
- namespace VikingIO.ServerNode
8
- {
9
- class Program
10
- {
11
- static void Main(string[] args)
12
- {
13
- if (args.Length == 0)
14
- {
15
- Console.WriteLine("Supply port as first argument.");
16
- return;
17
- }
18
- VikingServer.Instance.SetNode(new [MODULE_NAME]());
19
- VikingServer.Instance.Start("[APP_NAME]", int.Parse(args[0]));
20
- }
21
- }
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Text;
4
+
5
+ using VikingIO.Network;
6
+
7
+ namespace VikingIO.ServerNode
8
+ {
9
+ class Program
10
+ {
11
+ static void Main(string[] args)
12
+ {
13
+ if (args.Length == 0)
14
+ {
15
+ Console.WriteLine("Supply port as first argument.");
16
+ return;
17
+ }
18
+ VikingServer.Instance.SetNode(new [MODULE_NAME]());
19
+ VikingServer.Instance.Start("[APP_NAME]", int.Parse(args[0]));
20
+ }
21
+ }
22
22
  }
@@ -1,39 +1,39 @@
1
- using System;
2
- using System.Collections;
3
- using System.Collections.Generic;
4
-
5
- using VikingIO.Network;
6
- using VikingIO.Network.Messaging;
7
-
8
- public class [SERVER_NAME] : IVikingNode
9
- {
10
- public void Start()
11
- {
12
- Console.WriteLine("[[SERVER_NAME]] Start");
13
- }
14
-
15
- public void OnConnect(NetConnection conn)
16
- {
17
- Console.WriteLine(conn.RemoteEndPoint.ToString () + " connected.");
18
- }
19
-
20
- public void OnDisconnect(NetConnection conn)
21
- {
22
- Console.WriteLine(conn.RemoteEndPoint.ToString () + " disconnected.");
23
- }
24
-
25
- public void Stop()
26
- {
27
- Console.WriteLine("[[SERVER_NAME]] Stop");
28
- }
29
-
30
- public void Update(float dt)
31
- {
32
-
33
- }
34
-
35
- public void FixedUpdate(float dt)
36
- {
37
-
38
- }
39
- }
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+
5
+ using VikingIO.Network;
6
+ using VikingIO.Network.Messaging;
7
+
8
+ public class [SERVER_NAME] : IVikingNode
9
+ {
10
+ public void Start()
11
+ {
12
+ Console.WriteLine("[[SERVER_NAME]] Start");
13
+ }
14
+
15
+ public void OnConnect(NetConnection conn)
16
+ {
17
+ Console.WriteLine(conn.RemoteEndPoint.ToString () + " connected.");
18
+ }
19
+
20
+ public void OnDisconnect(NetConnection conn)
21
+ {
22
+ Console.WriteLine(conn.RemoteEndPoint.ToString () + " disconnected.");
23
+ }
24
+
25
+ public void Stop()
26
+ {
27
+ Console.WriteLine("[[SERVER_NAME]] Stop");
28
+ }
29
+
30
+ public void Update(float dt)
31
+ {
32
+
33
+ }
34
+
35
+ public void FixedUpdate(float dt)
36
+ {
37
+
38
+ }
39
+ }
@@ -1,9 +1,9 @@
1
- using UnityEngine;
2
- using System.Collections;
3
-
4
- public class VikingIOConfig {
5
-
6
- public const string APP_NAME = "[APP_NAME]";
7
- public const int APP_ID = [APP_ID];
8
-
1
+ using UnityEngine;
2
+ using System.Collections;
3
+
4
+ public class VikingIOConfig {
5
+
6
+ public const string APP_NAME = "[APP_NAME]";
7
+ public const int APP_ID = [APP_ID];
8
+
9
9
  }
data/vikingio-cli.gemspec CHANGED
@@ -1,23 +1,23 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'vikingio/cli/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "vikingio"
8
- spec.version = VikingIO::CLI::VERSION
9
- spec.authors = ["Eric Campbell"]
10
- spec.email = ["info@vikingio.com"]
11
- spec.summary = %q{VikingIO command line toolkit.}
12
- spec.description = %q{VikingIO command line toolkit.}
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = ["vikingio"]
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
23
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vikingio/cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vikingio"
8
+ spec.version = VikingIO::CLI::VERSION
9
+ spec.authors = ["Eric Campbell"]
10
+ spec.email = ["info@vikingio.com"]
11
+ spec.summary = %q{VikingIO command line toolkit.}
12
+ spec.description = %q{VikingIO command line toolkit.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ["vikingio"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vikingio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Campbell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.2.2
90
+ rubygems_version: 2.0.14
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: VikingIO command line toolkit.