clustered 0.0.0 → 0.0.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8da48f1afdf9016bf016a6e19f9ff0751903fd0e
4
- data.tar.gz: feebe4dc25ffd342ed4019eb95635e54c5ff178e
3
+ metadata.gz: c71e55f2487fd59f3ac2dd6940844846f78354f6
4
+ data.tar.gz: 6fa4b21f8e32e470583ae62961fb7cae1e1e73f1
5
5
  SHA512:
6
- metadata.gz: b5a5e6f35dd71e2a8048fdea680400257aab36e1a67385cb9d1be4e1086686947be95b23ac2da0acf951ff12d0ceaf6f488c080f5a8190d149bc9fb1cf8cbcf0
7
- data.tar.gz: acaecf34592ee46fb4ff1fd8bcc44f2044b9ac3dd050d974769178adc890ce688cdac5b2a84094b8442881586a912283678a440663b4aeae760cf20e2b39f6c4
6
+ metadata.gz: 7cdafe8d3853412ea0923688529e628e2c2e2c52ba313be3338249804a468e1ff71fababb486debc7e72cf02cf90680b0d99cc0a9cde927539fa8d708976154b
7
+ data.tar.gz: 952c447634285fce8ef50e2d760b84382468c05fe13d144f7f876dccc7a01a4b2d999e83002d290eed8f97138298991615981898ab0064d6e2a8195a8c7fd19e
data/lib/client.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  class Client
2
- attr_accessor :tasks, :name, :top_task
2
+ attr_accessor :tasks, :name
3
3
 
4
4
  def initialize(name)
5
5
  @name = name
6
6
  @tasks = []
7
- @top_task = top_task
8
7
  end
9
8
 
10
9
  def add_task(task_description)
@@ -12,6 +11,6 @@ class Client
12
11
  end
13
12
 
14
13
  def top_task
15
- @tasks[-1]
14
+ @tasks.last
16
15
  end
17
16
  end
@@ -1,4 +1,4 @@
1
- require 'client'
1
+ require_relative 'client'
2
2
 
3
3
  class ClientManager
4
4
  attr_accessor :clients
@@ -12,7 +12,9 @@ class ClientManager
12
12
  end
13
13
 
14
14
  def new_client(name)
15
- new_client = Client.new(name)
16
- add_client(new_client)
15
+ if !(@clients.has_key?(name))
16
+ client = Client.new(name)
17
+ add_client(client)
18
+ end
17
19
  end
18
20
  end
@@ -0,0 +1,38 @@
1
+ $LOAD_PATH.unshift File.expand_path('./', __FILE__)
2
+
3
+ require 'sinatra'
4
+ require 'sinatra/cookies'
5
+ require 'bundler'
6
+ require_relative 'client_manager'
7
+
8
+ Bundler.require(:default)
9
+ Bundler.setup
10
+
11
+ class Sinatra_Cluster < Sinatra::Base
12
+ attr_reader :params, :client_manager
13
+
14
+ get '/' do
15
+ initialize_client_manager
16
+ @client_list = @@client_manager
17
+ erb :home
18
+ end
19
+
20
+ post '/' do
21
+ make_new_client
22
+ add_task
23
+ @client_list = @@client_manager
24
+ erb :home
25
+ end
26
+
27
+ def initialize_client_manager
28
+ @@client_manager ||= ClientManager.new
29
+ end
30
+
31
+ def make_new_client
32
+ @@client_manager.new_client(params[:new_client].to_s)
33
+ end
34
+
35
+ def add_task
36
+ @@client_manager.clients[params[:new_client].to_s].add_task(params[:task].to_s)
37
+ end
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clustered
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Szalwinski
@@ -18,6 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/client.rb
20
20
  - lib/client_manager.rb
21
+ - lib/sinatra_cluster.rb
21
22
  homepage: http://rubygems.org/gems/clustered
22
23
  licenses:
23
24
  - MIT