embork 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +5 -0
  7. data/TODO.md +16 -0
  8. data/bin/embork +63 -0
  9. data/blueprint/Borkfile +42 -0
  10. data/blueprint/Gemfile +13 -0
  11. data/blueprint/README.md +25 -0
  12. data/blueprint/app/app.js +11 -0
  13. data/blueprint/app/components/.gitkeep +0 -0
  14. data/blueprint/app/controllers/.gitkeep +0 -0
  15. data/blueprint/app/helpers/.gitkeep +0 -0
  16. data/blueprint/app/index.html.erb +18 -0
  17. data/blueprint/app/initializers/.gitkeep +0 -0
  18. data/blueprint/app/mixins/.gitkeep +0 -0
  19. data/blueprint/app/models/.gitkeep +0 -0
  20. data/blueprint/app/router.js +8 -0
  21. data/blueprint/app/routes/.gitkeep +0 -0
  22. data/blueprint/app/routes/index.js +1 -0
  23. data/blueprint/app/styles/.gitkeep +0 -0
  24. data/blueprint/app/styles/app.scss +3 -0
  25. data/blueprint/app/templates/.gitkeep +0 -0
  26. data/blueprint/app/templates/application.hbs +3 -0
  27. data/blueprint/app/templates/components/.gitkeep +0 -0
  28. data/blueprint/app/utils/.gitkeep +0 -0
  29. data/blueprint/app/views/.gitkeep +0 -0
  30. data/blueprint/bower.json +16 -0
  31. data/blueprint/bowerrc +3 -0
  32. data/blueprint/config/development/application.css +0 -0
  33. data/blueprint/config/development/application.js +12 -0
  34. data/blueprint/config/production/application.css +0 -0
  35. data/blueprint/config/production/application.js +12 -0
  36. data/blueprint/dotfiles +3 -0
  37. data/blueprint/erbfiles +5 -0
  38. data/blueprint/gitignore +17 -0
  39. data/blueprint/jshintrc +40 -0
  40. data/blueprint/package.json +15 -0
  41. data/blueprint/static/.gitkeep +0 -0
  42. data/blueprint/tests/.jshintrc +71 -0
  43. data/blueprint/tests/helpers/resolver.js +7 -0
  44. data/blueprint/tests/helpers/start-app.js +29 -0
  45. data/blueprint/tests/index.html +44 -0
  46. data/blueprint/tests/test-helper.js +6 -0
  47. data/blueprint/tests/test-loader.js +8 -0
  48. data/blueprint/tests/unit/.gitkeep +0 -0
  49. data/embork.gemspec +41 -0
  50. data/lib/embork.rb +23 -0
  51. data/lib/embork/borkfile.rb +148 -0
  52. data/lib/embork/build_versions.rb +21 -0
  53. data/lib/embork/builder.rb +156 -0
  54. data/lib/embork/environment.rb +90 -0
  55. data/lib/embork/forwarder.rb +23 -0
  56. data/lib/embork/generator.rb +184 -0
  57. data/lib/embork/logger.rb +40 -0
  58. data/lib/embork/pushstate.rb +16 -0
  59. data/lib/embork/server.rb +80 -0
  60. data/lib/embork/sprockets.rb +6 -0
  61. data/lib/embork/sprockets/ember_handlebars_compiler.rb +75 -0
  62. data/lib/embork/sprockets/es6_module_transpiler.rb +120 -0
  63. data/lib/embork/sprockets/frameworks.rb +34 -0
  64. data/lib/embork/sprockets/helpers.rb +45 -0
  65. data/lib/embork/sprockets/support/es6-module-transpiler.js +7190 -0
  66. data/lib/embork/sprockets/support/node_runner.js +22 -0
  67. data/lib/embork/version.rb +3 -0
  68. data/lib/string/strip.rb +27 -0
  69. data/spec/embork/borkfile/Borkfile.empty +0 -0
  70. data/spec/embork/borkfile/Borkfile.full +32 -0
  71. data/spec/embork/borkfile/Borkfile.rack +5 -0
  72. data/spec/embork/borkfile/Borkfile.relative +3 -0
  73. data/spec/embork/borkfile_spec.rb +119 -0
  74. data/spec/embork/builder/Borkfile +20 -0
  75. data/spec/embork/builder/app/index.html.erb +9 -0
  76. data/spec/embork/builder/config/production/application.css +0 -0
  77. data/spec/embork/builder/config/production/application.js +0 -0
  78. data/spec/embork/builder/config/production/deeply/nested/asset.js +0 -0
  79. data/spec/embork/builder/static/images/image.png +0 -0
  80. data/spec/embork/builder_spec.rb +95 -0
  81. data/spec/embork/environment_spec.rb +78 -0
  82. data/spec/embork/generator_spec.rb +84 -0
  83. data/spec/embork/server/example_app/Borkfile +1 -0
  84. data/spec/embork/server/example_app/app/app.js.erb +3 -0
  85. data/spec/embork/server/example_app/app/css/main.sass +3 -0
  86. data/spec/embork/server/example_app/app/index.html +9 -0
  87. data/spec/embork/server/example_app/build/development/application-12345.js +14 -0
  88. data/spec/embork/server/example_app/build/development/index.html +9 -0
  89. data/spec/embork/server/example_app/components/some/component.js +6 -0
  90. data/spec/embork/server/example_app/config/development/application.css +4 -0
  91. data/spec/embork/server/example_app/config/development/application.js +2 -0
  92. data/spec/embork/server/example_app/config/production/application.css +4 -0
  93. data/spec/embork/server/example_app/config/production/application.js +4 -0
  94. data/spec/embork/server/example_app/static/fonts/.gitkeep +0 -0
  95. data/spec/embork/server/example_app/static/images/.gitkeep +0 -0
  96. data/spec/embork/server/example_app/static/images/image.png +0 -0
  97. data/spec/embork/server/specimen.css +7 -0
  98. data/spec/embork/server/specimen.js +14 -0
  99. data/spec/embork/server_spec.rb +152 -0
  100. data/spec/embork/sprockets/ember_handlebars_compiler/amd_template.js +26 -0
  101. data/spec/embork/sprockets/ember_handlebars_compiler/cjs_template.js +24 -0
  102. data/spec/embork/sprockets/ember_handlebars_compiler/global_handlebars_template.js +17 -0
  103. data/spec/embork/sprockets/ember_handlebars_compiler/global_hbs_template.js +17 -0
  104. data/spec/embork/sprockets/ember_handlebars_compiler/my/hbs/template.hbs +5 -0
  105. data/spec/embork/sprockets/ember_handlebars_compiler/my_handlebars_template.js.handlebars +5 -0
  106. data/spec/embork/sprockets/ember_handlebars_compiler/my_hbs_template.js.hbs +5 -0
  107. data/spec/embork/sprockets/ember_handlebars_compiler/transformed_template.js +26 -0
  108. data/spec/embork/sprockets/ember_handlebars_compiler_spec.rb +82 -0
  109. data/spec/embork/sprockets/es6_module_transpiler/app/my/transformed/module.js +13 -0
  110. data/spec/embork/sprockets/es6_module_transpiler/app/my_fancy_module.js +13 -0
  111. data/spec/embork/sprockets/es6_module_transpiler/compiled_amd.js +20 -0
  112. data/spec/embork/sprockets/es6_module_transpiler/compiled_cjs.js +20 -0
  113. data/spec/embork/sprockets/es6_module_transpiler/component.js +1 -0
  114. data/spec/embork/sprockets/es6_module_transpiler/components/some_component.js +1 -0
  115. data/spec/embork/sprockets/es6_module_transpiler/config/application.js +1 -0
  116. data/spec/embork/sprockets/es6_module_transpiler/manifest.js +20 -0
  117. data/spec/embork/sprockets/es6_module_transpiler/namespaced.js +20 -0
  118. data/spec/embork/sprockets/es6_module_transpiler/transformed.js +20 -0
  119. data/spec/embork/sprockets/es6_module_transpiler_spec.rb +97 -0
  120. data/spec/spec_helper.rb +13 -0
  121. metadata +468 -0
