soca 0.1.1 → 0.1.2

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 CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.1.2 [10-26-10]
2
+
3
+ - Added mustache plugin for interpolating env and config data into static HTML
4
+ before push
5
+ - soca purge deletes the design doc
6
+ - Upgraded sammy to 0.6.2
7
+
1
8
  == 0.1.1 [10-04-10]
2
9
 
3
10
  - Fixed compass url (poswald)
data/Rakefile CHANGED
@@ -17,6 +17,7 @@ begin
17
17
  gem.add_dependency 'thor', '~>0.14.0'
18
18
  gem.add_dependency 'jim', '~>0.2.3'
19
19
  gem.add_dependency 'compass', '~>0.10.5'
20
+ gem.add_dependency 'mustache', '~>0.11.2'
20
21
  gem.add_development_dependency "shoulda", ">= 0"
21
22
  gem.add_development_dependency "yard", ">= 0"
22
23
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/lib/soca/cli.rb CHANGED
@@ -172,6 +172,12 @@ module Soca
172
172
  end
173
173
  end
174
174
 
175
+ desc 'purge [ENV]', "deletes the design document for the database at ENV"
176
+ def purge(env = 'default')
177
+ push = pusher(env)
178
+ push.purge!
179
+ end
180
+
175
181
  private
176
182
  def appname
177
183
  @appname = options[:name] || File.basename(appdir)
data/lib/soca/plugin.rb CHANGED
@@ -15,7 +15,7 @@ module Soca
15
15
  @pusher = pusher
16
16
  end
17
17
 
18
- def run
18
+ def run(options = {})
19
19
  raise "you need to subclass plugin and provide your own logic, please"
20
20
  end
21
21
 
@@ -8,14 +8,15 @@ module Soca
8
8
 
9
9
  name 'compass'
10
10
 
11
- def run
11
+ def run(options = {})
12
12
  Soca.logger.info "compiling compass"
13
13
  compass_from = File.join(app_dir, 'sass')
14
14
  compass_to = File.join(app_dir, 'css')
15
15
  unless Soca.debug
16
- options = {:logger => ::Compass::NullLogger.new}
16
+ options = {:logger => ::Compass::NullLogger.new}.merge(options)
17
17
  end
18
18
  compass = ::Compass::Compiler.new(app_dir, compass_from, compass_to, ::Compass.sass_engine_options.merge(options || {}))
19
+ Soca.logger.debug "compass: #{compass.inspect}"
19
20
  compass.run
20
21
  end
21
22
 
@@ -6,7 +6,7 @@ module Soca
6
6
 
7
7
  name 'jim'
8
8
 
9
- def run
9
+ def run(options = {})
10
10
  jimfile = File.join(app_dir, 'Jimfile')
11
11
  ::Jim.logger = logger
12
12
  logger.debug "bundling js"
@@ -0,0 +1,40 @@
1
+ require 'mustache'
2
+
3
+ module Soca
4
+ module Plugins
5
+ class Mustache < Soca::Plugin
6
+
7
+ name 'mustache'
8
+
9
+ # Run the mustache plugin.
10
+ # Available options:
11
+ #
12
+ # * :files - Run these files through mustache. Can be an array of patterns
13
+ # or a single file. The default is '*.mustache'.
14
+ # * :vars - Additional variables to interpolate. By default the `env` and
15
+ # `config` are interpolated.
16
+ #
17
+ def run(options = {})
18
+ file_patterns = options[:files] || '*.mustache'
19
+ files = Dir[*[file_patterns].flatten]
20
+ vars = {
21
+ :env => pusher.env,
22
+ :config => pusher.config
23
+ }.merge(options[:vars] || {})
24
+ Soca.logger.debug "Mustache vars: #{vars.inspect}"
25
+ files.each do |file|
26
+ Soca.logger.debug "Running #{file} through mustache."
27
+ basename = File.basename(file)
28
+ dir = File.dirname(file)
29
+ parts = basename.split(/\./)
30
+ new_file = parts.length > 2 ? parts[0..-2].join('.') : basename[0] + ".html"
31
+ File.open(File.join(dir, new_file), 'w') do |f|
32
+ f << ::Mustache.render(File.read(file), vars)
33
+ end
34
+ Soca.logger.debug "Wrote to #{new_file}"
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
data/lib/soca/pusher.rb CHANGED
@@ -41,7 +41,7 @@ module Soca
41
41
  end
