spellbook 0.2.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.
Files changed (46) hide show
  1. data/Gemfile +45 -0
  2. data/Gemfile.lock +65 -0
  3. data/README.mkd +63 -0
  4. data/Rakefile +35 -0
  5. data/TODO +18 -0
  6. data/VERSION +1 -0
  7. data/bin/spellbook +28 -0
  8. data/config.ru +4 -0
  9. data/db/migrate/20110419111502_create_apps.rb +13 -0
  10. data/db/migrate/20110419135238_add_proxy_to_apps.rb +9 -0
  11. data/examples/rails_hello/app/controllers/application_controller.rb +3 -0
  12. data/examples/rails_hello/app/controllers/top_controller.rb +5 -0
  13. data/examples/rails_hello/app/helpers/application_helper.rb +2 -0
  14. data/examples/rails_hello/config/application.rb +42 -0
  15. data/examples/rails_hello/config/boot.rb +6 -0
  16. data/examples/rails_hello/config/environment.rb +5 -0
  17. data/examples/rails_hello/config/environments/development.rb +26 -0
  18. data/examples/rails_hello/config/environments/production.rb +50 -0
  19. data/examples/rails_hello/config/environments/test.rb +35 -0
  20. data/examples/rails_hello/config/initializers/backtrace_silencers.rb +7 -0
  21. data/examples/rails_hello/config/initializers/inflections.rb +10 -0
  22. data/examples/rails_hello/config/initializers/mime_types.rb +5 -0
  23. data/examples/rails_hello/config/initializers/secret_token.rb +7 -0
  24. data/examples/rails_hello/config/initializers/session_store.rb +8 -0
  25. data/examples/rails_hello/config/routes.rb +60 -0
  26. data/examples/rails_hello/db/seeds.rb +7 -0
  27. data/examples/rails_hello/main.rb +76 -0
  28. data/examples/rails_hello/test/performance/browsing_test.rb +9 -0
  29. data/examples/rails_hello/test/test_helper.rb +13 -0
  30. data/examples/sinatra_hello/app.rb +124 -0
  31. data/lib/spellbook.rb +8 -0
  32. data/lib/spellbook/app.rb +16 -0
  33. data/lib/spellbook/proxy.rb +14 -0
  34. data/lib/spellbook/server.rb +202 -0
  35. data/lib/spellbook/views/apps_edit.slim +34 -0
  36. data/lib/spellbook/views/apps_index.slim +36 -0
  37. data/lib/spellbook/views/apps_new.slim +33 -0
  38. data/lib/spellbook/views/apps_show.slim +2 -0
  39. data/lib/spellbook/views/error.slim +7 -0
  40. data/lib/spellbook/views/layout.slim +22 -0
  41. data/lib/spellbook/views/screen.sass +29 -0
  42. data/lib/spellbook/views/top.slim +2 -0
  43. data/spec/database_spec.rb +29 -0
  44. data/spec/server_spec.rb +99 -0
  45. data/spec/spec_helper.rb +16 -0
  46. metadata +315 -0
