bpm 1.0.0.beta.4 → 1.0.0.beta.5

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 (82) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/TODO.md +4 -10
  3. data/backbone/LICENSE +22 -0
  4. data/backbone/README +25 -0
  5. data/backbone/Rakefile +42 -0
  6. data/backbone/backbone-0.5.1.bpkg +0 -0
  7. data/backbone/examples/backbone-localstorage.js +84 -0
  8. data/backbone/examples/todos/destroy.png +0 -0
  9. data/backbone/examples/todos/index.html +87 -0
  10. data/backbone/examples/todos/todos.css +311 -0
  11. data/backbone/examples/todos/todos.js +258 -0
  12. data/backbone/index.html +2606 -0
  13. data/backbone/index.js +1 -0
  14. data/backbone/lib/backbone.js +1149 -0
  15. data/backbone/lib/index.js +1 -0
  16. data/backbone/package.json +14 -0
  17. data/backbone/test/collection.js +345 -0
  18. data/backbone/test/events.js +70 -0
  19. data/backbone/test/model.coffee +43 -0
  20. data/backbone/test/model.js +424 -0
  21. data/backbone/test/noconflict.js +12 -0
  22. data/backbone/test/router.js +116 -0
  23. data/backbone/test/speed.js +45 -0
  24. data/backbone/test/sync.js +133 -0
  25. data/backbone/test/test-zepto.html +30 -0
  26. data/backbone/test/test.html +31 -0
  27. data/backbone/test/vendor/jquery-1.5.js +8176 -0
  28. data/backbone/test/vendor/jslitmus.js +649 -0
  29. data/backbone/test/vendor/json2.js +481 -0
  30. data/backbone/test/vendor/qunit.css +196 -0
  31. data/backbone/test/vendor/qunit.js +1364 -0
  32. data/backbone/test/vendor/underscore-1.1.6.js +807 -0
  33. data/backbone/test/vendor/zepto-0.6.js +692 -0
  34. data/backbone/test/view.js +137 -0
  35. data/lib/bpm/cli/base.rb +22 -7
  36. data/lib/bpm/package.rb +17 -5
  37. data/lib/bpm/project.rb +49 -32
  38. data/lib/bpm/version.rb +1 -1
  39. data/spec/cli/add_spec.rb +22 -4
  40. data/spec/cli/fetch_spec.rb +0 -1
  41. data/spec/cli/init_spec.rb +25 -10
  42. data/spec/cli/list_spec.rb +103 -62
  43. data/spec/cli/pack_spec.rb +36 -4
  44. data/spec/fixtures/packages/backbone/LICENSE +22 -0
  45. data/spec/fixtures/packages/backbone/README +25 -0
  46. data/spec/fixtures/packages/backbone/Rakefile +42 -0
  47. data/spec/fixtures/packages/backbone/examples/backbone-localstorage.js +84 -0
  48. data/spec/fixtures/packages/backbone/examples/todos/destroy.png +0 -0
  49. data/spec/fixtures/packages/backbone/examples/todos/index.html +87 -0
  50. data/spec/fixtures/packages/backbone/examples/todos/todos.css +311 -0
  51. data/spec/fixtures/packages/backbone/examples/todos/todos.js +258 -0
  52. data/spec/fixtures/packages/backbone/index.html +2606 -0
  53. data/spec/fixtures/packages/backbone/lib/backbone.js +1149 -0
  54. data/spec/fixtures/packages/backbone/lib/index.js +1 -0
  55. data/spec/fixtures/packages/backbone/package.json +14 -0
  56. data/spec/fixtures/packages/backbone/test/collection.js +345 -0
  57. data/spec/fixtures/packages/backbone/test/events.js +70 -0
  58. data/spec/fixtures/packages/backbone/test/model.coffee +43 -0
  59. data/spec/fixtures/packages/backbone/test/model.js +424 -0
  60. data/spec/fixtures/packages/backbone/test/noconflict.js +12 -0
  61. data/spec/fixtures/packages/backbone/test/router.js +116 -0
  62. data/spec/fixtures/packages/backbone/test/speed.js +45 -0
  63. data/spec/fixtures/packages/backbone/test/sync.js +133 -0
  64. data/spec/fixtures/packages/backbone/test/test-zepto.html +30 -0
  65. data/spec/fixtures/packages/backbone/test/test.html +31 -0
  66. data/spec/fixtures/packages/backbone/test/vendor/jquery-1.5.js +8176 -0
  67. data/spec/fixtures/packages/backbone/test/vendor/jslitmus.js +649 -0
  68. data/spec/fixtures/packages/backbone/test/vendor/json2.js +481 -0
  69. data/spec/fixtures/packages/backbone/test/vendor/qunit.css +196 -0
  70. data/spec/fixtures/packages/backbone/test/vendor/qunit.js +1364 -0
  71. data/spec/fixtures/packages/backbone/test/vendor/underscore-1.1.6.js +807 -0
  72. data/spec/fixtures/packages/backbone/test/vendor/zepto-0.6.js +692 -0
  73. data/spec/fixtures/packages/backbone/test/view.js +137 -0
  74. data/spec/fixtures/projects/init_app/assets/bpm_libs.js +1 -1
  75. data/spec/fixtures/projects/init_app/assets/bpm_styles.css +1 -1
  76. data/spec/fixtures/projects/init_app/new_project.json +1 -10
  77. data/spec/pipeline_spec.rb +5 -5
  78. data/spec/plugins/minifier_spec.rb +1 -1
  79. data/spec/plugins/transport_spec.rb +1 -1
  80. metadata +116 -28
  81. data/spec/fixtures/projects/init_app/assets/new_project/bpm_libs.js +0 -6
  82. data/spec/fixtures/projects/init_app/assets/new_project/bpm_styles.css +0 -5
