coffeeshop 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in coffeeshop.gemspec
4
+ gemspec
5
+
6
+ gem "sinatra"
7
+ gem "coffee-script"
8
+ gem "redis"
data/README.markdown ADDED
@@ -0,0 +1,27 @@
1
+ # coffeeshop
2
+
3
+ `coffeeshop` is a simple Sinatra app that serves up all CoffeeScript files in a directory as JavaScript. For example, if you had `/my/project/src/rad.coffee`, and ran `coffeeshop` in `/my/project` you could hit `http://localhost:4567/src/rad.coffee` and it will be served up as JavaScript.
4
+
5
+ `coffeeshop` uses Redis for simple 1-hour caching of the generated JavaScript to keep things snappy.
6
+
7
+ ## Usage
8
+
9
+ > gem install coffeeshop
10
+ > cd /my/project/
11
+ > coffeeshop
12
+
13
+ `coffeeshop` accepts the usual [Sinatra][sinatra] options:
14
+
15
+ -p port set the port (default is 4567)
16
+ -o addr set the host (default is 0.0.0.0)
17
+ -e env set the environment (default is development)
18
+ -s server specify rack server/handler (default is thin)
19
+ -x turn on the mutex lock (default is off)
20
+
21
+ [sinatra]: http://www.sinatrarb.com/
22
+
23
+ ## FAQ
24
+
25
+ ### Is this web-scale?
26
+
27
+ No.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/coffeeshop ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler"
4
+ require "sinatra"
5
+ require_relative "../lib/coffeeshop"
6
+
7
+ get /\/(.+)/ do
8
+ content_type "text/javascript"
9
+ path = params[:captures].first
10
+
11
+ if File.exists?( path )
12
+ Coffeeshop.to_js path
13
+ else
14
+ raise Sinatra::NotFound
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "coffeeshop/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "coffeeshop"
7
+ s.version = Coffeeshop::VERSION
8
+ s.authors = ["Tyson Tate"]
9
+ s.email = ["tyson@tysontate.com"]
10
+ s.homepage = "http://github.com/tysontate/coffeeshop"
11
+ s.summary = %q{Simple Sinatra app to serve up CoffeeScript as JavaScript quickly.}
12
+ s.description = %q{coffeeshop is a quick and dirty Sinatra app that serves up any CoffeeScript in a directory as JavaScript. It uses Redis for basic caching because that's how I roll.}
13
+
14
+ s.rubyforge_project = "coffeeshop"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "sinatra"
24
+ s.add_runtime_dependency "coffee-script"
25
+ s.add_runtime_dependency "redis"
26
+ end
@@ -0,0 +1,3 @@
1
+ class Coffeeshop
2
+ VERSION = "0.0.1"
3
+ end
data/lib/coffeeshop.rb ADDED
@@ -0,0 +1,30 @@
1
+ require "coffee-script"
2
+ require "digest/md5"
3
+ require "redis"
4
+ require_relative "coffeeshop/version"
5
+
6
+ class Coffeeshop
7
+ REDIS = Redis.new
8
+ EXPIRE = 24 * 60 * 60
9
+
10
+ def self.to_js( path )
11
+ coffee = File.read( path )
12
+ k = key( digest( coffee ) )
13
+ unless js = REDIS.get( k )
14
+ js = CoffeeScript.compile( coffee )
15
+ REDIS.multi do
16
+ REDIS.set( k, js )
17
+ REDIS.expire( k, EXPIRE )
18
+ end
19
+ end
20
+ js
21
+ end
22
+
23
+ def self.digest( text )
24
+ Digest::MD5.hexdigest( text )
25
+ end
26
+
27
+ def self.key( digest )
28
+ "coffeeshop:#{digest}"
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coffeeshop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tyson Tate
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: &70206248599900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70206248599900
25
+ - !ruby/object:Gem::Dependency
26
+ name: coffee-script
27
+ requirement: &70206248599480 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70206248599480
36
+ - !ruby/object:Gem::Dependency
37
+ name: redis
38
+ requirement: &70206248599060 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70206248599060
47
+ description: coffeeshop is a quick and dirty Sinatra app that serves up any CoffeeScript
48
+ in a directory as JavaScript. It uses Redis for basic caching because that's how
49
+ I roll.
50
+ email:
51
+ - tyson@tysontate.com
52
+ executables:
53
+ - coffeeshop
54
+ extensions: []
55
+ extra_rdoc_files: []
56
+ files:
57
+ - .gitignore
58
+ - Gemfile
59
+ - README.markdown
60
+ - Rakefile
61
+ - bin/coffeeshop
62
+ - coffeeshop.gemspec
63
+ - lib/coffeeshop.rb
64
+ - lib/coffeeshop/version.rb
65
+ homepage: http://github.com/tysontate/coffeeshop
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project: coffeeshop
85
+ rubygems_version: 1.8.11
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Simple Sinatra app to serve up CoffeeScript as JavaScript quickly.
89
+ test_files: []