magnetised-shrimp 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/LICENSE +0 -0
  2. data/README +0 -0
  3. data/Rakefile +28 -0
  4. data/bin/compress +9 -0
  5. data/lib/shrimp.rb +44 -0
  6. metadata +71 -0
data/LICENSE ADDED
File without changes
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ # Gem::manage_gems
3
+ require 'rake/gempackagetask'
4
+
5
+ spec = Gem::Specification.new do |s|
6
+ s.name = "Shrimp"
7
+ s.version = "0.0.1"
8
+ s.author = "Garry Hill"
9
+ s.email = "garry@magnetised.info"
10
+ s.homepage = "http://shrimp.magnetised.info/"
11
+ s.platform = Gem::Platform::RUBY
12
+ s.summary = "Shrimp provides a Java-free way to use the excellent YUI compressor"
13
+ s.files = FileList["{bin,lib}/**/*"].to_a
14
+ s.require_path = "lib"
15
+ s.autorequire = "name"
16
+ s.test_files = FileList["{test}/**/*test.rb"].to_a
17
+ s.has_rdoc = true
18
+ s.extra_rdoc_files = ["README"]
19
+ s.add_dependency("multipart-post", ">= 1.0")
20
+ end
21
+
22
+ Rake::GemPackageTask.new(spec) do |pkg|
23
+ pkg.need_tar = true
24
+ end
25
+ task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
26
+ puts "generated latest version"
27
+ end
28
+
data/bin/compress ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join(File.dirname(__FILE__), "../lib"))
4
+
5
+ require 'shrimp'
6
+
7
+ js = Shrimp::JS.compress_all(ARGV)
8
+
9
+ puts js.join("\n")
data/lib/shrimp.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'net/http/post/multipart'
3
+
4
+ module Shrimp
5
+ def self.compress_url
6
+ URI.parse('http://shrimp.magnetised.info/compress')
7
+ end
8
+ def self.compress_file(filepath, params={})
9
+ url = compress_url
10
+ File.open(filepath) do |file|
11
+ req = Net::HTTP::Post::Multipart.new(url.path, 'file' => UploadIO.new(file, 'text/javascript', filepath))
12
+ result = Net::HTTP.start(url.host, url.port) do |http|
13
+ http.request(req)
14
+ end
15
+ result.body
16
+ end
17
+ end
18
+
19
+ module JS
20
+ def self.compress(input_file)
21
+ compressor = Shrimp::JS::Compressor.new(input_file)
22
+ compressor.compress
23
+ end
24
+
25
+ def self.compress_all(input_files)
26
+ compressors = input_files.map {|f| Shrimp::JS::Compressor.new(f)}
27
+ compressed = []
28
+ compressors.each do |c|
29
+ compressed << c.compress
30
+ end
31
+ compressed
32
+ end
33
+
34
+ class Compressor
35
+ def initialize(filepath)
36
+ @filepath = filepath
37
+ end
38
+
39
+ def compress(options={})
40
+ Shrimp.compress_file(@filepath)
41
+ end
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: magnetised-shrimp
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.2"
5
+ platform: ruby
6
+ authors:
7
+ - Garry Hill
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-27 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: multipart-post
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "1.0"
24
+ version:
25
+ description: Shrimp provides YUI compression without the need for java to be installed
26
+ email: garry@magnetised.info
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ - LICENSE
34
+ files:
35
+ - README
36
+ - LICENSE
37
+ - Rakefile
38
+ - bin
39
+ - bin/compress
40
+ - lib
41
+ - lib/shrimp.rb
42
+ has_rdoc: false
43
+ homepage: http://shrimp.magnetised.info
44
+ licenses:
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --inline-source
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project: ""
66
+ rubygems_version: 1.3.5
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: Shrimp provides YUI compression without the need for java to be installed.
70
+ test_files: []
71
+