@@ -0,0 +1,40 @@
1
+ {
2
+ "predef": {
3
+ "document": true,
4
+ "window": true,
5
+ "location": true,
6
+ "setTimeout": true,
7
+ "Ember": true,
8
+ "Em": true,
9
+ "DS": true,
10
+ "$": true,
11
+ "ENV": true,
12
+ "module": true
13
+ },
14
+ "node" : false,
15
+ "browser" : false,
16
+ "boss" : true,
17
+ "curly": false,
18
+ "debug": false,
19
+ "devel": false,
20
+ "eqeqeq": true,
21
+ "evil": true,
22
+ "forin": false,
23
+ "immed": false,
24
+ "laxbreak": false,
25
+ "newcap": true,
26
+ "noarg": true,
27
+ "noempty": false,
28
+ "nonew": false,
29
+ "nomen": false,
30
+ "onevar": false,
31
+ "plusplus": false,
32
+ "regexp": false,
33
+ "undef": true,
34
+ "sub": true,
35
+ "strict": false,
36
+ "white": false,
37
+ "eqnull": true,
38
+ "esnext": true,
39
+ "unused": true
40
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "<%= namespace %>",
3
+ "version": "0.0.0",
4
+ "author": "",
5
+ "license": "MIT",
6
+ "devDependencies": {
7
+ "jshint": "~>2.5.1",
8
+ "bower": "~>1.3.3"
9
+ },
10
+ "scripts": {
11
+ "bower-deps": "bower install",
12
+ "hint-app": "jshint app; true",
13
+ "hint-tests": "jshint tests; true"
14
+ }
15
+ }
File without changes
@@ -0,0 +1,71 @@
1
+ {
2
+ "predef": [
3
+ "document",
4
+ "window",
5
+ "location",
6
+ "setTimeout",
7
+ "Ember",
8
+ "Em",
9
+ "$",
10
+ "QUnit",
11
+ "define",
12
+ "console",
13
+ "equal",
14
+ "notEqual",
15
+ "notStrictEqual",
16
+ "test",
17
+ "asyncTest",
18
+ "testBoth",
19
+ "testWithDefault",
20
+ "raises",
21
+ "throws",
22
+ "deepEqual",
23
+ "start",
24
+ "stop",
25
+ "ok",
26
+ "strictEqual",
27
+ "module",
28
+ "process",
29
+ "expect",
30
+ "visit",
31
+ "exists",
32
+ "fillIn",
33
+ "click",
34
+ "keyEvent",
35
+ "find",
36
+ "wait",
37
+ "DS",
38
+ "keyEvent",
39
+ "isolatedContainer",
40
+ "startApp",
41
+ "andThen",
42
+ "currentURL",
43
+ "currentPath",
44
+ "currentRouteName"
45
+ ],
46
+ "node" : false,
47
+ "browser" : false,
48
+ "boss" : true,
49
+ "curly": false,
50
+ "debug": false,
51
+ "devel": false,
52
+ "eqeqeq": true,
53
+ "evil": true,
54
+ "forin": false,
55
+ "immed": false,
56
+ "laxbreak": false,
57
+ "newcap": true,
58
+ "noarg": true,
59
+ "noempty": false,
60
+ "nonew": false,
61
+ "nomen": false,
62
+ "onevar": false,
63
+ "plusplus": false,
64
+ "regexp": false,
65
+ "undef": true,
66
+ "sub": true,
67
+ "strict": false,
68
+ "white": false,
69
+ "eqnull": true,
70
+ "esnext": true
71
+ }
@@ -0,0 +1,7 @@
1
+ import Resolver from 'embork/resolver';
2
+
3
+ var resolver = Resolver.create();
4
+
5
+ resolver.namespace = '<%= namespace %>';
6
+
7
+ export default resolver;
@@ -0,0 +1,29 @@
1
+ /* global require */
2
+
3
+ var Application = require('<%= namespace %>/app')['default'];
4
+ var Router = require('<%= namespace %>/router')['default'];
5
+
6
+ export default function startApp(attrs) {
7
+ var App;
8
+
9
+ var attributes = Ember.merge({
10
+ // useful Test defaults
11
+ rootElement: '#ember-testing',
12
+ LOG_ACTIVE_GENERATION:false,
13
+ LOG_VIEW_LOOKUPS: false
14
+ }, attrs); // but you can override;
15
+
16
+ Router.reopen({
17
+ location: 'none'
18
+ });
19
+
20
+ Ember.run(function(){
21
+ App = Application.create(attributes);
22
+ App.setupForTesting();
23
+ App.injectTestHelpers();
24
+ });
25
+
26
+ App.reset();
27
+
28
+ return App;
29
+ }
@@ -0,0 +1,44 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title><%= namespace %> Tests</title>
7
+ <meta name="description" content="">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+
10
+
11
+ <link rel="stylesheet" href="assets/qunit.css">
12
+ <style>
13
+ #ember-testing-container {
14
+ position: absolute;
15
+ background: white;
16
+ bottom: 0;
17
+ right: 0;
18
+ width: 640px;
19
+ height: 384px;
20
+ overflow: auto;
21
+ z-index: 9999;
22
+ border: 1px solid #ccc;
23
+ }
24
+ #ember-testing {
25
+ zoom: 50%;
26
+ }
27
+ </style>
28
+ </head>
29
+ <body>
30
+ <div id="qunit"></div>
31
+ <div id="qunit-fixture"></div>
32
+
33
+ <script>
34
+ window.ENV = {{ENV}};
35
+ </script>
36
+ <script src="assets/qunit.js"></script>
37
+ <script src="assets/application.js"></script>
38
+ <script src="assets/tests.js"></script>
39
+ <script>
40
+ require('<%= namespace %>/tests/test-helper');
41
+ require('<%= namespace %>/tests/test-loader');
42
+ </script>
43
+ </body>
44
+ </html>
@@ -0,0 +1,6 @@
1
+ import resolver from './helpers/resolver';
2
+ import { setResolver } from 'ember-qunit';
3
+
4
+ setResolver(resolver);
5
+
6
+ document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
@@ -0,0 +1,8 @@
1
+ /* globals requirejs,require */
2
+
3
+ // TODO: load based on params
4
+ Ember.keys(requirejs.entries).forEach(function(entry) {
5
+ if ((/\-test/).test(entry)) {
6
+ require(entry, null, null, true);
7
+ }
8
+ });
File without changes
data/embork.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'embork/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'embork'
8
+ spec.version = Embork::VERSION
9
+ spec.authors = ['Matthew Smart']
10
+ spec.email = ['mdsmart@gmail.com']
11
+ spec.description = %q{A tool set for building ember apps.}
12
+ spec.summary = %q{A tool set for building ember apps.}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'sprockets', '~> 2.0'
22
+ spec.add_runtime_dependency 'ember-source', '~> 1.5.1.1'
23
+ spec.add_runtime_dependency 'handlebars-source', '~> 1.3.0'
24
+ spec.add_runtime_dependency 'thor', '~> 0.19.1'
25
+ spec.add_runtime_dependency 'rack'
26
+ spec.add_runtime_dependency 'coffee-script'
27
+ spec.add_runtime_dependency 'sass'
28
+ spec.add_runtime_dependency 'execjs'
29
+ spec.add_runtime_dependency 'barber'
30
+ spec.add_runtime_dependency 'colorize'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.3'
33
+ spec.add_development_dependency 'rspec', '~> 3.0.0.beta1'
34
+ spec.add_development_dependency 'rake'
35
+ spec.add_development_dependency 'rack-test'
36
+ spec.add_development_dependency 'rb-fsevent'
37
+ spec.add_development_dependency 'pry', '0.9.12.2'
38
+ spec.add_development_dependency 'compass'
39
+ spec.add_development_dependency 'bootstrap-sass'
40
+
41
+ end
data/lib/embork.rb ADDED
@@ -0,0 +1,23 @@
1
+ require "embork/version"
2
+
3
+ require "string/strip"
4
+
5
+ require "embork/borkfile"
6
+ require "embork/builder"
7
+ require "embork/environment"
8
+ require "embork/forwarder"
9
+ require "embork/generator"
10
+ require "embork/logger"
11
+ require "embork/pushstate"
12
+ require "embork/server"
13
+ require "embork/sprockets"
14
+
15
+ class Embork
16
+ def self.env
17
+ @env
18
+ end
19
+
20
+ def self.env=(environment)
21
+ @env = environment
22
+ end
23
+ end
@@ -0,0 +1,148 @@
1
+ require 'embork'
2
+ require 'embork/sprockets'
3
+ require 'embork/logger'
4
+
5
+ class Embork::Borkfile
6
+ module Attributes
7
+ attr_reader :asset_paths
8
+ attr_reader :helpers
9
+ attr_reader :project_root
10
+ attr_reader :sprockets_postprocessors
11
+ attr_reader :sprockets_preprocessors
12
+ attr_reader :sprockets_engines
13
+ attr_reader :backend
14
+ attr_reader :html
15
+ attr_reader :frameworks
16
+
17
+ def keep_old_versions(number_to_keep = nil)
18
+ @keep_old_versions = number_to_keep || @keep_old_versions
19
+ end
20
+
21
+ def es6_namespace(namespace = nil)
22
+ @es6_namespace = namespace || @es6_namespace
23
+ end
24
+ end
25
+
26
+ class DSL
27
+ include Attributes
28
+
29
+ SUPPORTED_FRAMEWORKS = %w(bootstrap compass)
30
+
31
+ def initialize(environment, logger)
32
+ Embork.env = @environment = environment
33
+ @asset_paths = []
34
+ @helpers = []
35
+ @sprockets_postprocessors = []
36
+ @sprockets_preprocessors = []
37
+ @sprockets_engines = []
38
+ @project_root = nil
39
+ @html = []
40
+ @backend = :static_index
41
+ @keep_old_versions = 5
42
+ @es6_namespace = nil
43
+ @frameworks = []
44
+ @logger = logger
45
+ end
46
+
47
+ def use_framework(framework)
48
+ framework = framework.to_s
49
+ if SUPPORTED_FRAMEWORKS.include? framework.to_s
50
+ @frameworks.push framework
51
+ else
52
+ @logger.critical 'Framework "%s" is not currently supported by embork.' % framework
53
+ @logger.unknown ''
54
+ exit 1
55
+ end
56
+ end
57
+
58
+ def register_postprocessor(mime_type, klass)
59
+ @sprockets_postprocessors.push({ :mime_type => mime_type, :klass => klass })
60
+ end
61
+
62
+ def register_preprocessor(mime_type, klass)
63
+ @sprockets_preprocessors.push({ :mime_type => mime_type, :klass => klass })
64
+ end
65
+
66
+ def register_engine(extension, klass)
67
+ @sprockets_engines.push({ :extension => extension, :klass => klass })
68
+ end
69
+
70
+ def append_asset_path(path)
71
+ @asset_paths.push path
72
+ end
73
+
74
+ def add_sprockets_helpers(&block)
75
+ helpers.push block
76
+ end
77
+
78
+ def set_project_root(path)
79
+ @project_root = path
80
+ end
81
+
82
+ def set_backend(app)
83
+ @backend = app
84
+ end
85
+
86
+ def configure(environment, &block)
87
+ if environment == @environment
88
+ self.instance_exec &block
89
+ end
90
+ end
91
+
92
+ def get_binding
93
+ return binding
94
+ end
95
+
96
+ def compile_html(files)
97
+ files = [ files ] unless files.kind_of? Array
98
+ @html.concat files
99
+ end
100
+ end
101
+
102
+ include Attributes
103
+
104
+ def initialize(path_to_borkfile, environment = :development)
105
+ @logger = Embork::Logger.new(STDOUT, :simple)
106
+ @path_to_borkfile = path_to_borkfile
107
+ @environment = environment.to_sym
108
+ check_borkfile
109
+ file = DSL.new(environment, @logger)
110
+ file.get_binding.eval File.read(@path_to_borkfile)
111
+ set_options file
112
+ end
113
+
114
+ protected
115
+
116
+ def check_borkfile
117
+ unless File.exists? @path_to_borkfile
118
+ @logger.error 'No Borkfile found at %s.' % @path_to_borkfile
119
+ exit 1
120
+ end
121
+ end
122
+
123
+ def set_options(file)
124
+ # Setup paths
125
+ default_paths = [
126
+ 'app',
127
+ 'config/%s' % [ @environment.to_s ],
128
+ 'components'
129
+ ]
130
+ @asset_paths = default_paths.concat file.asset_paths
131
+
132
+ # Setup root
133
+ if file.project_root
134
+ if file.project_root[0] == '/'
135
+ @project_root = file.project_root
136
+ else
137
+ @project_root = File.expand_path "../#{file.project_root}", @path_to_borkfile
138
+ end
139
+ else
140
+ @project_root = File.expand_path '..', @path_to_borkfile
141
+ end
142
+
143
+ # Copy everything else
144
+ (Attributes.instance_methods - [ :asset_paths, :project_root ]).each do |attr|
145
+ self.instance_variable_set("@#{attr}".to_sym, file.send(attr))
146
+ end
147
+ end
148
+ end