Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm use 1.9.3-p194
View
13 Gemfile
@@ -0,0 +1,13 @@
+source "https://rubygems.org"
+
+gem "sprockets"
+
+gem "sass"
+gem "haml"
+gem "ejs"
+gem "coffee-script"
+gem "haml_assets"
+
+group :development do
+ gem "pry"
+end
View
44 Gemfile.lock
@@ -0,0 +1,44 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ coderay (1.0.9)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.6.1)
+ ejs (1.1.1)
+ execjs (1.4.0)
+ multi_json (~> 1.0)
+ haml (4.0.0)
+ tilt
+ haml_assets (0.2.1)
+ haml
+ tilt
+ hike (1.2.1)
+ method_source (0.8.1)
+ multi_json (1.6.1)
+ pry (0.9.12)
+ coderay (~> 1.0.5)
+ method_source (~> 0.8)
+ slop (~> 3.4)
+ rack (1.5.2)
+ sass (3.2.7)
+ slop (3.4.3)
+ sprockets (2.9.0)
+ hike (~> 1.2)
+ multi_json (~> 1.0)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ tilt (1.3.5)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-script
+ ejs
+ haml
+ haml_assets
+ pry
+ sass
+ sprockets
View
14 code_sync.gemspec
@@ -1,18 +1,18 @@
$:.push File.expand_path("../lib", __FILE__)
-require 'smooth/version'
+require 'code_sync/version'
Gem::Specification.new do |s|
- s.name = "smooth"
- s.version = Smooth::Version
+ s.name = "code sync"
+ s.version = CodeSync::Version
s.platform = Gem::Platform::RUBY
s.authors = ["Jonathan Soeder"]
s.email = ["jonathan.soeder@gmail.com"]
- s.homepage = "http://smooth.io"
- s.summary = "Smooth persistence"
- s.description = "Cross platform, syncable persistence"
+ s.homepage = "http://codesync.io"
+ s.summary = "Turn your browser into a coffeescript / sass canvas"
+ s.description = ""
s.add_dependency 'faye'
- s.add_dependency 'listener'
+ s.add_dependency 'listen'
s.add_dependency 'sprockets'
s.files = `git ls-files`.split("\n")
View
1 lib/assets/javascripts/code_sync/client/index.coffee
@@ -0,0 +1 @@
+#= require 'backbone-events'
View
8 lib/code_sync.rb
@@ -1,5 +1,9 @@
-require 'code_sync/version'
+$:.unshift File.dirname(__FILE__)
module CodeSync
-
+ require 'code_sync/version'
+ require 'code_sync/publisher'
+ require 'code_sync/server'
+ require 'code_sync/sprockets_adapter'
+ require 'code_sync/watcher'
end
View
6 lib/code_sync/publisher.rb
@@ -0,0 +1,6 @@
+module CodeSync
+ class Publisher
+ def initialize options={}
+ end
+ end
+end
View
35 lib/code_sync/sprockets_adapter.rb
@@ -0,0 +1,35 @@
+require 'sprockets'
+
+module CodeSync
+ class SprocketsAdapter
+ attr_accessor :env, :options
+
+ def initialize options={}
+ @options = options
+
+ options[:root] ||= Dir.pwd()
+ @env = Sprockets::Environment.new(options[:root])
+
+ append_asset_paths() if env.paths.length == 0
+
+ end
+
+ protected
+
+ def append_asset_paths base_path=nil
+ base_path ||= env.root
+
+ %w{lib vendor app}.each do |base|
+ path = File.join(env.root, base, 'assets' )
+
+ if File.exists?(path)
+ %w{images stylesheets javascripts}.each do |type|
+ if File.exists?(File.join(path, type))
+ env.append_path(File.join(path, type))
+ end
+ end
+ end
+ end
+ end
+ end
+end
View
160 vendor/assets/javascripts/backbone-events.js
@@ -0,0 +1,160 @@
+(function(){
+ // Backbone.Events
+ // ---------------
+
+ // Regular expression used to split event strings.
+ var eventSplitter = /\s+/;
+
+ // Implement fancy features of the Events API such as multiple event
+ // names `"change blur"` and jQuery-style event maps `{change: action}`
+ // in terms of the existing API.
+ var eventsApi = function(obj, action, name, rest) {
+ if (!name) return true;
+ if (typeof name === 'object') {
+ for (var key in name) {
+ obj[action].apply(obj, [key, name[key]].concat(rest));
+ }
+ } else if (eventSplitter.test(name)) {
+ var names = name.split(eventSplitter);
+ for (var i = 0, l = names.length; i < l; i++) {
+ obj[action].apply(obj, [names[i]].concat(rest));
+ }
+ } else {
+ return true;
+ }
+ };
+
+ // Optimized internal dispatch function for triggering events. Tries to
+ // keep the usual cases speedy (most Backbone events have 3 arguments).
+ var triggerEvents = function(events, args) {
+ var ev, i = -1, l = events.length;
+ switch (args.length) {
+ case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx);
+ return;
+ case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0]);
+ return;
+ case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1]);
+ return;
+ case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1], args[2]);
+ return;
+ default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
+ }
+ };
+
+ // A module that can be mixed in to *any object* in order to provide it with
+ // custom events. You may bind with `on` or remove with `off` callback
+ // functions to an event; `trigger`-ing an event fires all callbacks in
+ // succession.
+ //
+ // var object = {};
+ // _.extend(object, Backbone.Events);
+ // object.on('expand', function(){ alert('expanded'); });
+ // object.trigger('expand');
+ //
+ var Events = {
+
+ // Bind one or more space separated events, or an events map,
+ // to a `callback` function. Passing `"all"` will bind the callback to
+ // all events fired.
+ on: function(name, callback, context) {
+ if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this;
+ this._events || (this._events = {});
+ var list = this._events[name] || (this._events[name] = []);
+ list.push({callback: callback, context: context, ctx: context || this});
+ return this;
+ },
+
+ // Bind events to only be triggered a single time. After the first time
+ // the callback is invoked, it will be removed.
+ once: function(name, callback, context) {
+ if (!(eventsApi(this, 'once', name, [callback, context]) && callback)) return this;
+ var self = this;
+ var once = _.once(function() {
+ self.off(name, once);
+ callback.apply(this, arguments);
+ });
+ once._callback = callback;
+ this.on(name, once, context);
+ return this;
+ },
+
+ // Remove one or many callbacks. If `context` is null, removes all
+ // callbacks with that function. If `callback` is null, removes all
+ // callbacks for the event. If `name` is null, removes all bound
+ // callbacks for all events.
+ off: function(name, callback, context) {
+ var list, ev, events, names, i, l, j, k;
+ if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
+ if (!name && !callback && !context) {
+ this._events = {};
+ return this;
+ }
+
+ names = name ? [name] : _.keys(this._events);
+ for (i = 0, l = names.length; i < l; i++) {
+ name = names[i];
+ if (list = this._events[name]) {
+ events = [];
+ if (callback || context) {
+ for (j = 0, k = list.length; j < k; j++) {
+ ev = list[j];
+ if ((callback && callback !== ev.callback &&
+ callback !== ev.callback._callback) ||
+ (context && context !== ev.context)) {
+ events.push(ev);
+ }
+ }
+ }
+ this._events[name] = events;
+ }
+ }
+
+ return this;
+ },
+
+ // Trigger one or many events, firing all bound callbacks. Callbacks are
+ // passed the same arguments as `trigger` is, apart from the event name
+ // (unless you're listening on `"all"`, which will cause your callback to
+ // receive the true name of the event as the first argument).
+ trigger: function(name) {
+ if (!this._events) return this;
+ var args = slice.call(arguments, 1);
+ if (!eventsApi(this, 'trigger', name, args)) return this;
+ var events = this._events[name];
+ var allEvents = this._events.all;
+ if (events) triggerEvents(events, args);
+ if (allEvents) triggerEvents(allEvents, arguments);
+ return this;
+ },
+
+ // An inversion-of-control version of `on`. Tell *this* object to listen to
+ // an event in another object ... keeping track of what it's listening to.
+ listenTo: function(obj, name, callback) {
+ var listeners = this._listeners || (this._listeners = {});
+ var id = obj._listenerId || (obj._listenerId = _.uniqueId('l'));
+ listeners[id] = obj;
+ obj.on(name, typeof name === 'object' ? this : callback, this);
+ return this;
+ },
+
+ // Tell this object to stop listening to either specific events ... or
+ // to every object it's currently listening to.
+ stopListening: function(obj, name, callback) {
+ var listeners = this._listeners;
+ if (!listeners) return;
+ if (obj) {
+ obj.off(name, typeof name === 'object' ? this : callback, this);
+ if (!name && !callback) delete listeners[obj._listenerId];
+ } else {
+ if (typeof name === 'object') callback = this;
+ for (var id in listeners) {
+ listeners[id].off(name, callback, this);
+ }
+ this._listeners = {};
+ }
+ return this;
+ }
+ };
+
+ window.CodeSyncEvents = Events;
+})();

No commit comments for this range

Something went wrong with that request. Please try again.