towsta 1.0.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/towsta ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+ require 'net/http'
3
+ action = ARGV.first
4
+ if action == 'new'
5
+ project = ARGV[1]
6
+ Dir.mkdir project
7
+ configru = "require './app'\n"
8
+ configru += "run Sinatra::Application"
9
+ File.open("#{project}/config.ru", 'w') {|f| f.write(configru) }
10
+ gemfile = "source :rubygems \n"
11
+ gemfile += "gem 'towsta'"
12
+ File.open("#{project}/Gemfile", 'w') {|f| f.write(gemfile) }
13
+ apprb = "#coding: utf-8 \n"
14
+ apprb += "require 'sinatra'\n"
15
+ apprb += "require 'towsta'\n\n"
16
+ apprb += "$towsta_secret = '#{ARGV[2]}'\n"
17
+ apprb += "# $towsta_cache = true\n\n"
18
+ apprb += "get '/' do\n"
19
+ apprb += " sync_with_towsta\n"
20
+ apprb += " haml :index\n"
21
+ apprb += "end\n"
22
+ File.open("#{project}/app.rb", 'w') {|f| f.write(apprb) }
23
+ Dir.mkdir "#{project}/views"
24
+ layout = "!!!\n"
25
+ layout += "%html\n"
26
+ layout += " %head\n"
27
+ layout += " = partial :head\n"
28
+ layout += " %body\n"
29
+ layout += " #top\n"
30
+ layout += " .wrapper\n"
31
+ layout += " #middle\n"
32
+ layout += " .wrapper\n"
33
+ layout += " = yield\n"
34
+ layout += " #bottom\n"
35
+ layout += " .wrapper\n"
36
+ File.open("#{project}/views/layout.haml", 'w') {|f| f.write(layout)}
37
+ index = '%h1 Hello Towsta'
38
+ File.open("#{project}/views/index.haml", 'w') {|f| f.write(index)}
39
+ Dir.mkdir "#{project}/models"
40
+ Dir.mkdir "#{project}/public"
41
+ Dir.mkdir "#{project}/views/stylesheets"
42
+ css = "@import compass/reset\n"
43
+ css += "@import compass/css3\n\n"
44
+ css += "$wrapper: 940px\n\n"
45
+ css += ".wrapper\n"
46
+ css += " :width $wrapper\n"
47
+ css += " :margin 0 auto\n"
48
+ css += "#top, #middle, #bottom\n"
49
+ css += " :float left\n"
50
+ css += " :width 100%"
51
+ File.open("#{project}/views/stylesheets/#{project}.sass", 'w') {|f| f.write(css)}
52
+ Dir.mkdir "#{project}/views/partials"
53
+ head = "%title #{project}\n"
54
+ head += "%meta{'http-equiv': 'Content-Type', content: 'text/html', charset: 'utf-8'}\n"
55
+ head += "%link{rel: 'stylesheet', type: 'text/css', href: '/stylesheets/#{project}.css'}\n"
56
+ head += "%link{rel: 'shortcut icon', type: 'image/x-icon', href: '/images/favicon.png'}\n"
57
+ head += "%script{src: '/js/jquery.js'}\n"
58
+ head += "%script{src: '/js/#{project}.js'}"
59
+ File.open("#{project}/views/partials/_head.haml", 'w') {|f| f.write(head)}
60
+ Dir.mkdir "#{project}/public/js"
61
+ js = "$(function() {\n\n"
62
+ js += "});"
63
+ File.open("#{project}/public/js/#{project}.js", 'w') {|f| f.write(js)}
64
+ Net::HTTP.start("code.jquery.com"){|http| @jquery = http.get('/jquery.min.js').body}
65
+ File.open("#{project}/public/js/jquery.js", 'w') {|f| f.write(@jquery)}
66
+ Dir.mkdir "#{project}/public/images"
67
+ puts "#{project} is ready to towst!"
68
+ elsif action == 'server'
69
+ port = ARGV[1].nil? ? '6937' : ARGV[1]
70
+ system "shotgun -I config.ru -p #{port}"
71
+ elsif action == 'console'
72
+ system 'irb -r ./app.rb'
73
+ elsif action == 'help'
74
+ puts 'towsta new {projectname} {optional: secret} to generate a new project'
75
+ puts 'towsta server {optional: port} to run the application server'
76
+ puts 'towsta console to run the application console'
77
+ else
78
+ puts 'Comand not found, try running "towsta help"'
79
+ end
data/lib/towsta/memory.rb CHANGED
@@ -1,6 +1,3 @@
1
- require 'dalli'
2
- require 'digest/md5'
3
-
4
1
  set :cache, Dalli::Client.new
5
2
 
6
3
  module Towsta
