eyeballs 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG +15 -0
  2. data/README.md +293 -0
  3. data/Rakefile +45 -0
  4. data/bin/eyeballs +9 -0
  5. data/config.ru +2 -0
  6. data/dist/jquery-1.4.2.min.js +154 -0
  7. data/dist/jquery.livequery.js +226 -0
  8. data/dist/mustache.js +324 -0
  9. data/eyeballs.gemspec +86 -0
  10. data/eyeballs.js.gemspec +83 -0
  11. data/lib/eyeballs.rb +11 -0
  12. data/lib/eyeballs/app_detector.rb +29 -0
  13. data/lib/eyeballs/app_generator.rb +30 -0
  14. data/lib/eyeballs/cli.rb +14 -0
  15. data/lib/eyeballs/controller_generator.rb +26 -0
  16. data/lib/eyeballs/model_generator.rb +26 -0
  17. data/lib/eyeballs/scaffold_generator.rb +66 -0
  18. data/spec/app_generator_spec.rb +51 -0
  19. data/spec/controller_generator_spec.rb +22 -0
  20. data/spec/model_generator_spec.rb +23 -0
  21. data/spec/rack_app_detector_spec.rb +25 -0
  22. data/spec/scaffold_generator_spec.rb +42 -0
  23. data/spec/spec_helper.rb +42 -0
  24. data/src/jquery.o_O.couchdb.js +107 -0
  25. data/src/jquery.o_O.dom.js +37 -0
  26. data/src/jquery.o_O.js +120 -0
  27. data/src/jquery.o_O.rails.js +68 -0
  28. data/src/o_O.js +286 -0
  29. data/src/o_O.localstorage.js +60 -0
  30. data/templates/app_root/index.html +26 -0
  31. data/templates/controller.js +3 -0
  32. data/templates/model.js +3 -0
  33. data/templates/scaffold_controller.js +75 -0
  34. data/templates/scaffold_edit.html.mustache +13 -0
  35. data/templates/scaffold_index.html +47 -0
  36. data/templates/scaffold_partial.html.mustache +12 -0
  37. data/test/unit/qunit.css +119 -0
  38. data/test/unit/qunit.js +1069 -0
  39. data/test/unit/test_controller.html +137 -0
  40. data/test/unit/test_dom.html +81 -0
  41. data/test/unit/test_dom_with_callbacks.html +121 -0
  42. data/test/unit/test_form.html +42 -0
  43. data/test/unit/test_localstorage.html +79 -0
  44. data/test/unit/test_model.html +136 -0
  45. data/test/unit/test_model_with_callbacks.html +118 -0
  46. data/test/unit/test_rails.html +97 -0
  47. metadata +117 -0
