bjork 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/bjork ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bjork/cli"
4
+
5
+ Signal.trap("INT") { exit 1 }
6
+
7
+ Bjork::CLI.start
data/bjork.gemspec CHANGED
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "haml"
27
27
  spec.add_dependency "sprockets"
28
28
  spec.add_dependency "shank"
29
+ spec.add_dependency "thor"
29
30
  spec.add_dependency "jquery-source", "1.9.1.1"
30
31
  end
data/lib/bjork/cli.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "thor"
2
+
3
+ module Bjork
4
+ class CLI < Thor
5
+ desc "version", "Show version"
6
+ def version
7
+ require "bjork/version"
8
+ say "Bjork #{VERSION}"
9
+ end
10
+
11
+ desc "create NAME", "Create a project"
12
+ def create(name)
13
+ say "Creating #{name}"
14
+ require "bjork/generator"
15
+
16
+ Bjork::Generator.new([name]).invoke_all
17
+ end
18
+
19
+ desc "server", "Run your game!"
20
+ def server
21
+ # TODO Move into server file
22
+ require "bjork"
23
+ Bjork::Server.run!
24
+ end
25
+
26
+ default_task :server
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ require "thor"
2
+ require "thor/group"
3
+
4
+ module Bjork
5
+ class Generator < ::Thor::Group
6
+ include Thor::Actions
7
+
8
+ source_root File.join(File.dirname(__FILE__), "templates")
9
+
10
+ argument :location, :type => :string
11
+
12
+ def generate_files!
13
+ # Copy project template
14
+ directory "project", location
15
+
16
+ %w[
17
+ Gemfile
18
+ ].each do |file|
19
+ template file, File.join(location, file)
20
+ end
21
+ end
22
+
23
+ def setup!
24
+ inside(location) do
25
+ fn = -> { run('bundle install') }
26
+
27
+ if defined? Bundler
28
+ Bundler.with_clean_env(&fn)
29
+ else
30
+ fn.call
31
+ end
32
+ end
33
+ end
34
+
35
+ # TODO Generate static docs
36
+ end
37
+ end
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "bjork"
4
+ gem "thin"
5
+
6
+ group :components do
7
+ # Add components here
8
+ end
@@ -0,0 +1,3 @@
1
+ App =
2
+ width: 800
3
+ height: 450
@@ -0,0 +1,17 @@
1
+ #= require_tree .
2
+
3
+ canvas = $("canvas").attr(
4
+ width: App.width
5
+ height: App.height
6
+ ).pixieCanvas()
7
+
8
+ window.engine = Engine
9
+ backgroundColor: Color("Slate Gray").lighten(0.2)
10
+ canvas: canvas
11
+ FPS: 60
12
+
13
+ engine.add "Player",
14
+ x: App.width/2
15
+ y: App.height/2
16
+
17
+ engine.start()
@@ -0,0 +1,24 @@
1
+ # Player class constructor
2
+ Player = (I={}) ->
3
+
4
+ # Default values that can be overriden when creating a new player.
5
+ Object.defaults I,
6
+ width: 16
7
+ height: 16
8
+ speed: 90
9
+
10
+ # The player is a GameObject
11
+ self = GameObject(I)
12
+
13
+ # Automatically get arrow key controls by including "Controllable"
14
+ self.include "Controllable"
15
+
16
+ # Bind an update event
17
+ # This will run each game step
18
+ self.on "update", (elapsedTime) ->
19
+ # Clamp the player's position to be within the screen
20
+ I.x = I.x.clamp(I.width/2, App.width - I.width/2)
21
+ I.y = I.y.clamp(I.height/2, App.height - I.height/2)
22
+
23
+ # We must return a reference to self from the constructor
24
+ return self
data/lib/bjork/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bjork
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/bjork.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require "bundler/setup"
2
+ Bundler.require :components
3
+
1
4
  require "bjork/version"
2
5
  require "bjork/try_static"
3
6
 
@@ -11,12 +14,14 @@ require "sprockets"
11
14
  require "shank"
12
15
  require "jquery-source"
13
16
 
17
+ # TODO: Is there a way we can get the best of both worlds?
14
18
  # Defaulting to bare compilation
15
19
  Tilt::CoffeeScriptTemplate.default_bare = true
16
20
 
17
21
  module Bjork
18
22
  class Server < Sinatra::Base
19
23
  configure do
24
+ set :port, ENV["PORT"] || 1999
20
25
  enable :logging
21
26
 
