neptune_coffee 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cddf86c8945bc610d8cf38f4f7ba8bafa62a84d6
4
- data.tar.gz: f4690c75025d2dbaf2d470bcb57f405d94fedbff
3
+ metadata.gz: 66c47955d9f4f7c61196d9ebfd93b28685cb5245
4
+ data.tar.gz: a349b48feed11d4ff8b57ef448e39942f987bcea
5
5
  SHA512:
6
- metadata.gz: b9184a51f6980940d3b326f7e45fc45637e40c7eac994030d66695f344a0ecd89ec780aafe7213af5f682b8ed23150af2a3485a651a53f6d96d78336bf5b1a99
7
- data.tar.gz: 4272f120cb31e48f4f3b70315c213faa483029314e4e29c60114f5e4ff5672db039b8606a8ed892c8ccbba875a02433ec7726cd3ab70f3ea3546112e6ff9e85c
6
+ metadata.gz: ec430a0759d0b17964bdc57b0cc810a65036048d0a6a4aff2c62d0691997739dd76e05c61be071b5ea487492e08f4a62c9dd29ea4f9f557859e8b9ccbff7efae
7
+ data.tar.gz: b147d1d105f107af09d10be2fb743dec82c1464396bee603c7eab5910188a84fbf4c657e07fe474bd15ab12cfedac2cc88d80b153d775183c5460471e839518a
data/README.md CHANGED
@@ -23,6 +23,7 @@ NeptuneCoffee has an opinion about how you should organize your javascript for A
23
23
  * Directories are AMD modules
24
24
  * Directory's name defines the AMD module's name
25
25
  * Directory names should be snake_case
26
+ * module js files return classes to be attached to their directory's namespace
26
27
  * generated AMD module names will be CamelCase
27
28
  * require "foo/bar" includes all files in the module defined by the directory "foo/bar"
28
29
  * Defines a hierachical namespace based on module names and directory structure nesting
@@ -71,13 +72,15 @@ NeptuneCoffee generates:
71
72
 
72
73
  geometry.js might look like:
73
74
 
74
- // Generated by NeptuneCoffee 0.0.2
75
+ // Generated by NeptuneCoffee 0.2.0
75
76
  define([
76
- './geometry/namespace'
77
- './geometry/box'
78
- './geometry/circle'
77
+ './geometry/namespace',
78
+ './geometry/box',
79
+ './geometry/circle',
79
80
  './geometry/solids'
80
- ], function(Geometry) {
81
+ ], function(Geometry, Box, Circle) {
82
+ Geometry.Box = Box; Box.namespace = Geometry;
83
+ Geometry.Circle = Circle; Circle.namespace = Geometry;
81
84
  return Geometry;
82
85
  });
83
86
 
