collin-lucky7 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/README +65 -0
  2. data/Rakefile.rb +55 -0
  3. data/config/environment.rb +9 -0
  4. data/lib/jabs.rb +9 -0
  5. data/lib/jass.rb +23 -0
  6. data/lib/jsspec/example.html.jass +180 -0
  7. data/lib/jsspec/layout.html.haml +14 -0
  8. data/lib/lucky7.rb +5 -0
  9. data/lib/lucky7/builder.rb +140 -0
  10. data/lib/lucky7/renders.rb +9 -0
  11. data/rspec/fixtures/lucky7/build/app/layout.html +4 -0
  12. data/rspec/fixtures/lucky7/src/app/_category.html.haml +2 -0
  13. data/rspec/fixtures/lucky7/src/app/_header.html.haml +7 -0
  14. data/rspec/fixtures/lucky7/src/app/_page_link.html.haml +2 -0
  15. data/rspec/fixtures/lucky7/src/app/_pagination.html.haml +3 -0
  16. data/rspec/fixtures/lucky7/src/app/_result.html.haml +3 -0
  17. data/rspec/fixtures/lucky7/src/app/_result_set.html.haml +4 -0
  18. data/rspec/fixtures/lucky7/src/app/_side_bar.html.haml +3 -0
  19. data/rspec/fixtures/lucky7/src/app/behavior.css.sass +3 -0
  20. data/rspec/fixtures/lucky7/src/app/controller.js.jabs +3 -0
  21. data/rspec/fixtures/lucky7/src/app/fixture_spec.html.jass +6 -0
  22. data/rspec/fixtures/lucky7/src/app/layout.html.haml +4 -0
  23. data/rspec/fixtures/lucky7/src/app/no_results.html.haml +10 -0
  24. data/rspec/fixtures/lucky7/src/app/results.html.haml +5 -0
  25. data/rspec/jabs/jabs_engine_spec.rb +3 -0
  26. data/rspec/jabs/jabs_precompiler_spec.rb +50 -0
  27. data/rspec/jabs_spec.rb +15 -0
  28. data/rspec/jabs_spec_helper.rb +2 -0
  29. data/rspec/jass/jass_engine_spec.rb +1 -0
  30. data/rspec/jass/jass_precompiler_spec.rb +49 -0
  31. data/rspec/jass_spec.rb +15 -0
  32. data/rspec/lucky7/builder_spec.rb +322 -0
  33. data/rspec/lucky7/renders_spec.rb +13 -0
  34. data/rspec/lucky7_spec.rb +19 -0
  35. data/rspec/lucky7_spec_helper.rb +1 -0
  36. data/rspec/spec_helper.rb +3 -0
  37. data/templates/environment/[environment].rb +1 -0
  38. data/templates/skeleton/[application]/README +1 -0
  39. data/templates/skeleton/[application]/Rakefile.rb +1 -0
  40. data/templates/skeleton/[application]/environment/environment.rb +1 -0
  41. data/vendor/jquery/jquery-1.2.6.js +3549 -0
  42. data/vendor/jquery/jquery-1.2.6.min.js +32 -0
  43. data/vendor/jquery/jquery-1.2.6.pack.js.gz +11 -0
  44. data/vendor/jquery/jquery.simulate.js +152 -0
  45. data/vendor/js_spec/JSSpec.css +224 -0
  46. data/vendor/js_spec/JSSpec.js +1548 -0
  47. data/vendor/js_spec/copying +459 -0
  48. data/vendor/js_spec/demo.html +210 -0
  49. data/vendor/js_spec/diff_match_patch.js +1 -0
  50. data/vendor/js_spec/example.spec.html +198 -0
  51. data/vendor/js_spec/exp/build.properties +1 -0
  52. data/vendor/js_spec/exp/build.xml +9 -0
  53. data/vendor/js_spec/exp/lib/diff_match_patch.js +1 -0
  54. data/vendor/js_spec/exp/lib/js.jar +0 -0
  55. data/vendor/js_spec/exp/src/JSSpec2.js +356 -0
  56. data/vendor/js_spec/exp/src/JSSpec2_spec.js +238 -0
  57. data/vendor/js_spec/sample/datetime/String_Parser.html +22 -0
  58. data/vendor/js_spec/sample/datetime/datetime.js +24 -0
  59. data/vendor/orbited/ez_setup.py +272 -0
  60. data/vendor/orbited/pyevent-0.3/Makefile +18 -0
  61. data/vendor/orbited/pyevent-0.3/build/lib.linux-i686-2.5/event.so +0 -0
  62. data/vendor/orbited/pyevent-0.3/build/temp.linux-i686-2.5/event.o +0 -0
  63. data/vendor/orbited/pyevent-0.3/changes +9 -0
  64. data/vendor/orbited/pyevent-0.3/cvs/Entries +9 -0
  65. data/vendor/orbited/pyevent-0.3/cvs/Repository +1 -0
  66. data/vendor/orbited/pyevent-0.3/cvs/Root +1 -0
  67. data/vendor/orbited/pyevent-0.3/event.c +2516 -0
  68. data/vendor/orbited/pyevent-0.3/event.pyx +280 -0
  69. data/vendor/orbited/pyevent-0.3/license +29 -0
  70. data/vendor/orbited/pyevent-0.3/readme +12 -0
  71. data/vendor/orbited/pyevent-0.3/setup.py +61 -0
  72. data/vendor/orbited/pyevent-0.3/test.py +73 -0
  73. data/vendor/orbited/ruby-orbited.rb +84 -0
  74. metadata +188 -0
data/README ADDED
@@ -0,0 +1,65 @@
1
+ ## Collin Miller claims authorship! $$$
2
+ ##### MIT license for all Earthlings ***
3
+ #### http://www.opensource.org/licenses/mit-license.php ^^^
4
+ ## Martians and Moonlings pay extra ##
5
+
6
+ #### Welcome to Lucky7 %%%
7
+
8
+ Place your bets: Increased odds on outside scrambles.
9
+
10
+ Try out the specs:
11
+ >> rake spec:all
12
+
13
+ The prettier version:
14
+ >> rake spec:doc
15
+
16
+ What are all the bits?
17
+
18
+ Some come from the outside world:
19
+ jsspec - http://jania.pe.kr/aw/moin.cgi/JSSpec
20
+ orbited - http://orbited.org
21
+ haml/sass - http://haml.hamptoncatlin.com
22
+
23
+ We have a little abstraction, Fold, to do preprocessing.
24
+ Haml and Sass inspired Fold. Poorer in features though.
25
+
26
+ Jabs(javascript abstract behavior syntax) and
27
+ Jass(javascript abstract spec syntax) follow the Fold.
28
+
29
+ One might have such a file:
30
+ # somespec.html.jass
31
+ describe Object
32
+ it has a prototype
33
+ expects(Object).should_have('prototype');
34
+
35
+ Jass generates
36
+ describe("Object", {
37
+ "has a prototype": function() {
38
+ expects(Object.should_hav('prototype');
39
+ }
40
+ });
41
+
42
+ Jass even wraps it in the needed HTML boilerplate for jsspec.
43
+
44
+ Open up in a browser:
45
+ /lucky7/vendor/js_spec/example.spec.html <-- Jass generated this one.
46
+ /lucky7/vendor/js_spec/demo.html <-- This one comes with jsspec
47
+
48
+ Jabs remains more mysterious. Jabs wants to have a nice little MVC
49
+ pattern shared between Client and Server code.
50
+
51
+ Only write your validations in one place, Only specify your models once.
52
+
53
+ That sort of thing. And a little bit more. Lucky7 reccomends knowing
54
+ Javascript and Ruby fairly well.
55
+
56
+ Oh wait, before we go on to write more code! Let's have something about...
57
+
58
+ Lucky7::Builder
59
+
60
+ Luck7 has a continuous builder. It watches your file system for changes and
61
+ rebuilds your project as you go. At rebuild time tests can be run. Other things
62
+ might happen as well.
63
+
64
+ Well, there is more about that later. I didn't even explain why Orbited
65
+ is right there in the vendor folder. More on that later.
data/Rakefile.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ desc "Watch files for changes and rebuild on the fly."
5
+ task :build => :environment do
6
+ require 'lib/lucky7/builder'
7
+ Lucky7::Builder.build_continuously
8
+ end
9
+
10
+ task :environment do
11
+ require 'config/environment'
12
+ end
13
+
14
+ namespace :spec do
15
+ task :prepare => :environment do
16
+ @specs= Dir.glob("#{Lucky7Root}/rspec/**/*.rb").join(' ')
17
+ end
18
+
19
+ task :all => :prepare do
20
+ system "spec #{@specs}"
21
+ end
22
+
23
+ task :doc => :prepare do
24
+ system "spec #{@specs} --format specdoc"
25
+ end
26
+
27
+ namespace :js do
28
+ task :example => :environment do
29
+ Lucky7::Builder.build_spec ["#{Lucky7Root}/lib/jsspec/example.html.jass"]
30
+ end
31
+ end
32
+ end
33
+
34
+ task :install => :environment do
35
+ p "email collintmiller@gmail.com for help" unless system %{
36
+ sudo python #{Lucky7Root}/vendor/orbited/ez_setup.py orbited;
37
+ sudo easy_install demjson;
38
+ sudo easy_install rel;
39
+ sudo apt-get install python-dev libevent1 libevent-dev gcc libc6-dev;
40
+ cd #{Lucky7Root}/vendor/orbited/pyevent-0.3/;
41
+ sudo python setup.py install;
42
+ }
43
+ end
44
+
45
+ task :take_home do
46
+ "insert your thumb drive, dumbass!" unless system %{
47
+ sudo cp -R ~/workspace/lucky7 /media/disk
48
+ }
49
+ end
50
+
51
+ task :bring_back do
52
+ "insert your thumb drive, dumbass!" unless system %{
53
+ sudo cp -R /media/disk/lucky7 ~/workspace/
54
+ }
55
+ end
@@ -0,0 +1,9 @@
1
+ Lucky7Root= File.expand_path("#{File.dirname(__FILE__)}/..")
2
+ require 'rubygems'
3
+ require 'facets'
4
+ require 'basis'
5
+
6
+ require 'lib/lucky7'
7
+ require 'fold'
8
+ require 'lib/jabs'
9
+ require 'lib/jass'
data/lib/jabs.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Jabs
2
+ class Precompiler < Fold::Precompiler
3
+ folds :Line, //
4
+ folds :Action, /^\!/
5
+ folds :Selector, /^\?/
6
+ end
7
+
8
+ class Engine < Fold::Engine; end
9
+ end
data/lib/jass.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'haml'
2
+
3
+ module Jass
4
+ class Precompiler < Fold::Precompiler
5
+ folds :Line, //
6
+
7
+ folds :ExampleGroup, /^describe / do
8
+ "describe(\"#{text}\", {\n #{render_children.join(' ,')}});\n\n"
9
+ end
10
+
11
+ folds :Example, /^it / do
12
+ "\"#{text}\": function() {\n #{render_children}\n }\n"
13
+ end
14
+ end
15
+
16
+ class Engine < Fold::Engine
17
+ Layout= Haml::Engine.new File.read("#{Lucky7Root}/lib/jsspec/layout.html.haml")
18
+
19
+ def render
20
+ Layout.render Object.new, {:test=>super}
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,180 @@
1
+ describe Foo (base)
2
+ it before
3
+ target = {sayFoo: function() {return "foo";}};
4
+
5
+ it should say 'foo'
6
+ value_of(target.sayFoo()).should_be("foo");
7
+
8
+ describe Boo (derived)
9
+ it before
10
+ target = {};
11
+ target['sayFoo'] = function() {return "foo";};
12
+ target['sayBar'] = function() {return "bar";};
13
+
14
+ it should also say 'bar'
15
+ value_of(target.sayBar()).should_be("bar");
16
+
17
+
18
+ describe Plus operator (just for example)
19
+ it should concatenate two strings
20
+ value_of("Hello " + "World").should_be("Hello World");
21
+
22
+ it should add two numbers
23
+ value_of(1 + 2).should_be(3);
24
+
25
+ describe Should match's
26
+ it Should match
27
+ value_of("Hello").should_match(/ell/);
28
+
29
+ it Should match 1
30
+ value_of("Hello").should_match(/x/);
31
+
32
+ it Should match 2
33
+ value_of([1,2,3]).should_match(/x/);
34
+
35
+ it Should not match 1
36
+ value_of("Hello").should_not_match(/ell/);
37
+
38
+ it Should not match 2
39
+ value_of([1,2,3]).should_not_match(/x/);
40
+
41
+
42
+ describe Should includes
43
+ it Should include
44
+ value_of([1,2,3]).should_include(4);
45
+
46
+ it Should not include
47
+ value_of([1,2,3]).should_not_include(2);
48
+
49
+ it Should include / Non-array object
50
+ value_of(new Date()).should_include(4);
51
+
52
+ it Should not include / Non-array object
53
+ value_of(new Date()).should_not_include('getMonth');
54
+
55
+ it Should include 2
56
+ value_of({a:1, b:2}).should_not_include('a');
57
+
58
+ describe Should have's
59
+ it String length
60
+ value_of("Hello").should_have(4, "characters");
61
+
62
+ it Array length
63
+ value_of([1,2,3]).should_have(4, "items");
64
+
65
+ it Object\'s item length
66
+ value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(3, "accounts");
67
+
68
+ it No match
69
+ value_of("This is a string").should_have(5, "players");
70
+
71
+ it Exactly
72
+ value_of([1,2,3]).should_have_exactly(2, "items");
73
+
74
+ it At least
75
+ value_of([1,2,3]).should_have_at_least(4, "items");
76
+
77
+ it At most
78
+ value_of([1,2,3]).should_have_at_most(2, "items");
79
+
80
+ it Member
81
+ value_of({x: 0}).should_have_member('x');
82
+ value_of({x: 0}).should_have_member('y');
83
+
84
+ describe Should be empty's
85
+ it String
86
+ value_of("Hello").should_be_empty();
87
+
88
+ it Array
89
+ value_of([1,2,3]).should_be_empty();
90
+
91
+ it Object\'s item
92
+ value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(0, "accounts");
93
+
94
+ describe Failure messages
95
+ it Should be (String)
96
+ value_of("Hello World").should_be("Good-bye world");
97
+
98
+ it Should have (Object\s item)
99
+ value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(3, "accounts");
100
+
101
+ it Should have at least
102
+ value_of([1,2,3]).should_have_at_least(4, "items");
103
+
104
+ it Should include
105
+ value_of([1,2,3]).should_include(4);
106
+
107
+ it Should match
108
+ value_of("Hello").should_match(/bye/);
109
+
110
+ describe Should be's
111
+ it String mismatch
112
+ value_of("Hello world").should_be("Good-bye world");
113
+
114
+ it Array item mismatch
115
+ value_of(['ab','cd','ef']).should_be(['ab','bd','ef']);
116
+
117
+ it Array length mismatch
118
+ value_of(['a',2,'4',5]).should_be([1,2,[4,5,6],6,7]);
119
+
120
+ it Undefined value
121
+ value_of("Test").should_be(undefined);
122
+
123
+ it Null value
124
+ value_of(null).should_be("Test");
125
+
126
+ it Boolean value 1
127
+ value_of(true).should_be(false);
128
+
129
+ it Boolean value 2
130
+ value_of(false).should_be_true();
131
+
132
+ it Boolean value 3
133
+ value_of(true).should_be_false();
134
+
135
+ it Number mismatch
136
+ value_of(1+2).should_be(4);
137
+
138
+ it Date mismatch
139
+ value_of(new Date(1979, 3, 27)).should_be(new Date(1976, 7, 23));
140
+
141
+ it Object mismatch 1
142
+ var actual = {a:1, b:2};
143
+ var expected = {a:1, b:2, d:3};
144
+
145
+ value_of(actual).should_be(expected);
146
+
147
+ it Object mismatch 2
148
+ var actual = {a:1, b:2, c:3, d:4};
149
+ var expected = {a:1, b:2, c:3};
150
+
151
+ value_of(actual).should_be(expected);
152
+
153
+ it Object mismatch 3
154
+ var actual = {a:1, b:4, c:3};
155
+ var expected = {a:1, b:2, c:3};
156
+
157
+ value_of(actual).should_be(expected);
158
+
159
+ it null should be null
160
+ value_of(null).should_be(null);
161
+
162
+ it null should not be undefined
163
+ value_of(null).should_be(undefined);
164
+
165
+ it null should not be null
166
+ value_of(null).should_not_be(null);
167
+
168
+ it empty array 1
169
+ value_of([]).should_be_empty();
170
+ value_of([1]).should_be_empty();
171
+
172
+ it empty array 2
173
+ value_of([1]).should_not_be_empty();
174
+ value_of([]).should_not_be_empty();
175
+
176
+ describe Equality operator
177
+ it should work for different Date instances which have same value
178
+ var date1 = new Date(1979, 03, 27);
179
+ var date2 = new Date(1979, 03, 27);
180
+ value_of(date1).should_be(date2);
@@ -0,0 +1,14 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Generated Test
5
+ %meta{"http-equiv"=>"content-type", "content"=>"text/html; charset=utf-8"}
6
+ %link{:type=>"text/css", :rel=>"stylesheet", :href=>"JSSpec.css"}
7
+ %script{:type=>"text/javascript", :src=>"diff_match_patch.js"}
8
+ %script{:type=>"text/javascript", :src=>"JSSpec.js"}
9
+ %body
10
+ %script{:type=>"text/javascript"}
11
+ ==// <![CDATA[
12
+ = test
13
+ ==// ]]>
14
+
data/lib/lucky7.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Lucky7
2
+ require 'lib/lucky7/renders'
3
+ require 'lib/lucky7/builder'
4
+ require 'lib/lucky7/generator'
5
+ end
@@ -0,0 +1,140 @@
1
+ require 'haml'
2
+ require 'sass'
3
+
4
+ module Lucky7
5
+ module Builder
6
+ SrcRegex= /src/
7
+ BuildDirectory= "build"
8
+
9
+ class << self
10
+ def haml_glob
11
+ "#{Lucky7Root}/**/*.html.haml"
12
+ end
13
+
14
+ def sass_glob
15
+ "#{Lucky7Root}/**/*.css.sass"
16
+ end
17
+
18
+ def jabs_glob
19
+ "#{Lucky7Root}/**/*.js.jabs"
20
+ end
21
+
22
+ def spec_glob
23
+ "#{Lucky7Root}/**/*.html.jass"
24
+ end
25
+
26
+ def files
27
+ {:haml=>haml_glob,
28
+ :sass=>sass_glob,
29
+ :jabs=>jabs_glob,
30
+ :spec=>spec_glob}.inject({}) do |hash, pair|
31
+ hash[pair.first]= Dir.glob(pair.last)
32
+ hash
33
+ end
34
+ end
35
+
36
+ def files_flattened
37
+ files.map{|pair| pair.last}.flatten
38
+ end
39
+
40
+ def mtimes
41
+ files_flattened.inject({}) do |hash, filename|
42
+ hash[filename] = File.stat(filename).mtime
43
+ hash
44
+ end
45
+ end
46
+
47
+ def cache_mtimes!
48
+ @cached_mtimes = mtimes
49
+ end
50
+
51
+ def cached_mtimes
52
+ @cached_mtimes
53
+ end
54
+
55
+ def modified_files
56
+ files.inject({}) do |hash, pair|
57
+ hash[pair.first] = pair.last.select do |file|
58
+ File.stat(file).mtime.to_i > cached_mtimes[file].to_i
59
+ end
60
+ hash
61
+ end
62
+ end
63
+
64
+ def build_continuously loop=true
65
+ cache_mtimes!
66
+ begin
67
+ build
68
+ sleep 1 if loop
69
+ end while loop
70
+ end
71
+
72
+ def build
73
+ m = modified_files
74
+
75
+ build_sass m[:sass]
76
+ build_haml m[:haml]
77
+ build_jabs m[:jabs]
78
+ build_spec m[:spec]
79
+ pack
80
+ end
81
+
82
+ def haml_render_context
83
+ Lucky7::Renders
84
+ end
85
+
86
+ def build_haml paths
87
+ paths.each do |path|
88
+ file= File.new build_path_for(:html, path), 'w'
89
+ haml= File.read(path)
90
+ en= Haml::Engine.new(haml)
91
+ html= en.render haml_render_context
92
+ file.write(html)
93
+ file.close
94
+ end
95
+ end
96
+
97
+ def build_sass paths
98
+ paths.each do |path|
99
+ file= File.new build_path_for(:css, path), 'w'
100
+ sass= File.read(path)
101
+ en= Sass::Engine.new(sass)
102
+ css= en.render
103
+ file.write(css)
104
+ file.close
105
+ end
106
+ end
107
+
108
+ def build_spec paths
109
+ paths.each do |path|
110
+ file= File.new build_path_for('spec.html', path), 'w'
111
+ jass= File.read(path)
112
+ en= Jass::Engine.new(jass)
113
+ js_spec= en.render
114
+ file.write js_spec
115
+ file.close
116
+ end
117
+ end
118
+
119
+ def build_jabs files
120
+
121
+ end
122
+
123
+ def pack
124
+
125
+ end
126
+
127
+ def ensure_build_path! path
128
+ FileUtils.mkdir_p File.dirname(path)
129
+ end
130
+
131
+ def build_path_for extension, src_path
132
+ path= File.dirname(src_path).gsub(SrcRegex, BuildDirectory)
133
+ src_path= src_path.split('.').first
134
+ path+= "/#{File.basename(src_path)}.#{extension}"
135
+ ensure_build_path! path
136
+ path
137
+ end
138
+ end
139
+ end
140
+ end