cellect-server 0.1.0 → 0.1.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: 2c4c76b5033ebc886495182a0cceda05b09dfb94
4
- data.tar.gz: 7c58e799df156fada54824d98be0c9dc7d1dc276
3
+ metadata.gz: e6f50bc35da0b22aed570a3820f089359cd29aaf
4
+ data.tar.gz: 1ee19a258a5ec1eac02d34e7cf87fdb6c31e70fa
5
5
  SHA512:
6
- metadata.gz: 4c6a8b5e0dfab1ad0605789175cd01ab8bf222aa6daf059e0862145b6b756606ffd8114d652bcd089bc0149bfb81b940c17e56cd107702feeaf1c6798dd0bb77
7
- data.tar.gz: 0744ec694028b02e2a1ca0b978f446e55b019fbb6d52d88926eeed476d328bbecfd39cdc9f20a8d2062c1d3cb2aed7d3b79bf8740a31f83527c3f536e4dd3c79
6
+ metadata.gz: df88efc975c8fb833e6e63d56c051aaa25c91fbf045d46ed64dc5704420c5f3f8f4d4a837aaa6aa5aa05639b55875e9477284788df77496ca8f3652b5e7f2bdc
7
+ data.tar.gz: e1af49629a0d2024a3d25d70b3df749699ae6b5b3586c09837dd3da07550c59437907c60cbcc760d5677707a6c93139866dcb29f32270f1e3ac93e60f13dc3b0
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ before_install:
5
+ - sudo add-apt-repository ppa:boost-latest/ppa -y
6
+ - sudo apt-get update -q
7
+ - sudo apt-get install -y autoconf automake boost1.55 libffi-dev
8
+
9
+ before_script:
10
+ - test `which zkServer.sh` && zkServer.sh stop && rm -rf /tmp/zookeeper/*; true
11
+ - wget -q -O - "http://mirrors.koehn.com/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz" | tar zx -C "$HOME/"
12
+ - export PATH="$PATH:/$HOME/zookeeper-3.4.6/bin"
13
+ - cp "$HOME/zookeeper-3.4.6/conf/zoo_sample.cfg" "$HOME/zookeeper-3.4.6/conf/zoo.cfg"
14
+ - zkServer.sh start
15
+
16
+ rvm:
17
+ - 2.1.5
18
+ - 2.1.2
19
+ - 2.2.0
20
+
21
+ jdk:
22
+ - openjdk7
23
+
24
+ script: ZK_URL=localhost:2181 bundle exec rake
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cellect
1
+ # Cellect [![Build Status](https://travis-ci.org/zooniverse/Cellect.svg?branch=master)](https://travis-ci.org/zooniverse/Cellect)
2
2
 
3
3
  This is a work in progress
4
4
 
@@ -10,7 +10,7 @@ module Cellect
10
10
  # 'pairwise' => false,
11
11
  # 'grouped' => false
12
12
  # }, ...]
13
- def workflow_list
13
+ def workflow_list(*names)
14
14
  raise NotImplementedError
15
15
  end
16
16
 
@@ -34,8 +34,8 @@ module Cellect
34
34
  raise NotImplementedError
35
35
  end
36
36
 
37
- def load_workflows
38
- workflow_list.each{ |workflow_info| load_workflow workflow_info }
37
+ def load_workflows(*names)
38
+ workflow_list(*names).each{ |workflow_info| load_workflow workflow_info }
39
39
  end
40
40
 
41
41
  def load_workflow(args)
@@ -52,7 +52,8 @@ module Cellect
52
52
 
53
53
  def workflow_for(opts = { })
54
54
  workflow_klass = opts.fetch('grouped', false) ? GroupedWorkflow : Workflow
55
- workflow_klass[opts['name'], pairwise: opts['pairwise'], prioritized: opts['prioritized']]
55
+ workflow_klass[opts['name']] = opts
56
+ workflow_klass[opts['name']]
56
57
  end
57
58
  end
58
59
  end
@@ -11,9 +11,18 @@ module Cellect
11
11
  end
12
12
  end
13
13
 
14
- def workflow_list
14
+ def workflow_list(*names)
15
15
  with_pg do |pg|
16
- pg.exec('SELECT * FROM workflows').collect do |row|
16
+ statement = 'SELECT * FROM workflows'
17
+ statement += case names.length
18
+ when 0
19
+ ""
20
+ when 1
21
+ "WHERE \"workflows\".\"id\" = #{ names.first }"
22
+ else
23
+ "WHERE \"workflows\".\"id\" IN (#{ names.join(',') })"
24
+ end
25
+ pg.exec(statement).collect do |row|
17
26
  {
18
27
  'id' => row['id'].to_i,
19
28
  'name' => row['id'],
@@ -6,10 +6,13 @@ module Cellect
6
6
  attr_accessor :name, :users, :subjects, :state
7
7
  attr_accessor :pairwise, :prioritized
8
8
 
9
- def self.[](name, pairwise: false, prioritized: false)
10
- key = "workflow_#{ name }".to_sym
11
- Actor[key] ||= supervise name, pairwise: pairwise, prioritized: prioritized
12
- Actor[key].actors.first
9
+ def self.[](name)
10
+ Cellect::Server.adapter.load_workflows(name) unless Actor[name]
11
+ Actor[name].actors.first
12
+ end
13
+
14
+ def self.[]=(name, opts)
15
+ Actor[name] = supervise name, pairwise: opts['pairwise'], prioritized: opts['prioritized']
13
16
  end
14
17
 
15
18
  def self.names
@@ -1,3 +1,3 @@
1
1
  module Cellect
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -2,6 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  module Cellect::Server
4
4
  describe Workflow do
5
+ it "should try to load workflows that aren't loaded" do
6
+ expect(Cellect::Server.adapter).to receive(:load_workflows).with('random').and_call_original
7
+ Workflow['random']
8
+ end
9
+
5
10
  SET_TYPES.each do |workflow_type|
6
11
  context workflow_type do
7
12
  it_behaves_like 'workflow', :workflow
@@ -35,8 +40,8 @@ module Cellect::Server
35
40
  end
36
41
 
37
42
  it 'should remove subjects' do
38
- expect(workflow.subjects).to receive(:add).with 123
39
- workflow.add subject_id: 123
43
+ expect(workflow.subjects).to receive(:remove).with 123
44
+ workflow.remove subject_id: 123
40
45
  end
41
46
 
42
47
  it 'should be notified of a user ttl expiry' do
@@ -14,6 +14,7 @@ shared_examples_for 'node set' do
14
14
  end
15
15
 
16
16
  it 'should accept a connection string' do
17
+ url_before = ENV['ZK_URL']
17
18
  begin
18
19
  pass_until node_set, is: :ready
19
20
  ENV['ZK_URL'] = 'foobar'
@@ -21,7 +22,7 @@ shared_examples_for 'node set' do
21
22
  ENV.delete 'ZK_URL'
22
23
  expect(node_set.send(:zk_url)).to eq 'localhost:2181'
23
24
  ensure
24
- ENV['ZK_URL'] = 'localhost:21811'
25
+ ENV['ZK_URL'] = url_before
25
26
  end
26
27
  end
27
28
  end
@@ -6,8 +6,8 @@ shared_examples_for 'workflow' do |name|
6
6
  end
7
7
 
8
8
  it 'should add singleton instances to the registry' do
9
- expect(obj.class[:foo]).to be_a_kind_of Cellect::Server::Workflow
10
- expect(obj.class[:foo].object_id).to eq obj.class[:foo].object_id
9
+ expect(obj.class[obj.name]).to be_a_kind_of Cellect::Server::Workflow
10
+ expect(obj.class[obj.name].object_id).to eq obj.class[obj.name].object_id
11
11
  end
12
12
 
13
13
  it 'should initialize empty' do
@@ -1,8 +1,12 @@
1
1
  require 'oj'
2
2
 
3
3
  class SpecAdapter < Cellect::Server::Adapters::Default
4
- def workflow_list
5
- fixtures.values
4
+ def workflow_list(*names)
5
+ if names.empty?
6
+ fixtures.values
7
+ else
8
+ fixtures.values_at(*names)
9
+ end
6
10
  end
7
11
 
8
12
  def load_data_for(workflow_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cellect-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Parrish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -229,6 +229,7 @@ extra_rdoc_files: []
229
229
  files:
230
230
  - ".gitignore"
231
231
  - ".rspec"
232
+ - ".travis.yml"
232
233
  - Gemfile
233
234
  - README.md
234
235
  - Rakefile