@@ -0,0 +1,15 @@
1
+ helpers do
2
+ def partial page
3
+ haml "partials/_#{page}".to_sym
4
+ end
5
+ end
6
+
7
+ post '/flush' do
8
+ clear_sync
9
+ 'CLEAR'
10
+ end
11
+
12
+ get '/stylesheets/:name.css' do
13
+ content_type 'text/css', :charset => 'utf-8'
14
+ sass(:"stylesheets/#{params[:name]}", Compass.sass_engine_options)
15
+ end
@@ -1,8 +1,3 @@
1
- require 'net/http'
2
- require 'cgi'
3
- require 'json'
4
- require 'time'
5
-
6
1
  module Towsta
7
2
  class Synchronizer
8
3
 
@@ -1,3 +1,3 @@
1
1
  module Towsta
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -1,7 +1,3 @@
1
- require 'date'
2
- require 'time'
3
- require 'bresson'
4
-
5
1
  module Towsta
6
2
 
7
3
  class Vertical
data/lib/towsta.rb CHANGED
@@ -1,7 +1,20 @@
1
- #require File.expand_path('../towsta/tree', __FILE__)
1
+ #coding: utf-8
2
+ require 'dalli'
3
+ require 'digest/md5'
4
+ require 'net/http'
5
+ require 'cgi'
6
+ require 'json'
7
+ require 'time'
8
+ require 'date'
9
+ require 'time'
10
+ require 'bresson'
11
+ require 'sinatra'
12
+ require 'compass'
13
+
2
14
  require File.expand_path('../towsta/vertical', __FILE__)
3
15
  require File.expand_path('../towsta/synchronizer', __FILE__)
4
16
  require File.expand_path('../towsta/memory', __FILE__)
17
+ require File.expand_path('../towsta/sinatra_extension', __FILE__)
5
18
 
6
19
  module Towsta
7
20
  end
data/towsta.gemspec CHANGED
@@ -17,6 +17,10 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency("json")
18
18
  s.add_dependency("bresson")
19
19
  s.add_dependency("dalli")
20
+ s.add_dependency("compass")
21
+ s.add_dependency("haml")
22
+ s.add_dependency("sinatra")
23
+ s.add_dependency("shotgun")
20
24
 
21
25
  s.files = `git ls-files`.split("\n")
22
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 0
8
7
  - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mortaro
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-10-31 00:00:00 -02:00
17
+ date: 2011-11-06 00:00:00 -02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -56,11 +56,63 @@ dependencies:
56
56
  version: "0"
57
57
  type: :runtime
58
58
  version_requirements: *id003
59
+ - !ruby/object:Gem::Dependency
60
+ name: compass
61
+ prerelease: false
62
+ requirement: &id004 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ type: :runtime
71
+ version_requirements: *id004
72
+ - !ruby/object:Gem::Dependency
73
+ name: haml
74
+ prerelease: false
75
+ requirement: &id005 !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ type: :runtime
84
+ version_requirements: *id005
85
+ - !ruby/object:Gem::Dependency
86
+ name: sinatra
87
+ prerelease: false
88
+ requirement: &id006 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ type: :runtime
97
+ version_requirements: *id006
98
+ - !ruby/object:Gem::Dependency
99
+ name: shotgun
100
+ prerelease: false
101
+ requirement: &id007 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ type: :runtime
110
+ version_requirements: *id007
59
111
  description: Simply integrates the towsta api
60
112
  email:
61
113
  - mortaro@towsta.com
62
- executables: []
63
-
114
+ executables:
115
+ - towsta
64
116
  extensions: []
65
117
 
66
118
  extra_rdoc_files: []
@@ -69,10 +121,11 @@ files:
69
121
  - .gitignore
70
122
  - Gemfile
71
123
  - Rakefile
124
+ - bin/towsta
72
125
  - lib/towsta.rb
73
126
  - lib/towsta/memory.rb
127
+ - lib/towsta/sinatra_extension.rb
74
128
  - lib/towsta/synchronizer.rb
75
- - lib/towsta/tree.rb
76
129
  - lib/towsta/version.rb
77
130
  - lib/towsta/vertical.rb
78
131
  - towsta.gemspec
data/lib/towsta/tree.rb DELETED
@@ -1,36 +0,0 @@
1
- module Towsta
2
-
3
- class Tree
4
-
5
- attr_accessor :parent, :item, :left, :right
6
-
7
- def initialize element
8
- @item = element
9
- end
10
-
11
- def add element
12
- item.id > element.id ? ( @right ? @right.add(element) : add_right(Tree.new(element))) : (@left ? @left.add(element): add_left(Tree.new(element)))
13
- end
14
-
15
- def add_left tree
16
- @left = tree
17
- @left.parent = self
18
- end
19
-
20
- def add_right tree
21
- @right = tree
22
- @right.parent = self
23
- end
24
-
25
- def delete element
26
- end
27
-
28
- def find id
29
- return self.item if @item.id == id
30
- return @right.find id if @right && @item.id > id
31
- return @left.find id if @left
32
- end
33
-
34
- end
35
-
36
- end