lattice 0.0.0 → 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd35aad62903ddaf3add6cde5a20a9e9f602190c
4
+ data.tar.gz: 72ba50be9460b11da83f35bb40352d571f63a009
5
+ SHA512:
6
+ metadata.gz: 173ccef41e001527e66488f192d3ed69b0374a050397ec3bdf60b846a185eb906d20c6ecdcf54002743c00dfa562bf13b4881f592f4879da411f03a40f64af77
7
+ data.tar.gz: 6267e585042de5076c09998f6ca4e3ff640d7682b45e9337746576c6d726444a2ea4c98ad35bd44a012e8948e6d5d68e24a2eedb65ce566dd5910780f63d5c1b
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format documentation
3
+ --backtrace
4
+ --default_path spec
@@ -0,0 +1,3 @@
1
+ branches:
2
+ except:
3
+ - master
@@ -0,0 +1,3 @@
1
+ 0.1.0 (2013-09-15)
2
+ ------------------
3
+ * Initial release(-ish)
data/Gemfile CHANGED
@@ -1,4 +1,13 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
+ gem 'celluloid', github: 'celluloid/celluloid'
4
+ gem 'reel', github: 'celluloid/reel'
5
+
6
+ gem 'webmachine', github: 'seancribbs/webmachine-ruby'
7
+
3
8
  # Specify your gem's dependencies in lattice.gemspec
4
9
  gemspec