@@ -1,4 +1,12 @@
1
- // example source file
2
- function(){
3
- window.box = "box";
4
- }();
1
+ // Generated by CoffeeScript 1.6.3
2
+ (function() {
3
+ var Box;
4
+
5
+ Box = (function() {
6
+ function Box() {}
7
+
8
+ return Box;
9
+
10
+ })();
11
+
12
+ }).call(this);
@@ -1,4 +1,12 @@
1
- // example source file
2
- function(){
3
- window.circle = "circle";
4
- }();
1
+ // Generated by CoffeeScript 1.6.3
2
+ (function() {
3
+ var Circle;
4
+
5
+ Circle = (function() {
6
+ function Circle() {}
7
+
8
+ return Circle;
9
+
10
+ })();
11
+
12
+ }).call(this);
@@ -1,4 +1,4 @@
1
- // Generated by NeptuneCoffee 0.1.0
1
+ // Generated by NeptuneCoffee 0.2.0
2
2
  define([
3
3
  './solids/namespace'
4
4
  ], function(Solids) {
@@ -1,4 +1,12 @@
1
- // example source file
2
- function(){
3
- window.cone = "cone";
4
- }();
1
+ // Generated by CoffeeScript 1.6.3
2
+ (function() {
3
+ var Cone;
4
+
5
+ Cone = (function() {
6
+ function Cone() {}
7
+
8
+ return Cone;
9
+
10
+ })();
11
+
12
+ }).call(this);
@@ -1,4 +1,4 @@
1
- // Generated by NeptuneCoffee 0.1.0
1
+ // Generated by NeptuneCoffee 0.2.0
2
2
  define([], function() {
3
3
  Solids = (function() {
4
4
  function Solids() {}
@@ -1,7 +1,8 @@
1
- // Generated by NeptuneCoffee 0.1.0
1
+ // Generated by NeptuneCoffee 0.2.0
2
2
  define([
3
3
  './solids/namespace',
4
4
  './solids/cone'
5
- ], function(Solids) {
5
+ ], function(Solids, Cone) {
6
+ if (typeof Cone == 'function') {Solids.Cone = Cone; Cone.namespace = Solids;}
6
7
  return Solids;
7
8
  });
@@ -1,9 +1,11 @@
1
- // Generated by NeptuneCoffee 0.1.0
1
+ // Generated by NeptuneCoffee 0.2.0
2
2
  define([
3
3
  './geometry/namespace',
4
4
  './geometry/box',
5
5
  './geometry/circle',
6
6
  './geometry/solids'
7
- ], function(Geometry) {
7
+ ], function(Geometry, Box, Circle) {
8
+ if (typeof Box == 'function') {Geometry.Box = Box; Box.namespace = Geometry;}
9
+ if (typeof Circle == 'function') {Geometry.Circle = Circle; Circle.namespace = Geometry;}
8
10
  return Geometry;
9
11
  });
@@ -1,4 +1,4 @@
1
- // Generated by NeptuneCoffee 0.1.0
1
+ // Generated by NeptuneCoffee 0.2.0
2
2
  define([
3
3
  './geometry/namespace'
4
4
  ], function(Geometry) {
@@ -1,4 +1,12 @@
1
- // example source file
2
- function(){
3
- window.box = "box";
4
- }();
1
+ // Generated by CoffeeScript 1.6.3
2
+ (function() {
3
+ var Box;
4
+
5
+ Box = (function() {
6
+ function Box() {}
7
+
8
+ return Box;
9
+
10
+ })();
11
+
12
+ }).call(this);
@@ -1,4 +1,12 @@
1
- // example source file
2
- function(){
3
- window.circle = "circle";
4
- }();
1
+ // Generated by CoffeeScript 1.6.3
2
+ (function() {
3
+ var Circle;
4
+
5
+ Circle = (function() {
6
+ function Circle() {}
7
+
8
+ return Circle;
9
+
10
+ })();
11
+
12
+ }).call(this);
@@ -1,4 +1,12 @@
1
- // example source file
2
- function(){
3
- window.cone = "cone";
4
- }();
1
+ // Generated by CoffeeScript 1.6.3
2
+ (function() {
3
+ var Cone;
4
+
5
+ Cone = (function() {
6
+ function Cone() {}
7
+
8
+ return Cone;
9
+
10
+ })();
11
+
12
+ }).call(this);
@@ -86,8 +86,9 @@ module NeptuneCoffee
86
86
  end
87
87
 
88
88
  def generate_module dir
89
- files = dir.children.select {|f| f.extname.downcase == ".js"}
90
- safe_generate(dir.sub_ext(".js")) {JavascriptGenerator.new(root, dir).module(@dirs.subdirs(dir) + files)}
89
+ subdirs = @dirs.subdirs(dir)
90
+ files = dir.children.select {|f| f.extname.downcase == ".js" && !subdirs.index(f.sub_ext(""))}
91
+ safe_generate(dir.sub_ext(".js")) {JavascriptGenerator.new(root, dir).module(@dirs.subdirs(dir), files)}
91
92
  end
92
93
 
93
94
  def generate_namespace dir
@@ -11,13 +11,19 @@ module NeptuneCoffee
11
11
  "define([#{files_js}], function"
12
12
  end
13
13
 
14
- def module files
14
+ def module sub_modules, class_files
15
15
  # subfiles ||= dir.children.select{|c| !c.directory? && c.extname == ".js"}
16
- files = files.map{|f|f.sub_ext("")}
17
- files = [dir + "namespace"] + files.select{|c|c.basename.to_s!="namespace"}.sort.uniq
16
+ class_files = class_files.map{|f|f.sub_ext("")}.select {|c|c.basename.to_s!="namespace"}.sort.uniq
17
+ files = [dir + "namespace"] + class_files + sub_modules.sort.uniq
18
+
19
+ file_class_names = class_files.map {|files| files.basename.to_s.camel_case}
18
20
 
19
21
  <<-ENDJS
20
- #{define_js files, dir.dirname}(#{namespace_name}) {
22
+ #{define_js files, dir.dirname}(#{([namespace_name]+file_class_names).join ', '}) {#{
23
+ file_class_names.map do |fcn|
24
+ "\n if (typeof #{fcn} == 'function') {#{namespace_name}.#{fcn} = #{fcn}; #{fcn}.namespace = #{namespace_name};}"
25
+ end.join
26
+ }
21
27
  return #{namespace_name};
22
28
  });
23
29
  ENDJS
@@ -1,3 +1,3 @@
1
1
  module NeptuneCoffee
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -14,8 +14,9 @@ describe JavascriptGenerator do
14
14
 
15
15
  it "module_js" do
16
16
  module_js = JavascriptGenerator.new(Pathname["foo"], Pathname["foo/bar"]).module [
17
- Pathname["foo/bar/subdir1.js"],
18
- Pathname["foo/bar/subdir2.js"],
17
+ Pathname["foo/bar/subdir1"],
18
+ Pathname["foo/bar/subdir2"]
19
+ ], [
19
20
  Pathname["foo/bar/file1"],
20
21
  Pathname["foo/bar/file2"]
21
22
  ]
@@ -27,7 +28,9 @@ define([
27
28
  './bar/file2',
28
29
  './bar/subdir1',
29
30
  './bar/subdir2'
30
- ], function(Bar) {
31
+ ], function(Bar, File1, File2) {
32
+ if (typeof File1 == 'function') {Bar.File1 = File1; File1.namespace = Bar;}
33
+ if (typeof File2 == 'function') {Bar.File2 = File2; File2.namespace = Bar;}
31
34
  return Bar;
32
35
  });
33
36
  ENDJS
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neptune_coffee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Brinkman-Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop