jqueryplugingen 0.1.4 → 0.2.0
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.
- data/History.txt +11 -0
- data/Manifest.txt +5 -0
- data/README.rdoc +81 -20
- data/lib/jqp/cli.rb +37 -7
- data/lib/jquery_plugin_gen/compiletask.rb +1 -1
- data/lib/jquery_plugin_gen/generator.rb +16 -5
- data/lib/jquery_plugin_gen/support/build.rake +1 -1
- data/lib/jquery_plugin_gen/support/jquery.rake +75 -66
- data/lib/jquery_plugin_gen/support/package.rake +1 -1
- data/lib/jquery_plugin_gen/support/test.rake +20 -0
- data/lib/jquery_plugin_gen.rb +1 -1
- data/lib/jsspec/JSSpec.css +224 -0
- data/lib/jsspec/JSSpec.js +1548 -0
- data/lib/jsspec/diff_match_patch.js +1 -0
- data/lib/templates/Rakefile.erb +2 -2
- data/lib/templates/example.html.erb +10 -12
- data/lib/templates/src/plugin.js.erb +20 -15
- data/lib/templates/test/acceptance.html.erb +32 -0
- data/lib/templates/test/spec_plugin.js.erb +12 -3
- data/lib/templates/test/specs.html.erb +11 -8
- metadata +6 -1
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.2.0 2009-06-08
|
2
|
+
|
3
|
+
* rewrite of js plugin structure/code
|
4
|
+
* add rake bootstrap sequence
|
5
|
+
* add rake open tasks to browser for testing
|
6
|
+
|
7
|
+
== 0.1.5 2009-06-08
|
8
|
+
|
9
|
+
* add jsspec library
|
10
|
+
* add acceptance tests
|
11
|
+
|
1
12
|
== 0.1.4 2009-06-08
|
2
13
|
|
3
14
|
* BUG-FIX: plugin name was hardcoded on rake compile
|
data/Manifest.txt
CHANGED
@@ -169,7 +169,11 @@ lib/jquery_plugin_gen/support/build.rake
|
|
169
169
|
lib/jquery_plugin_gen/support/bundles.rake
|
170
170
|
lib/jquery_plugin_gen/support/jquery.rake
|
171
171
|
lib/jquery_plugin_gen/support/package.rake
|
172
|
+
lib/jquery_plugin_gen/support/test.rake
|
172
173
|
lib/jquery_plugin_gen/tasks.rb
|
174
|
+
lib/jsspec/JSSpec.css
|
175
|
+
lib/jsspec/JSSpec.js
|
176
|
+
lib/jsspec/diff_match_patch.js
|
173
177
|
lib/packer/Pack.pm
|
174
178
|
lib/packer/ParseMaster.pm
|
175
179
|
lib/packer/jsPacker.pl
|
@@ -178,6 +182,7 @@ lib/templates/README.txt.erb
|
|
178
182
|
lib/templates/Rakefile.erb
|
179
183
|
lib/templates/example.html.erb
|
180
184
|
lib/templates/src/plugin.js.erb
|
185
|
+
lib/templates/test/acceptance.html.erb
|
181
186
|
lib/templates/test/spec_plugin.js.erb
|
182
187
|
lib/templates/test/specs.html.erb
|
183
188
|
script/console
|
data/README.rdoc
CHANGED
@@ -9,10 +9,10 @@ Generate the structure of jquery plugins easily. Manage library dependencies suc
|
|
9
9
|
|
10
10
|
== FEATURES/PROBLEMS:
|
11
11
|
|
12
|
+
* CAN't have a '-' or '.' in the project name [need to split plugin name and filename :-)]
|
13
|
+
* refactor jquery.rake task like compiletask as it is pretty ugly and has some spaghetti going on
|
12
14
|
* be able to use the produced code on linux and windows (need jqp.bat)
|
13
|
-
* bundle up jsspec
|
14
15
|
* include qunit
|
15
|
-
* add acceptance test
|
16
16
|
* add hoe-type features for updating plugins to jquery plugin page (as rake tasks)
|
17
17
|
* be able to bundle/package library dependencies
|
18
18
|
* be able to switch between local and remote libraries in actual html pages (perhaps this is the release bundle)
|
@@ -23,28 +23,89 @@ Generate the structure of jquery plugins easily. Manage library dependencies suc
|
|
23
23
|
|
24
24
|
jqp -p myplugin
|
25
25
|
|
26
|
-
|
26
|
+
jQuery plugin generator to help you kick start your plugin development with the following structure:
|
27
|
+
|
28
|
+
plugin
|
29
|
+
/src
|
30
|
+
/css
|
31
|
+
/images
|
32
|
+
query.plugin.js
|
33
|
+
/test
|
34
|
+
spec_plugin.js
|
35
|
+
acceptance_plugin.js
|
36
|
+
specs.html
|
37
|
+
acceptance.html
|
38
|
+
/lib
|
39
|
+
/jsspec
|
40
|
+
jquery.min.js
|
41
|
+
jquery-ui.js
|
42
|
+
/themes
|
43
|
+
/base
|
44
|
+
example.html
|
45
|
+
Rakefile
|
46
|
+
History.txt
|
47
|
+
README.txt
|
48
|
+
|
49
|
+
It will generate a base plugin of the structure:
|
50
|
+
|
51
|
+
;(function($) {
|
52
|
+
|
53
|
+
$.jquery.test = {
|
54
|
+
VERSION: "0.0.1",
|
55
|
+
defaults: {
|
56
|
+
key: 'value'
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
$.fn.extend({
|
61
|
+
jquery.test: function(settings) {
|
62
|
+
settings = $.extend({}, $.jquery.test.defaults, settings);
|
63
|
+
return this.each( function(){
|
64
|
+
self = this;
|
65
|
+
|
66
|
+
// NOTE: semicolons are needed more if you are planning on packing your code
|
67
|
+
console.log(this);
|
68
|
+
console.log($(this));
|
69
|
+
console.log($.jquery.test.VERSION);
|
70
|
+
console.log($.jquery.test.defaults.key);
|
71
|
+
// your plugin
|
72
|
+
|
73
|
+
})
|
74
|
+
}
|
75
|
+
|
76
|
+
})
|
77
|
+
})(jQuery);
|
78
|
+
|
79
|
+
And a base set of jsspec tests all hooked into an html page ready to go:
|
80
|
+
|
81
|
+
describe('The tests can load', {
|
82
|
+
|
83
|
+
'before': function() {
|
84
|
+
},
|
85
|
+
|
86
|
+
'after': function(){
|
87
|
+
},
|
88
|
+
|
89
|
+
'should load': function(){
|
90
|
+
|
91
|
+
},
|
92
|
+
|
93
|
+
})
|
94
|
+
|
95
|
+
Once you have written your code. You have three views of the plugin:
|
96
|
+
|
97
|
+
1. Acceptance: rake acceptance (compiles and loads tests in browser)
|
98
|
+
2. Specs: rake specs (loads tests in browser)
|
99
|
+
3. Example: rake show (compiles and loads the sample page in a browser)
|
100
|
+
|
101
|
+
Finally, package your plugin ready for uploading the plugins.jquery.com
|
102
|
+
|
103
|
+
rake package
|
27
104
|
|
28
|
-
/src
|
29
|
-
jquery.myplugin.js
|
30
|
-
/test
|
31
|
-
spec_myplugin.js
|
32
|
-
specs.html
|
33
|
-
example.html
|
34
|
-
/lib
|
35
|
-
Rakefile
|
36
|
-
Makefile
|
37
|
-
|
38
|
-
Once you have written your code:
|
39
|
-
|
40
|
-
(a) test with jsspec at test/specs.html
|
41
|
-
(b) package with make and see the results in /dist
|
42
105
|
|
43
106
|
== REQUIREMENTS:
|
44
107
|
|
45
|
-
* jquery
|
46
|
-
* jspec
|
47
|
-
* a packer (currently linux or cygwin)
|
108
|
+
* jquery (installed with rake:jquery:add)
|
48
109
|
|
49
110
|
== INSTALL:
|
50
111
|
|
data/lib/jqp/cli.rb
CHANGED
@@ -4,13 +4,11 @@ module Jqp
|
|
4
4
|
class CLI
|
5
5
|
def self.execute(stdout, arguments=[])
|
6
6
|
|
7
|
-
# NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
|
8
|
-
|
9
7
|
options = {
|
10
|
-
:project => '
|
8
|
+
:project => 'jqplugin',
|
11
9
|
:version => '0.0.1'
|
12
10
|
}
|
13
|
-
mandatory_options = %w(
|
11
|
+
mandatory_options = %w(project)
|
14
12
|
|
15
13
|
parser = OptionParser.new do |opts|
|
16
14
|
opts.banner = <<-BANNER.gsub(/^ /,'')
|
@@ -23,8 +21,16 @@ module Jqp
|
|
23
21
|
query.plugin.js
|
24
22
|
/test
|
25
23
|
spec_plugin.js
|
26
|
-
|
27
|
-
|
24
|
+
acceptance_plugin.js
|
25
|
+
specs.html
|
26
|
+
acceptance.html
|
27
|
+
/lib
|
28
|
+
/jsspec
|
29
|
+
jquery.min.js
|
30
|
+
jquery-ui.js
|
31
|
+
/themes
|
32
|
+
/base
|
33
|
+
example.html
|
28
34
|
Rakefile
|
29
35
|
History.txt
|
30
36
|
README.txt
|
@@ -51,7 +57,31 @@ module Jqp
|
|
51
57
|
|
52
58
|
JqueryPluginGen::Generator.execute(options)
|
53
59
|
|
54
|
-
stdout.puts
|
60
|
+
stdout.puts <<-MSG
|
61
|
+
|
62
|
+
**********************************************************
|
63
|
+
|
64
|
+
Now include the jQuery libraries with:
|
65
|
+
|
66
|
+
cd <jq-plugin>
|
67
|
+
rake first_time
|
68
|
+
|
69
|
+
First time will:
|
70
|
+
- add jquery core, ui and base themes
|
71
|
+
- compile js to a packed version (see build directory)
|
72
|
+
- load three html files in your browser to demon
|
73
|
+
1. Acceptance tests
|
74
|
+
2. Spec tests
|
75
|
+
3. Example page
|
76
|
+
|
77
|
+
Note: you don't have to add jquery core, ui and themes.
|
78
|
+
However, if you don't you will need to update the html
|
79
|
+
pages (example.html, test/spec.html). To see other options
|
80
|
+
use rake -T
|
81
|
+
|
82
|
+
**********************************************************
|
83
|
+
|
84
|
+
MSG
|
55
85
|
end
|
56
86
|
end
|
57
87
|
end
|
@@ -100,7 +100,6 @@ module Rake
|
|
100
100
|
def define
|
101
101
|
fail "Name required (or :noversion)" if @name.nil?
|
102
102
|
@name = nil if :noname == @name
|
103
|
-
|
104
103
|
|
105
104
|
desc "Build all the packages"
|
106
105
|
task :compile => :pack do
|
@@ -120,6 +119,7 @@ module Rake
|
|
120
119
|
|
121
120
|
desc "Merge js files into one"
|
122
121
|
task :merge do
|
122
|
+
FileUtils.mkdir(package_dir_path) rescue nil
|
123
123
|
`#{sed_command}`
|
124
124
|
end
|
125
125
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'rake'
|
2
3
|
|
3
4
|
module JqueryPluginGen
|
4
5
|
class Generator
|
@@ -6,7 +7,11 @@ module JqueryPluginGen
|
|
6
7
|
def self.base_dirs
|
7
8
|
%w(src lib test src/images src/css test/data tasks)
|
8
9
|
end
|
9
|
-
|
10
|
+
|
11
|
+
def self.copy_jsspec
|
12
|
+
FileUtils.cp_r(File.join(File.dirname(__FILE__), "../jsspec"), 'lib')
|
13
|
+
end
|
14
|
+
|
10
15
|
def self.execute(args)
|
11
16
|
|
12
17
|
project = args[:project]
|
@@ -30,18 +35,23 @@ module JqueryPluginGen
|
|
30
35
|
puts "creating: #{path}"
|
31
36
|
Dir.mkdir path
|
32
37
|
end
|
38
|
+
|
39
|
+
copy_jsspec
|
33
40
|
|
34
|
-
|
41
|
+
details = args
|
35
42
|
files = {
|
43
|
+
"Rakefile" => QuickTemplate.erb('Rakefile', details),
|
36
44
|
"History.txt" => QuickTemplate.erb('History.txt', details),
|
37
45
|
"README.txt" => QuickTemplate.erb('README.txt', details),
|
46
|
+
"example.html" => QuickTemplate.erb('example.html', details),
|
38
47
|
"src/#{file_name}.js" => QuickTemplate.erb('src/plugin.js', details),
|
39
|
-
"test/spec_#{file_name}.js" => QuickTemplate.erb('test/spec_plugin.js', details),
|
40
|
-
"Rakefile" => QuickTemplate.erb('Rakefile', details),
|
41
48
|
"src/css/screen.#{file_name}.css" => "",
|
42
49
|
"test/specs.html" => QuickTemplate.erb('test/specs.html', details),
|
50
|
+
"test/spec_#{file_name}.js" => QuickTemplate.erb('test/spec_plugin.js', details),
|
43
51
|
"test/data/#{file_name}_01.json" => "",
|
44
52
|
"test/data/#{file_name}_01.js" => "",
|
53
|
+
"test/acceptance.html" => QuickTemplate.erb('test/acceptance.html', details),
|
54
|
+
"test/acceptance_#{file_name}.js" => QuickTemplate.erb('test/spec_plugin.js', details),
|
45
55
|
}
|
46
56
|
|
47
57
|
files["Manifest.txt"] = files.keys.sort.join("\n")
|
@@ -52,7 +62,8 @@ module JqueryPluginGen
|
|
52
62
|
f.write content
|
53
63
|
end
|
54
64
|
end
|
55
|
-
|
65
|
+
|
66
|
+
end
|
56
67
|
end
|
57
68
|
|
58
69
|
end
|
@@ -1,76 +1,75 @@
|
|
1
1
|
begin
|
2
|
-
%w[rake fileutils simple-rss open-uri].each { |f| require f }
|
2
|
+
%w[rake tmpdir fileutils simple-rss open-uri].each { |f| require f }
|
3
3
|
rescue LoadError
|
4
4
|
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
5
|
%w[rake tmpdir fileutils simple-rss open-uri].each { |f| require f }
|
6
6
|
end
|
7
7
|
|
8
8
|
lib_dir = 'lib'
|
9
|
+
tmp_dir = Dir.tmpdir
|
9
10
|
|
10
11
|
namespace :jquery do
|
11
12
|
|
12
13
|
desc "Add latest jquery core, ui and themes to #{lib_dir}"
|
13
|
-
task :
|
14
|
+
task :add => [:add_core, :add_ui, :add_themes]
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "List jQuery packages available"
|
23
|
-
task :versions do
|
24
|
-
versions(jquery_atom){ |e| e.title.gsub(/jquery-(\d\.\d\.\d|\d\.\d).*/, '\1') }
|
25
|
-
end
|
16
|
+
desc "Add latest jQuery to library"
|
17
|
+
task :add_core do
|
18
|
+
uri = first(jquery_atom){ |e| e.content.gsub(/.*a href="(.*)".*/m, '\1') if e.title.include?('.min.js') }
|
19
|
+
get_and_install(uri, lib_dir, 'jquery.min.js')
|
20
|
+
end
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
desc "Add specific version of jQuery library: see with VERSION=X.X.X on command line"
|
34
|
-
task :add_version do
|
35
|
-
version = ENV['VERSION']
|
36
|
-
return puts('No version specified - add VERSION=X.X.X to rake command') if version.nil?
|
37
|
-
uri = first(jquery_atom){ |e| e.content.gsub(/.*a href="(.*)".*/m, '\1') if e.title.include?(version) }
|
38
|
-
return puts("Specified version #{version} not found in repository - use rake jquery:core:versions to determine available versions") if uri.nil?
|
39
|
-
get_and_install(uri, lib_dir, "jquery-#{version}.min.js")
|
40
|
-
end
|
22
|
+
desc "Add latest jQueryUI (without theme) to library"
|
23
|
+
task :add_ui do
|
24
|
+
uri = first(jqueryui_atom){ |e| e.content.gsub(/.*a href="(.*)".*/m, '\1') unless e.title.include?('themes') }
|
25
|
+
file = uri.gsub(/.*files\/(.*)(\d.\drc\d.\d|\d.\drc\d|\d\.\d\.\d|\d\.\d)(.*)/, '\1\2\3')
|
26
|
+
get_and_install(uri, tmp_dir, file)
|
27
|
+
unzip_and_install(lib_dir, tmp_dir, file)
|
41
28
|
end
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
30
|
+
desc "Add all themes to libary"
|
31
|
+
task :add_themes do
|
32
|
+
uri = first(jqueryui_atom){ |e| e.content.gsub(/.*a href="(.*)".*/m, '\1') if e.title.include?('themes') }
|
33
|
+
file = uri.gsub(/.*files\/(.*)(\d.\drc\d.\d|\d.\drc\d|\d\.\d\.\d|\d\.\d)(.*)/, '\1\2\3')
|
34
|
+
get_and_install(uri, tmp_dir, file)
|
35
|
+
unzip_and_install(lib_dir, tmp_dir, file)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Add specific version of jQuery library: see with VERSION=X.X.X on command line"
|
39
|
+
task :add_version do
|
40
|
+
version = ENV['VERSION']
|
41
|
+
return puts('No version specified - add VERSION=X.X.X to rake command') if version.nil?
|
42
|
+
uri = first(jquery_atom){ |e| e.content.gsub(/.*a href="(.*)".*/m, '\1') if e.title.include?(version) }
|
43
|
+
return puts("Specified version #{version} not found in repository - use rake jquery:core:versions to determine available versions") if uri.nil?
|
44
|
+
get_and_install(uri, lib_dir, "jquery-#{version}.min.js")
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "List all versions for core and ui "
|
48
|
+
task :versions => [:versions_core, :versions_ui]
|
49
|
+
|
50
|
+
desc "List jQuery packages available"
|
51
|
+
task :versions_core do
|
52
|
+
versions(jquery_atom){ |e| e.title.gsub(/jquery-(\d\.\d\.\d|\d\.\d).*/, '\1') }
|
62
53
|
end
|
63
54
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
55
|
+
desc "List jQuery UI packages available"
|
56
|
+
task :versions_ui do
|
57
|
+
versions(jqueryui_atom){ |e| e.title.gsub(/.*-(\d.\drc\d.\d|\d.\drc\d|\d\.\d\.\d|\d\.\d).*/, '\1') }
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "List all packages for core and ui"
|
61
|
+
task :packages => [:packages_core, :packages_ui]
|
62
|
+
|
63
|
+
desc "List versions of released packages"
|
64
|
+
task :packages_core do
|
65
|
+
versions(jquery_atom){ |e| e.title }
|
72
66
|
end
|
73
|
-
|
67
|
+
|
68
|
+
desc "List versions of released packages"
|
69
|
+
task :packages_ui do
|
70
|
+
versions(jqueryui_atom){ |e| e.title }
|
71
|
+
end
|
72
|
+
|
74
73
|
end
|
75
74
|
|
76
75
|
|
@@ -115,29 +114,39 @@ def get_and_install(uri, path, file)
|
|
115
114
|
|
116
115
|
File.open(new_file, 'w') do |file|
|
117
116
|
download.open { |jq| jq.each_line {|line| file.puts line} }
|
118
|
-
end
|
117
|
+
end unless File.exists?(new_file)
|
119
118
|
new_file
|
120
119
|
end
|
121
120
|
|
122
|
-
def unzip_and_install(
|
121
|
+
def unzip_and_install(dest, tmp_dir, file)
|
123
122
|
|
124
|
-
|
125
|
-
|
123
|
+
puts tmp_dir
|
124
|
+
# dest = File.join(dest)
|
125
|
+
extracted_folder = File.join(tmp_dir, file.gsub(/(.*)\.zip/, '\1'))
|
126
126
|
|
127
127
|
if /mswin|mingw/ =~ RUBY_PLATFORM then
|
128
128
|
zip = ENV['ZIP'] || '7z'
|
129
129
|
puts "Extracting using #{zip} - this should be on your path or set the ZIP=path/to/zip/cmd on rake command"
|
130
|
-
`#{zip} #{file} -o #{
|
130
|
+
`#{zip} #{tmp_dir}/#{file} -o #{tmp_dir}`
|
131
131
|
else
|
132
|
-
puts
|
133
|
-
`unzip -o #{
|
132
|
+
puts "Extracting files #{tmp_dir}/#{file} to #{tmp_dir}"
|
133
|
+
`unzip -o #{tmp_dir}/#{file} -d #{tmp_dir}`
|
134
134
|
end
|
135
135
|
|
136
|
-
puts
|
137
|
-
FileUtils.cp
|
138
|
-
|
136
|
+
puts "Copying ui and themes in #{extracted_folder} to #{dest}"
|
137
|
+
FileUtils.cp(Dir.glob("#{extracted_folder}/ui/jquery*.js"), dest) rescue nil
|
138
|
+
|
139
|
+
begin
|
140
|
+
FileUtils.cp_r("#{patch_themes_path(extracted_folder)}/themes", dest)
|
141
|
+
rescue LoadError
|
142
|
+
puts "Error in the way JQuery Themes was packaged please contact gem owner for patch"
|
143
|
+
end
|
139
144
|
|
140
145
|
puts 'Cleaning extracted files'
|
141
|
-
FileUtils.rm "#{
|
146
|
+
# FileUtils.rm "#{tmp_dir}/#{file}" # I'm allowing for caching
|
142
147
|
FileUtils.rm_rf extracted_folder
|
143
148
|
end
|
149
|
+
|
150
|
+
def patch_themes_path(extracted_path)
|
151
|
+
extracted_path.gsub(/1.7.2.0/, '1.7.2')
|
152
|
+
end
|