Skip to content
Browse files

thor gm:build task for building *.user.js files from source

remove now unnecessary delimiters in comments
  • Loading branch information...
1 parent 02bbae7 commit 908fe788e5eac9aedd73fcdc208c7aa58aa0b8e2 @mislav committed May 8, 2009
Showing with 26 additions and 6 deletions.
  1. +2 −1 .gitignore
  2. +24 −1 Thorfile
  3. +0 −4 endless_tweets/endless_tweets.js
View
3 .gitignore
@@ -1 +1,2 @@
-/config.xml
+/config.xml
+endless_tweets/endless_tweets.user.js
View
25 Thorfile
@@ -4,10 +4,33 @@ require 'curl'
require 'cgi'
class Gm < Thor
+ desc 'build', %(Builds the *.user.js files from *.js sources)
+ def build
+ for name in self.class.scripts.keys
+ source = File.open("#{name}/#{name}.js", 'r')
+ target = File.open("#{name}/#{name}.user.js", 'w')
+
+ for line in source
+ case line
+ when %r{(\s*)//= (\w+)}
+ helper_name = $2
+ target.puts "/*** #{helper_name} ***/"
+ target.write File.read("toolkit/#{helper_name}.js")
+ else
+ target.write line
+ end
+ end
+
+ source.close
+ target.close
+ puts target.path
+ end
+ end
+
desc 'check', %(Checks scriptLength property on both local and remote file)
def check
Net::HTTP.start('userscripts.org') do |http|
- self.class.scripts.each do |name, id|
+ for name, id in self.class.scripts
req = Net::HTTP::Head.new script_path(id)
res = http.request(req)
remote_size = res.content_length
View
4 endless_tweets/endless_tweets.js
@@ -605,8 +605,6 @@ if (address && /[+-]?\d+\.\d+,[+-]?\d+\.\d+/.test(address.textContent)) {
address.innerHTML = '<a class="googlemap" href="http://maps.google.com/maps?q=' + coordinates + '"><img src="http://maps.google.com/staticmap?center=' + coordinates + '&markers=' + coordinates + ',red&zoom=13&size=165x165&key=' + API_KEY + '" alt=""></a>'
}
-// *** update notification *** //
-
//= update_notifier
var scriptURL = 'http://userscripts.org/scripts/show/24398',
@@ -645,8 +643,6 @@ if (wrapper) checkUserscriptUpdate(scriptURL, scriptLength, function() {
")
})
-// ********* UTILITY FUNCTIONS ********* //
-
//= toolkit
function twitterLinkify(text) {

0 comments on commit 908fe78

Please sign in to comment.
Something went wrong with that request. Please try again.