42
42
 
43
43
  def json
44
- JSON.generate(build)
44
+ JSON.pretty_generate(build)
45
45
  end
46
46
 
47
47
  def db_url
@@ -90,6 +90,14 @@ module Soca
90
90
  run_hook_file!(:after_push)
91
91
  end
92
92
 
93
+ def purge!
94
+ get_current_revision
95
+ url = push_url
96
+ url += "?rev=#{revision}" if revision && revision.length > 0
97
+ logger.debug "deleting document at #{url}"
98
+ delete!(url)
99
+ end
100
+
93
101
  def compact!
94
102
  logger.debug "compacting #{db_url}"
95
103
  post!("#{db_url}/_compact")
@@ -110,10 +118,10 @@ module Soca
110
118
  end
111
119
  end
112
120
 
113
- def plugin(plugin_name)
121
+ def plugin(plugin_name, options = {})
114
122
  require "soca/plugins/#{plugin_name}"
115
123
  p = Soca::Plugin.plugins[plugin_name].new(self)
116
- p.run
124
+ p.run(options)
117
125
  end
118
126
 
119
127
  private
@@ -186,5 +194,12 @@ module Soca
186
194
  response
187
195
  end
188
196
 
197
+ def delete!(url)
198
+ logger.debug "DELETE #{url}"
199
+ response = Typhoeus::Request.delete(url)
200
+ logger.debug "Response: #{response.code} #{response.body[0..200]}"
201
+ response.code == 200 ? response.body : nil
202
+ end
203
+
189
204
  end
190
205
  end
@@ -7,6 +7,6 @@
7
7
  sha1
8
8
  jquery 1.4.2
9
9
  jquery.couch 0.11
10
- sammy 0.6.1
10
+ sammy 0.6.2
11
11
  sammy.couch 0.1.0
12
12
  js/app
@@ -1,7 +1,7 @@
1
1
  (function($) {
2
2
 
3
3
  var app = $.sammy('#container', function() {
4
-
4
+ this.use('Couch');
5
5
 
6
6
  });
7
7
 
@@ -1,5 +1,5 @@
1
1
  // name: sammy
2
- // version: 0.6.1
2
+ // version: 0.6.2
3
3
 
4
4
  (function($, window) {
5
5
 
@@ -70,7 +70,7 @@
70
70
  }
71
71
  };
72
72
 
73
- Sammy.VERSION = '0.6.1';
73
+ Sammy.VERSION = '0.6.2';
74
74
 
75
75
  // Add to the global logger pool. Takes a function that accepts an
76
76
  // unknown number of arguments and should print them or send them somewhere
@@ -91,9 +91,9 @@
91
91
  };
92
92
 
93
93
  if (typeof window.console != 'undefined') {
94
- if (_isFunction(console.log.apply)) {
94
+ if (_isFunction(window.console.log.apply)) {
95
95
  Sammy.addLogger(function() {
96
- window.console.log.apply(console, arguments);
96
+ window.console.log.apply(window.console, arguments);
97
97
  });
98
98
  } else {
99
99
  Sammy.addLogger(function() {
@@ -318,7 +318,18 @@
318
318
 
319
319
  // An array of the default events triggered by the
320
320
  // application during its lifecycle
321
- APP_EVENTS: ['run','unload','lookup-route','run-route','route-found','event-context-before','event-context-after','changed','error','check-form-submission','redirect'],
321
+ APP_EVENTS: ['run',
322
+ 'unload',
323
+ 'lookup-route',
324
+ 'run-route',
325
+ 'route-found',
326
+ 'event-context-before',
327
+ 'event-context-after',
328
+ 'changed',
329
+ 'error',
330
+ 'check-form-submission',
331
+ 'redirect',
332
+ 'location-changed'],
322
333
 
323
334
  _last_route: null,
324
335
  _location_proxy: null,
@@ -1153,9 +1164,9 @@
1153
1164
  // get current location
1154
1165
  location = this.getLocation();
1155
1166
  // compare to see if hash has changed
1156
- if (location != this.last_location) {
1167
+ if (!this.last_location || this.last_location[0] != 'get' || this.last_location[1] != location) {
1157
1168
  // reset last location
1158
- this.last_location = location;
1169
+ this.last_location = ['get', location];
1159
1170
  // lookup route for current hash
1160
1171
  returned = this.runRoute('get', location);
1161
1172
  }
@@ -1261,7 +1272,7 @@
1261
1272
  this.waiting = false;
1262
1273
  };
1263
1274
 
1264
- $.extend(Sammy.RenderContext.prototype, {
1275
+ Sammy.RenderContext.prototype = $.extend({}, Sammy.Object.prototype, {
1265
1276
 
1266
1277
  // The "core" of the `RenderContext` object, adds the `callback` to the
1267
1278
  // queue. If the context is `waiting` (meaning an async operation is happening)
@@ -1310,7 +1321,7 @@
1310
1321
  this.callbacks.push(callback);
1311
1322
  } else {
1312
1323
  this.wait();
1313
- setTimeout(function() {
1324
+ window.setTimeout(function() {
1314
1325
  var returned = callback.apply(context, [context.content, context.previous_content]);
1315
1326
  if (returned !== false) {
1316
1327
  context.next(returned);
@@ -1761,7 +1772,7 @@
1761
1772
  to = args[0];
1762
1773
  }
1763
1774
  this.trigger('redirect', {to: to});
1764
- this.app.last_location = this.path;
1775
+ this.app.last_location = [this.verb, this.path];
1765
1776
  this.app.setLocation(to);
1766
1777
  if (current_location == to) {
1767
1778
  this.app.trigger('location-changed');
data/lib/soca.rb CHANGED
@@ -7,7 +7,7 @@ require 'logger'
7
7
  $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__))))
8
8
 
9
9
  module Soca
10
- VERSION = '0.1.1'
10
+ VERSION = '0.1.2'
11
11
 
12
12
  class << self
13
13
  attr_accessor :debug
data/soca.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{soca}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
- s.date = %q{2010-10-04}
12
+ s.date = %q{2010-10-26}
13
13
  s.default_executable = %q{soca}
14
14
  s.description = %q{soca is a different way of writing apps for CouchDB. The structure is up to you.}
15
15
  s.email = %q{aaron@quirkey.com}
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/soca/plugin.rb",
32
32
  "lib/soca/plugins/compass.rb",
33
33
  "lib/soca/plugins/jim.rb",
34
+ "lib/soca/plugins/mustache.rb",
34
35
  "lib/soca/pusher.rb",
35
36
  "lib/soca/templates/Jimfile",
36
37
  "lib/soca/templates/config.js.erb",
@@ -42,7 +43,7 @@ Gem::Specification.new do |s|
42
43
  "lib/soca/templates/js/app.js",
43
44
  "lib/soca/templates/js/vendor/jquery-1.4.2.js",
44
45
  "lib/soca/templates/js/vendor/jquery.couch-0.11.js",
45
- "lib/soca/templates/js/vendor/sammy-0.6.1.js",
46
+ "lib/soca/templates/js/vendor/sammy-0.6.2.js",
46
47
  "lib/soca/templates/js/vendor/sammy.couch-0.1.0.js",
47
48
  "lib/soca/templates/js/vendor/sha1.js",
48
49
  "soca.gemspec",
@@ -87,6 +88,7 @@ Gem::Specification.new do |s|
87
88
  s.add_runtime_dependency(%q<thor>, ["~> 0.14.0"])
88
89
  s.add_runtime_dependency(%q<jim>, ["~> 0.2.3"])
89
90
  s.add_runtime_dependency(%q<compass>, ["~> 0.10.5"])
91
+ s.add_runtime_dependency(%q<mustache>, ["~> 0.11.2"])
90
92
  s.add_development_dependency(%q<shoulda>, [">= 0"])
91
93
  s.add_development_dependency(%q<yard>, [">= 0"])
92
94
  else
@@ -96,6 +98,7 @@ Gem::Specification.new do |s|
96
98
  s.add_dependency(%q<thor>, ["~> 0.14.0"])
97
99
  s.add_dependency(%q<jim>, ["~> 0.2.3"])
98
100
  s.add_dependency(%q<compass>, ["~> 0.10.5"])
101
+ s.add_dependency(%q<mustache>, ["~> 0.11.2"])
99
102
  s.add_dependency(%q<shoulda>, [">= 0"])
100
103
  s.add_dependency(%q<yard>, [">= 0"])
101
104
  end
@@ -106,6 +109,7 @@ Gem::Specification.new do |s|
106
109
  s.add_dependency(%q<thor>, ["~> 0.14.0"])
107
110
  s.add_dependency(%q<jim>, ["~> 0.2.3"])
108
111
  s.add_dependency(%q<compass>, ["~> 0.10.5"])
112
+ s.add_dependency(%q<mustache>, ["~> 0.11.2"])
109
113
  s.add_dependency(%q<shoulda>, [">= 0"])
110
114
  s.add_dependency(%q<yard>, [">= 0"])
111
115
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soca
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Quint
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 -07:00
18
+ date: 2010-10-26 00:00:00 -07:00
19
19
  default_executable: soca
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -114,9 +114,25 @@ dependencies:
114
114
  type: :runtime
115
115
  version_requirements: *id006
116
116
  - !ruby/object:Gem::Dependency
117
- name: shoulda
117
+ name: mustache
118
118
  prerelease: false
119
119
  requirement: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ hash: 55
125
+ segments:
126
+ - 0
127
+ - 11
128
+ - 2
129
+ version: 0.11.2
130
+ type: :runtime
131
+ version_requirements: *id007
132
+ - !ruby/object:Gem::Dependency
133
+ name: shoulda
134
+ prerelease: false
135
+ requirement: &id008 !ruby/object:Gem::Requirement
120
136
  none: false
121
137
  requirements:
122
138
  - - ">="
@@ -126,11 +142,11 @@ dependencies:
126
142
  - 0
127
143
  version: "0"
128
144
  type: :development
129
- version_requirements: *id007
145
+ version_requirements: *id008
130
146
  - !ruby/object:Gem::Dependency
131
147
  name: yard
132
148
  prerelease: false
133
- requirement: &id008 !ruby/object:Gem::Requirement
149
+ requirement: &id009 !ruby/object:Gem::Requirement
134
150
  none: false
135
151
  requirements:
136
152
  - - ">="
@@ -140,7 +156,7 @@ dependencies:
140
156
  - 0
141
157
  version: "0"
142
158
  type: :development
143
- version_requirements: *id008
159
+ version_requirements: *id009
144
160
  description: soca is a different way of writing apps for CouchDB. The structure is up to you.
145
161
  email: aaron@quirkey.com
146
162
  executables:
@@ -163,6 +179,7 @@ files:
163
179
  - lib/soca/plugin.rb
164
180
  - lib/soca/plugins/compass.rb
165
181
  - lib/soca/plugins/jim.rb
182
+ - lib/soca/plugins/mustache.rb
166
183
  - lib/soca/pusher.rb
167
184
  - lib/soca/templates/Jimfile
168
185
  - lib/soca/templates/config.js.erb
@@ -174,7 +191,7 @@ files:
174
191
  - lib/soca/templates/js/app.js
175
192
  - lib/soca/templates/js/vendor/jquery-1.4.2.js
176
193
  - lib/soca/templates/js/vendor/jquery.couch-0.11.js
177
- - lib/soca/templates/js/vendor/sammy-0.6.1.js
194
+ - lib/soca/templates/js/vendor/sammy-0.6.2.js
178
195
  - lib/soca/templates/js/vendor/sammy.couch-0.1.0.js
179
196
  - lib/soca/templates/js/vendor/sha1.js
180
197
  - soca.gemspec