ngi 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -1
  3. data/bin/ngi +1 -31
  4. data/lib/config/{angular_init.config.json → backup/angular_init.config.json} +0 -0
  5. data/lib/config/backup/config.components.aliases.yml +3 -0
  6. data/lib/config/backup/config.components.yml +55 -0
  7. data/lib/config/backup/config.configurable.yml +1 -0
  8. data/lib/config/backup/config.languages.yml +5 -0
  9. data/lib/config/backup/config.yml +3 -0
  10. data/lib/config/backup/template-skeleton.js +93 -0
  11. data/lib/config/config.components.aliases.yml +3 -0
  12. data/lib/config/config.components.yml +55 -0
  13. data/lib/config/config.configurable.yml +2 -0
  14. data/lib/config/config.languages.yml +5 -0
  15. data/lib/config/config.yml +4 -0
  16. data/lib/ngi.rb +4 -7
  17. data/lib/ngi/configure.rb +236 -75
  18. data/lib/ngi/delegate.rb +3 -8
  19. data/lib/ngi/generator.rb +74 -46
  20. data/lib/ngi/parser.rb +97 -0
  21. data/lib/{templates → ngi/templates}/markup/html/default/index.html +0 -0
  22. data/lib/{templates → ngi/templates}/script/coffee/default/basic.js +0 -0
  23. data/lib/{templates → ngi/templates}/script/coffee/default/config.js +0 -0
  24. data/lib/{templates → ngi/templates}/script/coffee/default/constant.js +0 -0
  25. data/lib/{templates → ngi/templates}/script/coffee/default/module.js +0 -0
  26. data/lib/{templates → ngi/templates}/script/es5/default/basic.js +0 -0
  27. data/lib/{templates → ngi/templates}/script/es5/default/config.js +0 -0
  28. data/lib/{templates → ngi/templates}/script/es5/default/constant.js +0 -0
  29. data/lib/{templates → ngi/templates}/script/es5/default/module.js +0 -0
  30. data/lib/ngi/utils/command_parser.rb +90 -75
  31. data/lib/ngi/utils/current_dir.rb +20 -0
  32. data/lib/ngi/utils/jser.rb +45 -32
  33. data/lib/ngi/utils/user_input.rb +22 -0
  34. data/lib/ngi/utils/utils.rb +4 -21
  35. data/lib/ngi/version.rb +1 -1
  36. data/ngi.gemspec +2 -1
  37. data/test/config/config.components.aliases.yml +3 -0
  38. data/test/config/config.components.yml +55 -0
  39. data/test/config/config.configurable.yml +2 -0
  40. data/test/config/config.languages.yml +5 -0
  41. data/test/config/config.yml +4 -0
  42. data/test/finished_files/script/coffee/directive.finished.coffee +20 -0
  43. data/test/finished_files/script/es5/controller.finished.js +13 -0
  44. data/test/finished_files/script/es5/directive.finished.js +25 -0
  45. data/test/finished_files/script/es5/filter.finished.js +18 -0
  46. data/test/templates/markup/html/default/index.html +11 -0
  47. data/test/templates/script/coffee/default/basic.js +23 -0
  48. data/test/templates/script/coffee/default/config.js +12 -0
  49. data/test/templates/script/coffee/default/constant.js +7 -0
  50. data/test/templates/script/coffee/default/module.js +7 -0
  51. data/test/templates/script/es5/default/basic.js +29 -0
  52. data/test/templates/script/es5/default/config.js +13 -0
  53. data/test/templates/script/es5/default/constant.js +7 -0
  54. data/test/templates/script/es5/default/module.js +7 -0
  55. data/test/test_ngi.rb +274 -56
  56. data/test/testing_utils.rb +26 -0
  57. metadata +78 -36
  58. data/lib/dep/json.rb +0 -62
  59. data/lib/dep/json/add/bigdecimal.rb +0 -28
  60. data/lib/dep/json/add/complex.rb +0 -28
  61. data/lib/dep/json/add/core.rb +0 -11
  62. data/lib/dep/json/add/date.rb +0 -34
  63. data/lib/dep/json/add/date_time.rb +0 -50
  64. data/lib/dep/json/add/exception.rb +0 -31
  65. data/lib/dep/json/add/ostruct.rb +0 -31
  66. data/lib/dep/json/add/range.rb +0 -29
  67. data/lib/dep/json/add/rational.rb +0 -27
  68. data/lib/dep/json/add/regexp.rb +0 -30
  69. data/lib/dep/json/add/struct.rb +0 -30
  70. data/lib/dep/json/add/symbol.rb +0 -25
  71. data/lib/dep/json/add/time.rb +0 -38
  72. data/lib/dep/json/common.rb +0 -484
  73. data/lib/dep/json/ext.rb +0 -21
  74. data/lib/dep/json/ext/.keep +0 -0
  75. data/lib/dep/json/generic_object.rb +0 -70
  76. data/lib/dep/json/pure.rb +0 -21
  77. data/lib/dep/json/pure/generator.rb +0 -522
  78. data/lib/dep/json/pure/parser.rb +0 -359
  79. data/lib/dep/json/version.rb +0 -8
  80. data/test/sup/test.config.json +0 -100