@@ -7,68 +7,109 @@ describe "bpm list" do
7
7
  start_fake(FakeGemServer.new)
8
8
  end
9
9
 
10
- it "lists latest packages by default" do
11
- bpm "list"
12
-
13
- output = stdout.read
14
- output.should include("builder (3.0.0)")
15
- output.should include("rake (0.8.7)")
16
- end
17
-
18
- it "lists all packages when given the all argument" do
19
- bpm "list", "-a"
20
-
21
- output = stdout.read
22
- output.should include("builder (3.0.0)")
23
- output.should include("rake (0.8.7, 0.8.6)")
10
+ describe "local" do
11
+ before do
12
+ FileUtils.cp_r project_fixture('hello_world'), home
13
+ cd home('hello_world')
14
+ end
15
+
16
+ it "lists non-development dependencies by default" do
17
+ bpm "list"
18
+ output = stdout.read
19
+ output.should include("ivory (0.0.1)")
20
+ output.should_not include("jquery (1.4.3)")
21
+ end
22
+
23
+ it "lists development dependencies with --dev option" do
24
+ bpm "list", "--dev"
25
+ output = stdout.read
26
+ output.should_not include("ivory (0.0.1)")
27
+ output.should include("jquery (1.4.3)")
28
+ end
29
+
30
+ it "should filter output by package name" do
31
+ bpm "list", "ivory", "spade"
32
+ output = stdout.read
33
+ output.should include("ivory (0.0.1)")
34
+ output.should include("spade (0.5.0)")
35
+ output.should_not include("optparse")
36
+ output.should_not include("core-test")
37
+ end
38
+
39
+ it "should complain when called outside of a project" do
40
+ cd home
41
+ bpm "list", :track_stderr => true
42
+ stderr.read.should include("inside of a bpm project")
43
+ end
44
+
24
45
  end