22
27
  # Serve any assets that exist in our folders
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bjork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: thor
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: jquery-source
128
144
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +158,8 @@ dependencies:
142
158
  description: A magical singing HTML5 game server
143
159
  email:
144
160
  - yahivin@gmail.com
145
- executables: []
161
+ executables:
162
+ - bjork
146
163
  extensions: []
147
164
  extra_rdoc_files: []
148
165
  files:
@@ -151,16 +168,21 @@ files:
151
168
  - LICENSE.txt
152
169
  - README.md
153
170
  - Rakefile
171
+ - bin/bjork
154
172
  - bjork.gemspec
155
173
  - lib/bjork.rb
156
- - lib/bjork/source_maps.rb
174
+ - lib/bjork/cli.rb
175
+ - lib/bjork/generator.rb
157
176
  - lib/bjork/tasks.rb
177
+ - lib/bjork/templates/Gemfile
178
+ - lib/bjork/templates/project/source/app.coffee
179
+ - lib/bjork/templates/project/source/main.coffee
180
+ - lib/bjork/templates/project/source/player.coffee
158
181
  - lib/bjork/try_static.rb
159
182
  - lib/bjork/version.rb
160
183
  - lib/stylesheets/all.css
161
184
  - lib/views/debug.haml
162
185
  - lib/views/index.haml
163
- - ! "\U0001F60E"
164
186
  homepage: ''
165
187
  licenses:
166
188
  - MIT
@@ -1,65 +0,0 @@
1
- # TODO: Not currently working with concatenated Sprockets files :(
2
-
3
- # Monkey patch some source maps
4
- module CoffeeScript
5
- class << self
6
- def compile(script, options = {})
7
- script = script.read if script.respond_to?(:read)
8
-
9
- if options.key?(:no_wrap) && !options.key?(:bare)
10
- options[:bare] = options[:no_wrap]
11
- else
12
- options[:bare] = false
13
- end
14
-
15
- # TODO: Better root_dir
16
- root_dir = Pathname("radical")
17
-
18
- pathname = options[:pathname]
19
- if pathname.nil?
20
- return Source.context.call("CoffeeScript.compile", script, options)
21
- else
22
- clean_name = pathname.basename.to_s.split(".").first
23
-
24
- rel_path = if pathname.to_s.start_with?(Bundler.bundle_path.to_s)
25
- Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path)).dirname
26
- else
27
- pathname.relative_path_from(root_dir).dirname
28
- end
29
-
30
- chill_dir = root_dir.join("source_maps")
31
- map_dir = chill_dir.join(rel_path)
32
- map_dir.mkpath
33
-
34
- map_file = map_dir.join("#{clean_name}.map")
35
- coffee_file = map_dir.join("#{clean_name}.coffee")
36
-
37
- options[:sourceMap] = true
38
- # coffee requires filename option to work with source maps (see http://coffeescript.org/documentation/docs/coffee-script.html#section-4)
39
- options[:filename] = "#{clean_name}.coffee"
40
- # specify coffee source file explicitly (see http://coffeescript.org/documentation/docs/sourcemap.html#section-8)
41
- options[:sourceFiles] = ["/#{coffee_file.relative_path_from(chill_dir)}"]
42
- ret = Source.context.call("CoffeeScript.compile", script, options)
43
-
44
- coffee_file.open('w') {|f| f.puts script }
45
- map_file.open('w') {|f| f.puts ret["v3SourceMap"]}
46
-
47
- comment = "//@ sourceMappingURL=/#{map_file.relative_path_from(chill_dir)}\n"
48
- return ret['js'] + comment
49
- end
50
-
51
- end
52
- end
53
- end
54
-
55
- # Monkeypatch this method to include the scripts' pathname
56
- require 'tilt/coffee'
57
-
58
- module Tilt
59
- class CoffeeScriptTemplate < Template
60
- def evaluate(scope, locals, &block)
61
- pathname = scope.respond_to?(:pathname) ? scope.pathname : nil
62
- @output ||= CoffeeScript.compile(data, options.merge(:pathname => pathname))
63
- end
64
- end
65
- end
data//360/237/230/216 DELETED
@@ -1,9 +0,0 @@
1
- # coding: utf-8
2
-
3
- 😎,😺,👮 = %w.🌟 💩 ⛵.;def 😃💬(*👝);puts 👝;end;
4
-
5
- 😃💬 😎
6
-
7
- 😃💬 😺
8
-
9
- 😃💬 👮