jbundle 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jbundle (0.0.10)
4
+ jbundle (0.0.11)
5
5
  closure-compiler
6
6
  rack
7
7
  thor
data/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## JBundle
2
2
 
3
+ Ruby utility to help in developing JavaScript libraries. Lets you declare JavaScript libraries composed of multiple files. Easily bundle and minify your JavaScript bundles when you're done. Includes a Rack server for easy testing.
4
+
5
+ ## Installation
6
+
7
+ JBundle is a Ruby gem.
8
+
9
+ gem install jbundle
10
+
11
+ ## Usage
12
+
3
13
  Define a set of javascript files to bundle and minify
4
14
 
5
15
  JBundle.config do
@@ -170,7 +180,32 @@ Learn more about the JBundle command-line with
170
180
 
171
181
  jbundle help # all commands
172
182
  jbundle help server # server command options
183
+
184
+ ## Generator
185
+
186
+ The command line has a quick generator that creates stub files for your library code, an example file and tests using Qunit.
187
+
188
+ jsbundle init my_library.js
173
189
 
190
+ create JFile
191
+ create src
192
+ create src/license.txt
193
+ create src/my_library.js
194
+ create test
195
+ create test/index.html
196
+ create test/tests.js
197
+ create test/qunit.js
198
+ create test/qunit.css
199
+ create dist
200
+ Done. Try it!
201
+
202
+ jbundle s
203
+ open test/index.html
204
+
205
+ At the moment only Qunit is supported in the generator but others (like Jasmine) would be easy to add.
206
+
207
+ If you don't need the test stubs run the command with --no-tests
208
+
174
209
  ## TODO
175
210
 
176
211
  - DRY up stuff, better error handling for missing config
@@ -2,6 +2,9 @@ require 'thor'
2
2
  module JBundle
3
3
 
4
4
  class CommandLine < Thor
5
+
6
+ include Thor::Actions
7
+
5
8
  default_task :bundle
6
9
 
7
10
  map "s" => :server
@@ -46,6 +49,40 @@ module JBundle
46
49
  def version
47
50
  puts JBundle::VERSION
48
51
  end
52
+
53
+ def self.source_root
54
+ ::File.dirname(__FILE__)
55
+ end
56
+
57
+ AFTER_INIT_MESSAGE = %(
58
+ Done. Try it!
59
+
60
+ jbundle s
61
+ open test/index.html
62
+
63
+ Then package your work
49
64
 
65
+ jsbundle
66
+ )
67
+
68
+ desc 'init', 'Create example JFile and test stubs'
69
+ method_option :tests, :default => 'qunit', :aliases => '-t'
70
+ def init(name)
71
+ @name = name
72
+ template('templates/jfile.tt', "JFile")
73
+ empty_directory 'src'
74
+ template('templates/license.tt', "src/license.txt")
75
+ template('templates/lib.tt', "src/#{name}")
76
+ if options[:tests] == 'qunit'
77
+ empty_directory 'test'
78
+ template('templates/index.tt', "test/index.html")
79
+ template('templates/tests.tt', "test/tests.js")
80
+ copy_file 'templates/qunit.tt', 'test/qunit.js'
81
+ copy_file 'templates/qunit_css.tt', 'test/qunit.css'
82
+ end
83
+ empty_directory 'dist'
84
+ say AFTER_INIT_MESSAGE, :yellow
85
+ end
86
+
50
87
  end
51
88
  end
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>QUnit Test Suite</title>
6
+ <link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
7
+ <script type="text/javascript" src="http://localhost:5555/<%= @name %>"></script>
8
+ <script type="text/javascript" src="qunit.js"></script>
9
+ <script type="text/javascript" src="tests.js"></script>
10
+ </head>
11
+ <body>
12
+ <h1 id="qunit-header">QUnit Test Suite</h1>
13
+ <h2 id="qunit-banner"></h2>
14
+ <div id="qunit-testrunner-toolbar"></div>
15
+ <h2 id="qunit-userAgent"></h2>
16
+ <ol id="qunit-tests"></ol>
17
+ <div id="qunit-fixture">test markup</div>
18
+ </body>
19
+ </html>
@@ -0,0 +1,30 @@
1
+ # The JFile defines your JavaScript library and it's dependencies.
2
+ # Read more on https://github.com/ismasan/jbundle/blob/master/README.md
3
+ #
4
+ # Version.
5
+ # jbundle command will put source and minified versions in
6
+ # - dist/0.0.1/
7
+ # - dist/0.0/
8
+ #
9
+ version '0.0.1'
10
+
11
+ # put your development files here
12
+ #
13
+ src_dir './src'
14
+
15
+ # Define one or more JavaScript bundles
16
+ #
17
+ bundle '<%= @name %>' do
18
+ license 'license.txt'
19
+ file '<%= @name %>'
20
+ end
21
+
22
+ # Optional post-bundling filter, for example for string substitution
23
+ #
24
+ filter do |src, config|
25
+ src.gsub /<VERSION>/, config.version.to_s
26
+ end
27
+
28
+ # your packaged, versioned releases go here
29
+ #
30
+ target_dir 'dist'
@@ -0,0 +1,14 @@
1
+ var <%= @name.sub('.js', '').capitalize %> = (function () {
2
+
3
+ function klass (name) {
4
+ this.name = name;
5
+ }
6
+
7
+ klass.prototype = {
8
+ title: function () {
9
+ return 'Mr. ' + this.name;
10
+ }
11
+ }
12
+
13
+ return klass;
14
+ })();
@@ -0,0 +1,25 @@
1
+ /* <%= @name %>, version <VERSION>
2
+
3
+ Copyright (c) <%= Time.now.year %> [your name here]
4
+
5
+ Permission is hereby granted, free of charge, to any person
6
+ obtaining a copy of this software and associated documentation
7
+ files (the "Software"), to deal in the Software without
8
+ restriction, including without limitation the rights to use,
9
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the
11
+ Software is furnished to do so, subject to the following
12
+ conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ OTHER DEALINGS IN THE SOFTWARE.
25
+ ------------------------------------------------------------------*/