data/Gemfile ADDED
@@ -0,0 +1,45 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sinatra', '>= 1.2'
4
+ gem 'sinatra-activerecord', '0.1.3'
5
+ gem 'slim'
6
+ gem 'sass'
7
+ gem 'childprocess'
8
+ gem 'slop'
9
+
10
+ # Bundle edge Rails instead:
11
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
12
+
13
+ gem 'sqlite3'
14
+
15
+ group :development do
16
+ gem 'sinatra-reloader'
17
+ gem 'thin'
18
+ end
19
+
20
+ group :test do
21
+ gem 'rspec'
22
+ end
23
+
24
+ # Use unicorn as the web server
25
+ # gem 'unicorn'
26
+
27
+ # Deploy with Capistrano
28
+ # gem 'capistrano'
29
+
30
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
31
+ # gem 'ruby-debug'
32
+ # gem 'ruby-debug19'
33
+
34
+ # Bundle the extra gems:
35
+ # gem 'bj'
36
+ # gem 'nokogiri'
37
+ # gem 'sqlite3-ruby', :require => 'sqlite3'
38
+ # gem 'aws-s3', :require => 'aws/s3'
39
+
40
+ # Bundle gems for the local environment. Make sure to
41
+ # put test-only gems in this group so their generators
42
+ # and rake tasks are available in development mode:
43
+ # group :development, :test do
44
+ # gem 'webrat'
45
+ # end
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ backports (2.1.0)
5
+ childprocess (0.1.8)
6
+ ffi (~> 1.0.6)
7
+ daemons (1.1.0)
8
+ diff-lcs (1.1.2)
9
+ eventmachine (0.12.10)
10
+ ffi (1.0.7)
11
+ rake (>= 0.8.7)
12
+ monkey-lib (0.5.4)
13
+ backports
14
+ rack (1.2.2)
15
+ rake (0.8.7)
16
+ rspec (2.5.0)
17
+ rspec-core (~> 2.5.0)
18
+ rspec-expectations (~> 2.5.0)
19
+ rspec-mocks (~> 2.5.0)
20
+ rspec-core (2.5.1)
21
+ rspec-expectations (2.5.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.5.0)
24
+ sass (3.1.0.alpha.221)
25
+ sinatra (1.2.3)
26
+ rack (~> 1.1)
27
+ tilt (>= 1.2.2, < 2.0)
28
+ sinatra-activerecord (0.1.3)
29
+ sinatra (>= 0.9.4)
30
+ sinatra-advanced-routes (0.5.1)
31
+ monkey-lib (~> 0.5.0)
32
+ sinatra (~> 1.0)
33
+ sinatra-sugar (~> 0.5.0)
34
+ sinatra-reloader (0.5.0)
35
+ sinatra (~> 1.0)
36
+ sinatra-advanced-routes (~> 0.5.0)
37
+ sinatra-sugar (0.5.0)
38
+ monkey-lib (~> 0.5.0)
39
+ sinatra (~> 1.0)
40
+ slim (0.9.2)
41
+ temple (~> 0.2.0)
42
+ tilt (~> 1.2)
43
+ slop (1.5.2)
44
+ sqlite3 (1.3.3)
45
+ temple (0.2.0)
46
+ thin (1.2.11)
47
+ daemons (>= 1.0.9)
48
+ eventmachine (>= 0.12.6)
49
+ rack (>= 1.0.0)
50
+ tilt (1.2.2)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ childprocess
57
+ rspec
58
+ sass
59
+ sinatra (>= 1.2)
60
+ sinatra-activerecord (= 0.1.3)
61
+ sinatra-reloader
62
+ slim
63
+ slop
64
+ sqlite3
65
+ thin
data/README.mkd ADDED
@@ -0,0 +1,63 @@
1
+ SpellBook
2
+ =========
3
+
4
+ SpellBook is a launcher for browser-based desktop apps.
5
+
6
+ What's "browser-based"?
7
+ -----------------------
8
+
9
+ Browser-GUI apps are desktop apps made with Web technology
10
+ like HTML, CSS and JavaScript.
11
+
12
+ Why not GUI toolkits?
13
+ ---------------------
14
+
15
+ There are many GUI libraries for Ruby, but I would like to
16
+ write desktop apps in Sinatra (or Rails).
17
+
18
+ Why do I need a launcher?
19
+ -------------------------
20
+
21
+ Browser-GUI apps work on web application frameworks and
22
+ web server.
23
+ When you have many Browser-GUI apps, it is difficult to
24
+ remember all the port numbers.
25
+
26
+ Install
27
+ =======
28
+
29
+ You need Ruby 1.8 or 1.9 and RubyGems.
30
+
31
+ $ gem i spellbook
32
+
33
+ Usage
34
+ =====
35
+
36
+ $ spellbook -h
37
+ $ spellbook
38
+
39
+ Then open http://localhost:3017 in your browser.
40
+
41
+ What SpellBook does
42
+ ===================
43
+
44
+ * Launcher
45
+ * Register an app
46
+ * Start an app
47
+ * Stop an running app
48
+ * Proxy
49
+ * Access to all the apps through one port number
50
+ * You don't need editing iptables everytime install new app
51
+
52
+ What SpellBook does not
53
+ -----------------------
54
+
55
+ * Installing apps
56
+ * Updating apps
57
+
58
+ Contact
59
+ =======
60
+
61
+ https://github.com/yhara/spellbook
62
+
63
+ http://twitter.com/yhara_en
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'sinatra/activerecord'
2
+ require 'sinatra/activerecord/rake'
3
+
4
+ desc "start server in port 3018"
5
+ task :server do
6
+ sh "ruby bin/spellbook -p 3018 -e development"
7
+ end
8
+
9
+ #
10
+ # Rakefile to creating gems
11
+ #
12
+ # configurations:
13
+ PROJECT_NAME = File.basename(File.dirname(__FILE__))
14
+
15
+ require 'jeweler'
16
+
17
+ Jeweler::Tasks.new do |gemspec|
18
+ gemspec.name = "#{PROJECT_NAME}"
19
+ gemspec.summary = "Launcher for browser-based desktop applications "
20
+ gemspec.email = "yutaka.hara/at/gmail.com"
21
+ gemspec.homepage = "http://github.com/yhara/#{PROJECT_NAME}"
22
+ gemspec.description = gemspec.summary
23
+ gemspec.authors = ["Yutaka HARA"]
24
+ gemspec.add_dependency('sinatra', '>= 1.2')
25
+ gemspec.add_dependency('sinatra-activerecord', '= 0.1.3')
26
+ gemspec.add_dependency('sqlite3')
27
+ gemspec.add_dependency('slim')
28
+ gemspec.add_dependency('sass')
29
+ gemspec.add_dependency('childprocess')
30
+ gemspec.add_development_dependency('rspec', '>= 2.0')
31
+ gemspec.add_development_dependency('sinatra-reloader')
32
+ gemspec.add_development_dependency('thin')
33
+ gemspec.executables = ["spellbook"]
34
+ end
35
+
data/TODO ADDED
@@ -0,0 +1,18 @@
1
+
2
+ high
3
+
4
+ middle
5
+
6
+ low
7
+ - 2 delete app
8
+ - running app shall not be deleted
9
+ - 3 show app logs
10
+ - 2 edit options manually
11
+
12
+ lower
13
+
14
+ lowest
15
+ - 1 move lib/spellbook/views to views/
16
+ - 2 dry up #new and #edit
17
+ - 1 rename to Spellbook?
18
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
data/bin/spellbook ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
+ require 'spellbook'
4
+ require 'slop'
5
+
6
+ module SpellBook
7
+
8
+ @@opts = Slop.parse(:help => true) do
9
+ on 'p', 'port',
10
+ 'Specify port number (default: 3017)', true, :as => :integer
11
+ on 'data',
12
+ 'Specify path of data file (default: ~/.spellbook.db)', true
13
+ on 'e', 'environment',
14
+ 'Specify Sinatra env (default: production)', true
15
+ on 'v', 'version', 'Print the version' do
16
+ puts "Spellbook version #{SpellBook::VERSION}"
17
+ exit
18
+ end
19
+ end
20
+
21
+ def self.opts
22
+ @@opts
23
+ end
24
+
25
+ end
26
+
27
+ require 'spellbook/server'
28
+ SpellBook::Server.run! :host => 'localhost'
data/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift "#{File.dirname __FILE__}/lib"
2
+
3
+ require 'spellbook'
4
+ run SpellBook::Server
@@ -0,0 +1,13 @@
1
+ class CreateApps < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :apps do |t|
4
+ t.string :name
5
+ t.integer :port
6
+ t.string :command
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :apps
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class AddProxyToApps < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :apps, :proxy, :boolean, :default => true
4
+ end
5
+
6
+ def self.down
7
+ remove_column :apps, :proxy
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,5 @@
1
+ class TopController < ApplicationController
2
+ def hello
3
+ render :text => "Hello, Rails!"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,42 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module RailsHello
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Custom directories with classes and modules you want to be autoloadable.
16
+ # config.autoload_paths += %W(#{config.root}/extras)
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named.
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running.
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # JavaScript files you want as :defaults (application.js is always included).
34
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+ end
42
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsHello::Application.initialize!
@@ -0,0 +1,26 @@
1
+ RailsHello::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,50 @@
1
+ RailsHello::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
50
+ p $pro = :production_rb_loaded