jim 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/HISTORY +28 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +2 -1
  4. data/jim.gemspec +67 -9
  5. data/lib/jim/bundler.rb +14 -11
  6. data/lib/jim/cli.rb +51 -9
  7. data/lib/jim/index.rb +3 -7
  8. data/lib/jim/installer.rb +140 -22
  9. data/lib/jim/templates/commands +21 -6
  10. data/lib/jim/version_parser.rb +2 -3
  11. data/lib/jim.rb +19 -2
  12. data/test/fixtures/jimfile +3 -3
  13. data/test/fixtures/sammy-0.5.0/HISTORY.md +135 -0
  14. data/test/fixtures/sammy-0.5.0/LICENSE +22 -0
  15. data/test/fixtures/sammy-0.5.0/README.md +81 -0
  16. data/test/fixtures/sammy-0.5.0/Rakefile +174 -0
  17. data/test/fixtures/sammy-0.5.0/examples/backend/README.md +23 -0
  18. data/test/fixtures/sammy-0.5.0/examples/backend/Rakefile +15 -0
  19. data/test/fixtures/sammy-0.5.0/examples/backend/app.rb +17 -0
  20. data/test/fixtures/sammy-0.5.0/examples/backend/app.ru +3 -0
  21. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/app.js +106 -0
  22. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/jquery.cloudkit.js +840 -0
  23. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/jquery.js +19 -0
  24. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/sammy.js +1013 -0
  25. data/test/fixtures/sammy-0.5.0/examples/backend/public/templates/index.html.erb +11 -0
  26. data/test/fixtures/sammy-0.5.0/examples/backend/public/templates/task.html.erb +4 -0
  27. data/test/fixtures/sammy-0.5.0/examples/backend/public/templates/task_details.html.erb +4 -0
  28. data/test/fixtures/sammy-0.5.0/examples/backend/views/app.sass +63 -0
  29. data/test/fixtures/sammy-0.5.0/examples/backend/views/index.haml +18 -0
  30. data/test/fixtures/sammy-0.5.0/examples/form_handling/files/form.html +12 -0
  31. data/test/fixtures/sammy-0.5.0/examples/form_handling/index.html +65 -0
  32. data/test/fixtures/sammy-0.5.0/examples/hello_world/index.html +50 -0
  33. data/test/fixtures/sammy-0.5.0/examples/location_override/README.md +15 -0
  34. data/test/fixtures/sammy-0.5.0/examples/location_override/data.html +110 -0
  35. data/test/fixtures/sammy-0.5.0/examples/location_override/index.html +79 -0
  36. data/test/fixtures/sammy-0.5.0/examples/location_override/test.html +121 -0
  37. data/test/fixtures/sammy-0.5.0/lib/min/sammy-0.5.0.min.js +5 -0
  38. data/test/fixtures/sammy-0.5.0/lib/min/sammy-lastest.min.js +5 -0
  39. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.cache.js +117 -0
  40. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.haml.js +539 -0
  41. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.json.js +362 -0
  42. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.mustache.js +415 -0
  43. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.nested_params.js +118 -0
  44. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.storage.js +515 -0
  45. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.template.js +117 -0
  46. data/test/fixtures/sammy-0.5.0/lib/sammy.js +1367 -0
  47. data/test/fixtures/sammy-0.5.0/test/fixtures/partial +1 -0
  48. data/test/fixtures/sammy-0.5.0/test/fixtures/partial.html +1 -0
  49. data/test/fixtures/sammy-0.5.0/test/fixtures/partial.noengine +1 -0
  50. data/test/fixtures/sammy-0.5.0/test/fixtures/partial.template +1 -0
  51. data/test/fixtures/sammy-0.5.0/test/index.html +84 -0
  52. data/test/fixtures/sammy-0.5.0/test/test_sammy_application.js +953 -0
  53. data/test/fixtures/sammy-0.5.0/test/test_sammy_event_context.js +252 -0
  54. data/test/fixtures/sammy-0.5.0/test/test_sammy_location_proxy.js +91 -0
  55. data/test/fixtures/sammy-0.5.0/test/test_sammy_plugins.js +296 -0
  56. data/test/fixtures/sammy-0.5.0/test/test_sammy_storage.js +175 -0
  57. data/test/fixtures/sammy-0.5.0/test/test_server +27 -0
  58. data/test/fixtures/sammy-0.5.0/vendor/jquery-1.4.1.js +6078 -0
  59. data/test/fixtures/sammy-0.5.0/vendor/jquery-1.4.1.min.js +152 -0
  60. data/test/fixtures/sammy-0.5.0/vendor/jsdoc/doc.haml +58 -0
  61. data/test/fixtures/sammy-0.5.0/vendor/jsdoc/jsdoc.rb +143 -0
  62. data/test/fixtures/sammy-0.5.0/vendor/jslitmus.js +670 -0
  63. data/test/fixtures/sammy-0.5.0/vendor/qunit/qunit.css +119 -0
  64. data/test/fixtures/sammy-0.5.0/vendor/qunit/qunit.js +1043 -0
  65. data/test/fixtures/sammy-0.5.0/vendor/qunit-spec.js +127 -0
  66. data/test/helper.rb +23 -3
  67. data/test/test_jim_bundler.rb +9 -8
  68. data/test/test_jim_cli.rb +21 -12
  69. data/test/test_jim_installer.rb +152 -35
  70. data/test/test_jim_version_parser.rb +4 -0
  71. metadata +117 -27
  72. data/.document +0 -5