25
-
26
- it "filters packages when given an argument" do
27
- bpm "list", "builder"
28
-
29
- output = stdout.read
30
- output.should include("builder (3.0.0)")
31
- output.should_not include("rake")
32
- end
33
-
34
- it "filters packages when given an argument and shows all versions" do
35
- bpm "list", "rake", "-a"
36
-
37
- output = stdout.read
38
- output.should include("rake (0.8.7, 0.8.6)")
39
- output.should_not include("builder")
40
- end
41
-
42
- it "filters multiple packages" do
43
- bpm "list", "rake", "highline"
44
-
45
- output = stdout.read
46
- output.should include("highline (1.6.1)")
47
- output.should include("rake (0.8.7)")
48
- output.should_not include("builder")
49
- end
50
-
51
- it "shows prerelease packages" do
52
- bpm "list", "--prerelease"
53
-
54
- output = stdout.read
55
- output.should include("bundler (1.1.pre)")
56
- output.should_not include("highline")
57
- output.should_not include("rake")
58
- output.should_not include("builder")
59
- end
60
-
61
- it "says it couldn't find any if none found" do
62
- bpm "list", "rails", :track_stderr => true
63
-
64
- stderr.read.strip.should == 'No packages found matching "rails".'
65
- exit_status.should_not be_success
66
- end
67
-
68
- it "says it couldn't find any if none found matching multiple packages" do
69
- bpm "list", "rails", "bake", :track_stderr => true
70
-
71
- stderr.read.strip.should == 'No packages found matching "rails", "bake".'
72
- exit_status.should_not be_success
46
+
47
+ describe "remote" do
48
+
49
+ it "lists latest packages by default" do
50
+ bpm "list", "--remote"
51
+
52
+ output = stdout.read
53
+ output.should include("builder (3.0.0)")
54
+ output.should include("rake (0.8.7)")
55
+ end
56
+
57
+ it "lists all packages when given the all argument" do
58
+ bpm "list", "--remote", "-a"
59
+
60
+ output = stdout.read
61
+ output.should include("builder (3.0.0)")
62
+ output.should include("rake (0.8.7, 0.8.6)")
63
+ end
64
+
65
+ it "filters packages when given an argument" do
66
+ bpm "list", "builder", "--remote"
67
+
68
+ output = stdout.read
69
+ output.should include("builder (3.0.0)")
70
+ output.should_not include("rake")
71
+ end
72
+
73
+ it "filters packages when given an argument and shows all versions" do
74
+ bpm "list", "rake", "-a", "--remote"
75
+
76
+ output = stdout.read
77
+ output.should include("rake (0.8.7, 0.8.6)")
78
+ output.should_not include("builder")
79
+ end
80
+
81
+ it "filters multiple packages" do
82
+ bpm "list", "rake", "highline", "--remote"
83
+
84
+ output = stdout.read
85
+ output.should include("highline (1.6.1)")
86
+ output.should include("rake (0.8.7)")
87
+ output.should_not include("builder")
88
+ end
89
+
90
+ it "shows prerelease packages" do
91
+ bpm "list", "--prerelease", "--remote"
92
+
93
+ output = stdout.read
94
+ output.should include("bundler (1.1.pre)")
95
+ output.should_not include("highline")
96
+ output.should_not include("rake")
97
+ output.should_not include("builder")
98
+ end
99
+
100
+ it "says it couldn't find any if none found" do
101
+ bpm "list", "rails", "--remote", :track_stderr => true
102
+
103
+ stderr.read.strip.should == 'No packages found matching "rails".'
104
+ exit_status.should_not be_success
105
+ end
106
+
107
+ it "says it couldn't find any if none found matching multiple packages" do
108
+ bpm "list", "rails", "bake", "--remote", :track_stderr => true
109
+
110
+ stderr.read.strip.should == 'No packages found matching "rails", "bake".'
111
+ exit_status.should_not be_success
112
+ end
73
113
  end
114
+
74
115
  end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "libgems/format"
3
3
 
4
- describe "bpm build when logged in" do
4
+ describe "bpm pack when logged in" do
5
5
  let(:email) { "who@example.com" }
6
6
 
7
7
  before do
@@ -25,12 +25,12 @@ describe "bpm build when logged in" do
25
25
  end
26
26
  end
27
27
 
28
- describe "bpm build without logging in" do
28
+ describe "bpm pack without logging in" do
29
29
  before do
30
30
  goto_home
31
31
  end
32
32
 
33
- it "builds a bpm from a given package.json" do
33
+ it "pack a bpm from a given package.json" do
34
34
  FileUtils.cp_r package_fixture("core-test"), "."
35
35
  cd "core-test"
36
36
  bpm "pack", "-e", "joe@example.com"
@@ -69,7 +69,7 @@ describe "bpm build without logging in" do
69
69
  end
70
70
  end
71
71
 
72
- describe "bpm build with an invalid package.json" do
72
+ describe "bpm pack with an invalid package.json" do
73
73
  before do
74
74
  goto_home
75
75
  write_api_key("deadbeef")
@@ -84,3 +84,35 @@ describe "bpm build with an invalid package.json" do
84
84
  output.should include("There was a problem parsing package.json")
85
85
  end
86
86
  end