10
+
11
+ group :development do
12
+ gem 'guard-rspec'
13
+ end
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/README.md CHANGED
@@ -1,23 +1,40 @@
1
- Lattice
2
- =======
1
+ ![Lattice](https://github.com/celluloid/lattice/raw/master/logo.png)
2
+ ==========
3
+ [![Build Status](https://secure.travis-ci.org/celluloid/lattice.png?branch=master)](http://travis-ci.org/celluloid/lattice)
4
+ [![Code Climate](https://codeclimate.com/github/celluloid/lattice.png)](https://codeclimate.com/github/celluloid/lattice)
3
5
 
4
- Lattice is a pervasively multithreaded web framework for Ruby which makes
5
- building realtime web applications with WebSockets simple and fun. It's
6
- built on the following primitives:
6
+ Lattice is an actor-based web framework for Ruby built on top of
7
+ [Celluloid][celluloid], [Reel][reel], and [Webmachine][webmachine]. Designed
8
+ from the ground up for realtime applications, end-to-end streaming, and
9
+ Websockets, Lattice provides solutions to some of the biggest pain points in
10
+ web application development today.
11
+
12
+ [celluloid]: https://github.com/celluloid/celluloid/
13
+ [reel]: https://github.com/celluloid/reel
14
+ [webmachine]: https://github.com/seancribbs/webmachine-ruby/
15
+
16
+ ## Features
7
17
 
8
18
  * Resources: the main glue type between Lattice and the web, resources provide
9
19
  an HTTP endpoint for interacting with entities in the system. Resources are
10
20
  in fact a special type of component, one which forms an entry point into the
11
- system.
21
+ system. Lattice uses [Webmachine](https://github.com/seancribbs/webmachine-ruby)
22
+ as its resource framework.
23
+
24
+ ## Vaporware Features (Coming Soon™!)
25
+
26
+ * Cells: Lattice's go-to domain model object. Cells represent data dependencies
27
+ of resources, or are resources themselves. Every Cell is a Celluloid actor,
28
+ which makes them multithreaded and allows them to compute in parallel (at least
29
+ on modern Ruby interpreters such as JRuby and Rubinius which don't have a Global
30
+ Interpreter Lock). They can also do scatter/gather-type I/O operations, making
31
+ them ideal for querying multiple services in parallel when computing a response.
32
+ Cells map data dependencies into "slots" which can be used by renderers to compute
33
+ representations of data within the system, an idea which combines Celluloid's
34
+ [futures][futures] with an API similar to [decent_exposure][decent_exposure].
12
35
 
13
- * Components: data dependencies of resources (or resources themselves).
14
- Components are inherently multithreaded and computed in parallel. Somewhat
15
- analogous to "models" in frameworks like Rails, components are the natural
16
- abstraction Lattice provides for subdividing the work needed to compute a
17
- representation of a particular resource, and are where things like database
18
- interactions and additional queries to external services should take place.
19
- Components map data dependencies into "slots" which can be used by renderers
20
- to compute representations of data within the system.
36
+ [futures]: https://github.com/celluloid/celluloid/wiki/futures
37
+ [decent_exposure]: https://github.com/voxdolo/decent_exposure
21
38
 
22
39
  * Renderers: translate data within the system, as fetched by components, into
23
40
  a requested representation. Renderers handle the specifics of dynamically
@@ -31,4 +48,5 @@ built on the following primitives:
31
48
  Copyright
32
49
  ---------
33
50
 
34
- Copyright © 2011 Tony Arcieri. See LICENSE.txt for further details.
51
+ Copyright © 2013 Tony Arcieri. Distributed under the MIT license.
52
+ See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ Dir["tasks/**/*.task"].each { |task| load task }
4
+
5
+ task :default => :spec
@@ -15,11 +15,10 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ['lib']
16
16
  gem.version = Lattice::VERSION
17
17
 
18
- gem.add_dependency 'celluloid'
19
- gem.add_dependency 'dcell'
20
- gem.add_dependency 'cramp'
21
- gem.add_dependency 'webmachine'
22
- gem.add_dependency 'activesupport'
18
+ gem.add_dependency 'celluloid', '>= 0.15.1'
19
+ gem.add_dependency 'reel', '>= 0.4.0'
20
+ gem.add_dependency 'webmachine', '~> 1.2.0'
21
+ gem.add_dependency 'activesupport', '~> 4.0.0'
23
22
 
24
23
  gem.add_development_dependency 'rake'
25
24
  gem.add_development_dependency "rspec", ">= 2.7.0"
@@ -1,5 +1,5 @@
1
- require "lattice/version"
1
+ require 'lattice/version'
2
+ require 'lattice/resource'
2
3
 
3
4
  module Lattice
4
- # Your code goes here...
5
5
  end
@@ -0,0 +1,63 @@
1
+ require 'webmachine'
2
+ require 'active_support/core_ext/class/attribute'
3
+
4
+ module Lattice
5
+ class Resource < Webmachine::Resource
6
+ class_attribute :allowed_methods
7
+ class_attribute :content_types_accepted
8
+ class_attribute :content_types_provided
9
+ class_attribute :encodings_provided
10
+
11
+ class << self
12
+ def allow_method(*methods)
13
+ self.allowed_methods ||= []
14
+ self.allowed_methods += methods.map(&:to_s).map(&:upcase)
15
+ end
16
+ alias allow allow_method
17
+
18
+ def accept_content_type(content_types)
19
+ content_types.each do |key, value|
20
+ self.content_types_accepted ||= []
21
+ content_types_accepted << [key, value]
22
+ end
23
+ end
24
+ alias accept accept_content_type
25
+
26
+ def provide_content_type(content_types)
27
+ content_types.each do |key, value|
28
+ self.content_types_provided ||= []
29
+ content_types_provided << [key, value]
30
+ end
31
+ end
32
+
33
+ def provide_encoding(encodings)
34
+ self.encodings_provided ||= {}
35
+ encodings_provided.merge!(encodings)
36
+ end
37
+ end
38
+
39
+ def allowed_methods
40
+ methods = self.class.allowed_methods
41
+ return methods if methods && !methods.empty?
42
+ super
43
+ end
44
+
45
+ def content_types_accepted
46
+ types = self.class.content_types_accepted
47
+ return types if types && !types.empty?
48
+ super
49
+ end
50
+
51
+ def content_types_provided
52
+ types = self.class.content_types_provided
53
+ return types if types && !types.empty?
54
+ super
55
+ end
56
+
57
+ def encodings_provided
58
+ encodings = self.class.encodings_provided
59
+ return encodings if encodings && !encodings.empty?
60
+ super
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Lattice
2
- VERSION = "0.0.0"
2
+ VERSION = "0.1.0"
3
3
  end
Binary file
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lattice::Resource do
4
+ context "allowable methods" do
5
+ it "can be declared with `allow_method'" do
6
+ klass = Class.new(described_class) do
7
+ allow_method :get
8
+ allow_method :post
9
+ end
10
+
11
+ klass.allowed_methods.should eq %W[GET POST]
12
+ end
13
+
14
+ it "can be declared with `allow'" do
15
+ klass = Class.new(described_class) do
16
+ allow :get
17
+ allow :post
18
+ end
19
+
20
+ klass.allowed_methods.should eq %W[GET POST]
21
+ end
22
+ end
23
+
24
+ context "acceptable content types" do
25
+ it "can be declared with `accept_content_type'" do
26
+ klass = Class.new(described_class) do
27
+ accept_content_type "application/json" => :to_json
28
+ accept_content_type "text/xml" => :to_xml
29
+ end
30
+
31
+ klass.content_types_accepted.should eq [
32
+ ["application/json", :to_json],
33
+ ["text/xml", :to_xml]
34
+ ]
35
+ end
36
+
37
+ it "can be declared with `accept'" do
38
+ klass = Class.new(described_class) do
39
+ accept "application/json" => :to_json
40
+ accept "text/xml" => :to_xml
41
+ end
42
+
43
+ klass.content_types_accepted.should eq [
44
+ ["application/json", :to_json],
45
+ ["text/xml", :to_xml]
46
+ ]
47
+ end
48
+ end
49
+
50
+ context "provided content types" do
51
+ it "can be declared with `provide_content_type'" do
52
+ klass = Class.new(described_class) do
53
+ provide_content_type "application/json" => :to_json
54
+ provide_content_type "text/xml" => :to_xml
55
+ end
56
+
57
+ klass.content_types_provided.should eq [
58
+ ["application/json", :to_json],
59
+ ["text/xml", :to_xml]
60
+ ]
61
+ end
62
+ end
63
+
64
+ context "provided encodings" do
65
+ it "can be declared with `provide_encoding'" do
66
+ klass = Class.new(described_class) do
67
+ provide_encoding 'gzip' => :encode_gzip
68
+ provide_encoding 'identity' => :encode_identity
69
+ end
70
+
71
+ klass.encodings_provided.should eq({
72
+ 'gzip' => :encode_gzip,
73
+ 'identity' => :encode_identity
74
+ })
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ require 'lattice'
@@ -0,0 +1,7 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new
4
+
5
+ RSpec::Core::RakeTask.new(:rcov) do |task|
6
+ task.rcov = true
7
+ end
metadata CHANGED
@@ -1,93 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lattice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tony Arcieri
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-12-11 00:00:00.000000000 Z
11
+ date: 2013-09-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: celluloid
16
- requirement: &70140403517900 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 0.15.1
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70140403517900
25
- - !ruby/object:Gem::Dependency
26
- name: dcell
27
- requirement: &70140403517400 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - ! '>='
24
+ - - '>='
31
25
  - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70140403517400
26
+ version: 0.15.1
36
27
  - !ruby/object:Gem::Dependency
37
- name: cramp
38
- requirement: &70140403516800 !ruby/object:Gem::Requirement
39
- none: false
28
+ name: reel
29
+ requirement: !ruby/object:Gem::Requirement
40
30
  requirements:
41
- - - ! '>='
31
+ - - '>='
42
32
  - !ruby/object:Gem::Version
43
- version: '0'
33
+ version: 0.4.0
44
34
  type: :runtime
45
35
  prerelease: false
46
- version_requirements: *70140403516800
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: webmachine
49
- requirement: &70140403515820 !ruby/object:Gem::Requirement
50
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ! '>='
45
+ - - ~>
53
46
  - !ruby/object:Gem::Version
54
- version: '0'
47
+ version: 1.2.0
55
48
  type: :runtime
56
49
  prerelease: false
57
- version_requirements: *70140403515820
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.0
58
55
  - !ruby/object:Gem::Dependency
59
56
  name: activesupport
60
- requirement: &70140403515400 !ruby/object:Gem::Requirement
61
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
62
58
  requirements:
63
- - - ! '>='
59
+ - - ~>
64
60
  - !ruby/object:Gem::Version
65
- version: '0'
61
+ version: 4.0.0
66
62
  type: :runtime
67
63
  prerelease: false
68
- version_requirements: *70140403515400
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
- requirement: &70140403514980 !ruby/object:Gem::Requirement
72
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - ! '>='
73
+ - - '>='
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  type: :development
78
77
  prerelease: false
79
- version_requirements: *70140403514980
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
80
83
  - !ruby/object:Gem::Dependency
81
84
  name: rspec
82
- requirement: &70140403514280 !ruby/object:Gem::Requirement
83
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ! '>='
87
+ - - '>='
86
88
  - !ruby/object:Gem::Version
87
89
  version: 2.7.0
88
90
  type: :development
89
91
  prerelease: false
90
- version_requirements: *70140403514280
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.7.0
91
97
  description: A concurrent realtime web framework for Ruby
92
98
  email:
93
99
  - tony.arcieri@gmail.com
@@ -96,41 +102,46 @@ extensions: []
96
102
  extra_rdoc_files: []
97
103
  files:
98
104
  - .gitignore
105
+ - .rspec
106
+ - .travis.yml
107
+ - CHANGES.md
99
108
  - Gemfile
109
+ - Guardfile
100
110
  - LICENSE.txt
101
111
  - README.md
102
112
  - Rakefile
103
113
  - lattice.gemspec
104
114
  - lib/lattice.rb
115
+ - lib/lattice/resource.rb
105
116
  - lib/lattice/version.rb
106
- - spec/fixtures/application/Appfile
107
- - spec/fixtures/application/README.md
117
+ - logo.png
118
+ - spec/lattice/resource_spec.rb
119
+ - spec/spec_helper.rb
120
+ - tasks/rspec.task
108
121
  homepage: https://github.com/tarcieri/lattice
109
122
  licenses: []
123
+ metadata: {}
110
124
  post_install_message:
111
125
  rdoc_options: []
112
126
  require_paths:
113
127
  - lib
114
128
  required_ruby_version: !ruby/object:Gem::Requirement
115
- none: false
116
129
  requirements:
117
- - - ! '>='
130
+ - - '>='
118
131
  - !ruby/object:Gem::Version
119
132
  version: '0'
120
133
  required_rubygems_version: !ruby/object:Gem::Requirement
121
- none: false
122
134
  requirements:
123
- - - ! '>='
135
+ - - '>='
124
136
  - !ruby/object:Gem::Version
125
137
  version: '0'
126
138
  requirements: []
127
139
  rubyforge_project:
128
- rubygems_version: 1.8.10
140
+ rubygems_version: 2.0.3
129
141
  signing_key:
130
- specification_version: 3
142
+ specification_version: 4
131
143
  summary: Lattice is a pervasively multithreaded web framework for Ruby which makes
132
144
  building realtime web applications with WebSockets simple and fun
133
145
  test_files:
134
- - spec/fixtures/application/Appfile
135
- - spec/fixtures/application/README.md
136
- has_rdoc:
146
+ - spec/lattice/resource_spec.rb
147
+ - spec/spec_helper.rb
@@ -1,2 +0,0 @@
1
- class ExampleApplication < Lattice::Application
2
- end
@@ -1,4 +0,0 @@
1
- Example
2
- =======
3
-
4
- This is an example application built with Lattice