@@ -0,0 +1,175 @@
1
+ (function($) {
2
+ with(QUnit) {
3
+
4
+ var stores = ['memory', 'data', 'local', 'session', 'cookie'];
5
+
6
+ $.each(stores, function(i, store_type) {
7
+ if (Sammy.Store.isAvailable(store_type)) {
8
+ context('Sammy.Store', store_type, {
9
+ before: function() {
10
+ this.store_attributes = {
11
+ element: '#main',
12
+ name: 'test_store',
13
+ type: store_type
14
+ };
15
+ this.store = new Sammy.Store(this.store_attributes);
16
+
17
+ this.other_store = new Sammy.Store({
18
+ element: '#main',
19
+ name: 'other_test_store',
20
+ type: store_type
21
+ });
22
+ this.store.clearAll();
23
+ this.other_store.clearAll();
24
+ }
25
+ })
26
+ .should('set store type', function() {
27
+ equal(this.store.type, store_type);
28
+ })
29
+ .should('set name', function() {
30
+ equal(this.store.name, 'test_store');
31
+ })
32
+ .should('set the element', function() {
33
+ equal(this.store.element, '#main');
34
+ })
35
+ .should('check if a key exists', function() {
36
+ ok(!this.store.exists('foo'));
37
+ this.store.set('foo', 'bar');
38
+ ok(this.store.exists('foo'));
39
+ ok(!this.other_store.exists('foo'));
40
+ })
41
+ .should('set and retrieve value as string', function() {
42
+ ok(this.store.set('foo', 'bar'));
43
+ equal(this.store.get('foo'), 'bar');
44
+ ok(!this.other_store.get('foo'));
45
+ })
46
+ .should('set and retrieve value as JSON', function() {
47
+ ok(this.store.set('foo', {'obj': 'is json'}));
48
+ equal(this.store.get('foo').obj,'is json');
49
+ ok(!this.other_store.get('foo'));
50
+ })
51
+ .should('should store in global space accessible by name', function() {
52
+ this.store.set('foo', 'bar');
53
+ var new_store = new Sammy.Store(this.store_attributes);
54
+ equal(new_store.get('foo'), 'bar');
55
+ })
56
+ .should('clear value', function() {
57
+ ok(this.store.set('foo', 'bar'));
58
+ ok(this.other_store.set('foo', 'bar'));
59
+ equal(this.store.get('foo'), 'bar');
60
+ this.store.clear('foo');
61
+ ok(!this.store.exists('foo'));
62
+ ok(this.other_store.get('foo'), 'bar');
63
+ })
64
+ .should('return list of keys', function() {
65
+ this.store.set('foo', 'bar');
66
+ this.store.set('blurgh', {boosh: 'blurgh'});
67
+ this.store.set(123, {boosh: 'blurgh'});
68
+ deepEqual(this.store.keys(), ['foo', 'blurgh', '123']);
69
+ deepEqual(this.other_store.keys(), []);
70
+ })
71
+ .should('clear all values', function() {
72
+ this.store.set('foo', 'bar');
73
+ this.store.set('blurgh', {boosh: 'blurgh'});
74
+ this.store.set(123, {boosh: 'blurgh'});
75
+ equal(this.store.keys().length, 3);
76
+ this.store.clearAll();
77
+ equal(this.store.keys().length, 0);
78
+ ok(!this.store.exists('blurgh'));
79
+ })
80
+ .should('fire events on get and set', function() {
81
+ var fired = false;
82
+ $('#main').bind('set-test_store.foo', function(e, key, value) {
83
+ fired = value;
84
+ });
85
+ this.store.set('foo', 'bar');
86
+ soon(function() {
87
+ equal(fired, 'bar');
88
+ $('#main').unbind('set-test_store.foo');
89
+ });
90
+ })
91
+ .should('fetch value or run callback', function() {
92
+ ok(!this.store.get('foo'));
93
+ this.store.fetch('foo', function() {
94
+ return "bar";
95
+ });
96
+ equal(this.store.get('foo'), 'bar');
97
+ equal(this.store.fetch('foo', function() {
98
+ return "baz";
99
+ }), 'bar');
100
+ equal(this.store.get('foo'), 'bar');
101
+ })
102
+ .should('load file into a key', function() {
103
+ ok(!this.store.get('foo'));
104
+ this.store.load('foo', 'fixtures/partial');
105
+ soon(function() {
106
+ equal(this.store.get('foo'), 'NOENGINE');
107
+ }, this, 2, 2);
108
+ });
109
+ }
110
+ });
111
+
112
+ context('Sammy.Storage', {
113
+ before: function() {
114
+ this.app = new Sammy.Application(function() {
115
+ this.use(Sammy.Storage);
116
+ });
117
+ this.context = new this.app.context_prototype(this.app, 'get', '#/', {});
118
+ }
119
+ })
120
+ .should('add the store method to the app', function() {
121
+ ok($.isFunction(this.app.store));
122
+ })
123
+ .should('add the store method to event contexts', function() {
124
+ ok($.isFunction(this.context.store));
125
+ });
126
+
127
+ context('Sammy.Storage', 'store', {
128
+ before: function() {
129
+ var store = null;
130
+ this.app = new Sammy.Application(function() {
131
+ this.use(Sammy.Storage);
132
+ store = this.store('session');
133
+ });
134
+ this.context = new this.app.context_prototype(this.app, 'get', '#/', {});
135
+ store.clearAll();
136
+ this.store = store;
137
+ }
138
+ })
139
+ .should('create a new sammy store if it doesnt exist', function() {
140
+ ok(this.store);
141
+ ok($.isFunction(this.store.get));
142
+ })
143
+ .should('add the a named method shortcut to the app', function() {
144
+ ok($.isFunction(this.app.session));
145
+ })
146
+ .should('add a named method shortcut to the event contexts', function() {
147
+ ok($.isFunction(this.context.session));
148
+ })
149
+ .should('should set value if value is passed', function() {
150
+ this.context.session('foo', 'bar')
151
+ equal(this.store.get('foo'), 'bar');
152
+ })
153
+ .should('should get value if no value is passed', function() {
154
+ this.store.set('foo', 'bar');
155
+ equal(this.context.session('foo'), 'bar');
156
+ })
157
+ .should('call fetch if callback is passed', function() {
158
+ ok(!this.store.get('foo'));
159
+ this.context.session('foo', function() {
160
+ return "bar";
161
+ });
162
+ equal(this.store.get('foo'), 'bar');
163
+ equal(this.context.session('foo', function() {
164
+ return "baz";
165
+ }), 'bar');
166
+ })
167
+ .should('add a clear store helper method', function() {
168
+ ok($.isFunction(this.context.clearSession));
169
+ this.context.session('foo', 'bar')
170
+ equal(this.store.get('foo'), 'bar');
171
+ equal(this.context.clearSession());
172
+ ok(!this.store.get('foo'));
173
+ });
174
+ };
175
+ })(jQuery);
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'sinatra/base'
4
+ require 'vegas'
5
+
6
+ class SammyTest < Sinatra::Application
7
+
8
+ set :public, File.expand_path(File.dirname(__FILE__))
9
+
10
+ get '/' do
11
+ content_type 'text/html'
12
+ read_relative_file 'index.html'
13
+ end
14
+
15
+ get /\/(lib|vendor)\/(.*)/ do
16
+ filename = File.join(params['captures'][0],params['captures'][1])
17
+ content_type File.extname(filename)
18
+ read_relative_file '..', filename
19
+ end
20
+
21
+ def read_relative_file(*args)
22
+ File.read(File.join(File.expand_path(File.dirname(__FILE__)), *args))
23
+ end
24
+
25
+ end
26
+
27
+ Vegas::Runner.new(SammyTest, 'sammy_test_server')