bluplate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 matthew jording
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = bluplate
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 matthew jording. See LICENSE for details.
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "bluplate"
8
+ gem.summary = %Q{share your work}
9
+ gem.description = %Q{a simple framework to share yourwork}
10
+ gem.email = "mjording@opengotham.com"
11
+ gem.homepage = "http://github.com/opengotham/bluplate"
12
+ gem.authors = ["matthew jording"]
13
+ gem.add_runtime_dependency "settingslogic"
14
+ gem.add_runtime_dependency "mongo"
15
+ gem.add_development_dependency "rspec", ">= 1.2.9"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs << 'lib' << 'spec'
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "bluplate #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{bluplate}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["matthew jording"]
12
+ s.date = %q{2010-05-23}
13
+ s.description = %q{a simple framework to share yourwork}
14
+ s.email = %q{mjording@opengotham.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bluplate.gemspec",
27
+ "config/application.yml",
28
+ "init.rb",
29
+ "lib/bluplate.rb",
30
+ "lib/persist.rb",
31
+ "lib/settings.rb",
32
+ "lib/task.rb",
33
+ "lib/ticket.rb",
34
+ "lib/user.rb",
35
+ "spec/bluplate_spec.rb",
36
+ "spec/spec.opts",
37
+ "spec/spec_helper.rb",
38
+ "spec/task_spec.rb",
39
+ "spec/ticket_spec.rb",
40
+ "spec/user_spec.rb"
41
+ ]
42
+ s.homepage = %q{http://github.com/opengotham/bluplate}
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.6}
46
+ s.summary = %q{share your work}
47
+ s.test_files = [
48
+ "spec/bluplate_spec.rb",
49
+ "spec/spec_helper.rb",
50
+ "spec/task_spec.rb",
51
+ "spec/ticket_spec.rb",
52
+ "spec/user_spec.rb"
53
+ ]
54
+
55
+ if s.respond_to? :specification_version then
56
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
57
+ s.specification_version = 3
58
+
59
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
+ s.add_runtime_dependency(%q<settingslogic>, [">= 0"])
61
+ s.add_runtime_dependency(%q<mongo>, [">= 0"])
62
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
63
+ else
64
+ s.add_dependency(%q<settingslogic>, [">= 0"])
65
+ s.add_dependency(%q<mongo>, [">= 0"])
66
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<settingslogic>, [">= 0"])
70
+ s.add_dependency(%q<mongo>, [">= 0"])
71
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
72
+ end
73
+ end
74
+
@@ -0,0 +1,4 @@
1
+ mongo:
2
+ host: localhost
3
+ db: bluplate
4
+
data/init.rb ADDED
File without changes
File without changes
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'mongo'
3
+ require 'settings'
4
+ require 'json'
5
+ require 'active_support/inflector'
6
+
7
+ module Persist
8
+
9
+
10
+ module Base
11
+
12
+
13
+ def save
14
+ self.class.db.collection(self.class.to_s.downcase.pluralize).insert(self.to_hash)
15
+ end
16
+
17
+ def self.included(base)
18
+ base.extend ClassMethods
19
+ end
20
+
21
+ module ClassMethods
22
+ def db
23
+ Persist.db
24
+ end
25
+ end
26
+ end
27
+
28
+ def db
29
+ @db ||= begin
30
+ Mongo::Connection.new(Settings.mongo.host).db(Settings.mongo.db)
31
+ end
32
+ end
33
+ module_function :db
34
+ end
35
+
@@ -0,0 +1,5 @@
1
+ require 'settingslogic'
2
+
3
+ class Settings < Settingslogic
4
+ source File.join(File.dirname(__FILE__), '..', 'config', 'application.yml')
5
+ end
@@ -0,0 +1,18 @@
1
+ require 'persist'
2
+ class Task
3
+ include Persist::Base
4
+ attr_accessor :tags, :description, :user_email
5
+
6
+ def initialize(user_email, description)
7
+ @user_email = user_email
8
+ @description = description
9
+ @tags ||= {}
10
+
11
+
12
+ end
13
+
14
+ def to_hash
15
+ {:tags => @tags, :user_email => @user_email, :description => @description}
16
+ end
17
+
18
+ end
@@ -0,0 +1,14 @@
1
+ class Ticket
2
+
3
+ attr_accessor :task, :user_email
4
+
5
+ def initialize(task, user_email)
6
+ @task = task
7
+ @user_email = user_email
8
+ end
9
+
10
+ def to_hash
11
+ {:task => @task, :user_email => @user_email}
12
+ end
13
+
14
+ end
@@ -0,0 +1,37 @@
1
+ require 'persist'
2
+ require 'mongo'
3
+ require 'json'
4
+ class User
5
+ include Persist::Base
6
+
7
+ attr_accessor :email, :inbox, :workstream, :contacts
8
+
9
+ def initialize(opts)
10
+
11
+ @email = opts[:email]
12
+ @inbox = opts[:inbox] || {}
13
+ @contacts = opts[:contacts] || {}
14
+ @workstream = opts[:workstream] || {}
15
+ end
16
+
17
+ def to_hash
18
+ {:email => @email, :inbox => @inbox, :workstream => @workstream, :contacts => @contacts }
19
+ end
20
+
21
+ def self.find_by_email(email)
22
+ if user_h = db.collection("users").find_one({"email" => email})
23
+ user_hash = user_h.each{ |doc| doc.inspect }
24
+ else
25
+ user_hash = nil
26
+ end
27
+ inbox = user_hash ? user_hash["inbox"] : {}
28
+ User.new(:email => email, :inbox => inbox)
29
+ end
30
+
31
+ def self.create(opts={})
32
+ u = self.new(opts)
33
+ u.save
34
+ u
35
+ end
36
+
37
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Bluplate" do
4
+ before(:each) do
5
+ @user = User.new(:email => "test@tester.com")
6
+ end
7
+ it "should have a user" do
8
+
9
+ @user.class.should == User
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'bluplate'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ require 'task'
7
+ require 'user'
8
+ require 'ticket'
9
+ Spec::Runner.configure do |config|
10
+
11
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Task" do
4
+
5
+ before(:each) do
6
+ @u = User.find_by_email("test@tester.com") ? User.find_by_email("test@tester.com") : User.create(:email => "test@tester.com")
7
+ @task = Task.new(@u.email, "this is my task, there are many like it, but this one is mine")
8
+
9
+ end
10
+
11
+ it "should have a list of tags" do
12
+ @task.tags.class == Hash
13
+ end
14
+
15
+
16
+
17
+ it "should persist" do
18
+ @u.class.should == User
19
+ @u.inbox["test"] = @task.to_hash
20
+ @u.save
21
+ @user = User.find_by_email(@u.email)
22
+ @user.inbox.first == @task
23
+ end
24
+
25
+ it "should have a description" do
26
+ @u.inbox["test"] = @task.to_hash
27
+ @u.save
28
+ @user = User.find_by_email(@u.email)
29
+
30
+
31
+ @user.inbox["test"].should_not == nil
32
+
33
+ @user.inbox["test"]["description"].should == @task.description
34
+ end
35
+
36
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticket" do
4
+
5
+ before(:each) do
6
+ @u = User.find_by_email("test@tester.com") ? User.find_by_email("test@tester.com") : User.create(:email => "test@tester.com")
7
+ @task = Task.new(@u.email, "this is my task, there are many like it, but this one is mine")
8
+ @u.inbox["test"] = @task.to_hash
9
+ @u.save
10
+
11
+ end
12
+
13
+ it "should have a task" do
14
+
15
+ @ticket = Ticket.new(@task, @u.email)
16
+ @ticket.task.should_not == nil
17
+ @ticket.task.class.should == Task
18
+ end
19
+
20
+ end
@@ -0,0 +1,57 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "User" do
4
+ before(:each) do
5
+ @user = User.find_by_email("test@tester.com") ? User.find_by_email("test@tester.com") : User.create(:email => "test@tester.com")
6
+
7
+ # @user = User.new(:email => "test@tester.com", :inbox => {})
8
+ #@user.save
9
+ end
10
+ it "should have an inbox hash of tasks" do
11
+
12
+ @user.inbox.class == Hash
13
+ @task = Task.new(@user.email, "this is my task, there are many like it, but this one is mine")
14
+ @user.inbox["test"] = @task.to_hash
15
+ @user.inbox["test"].class == Task
16
+ @user.save
17
+ end
18
+
19
+ it "can have a workstream hash" do
20
+ @user.workstream.class == Hash
21
+
22
+ end
23
+
24
+ it "can add a ticket to workstream from inbox task" do
25
+ @task = Task.new(@user.email, "this is my task, there are many like it, but this one is mine")
26
+ @user.inbox["test"] = @task.to_hash
27
+ @user.save
28
+ @u = User.find_by_email(@user.email)
29
+ @u.inbox.first == @task
30
+ @ticket = Ticket.new(@u.inbox.first, @user.email)
31
+ @u.workstream["test"] = @ticket.to_hash
32
+ @u.save
33
+ @uu = User.find_by_email(@user.email)
34
+ @uu.workstream.first == @ticket
35
+ end
36
+
37
+ it "should have a hash list of contacts" do
38
+ @user.contacts.should_not == nil
39
+ @user.contacts.class == Hash
40
+ end
41
+
42
+
43
+
44
+
45
+ it "should return a User object on find_by_email" do
46
+ @user.save
47
+ User.find_by_email(@user.email).class.should == User
48
+ end
49
+
50
+ it "should persist" do
51
+ @user.save
52
+ @u = User.find_by_email(@user.email)
53
+ @u.should_not == nil
54
+ end
55
+
56
+
57
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bluplate
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - matthew jording
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-23 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: settingslogic
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: mongo
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 1
53
+ - 2
54
+ - 9
55
+ version: 1.2.9
56
+ type: :development
57
+ version_requirements: *id003
58
+ description: a simple framework to share yourwork
59
+ email: mjording@opengotham.com
60
+ executables: []
61
+
62
+ extensions: []
63
+
64
+ extra_rdoc_files:
65
+ - LICENSE
66
+ - README.rdoc
67
+ files:
68
+ - .document
69
+ - .gitignore
70
+ - LICENSE
71
+ - README.rdoc
72
+ - Rakefile
73
+ - VERSION
74
+ - bluplate.gemspec
75
+ - config/application.yml
76
+ - init.rb
77
+ - lib/bluplate.rb
78
+ - lib/persist.rb
79
+ - lib/settings.rb
80
+ - lib/task.rb
81
+ - lib/ticket.rb
82
+ - lib/user.rb
83
+ - spec/bluplate_spec.rb
84
+ - spec/spec.opts
85
+ - spec/spec_helper.rb
86
+ - spec/task_spec.rb
87
+ - spec/ticket_spec.rb
88
+ - spec/user_spec.rb
89
+ has_rdoc: true
90
+ homepage: http://github.com/opengotham/bluplate
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options:
95
+ - --charset=UTF-8
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ requirements: []
113
+
114
+ rubyforge_project:
115
+ rubygems_version: 1.3.6
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: share your work
119
+ test_files:
120
+ - spec/bluplate_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/task_spec.rb
123
+ - spec/ticket_spec.rb
124
+ - spec/user_spec.rb