@@ -0,0 +1,20 @@
1
+ # angular_init (short-name: ngi)
2
+ # Copyright 2015 Joshua Beam
3
+ # github.com/joshbeam/angular_init
4
+ # MIT License
5
+
6
+ # Utilities
7
+ module Utils
8
+ # Current directory
9
+ class CurrentDir
10
+ @@dir = ''
11
+
12
+ def self.dir=(dir)
13
+ @@dir = dir
14
+ end
15
+
16
+ def self.dir
17
+ @@dir
18
+ end
19
+ end
20
+ end
@@ -3,44 +3,57 @@
3
3
  # github.com/joshbeam/angular_init
4
4
  # MIT License
5
5
 
6
- # Since ngi is an AngularJS tool and the users
7
- # are familiar with JavaScript, this module of classes
8
- # prints a string version of a Ruby hash or array
9
- # as it would appear in normal JavaScript syntax
10
- # For example:
11
- # { "hello" => "world" }
12
- # becomes:
13
- # { 'hello': 'world' }
14
- # and ["some","array"]
15
- # becomes:
16
- # ['some','array']
17
- module JSer
18
- def to_str
19
- to_s.gsub(/\"/, "'").gsub(/\=\>/, ': ')
20
- end
6
+ # Utilities
7
+ module Utils
8
+ # Since ngi is an AngularJS tool and the users
9
+ # are familiar with JavaScript, this module of classes
10
+ # prints a string version of a Ruby hash or array
11
+ # as it would appear in normal JavaScript syntax
12
+ # For example:
13
+ # { "hello" => "world" }
14
+ # becomes:
15
+ # { 'hello': 'world' }
16
+ # and ["some","array"]
17
+ # becomes:
18
+ # ['some','array']
19
+ module JSer
20
+ def to_str
21
+ to_s.gsub(/\"/, "'").gsub(/\=\>/, ': ')
22
+ end
21
23
 
22
- # A JSer class
23
- # Usage:
24
- # JSHash.new({"hello" => "world"}).to_str
25
- class JSHash < Hash
26
- def initialize(hash)
27
- super
28
- hash.each do |key, val|
29
- self[key] = val
24
+ # A JSer class
25
+ # Usage:
26
+ # JSHash.new({"hello" => "world"}).to_str
27
+ class JSHash < Hash
28
+ def initialize(hash)
29
+ super
30
+ hash.each do |key, val|
31
+ self[key] = val
32
+ end
30
33
  end
34
+
35
+ include JSer
31
36
  end
32
37
 
33
- include JSer
34
- end
38
+ # Another JSer class
39
+ # Usage:
40
+ # JSArray.new(["some","array"]).to_str
41
+ class JSArray < Array
42
+ def initialize(array)
43
+ super
44
+ end
35
45
 
36
- # Another JSer class
37
- # Usage:
38
- # JSArray.new(["some","array"]).to_str
39
- class JSArray < Array
40
- def initialize(array)
41
- super
46
+ include JSer
42
47
  end
43
48
 
44
- include JSer
49
+ module_function
50
+
51
+ def new(obj)
52
+ if obj.class == Array
53
+ return JSArray.new(obj)
54
+ elsif obj.class == Hash
55
+ return JSHash.new(obj)
56
+ end
57
+ end
45
58
  end
46
59
  end
@@ -0,0 +1,22 @@
1
+ # angular_init (short-name: ngi)
2
+ # Copyright 2015 Joshua Beam
3
+ # github.com/joshbeam/angular_init
4
+ # MIT License
5
+
6
+ # Utilities
7
+ module Utils
8
+ # This class is just a way to meaningfully
9
+ # collect an array of valid user inputs
10
+ # for use with OptionParser in bin/ngi
11
+ class UserInput
12
+ attr_reader :valid_inputs
13
+
14
+ def initialize(args)
15
+ @valid_inputs = args[:valid_inputs]
16
+ end
17
+
18
+ def valid?(input)
19
+ @valid_inputs.include?(input)
20
+ end
21
+ end
22
+ end
@@ -3,30 +3,13 @@
3
3
  # github.com/joshbeam/angular_init
4
4
  # MIT License
5
5
 
6
- require_relative 'command_parser'
7
- require_relative 'jser'
8
-
9
6
  # This module holds classes of basic utility
10
7
  # functions used throughout Ngi
11
8
  module Utils
12
- CommandParser = ::CommandParser
13
- JSArray = JSer::JSArray
14
- JSHash = JSer::JSHash
9
+ require_relative 'command_parser'
10
+ require_relative 'jser'
11
+ require_relative 'user_input'
12
+ require_relative 'current_dir'
15
13
 
16
14
  class AskLoop; end
17
-
18
- # This class is just a way to meaningfully
19
- # collect an array of valid user inputs
20
- # for use with OptionParser in bin/ngi
21
- class UserInput
22
- attr_reader :valid_inputs
23
-
24
- def initialize(args)
25
- @valid_inputs = args[:valid_inputs]
26
- end
27
-
28
- def valid?(input)
29
- @valid_inputs.include?(input)
30
- end
31
- end
32
15
  end
@@ -7,5 +7,5 @@
7
7
  # This uses semantic versioning.
8
8
  # See http://semver.org/
9
9
  module Ngi
10
- VERSION = '0.2.3'
10
+ VERSION = '0.3.0'
11
11
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.1"
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0") - %w(.gitignore ngi_example.gif pkg README.md)
17
+ spec.files = `git ls-files -z`.split("\x0") - %w(.gitignore ngi_example.gif pkg README.md TUTORIAL.md)
18
18
  spec.executables = ["ngi"]
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "memfs"
25
26
  end
@@ -0,0 +1,3 @@
1
+ aliases:
2
+ config:
3
+ - routes
@@ -0,0 +1,55 @@
1
+ -
2
+ name: "directive"
3
+ type: "script"
4
+ using: "default"
5
+ template: "basic.js"
6
+ -
7
+ name: "controller"
8
+ type: "script"
9
+ using: "default"
10
+ template: "basic.js"
11
+ -
12
+ name: "factory"
13
+ type: "script"
14
+ using: "default"
15
+ template: "basic.js"
16
+ -
17
+ name: "service"
18
+ type: "script"
19
+ using: "default"
20
+ template: "basic.js"
21
+ -
22
+ name: "config"
23
+ type: "script"
24
+ using: "default"
25
+ template: "config.js"
26
+ -
27
+ name: "run"
28
+ type: "script"
29
+ using: "default"
30
+ template: "config.js"
31
+ -
32
+ name: "routes"
33
+ type: "script"
34
+ using: "default"
35
+ template: "config.js"
36
+ -
37
+ name: "filter"
38
+ type: "script"
39
+ using: "default"
40
+ template: "basic.js"
41
+ -
42
+ name: "module"
43
+ type: "script"
44
+ using: "default"
45
+ template: "module.js"
46
+ -
47
+ name: "constant"
48
+ type: "script"
49
+ using: "default"
50
+ template: "constant.js"
51
+ -
52
+ name: "index"
53
+ type: "markup"
54
+ using: "default"
55
+ template: "index.html"
@@ -0,0 +1,2 @@
1
+ - language
2
+ - templates
@@ -0,0 +1,5 @@
1
+ script:
2
+ - coffee
3
+ - es5
4
+ markup:
5
+ - html
@@ -0,0 +1,4 @@
1
+ ---
2
+ language:
3
+ script: es5
4
+ markup: html
@@ -0,0 +1,20 @@
1
+ ((app) ->
2
+
3
+ 'use strict'
4
+
5
+ myDirective.$inject = ['someService', 'anotherService']
6
+
7
+ app.directive 'myDirective', myDirective
8
+
9
+ myDirective = (someService, anotherService) ->
10
+
11
+ d =
12
+ restrict: 'A'
13
+ link: link
14
+
15
+ link = (scope, element, attrs) ->
16
+
17
+ d
18
+
19
+
20
+ ) angular.module('myModule')
@@ -0,0 +1,13 @@
1
+ ;(function(app) {
2
+
3
+ 'use strict';
4
+
5
+ app.controller('MyController',MyController);
6
+
7
+ MyController.$inject = ['someService', 'anotherService', '$scope'];
8
+
9
+ function MyController(someService, anotherService, $scope) {
10
+
11
+ }
12
+
13
+ })(angular.module('myModule'));
@@ -0,0 +1,25 @@
1
+ ;(function(app) {
2
+
3
+ 'use strict';
4
+
5
+ app.directive('myDirective',myDirective);
6
+
7
+ myDirective.$inject = ['someService', 'anotherService'];
8
+
9
+ function myDirective(someService, anotherService) {
10
+
11
+ var d = {
12
+ restrict: 'A',
13
+ link: link
14
+ };
15
+
16
+ return d;
17
+
18
+ function link(scope, element, attrs) {
19
+
20
+ }
21
+
22
+
23
+ }
24
+
25
+ })(angular.module('myModule'));
@@ -0,0 +1,18 @@
1
+ ;(function(app) {
2
+
3
+ 'use strict';
4
+
5
+ app.filter('someFilter',someFilter);
6
+
7
+ someFilter.$inject = ['aService', 'andAnotherOne'];
8
+
9
+ function someFilter(aService, andAnotherOne) {
10
+
11
+
12
+ return function(input) {
13
+ return;
14
+ }
15
+
16
+ }
17
+
18
+ })(angular.module('myModule'));
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html ng-app="{{module}}">
3
+ <head>
4
+ <link href="" rel="stylesheet" type="text/css" />
5
+ <meta charset="utf-8">
6
+ <title></title>
7
+ </head>
8
+ <body>
9
+ <script src=""></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,23 @@
1
+ ((app) ->
2
+
3
+ 'use strict'
4
+
5
+ {{name}}.$inject = {{inject | array_string}}
6
+
7
+ app.{{type}} '{{name}}', {{name}}
8
+
9
+ {{name}} = ({{inject | comma_delimited_variables}}) ->
10
+ {% if directive %}
11
+ d =
12
+ restrict: 'A'
13
+ link: link
14
+
15
+ link = (scope, element, attrs) ->
16
+
17
+ d
18
+ {% endif directive %}
19
+ {% if filter %}
20
+ (input) ->
21
+ input
22
+ {% endif filter %}
23
+ ) angular.module('{{module}}')
@@ -0,0 +1,12 @@
1
+ ((app) ->
2
+
3
+ {{type}} = ({{inject | comma_delimited_variables}}) ->
4
+
5
+ 'use strict'
6
+
7
+ app.{{type}} {{type}}
8
+
9
+ config.$inject = {{inject | array_string}}
10
+ return
11
+
12
+ ) angular.module('{{module}}')
@@ -0,0 +1,7 @@
1
+ ((app) ->
2
+ 'use strict'
3
+
4
+ app.constant '{{name}}', {}
5
+ return
6
+
7
+ ) angular.module('{{module}}')
@@ -0,0 +1,7 @@
1
+ do (angular) ->
2
+
3
+ 'use strict'
4
+
5
+ angular.module '{{name}}', {{inject | array_string}}
6
+
7
+ return
@@ -0,0 +1,29 @@
1
+ ;(function(app) {
2
+
3
+ 'use strict';
4
+
5
+ app.{{type}}('{{name}}',{{name}});
6
+
7
+ {{name}}.$inject = {{inject | array_string}};
8
+
9
+ function {{name}}({{inject | comma_delimited_variables}}) {
10
+ {% if directive %}
11
+ var d = {
12
+ restrict: 'A',
13
+ link: link
14
+ };
15
+
16
+ return d;
17
+
18
+ function link(scope, element, attrs) {
19
+
20
+ }
21
+ {% endif directive %}
22
+ {% if filter %}
23
+ return function(input) {
24
+ return;
25
+ }
26
+ {% endif filter %}
27
+ }
28
+
29
+ })(angular.module('{{module}}'));