data/eyeballs.gemspec ADDED
@@ -0,0 +1,86 @@
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{eyeballs}
8
+ s.version = "0.3.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Paul Campbell"]
12
+ s.date = %q{2010-06-09}
13
+ s.default_executable = %q{eyeballs}
14
+ s.email = %q{paul@rslw.com}
15
+ s.executables = ["eyeballs"]
16
+ s.extra_rdoc_files = [
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "CHANGELOG",
21
+ "README.md",
22
+ "Rakefile",
23
+ "bin/eyeballs",
24
+ "config.ru",
25
+ "dist/jquery-1.4.2.min.js",
26
+ "dist/jquery.livequery.js",
27
+ "dist/mustache.js",
28
+ "eyeballs.gemspec",
29
+ "eyeballs.js.gemspec",
30
+ "lib/eyeballs.rb",
31
+ "lib/eyeballs/app_detector.rb",
32
+ "lib/eyeballs/app_generator.rb",
33
+ "lib/eyeballs/cli.rb",
34
+ "lib/eyeballs/controller_generator.rb",
35
+ "lib/eyeballs/model_generator.rb",
36
+ "lib/eyeballs/scaffold_generator.rb",
37
+ "src/jquery.o_O.couchdb.js",
38
+ "src/jquery.o_O.dom.js",
39
+ "src/jquery.o_O.js",
40
+ "src/jquery.o_O.rails.js",
41
+ "src/o_O.js",
42
+ "src/o_O.localstorage.js",
43
+ "templates/app_root/index.html",
44
+ "templates/controller.js",
45
+ "templates/model.js",
46
+ "templates/scaffold_controller.js",
47
+ "templates/scaffold_edit.html.mustache",
48
+ "templates/scaffold_index.html",
49
+ "templates/scaffold_partial.html.mustache",
50
+ "test/unit/qunit.css",
51
+ "test/unit/qunit.js",
52
+ "test/unit/test_controller.html",
53
+ "test/unit/test_dom.html",
54
+ "test/unit/test_dom_with_callbacks.html",
55
+ "test/unit/test_form.html",
56
+ "test/unit/test_localstorage.html",
57
+ "test/unit/test_model.html",
58
+ "test/unit/test_model_with_callbacks.html",
59
+ "test/unit/test_rails.html"
60
+ ]
61
+ s.has_rdoc = false
62
+ s.homepage = %q{http://www.github.com/paulca/eyeballs.js}
63
+ s.rdoc_options = ["--charset=UTF-8"]
64
+ s.require_paths = ["lib"]
65
+ s.rubygems_version = %q{1.3.7}
66
+ s.summary = %q{A lightweight javascript MVC framework.}
67
+ s.test_files = [
68
+ "spec/app_generator_spec.rb",
69
+ "spec/controller_generator_spec.rb",
70
+ "spec/model_generator_spec.rb",
71
+ "spec/rack_app_detector_spec.rb",
72
+ "spec/scaffold_generator_spec.rb",
73
+ "spec/spec_helper.rb"
74
+ ]
75
+
76
+ if s.respond_to? :specification_version then
77
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
78
+ s.specification_version = 3
79
+
80
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
+ else
82
+ end
83
+ else
84
+ end
85
+ end
86
+
@@ -0,0 +1,83 @@
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{eyeballs.js}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Paul Campbell"]
12
+ s.date = %q{2010-06-08}
13
+ s.default_executable = %q{eyeballs}
14
+ s.email = %q{paul@rslw.com}
15
+ s.executables = ["eyeballs"]
16
+ s.extra_rdoc_files = [
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "CHANGELOG",
21
+ "README.md",
22
+ "Rakefile",
23
+ "bin/eyeballs",
24
+ "config.ru",
25
+ "dist/jquery-1.4.2.min.js",
26
+ "dist/jquery.livequery.js",
27
+ "dist/mustache.js",
28
+ "eyeballs.js.gemspec",
29
+ "lib/eyeballs.rb",
30
+ "lib/eyeballs/app_generator.rb",
31
+ "lib/eyeballs/cli.rb",
32
+ "lib/eyeballs/controller_generator.rb",
33
+ "lib/eyeballs/model_generator.rb",
34
+ "lib/eyeballs/scaffold_generator.rb",
35
+ "src/jquery.o_O.couchdb.js",
36
+ "src/jquery.o_O.dom.js",
37
+ "src/jquery.o_O.js",
38
+ "src/jquery.o_O.rails.js",
39
+ "src/o_O.js",
40
+ "src/o_O.localstorage.js",
41
+ "templates/app_root/index.html",
42
+ "templates/controller.js",
43
+ "templates/model.js",
44
+ "templates/scaffold_controller.js",
45
+ "templates/scaffold_edit.html.mustache",
46
+ "templates/scaffold_index.html",
47
+ "templates/scaffold_partial.html.mustache",
48
+ "test/unit/qunit.css",
49
+ "test/unit/qunit.js",
50
+ "test/unit/test_controller.html",
51
+ "test/unit/test_dom.html",
52
+ "test/unit/test_dom_with_callbacks.html",
53
+ "test/unit/test_form.html",
54
+ "test/unit/test_localstorage.html",
55
+ "test/unit/test_model.html",
56
+ "test/unit/test_model_with_callbacks.html",
57
+ "test/unit/test_rails.html"
58
+ ]
59
+ s.has_rdoc = false
60
+ s.homepage = %q{http://www.github.com/paulca/eyeballs.js}
61
+ s.rdoc_options = ["--charset=UTF-8"]
62
+ s.require_paths = ["lib"]
63
+ s.rubygems_version = %q{1.3.7}
64
+ s.summary = %q{A lightweight javascript MVC framework.}
65
+ s.test_files = [
66
+ "spec/app_generator_spec.rb",
67
+ "spec/controller_generator_spec.rb",
68
+ "spec/model_generator_spec.rb",
69
+ "spec/scaffold_generator_spec.rb",
70
+ "spec/spec_helper.rb"
71
+ ]
72
+
73
+ if s.respond_to? :specification_version then
74
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
75
+ s.specification_version = 3
76
+
77
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
78
+ else
79
+ end
80
+ else
81
+ end
82
+ end
83
+
data/lib/eyeballs.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'thor'
3
+ require 'thor/group'
4
+ require 'active_support/inflector'
5
+
6
+ require 'eyeballs/app_detector'
7
+ require 'eyeballs/app_generator'
8
+ require 'eyeballs/cli'
9
+ require 'eyeballs/controller_generator'
10
+ require 'eyeballs/model_generator'
11
+ require 'eyeballs/scaffold_generator'
@@ -0,0 +1,29 @@
1
+ module Eyeballs
2
+
3
+ module AppDetector
4
+
5
+ def new_app_path
6
+ @new_app_path ||= if rack_app?
7
+ $stdout.puts "public folder detected, installing to public/javascripts"
8
+ 'public/javascripts'
9
+ else
10
+ name
11
+ end
12
+ end
13
+
14
+ def app_path
15
+ @app_path ||= if rack_app?
16
+ $stdout.puts "public folder detected, installing to public/javascripts"
17
+ 'public/javascripts'
18
+ else
19
+ '.'
20
+ end
21
+ end
22
+
23
+ def rack_app?
24
+ File.exists?('public')
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,30 @@
1
+ module Eyeballs
2
+ class AppGenerator < Thor::Group
3
+ include Thor::Actions
4
+ include Eyeballs::AppDetector
5
+
6
+ desc "Creates a new eyeballs.js app"
7
+
8
+ argument :name
9
+
10
+ def self.source_root
11
+ File.join(File.dirname(__FILE__), '..', '..')
12
+ end
13
+
14
+ def greeting
15
+ $stdout.puts "Creating new eyeballs.js app #{name}"
16
+ end
17
+
18
+ def build_the_app
19
+ directory "templates/app_root", new_app_path
20
+ copy_file 'dist/jquery-1.4.2.min.js', "#{new_app_path}/vendor/jquery/jquery-1.4.2.min.js"
21
+ copy_file 'dist/jquery.livequery.js', "#{new_app_path}/vendor/jquery/jquery.livequery.js"
22
+ copy_file 'dist/mustache.js', "#{new_app_path}/vendor/mustache/mustache.js"
23
+ directory "src", "#{new_app_path}/vendor/eyeballs/"
24
+ end
25
+
26
+ def farewell
27
+ $stdout.puts "Thank you for installing eyeballs.js"
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ module Eyeballs
2
+ class CLI < Thor
3
+
4
+ desc "eyeballs generate [generator] [name]", "call a generator"
5
+ def generate(requested_generator, name, *args)
6
+ ARGV.delete('generate')
7
+ if(ARGV.include?(requested_generator))
8
+ ARGV.delete(requested_generator)
9
+ "Eyeballs::#{requested_generator.capitalize}Generator".constantize.start
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ module Eyeballs
2
+ class ControllerGenerator < Thor::Group
3
+ include Thor::Actions
4
+ include Eyeballs::AppDetector
5
+
6
+ desc "Creates a new eyeballs.js controller"
7
+
8
+ argument :name
9
+
10
+ def self.source_root
11
+ File.join(File.dirname(__FILE__), '..', '..')
12
+ end
13
+
14
+ def greeting
15
+ $stdout.puts "Creating new eyeballs.js controller #{name}"
16
+ end
17
+
18
+ def build_the_model
19
+ template "templates/controller.js", "#{app_path}/app/controllers/#{name.downcase}_controller.js"
20
+ end
21
+
22
+ def farewell
23
+ $stdout.puts "Your controller is ready to rule!"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Eyeballs
2
+ class ModelGenerator < Thor::Group
3
+ include Thor::Actions
4
+ include Eyeballs::AppDetector
5
+
6
+ desc "Creates a new eyeballs.js model"
7
+
8
+ argument :name
9
+
10
+ def self.source_root
11
+ File.join(File.dirname(__FILE__), '..', '..')
12
+ end
13
+
14
+ def greeting
15
+ $stdout.puts "Creating new eyeballs.js model #{name}"
16
+ end
17
+
18
+ def build_the_model
19
+ template "templates/model.js", "#{app_path}/app/models/#{name.downcase}.js"
20
+ end
21
+
22
+ def farewell
23
+ $stdout.puts "Your model is ready to rock!"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,66 @@
1
+ module Eyeballs
2
+ class ScaffoldGenerator < Thor::Group
3
+ include Thor::Actions
4
+ include Eyeballs::AppDetector
5
+
6
+ desc "Creates a new eyeballs.js scaffold"
7
+
8
+ argument :name
9
+ argument :attrs, :type => :array
10
+
11
+ def self.source_root
12
+ File.join(File.dirname(__FILE__), '..', '..')
13
+ end
14
+
15
+ def self.destination_root
16
+ "#{name}"
17
+ end
18
+
19
+ def greeting
20
+ $stdout.puts "Creating new eyeballs.js scaffold, model controller and views for #{name}"
21
+ end
22
+
23
+ def build_the_model
24
+ template "templates/model.js", "app/models/#{name.downcase}.js"
25
+ end
26
+
27
+ def build_the_controller
28
+ template "templates/scaffold_controller.js", "#{app_path}/app/controllers/#{name.downcase.pluralize}_controller.js"
29
+ end
30
+
31
+ def build_the_views
32
+ template "templates/scaffold_index.html", "#{app_path}/#{name.downcase.pluralize}.html"
33
+ template "templates/scaffold_partial.html.mustache", "#{app_path}/app/views/#{name.downcase.pluralize}/_#{name.downcase}.html.mustache"
34
+ template "#{app_path}/templates/scaffold_edit.html.mustache", "app/views/#{name.downcase.pluralize}/edit.html.mustache"
35
+ end
36
+
37
+ def farewell
38
+ $stdout.puts "Your scaffold is ready to rumble!"
39
+ end
40
+
41
+ def attributes
42
+ AttributeCollector.new(attrs)
43
+ end
44
+ end
45
+
46
+ class AttributeCollector
47
+ class << self
48
+ def new(attrs)
49
+ attrs.collect do |attr|
50
+ parts = attr.split(':')
51
+ Attribute.new(:name => parts[0], :type => parts[1])
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ class Attribute
58
+ attr_accessor :name, :type
59
+
60
+ def initialize(attributes = {})
61
+ attributes.each_pair do |key, val|
62
+ self.send("#{key}=", val)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Eyeballs::AppGenerator do
4
+
5
+ describe "generate a simple app" do
6
+ before(:all) do
7
+ create_test_root
8
+ FileUtils.cd(test_root)
9
+ Eyeballs::AppGenerator.start('test')
10
+ end
11
+ let(:app_dir) { file('test', 'app') }
12
+ let(:model_dir) { file('test', 'app', 'models') }
13
+ let(:controller_dir) { file('test', 'app', 'controllers') }
14
+ let(:view_dir) { file('test', 'app', 'views') }
15
+ let(:vendor_dir) { file('test', 'vendor') }
16
+ let(:jquery_dir) { file('test', 'vendor', 'jquery') }
17
+ let(:eyeballs_dir) { file('test', 'vendor', 'eyeballs') }
18
+ let(:mustache_dir) { file('test', 'vendor', 'mustache') }
19
+
20
+ let(:jquery_file) { file('test', 'vendor', 'jquery', 'jquery-1.4.2.min.js') }
21
+ let(:livequery_file) { file('test', 'vendor', 'jquery', 'jquery.livequery.js') }
22
+ let(:mustache_file) { file('test', 'vendor', 'mustache', 'mustache.js') }
23
+ let(:index_file) { file('test', 'index.html') }
24
+
25
+ it "should create the test root" do
26
+ File.exists?(test_root).should be_true
27
+ end
28
+
29
+ it "should create the test app dirs" do
30
+ app_dir.should exist
31
+ model_dir.should exist
32
+ controller_dir.should exist
33
+ view_dir.should exist
34
+ vendor_dir.should exist
35
+ jquery_dir.should exist
36
+ eyeballs_dir.should exist
37
+ mustache_dir.should exist
38
+ end
39
+
40
+ it "should create the app files" do
41
+ jquery_file.should exist
42
+ livequery_file.should exist
43
+ mustache_file.should exist
44
+ index_file.should exist
45
+ end
46
+
47
+ after(:all) do
48
+ remove_test_root
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Eyeballs::ControllerGenerator do
4
+
5
+ before(:all) do
6
+ create_test_root
7
+ run_command("eyeballs generate controller Paul")
8
+ end
9
+ let(:controller_file) { file('app', 'controllers', 'paul_controller.js') }
10
+
11
+ it "should create my controller" do
12
+ controller_file.should exist
13
+ end
14
+
15
+ it "should create my file" do
16
+ controller_file.read.should include("o_O('PaulController', {")
17
+ end
18
+
19
+ after(:all) do
20
+ remove_test_root
21
+ end
22
+ end