87
+
88
+ describe "bpm pack npm-compatible package" do
89
+ before do
90
+ FileUtils.cp_r package_fixture("backbone"), "."
91
+ cd "backbone"
92
+ bpm "pack", :track_stderr => true and wait
93
+ end
94
+
95
+ it "successfully packs" do
96
+ exit_status.should be_success
97
+ end
98
+
99
+ it "implies the summary field" do
100
+ package = LibGems::Format.from_file_by_path("backbone-0.5.1.bpkg")
101
+ package.spec.summary.should == package.spec.description
102
+ end
103
+
104
+ it "gets name and version" do
105
+ package = LibGems::Format.from_file_by_path("backbone-0.5.1.bpkg")
106
+ package.spec.name.should == "backbone"
107
+ package.spec.version.should == LibGems::Version.new("0.5.1")
108
+ end
109
+
110
+ it "gets the homepage" do
111
+ package = LibGems::Format.from_file_by_path("backbone-0.5.1.bpkg")
112
+ package.spec.homepage.should == 'http://documentcloud.github.com/backbone/'
113
+ end
114
+
115
+
116
+ end
117
+
118
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010 Jeremy Ashkenas, DocumentCloud
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ ____ _ _ _
2
+ | _ \ | | | | (_)
3
+ | |_) | __ _ ___| | __| |__ ___ _ __ ___ _ ___
4
+ | _ < / _` |/ __| |/ /| '_ \ / _ \| '_ \ / _ \ | / __|
5
+ | |_) | (_| | (__| < | |_) | (_) | | | | __/_| \__ \
6
+ |____/ \__,_|\___|_|\_\|_.__/ \___/|_| |_|\___(_) |___/
7
+ _/ |
8
+ |__/
9
+ (_'___________________________________________________'_)
10
+ (_.———————————————————————————————————————————————————._)
11
+
12
+
13
+ Backbone supplies structure to JavaScript-heavy applications by providing models key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.
14
+
15
+ For Docs, License, Tests, and pre-packed downloads, see:
16
+ http://documentcloud.github.com/backbone/
17
+
18
+ To suggest a feature, report a bug, or general discussion:
19
+ http://github.com/documentcloud/backbone/issues/
20
+
21
+ All contributors are listed here:
22
+ http://github.com/documentcloud/backbone/contributors
23
+
24
+ Special thanks to Robert Kieffer for the original philosophy behind Backbone.
25
+ http://github.com/broofa
@@ -0,0 +1,42 @@
1
+ require 'rubygems'
2
+
3
+ HEADER = /((^\s*\/\/.*\n)+)/
4
+
5
+ desc "rebuild the backbone-min.js files for distribution"
6
+ task :build do
7
+ begin
8
+ require 'closure-compiler'
9
+ rescue LoadError
10
+ puts "closure-compiler not found.\nInstall it by running 'gem install closure-compiler"
11
+ exit
12
+ end
13
+ source = File.read 'backbone.js'
14
+ header = source.match(HEADER)
15
+ File.open('backbone-min.js', 'w+') do |file|
16
+ file.write header[1].squeeze(' ') + Closure::Compiler.new.compress(source)
17
+ end
18
+ end
19
+
20
+ desc "build the docco documentation"
21
+ task :doc do
22
+ check 'docco', 'docco', 'https://github.com/jashkenas/docco'
23
+ system 'docco backbone.js && docco examples/todos/todos.js examples/backbone-localstorage.js'
24
+ end
25
+
26
+ desc "run JavaScriptLint on the source"
27
+ task :lint do
28
+ system "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
29
+ end
30
+
31
+ desc "test the CoffeeScript integration"
32
+ task :test do
33
+ check 'coffee', 'CoffeeScript', 'https://github.com/jashkenas/coffee-script.git'
34
+ system "coffee test/*.coffee"
35
+ end
36
+
37
+ # Check for the existence of an executable.
38
+ def check(exec, name, url)
39
+ return unless `which #{exec}`.empty?
40
+ puts "#{name} not found.\nInstall it from #{url}"
41
+ exit
42
+ end
@@ -0,0 +1,84 @@
1
+ // A simple module to replace `Backbone.sync` with *localStorage*-based
2
+ // persistence. Models are given GUIDS, and saved into a JSON object. Simple
3
+ // as that.
4
+
5
+ // Generate four random hex digits.
6
+ function S4() {
7
+ return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
8
+ };
9
+
10
+ // Generate a pseudo-GUID by concatenating random hexadecimal.
11
+ function guid() {
12
+ return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
13
+ };
14
+
15
+ // Our Store is represented by a single JS object in *localStorage*. Create it
16
+ // with a meaningful name, like the name you'd give a table.
17
+ var Store = function(name) {
18
+ this.name = name;
19
+ var store = localStorage.getItem(this.name);
20
+ this.data = (store && JSON.parse(store)) || {};
21
+ };
22
+
23
+ _.extend(Store.prototype, {
24
+
25
+ // Save the current state of the **Store** to *localStorage*.
26
+ save: function() {
27
+ localStorage.setItem(this.name, JSON.stringify(this.data));
28
+ },
29
+
30
+ // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already
31
+ // have an id of it's own.
32
+ create: function(model) {
33
+ if (!model.id) model.id = model.attributes.id = guid();
34
+ this.data[model.id] = model;
35
+ this.save();
36
+ return model;
37
+ },
38
+
39
+ // Update a model by replacing its copy in `this.data`.
40
+ update: function(model) {
41
+ this.data[model.id] = model;
42
+ this.save();
43
+ return model;
44
+ },
45
+
46
+ // Retrieve a model from `this.data` by id.
47
+ find: function(model) {
48
+ return this.data[model.id];
49
+ },
50
+
51
+ // Return the array of all models currently in storage.
52
+ findAll: function() {
53
+ return _.values(this.data);
54
+ },
55
+
56
+ // Delete a model from `this.data`, returning it.
57
+ destroy: function(model) {
58
+ delete this.data[model.id];
59
+ this.save();
60
+ return model;
61
+ }
62
+
63
+ });
64
+
65
+ // Override `Backbone.sync` to use delegate to the model or collection's
66
+ // *localStorage* property, which should be an instance of `Store`.
67
+ Backbone.sync = function(method, model, options) {
68
+
69
+ var resp;
70
+ var store = model.localStorage || model.collection.localStorage;
71
+
72
+ switch (method) {
73
+ case "read": resp = model.id ? store.find(model) : store.findAll(); break;
74
+ case "create": resp = store.create(model); break;
75
+ case "update": resp = store.update(model); break;
76
+ case "delete": resp = store.destroy(model); break;
77
+ }
78
+
79
+ if (resp) {
80
+ options.success(resp);
81
+ } else {
82
+ options.error("Record not found");
83
+ }
84
+ };
@@ -0,0 +1,87 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <title>Backbone Demo: Todos</title>
6
+ <link href="todos.css" media="all" rel="stylesheet" type="text/css"/>
7
+ <script src="../../test/vendor/json2.js"></script>
8
+ <script src="../../test/vendor/jquery-1.5.js"></script>
9
+ <script src="../../test/vendor/underscore-1.1.6.js"></script>
10
+ <script src="../../backbone.js"></script>
11
+ <script src="../backbone-localstorage.js"></script>
12
+ <script src="todos.js"></script>
13
+ </head>
14
+
15
+ <body>
16
+
17
+ <!-- Todo App Interface -->
18
+
19
+ <div id="todoapp">
20
+
21
+ <div class="title">
22
+ <h1>Todos</h1>
23
+ </div>
24
+
25
+ <div class="content">
26
+
27
+ <div id="create-todo">
28
+ <input id="new-todo" placeholder="What needs to be done?" type="text" />
29
+ <span class="ui-tooltip-top" style="display:none;">Press Enter to save this task</span>
30
+ </div>
31
+
32
+ <div id="todos">
33
+ <ul id="todo-list"></ul>
34
+ </div>
35
+
36
+ <div id="todo-stats"></div>
37
+
38
+ </div>
39
+
40
+ </div>
41
+
42
+ <ul id="instructions">
43
+ <li>Double-click to edit a todo.</li>
44
+ <li><a href="../../docs/todos.html">View the annotated source.</a></li>
45
+ </ul>
46
+
47
+ <div id="credits">
48
+ Created by
49
+ <br />
50
+ <a href="http://jgn.me/">J&eacute;r&ocirc;me Gravel-Niquet</a>
51
+ </div>
52
+
53
+ <!-- Templates -->
54
+
55
+ <script type="text/template" id="item-template">
56
+ <div class="todo <%= done ? 'done' : '' %>">
57
+ <div class="display">
58
+ <input class="check" type="checkbox" <%= done ? 'checked="checked"' : '' %> />
59
+ <div class="todo-content"></div>
60
+ <span class="todo-destroy"></span>
61
+ </div>
62
+ <div class="edit">
63
+ <input class="todo-input" type="text" value="" />
64
+ </div>
65
+ </div>
66
+ </script>
67
+
68
+ <script type="text/template" id="stats-template">
69
+ <% if (total) { %>
70
+ <span class="todo-count">
71
+ <span class="number"><%= remaining %></span>
72
+ <span class="word"><%= remaining == 1 ? 'item' : 'items' %></span> left.
73
+ </span>
74
+ <% } %>
75
+ <% if (done) { %>
76
+ <span class="todo-clear">
77
+ <a href="#">
78
+ Clear <span class="number-done"><%= done %></span>
79
+ completed <span class="word-done"><%= done == 1 ? 'item' : 'items' %></span>
80
+ </a>
81
+ </span>
82
+ <% } %>
83
+ </script>
84
+
85
+ </body>
86
+
87
+ </html>