ngi 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -1
- data/bin/ngi +1 -31
- data/lib/config/{angular_init.config.json → backup/angular_init.config.json} +0 -0
- data/lib/config/backup/config.components.aliases.yml +3 -0
- data/lib/config/backup/config.components.yml +55 -0
- data/lib/config/backup/config.configurable.yml +1 -0
- data/lib/config/backup/config.languages.yml +5 -0
- data/lib/config/backup/config.yml +3 -0
- data/lib/config/backup/template-skeleton.js +93 -0
- data/lib/config/config.components.aliases.yml +3 -0
- data/lib/config/config.components.yml +55 -0
- data/lib/config/config.configurable.yml +2 -0
- data/lib/config/config.languages.yml +5 -0
- data/lib/config/config.yml +4 -0
- data/lib/ngi.rb +4 -7
- data/lib/ngi/configure.rb +236 -75
- data/lib/ngi/delegate.rb +3 -8
- data/lib/ngi/generator.rb +74 -46
- data/lib/ngi/parser.rb +97 -0
- data/lib/{templates → ngi/templates}/markup/html/default/index.html +0 -0
- data/lib/{templates → ngi/templates}/script/coffee/default/basic.js +0 -0
- data/lib/{templates → ngi/templates}/script/coffee/default/config.js +0 -0
- data/lib/{templates → ngi/templates}/script/coffee/default/constant.js +0 -0
- data/lib/{templates → ngi/templates}/script/coffee/default/module.js +0 -0
- data/lib/{templates → ngi/templates}/script/es5/default/basic.js +0 -0
- data/lib/{templates → ngi/templates}/script/es5/default/config.js +0 -0
- data/lib/{templates → ngi/templates}/script/es5/default/constant.js +0 -0
- data/lib/{templates → ngi/templates}/script/es5/default/module.js +0 -0
- data/lib/ngi/utils/command_parser.rb +90 -75
- data/lib/ngi/utils/current_dir.rb +20 -0
- data/lib/ngi/utils/jser.rb +45 -32
- data/lib/ngi/utils/user_input.rb +22 -0
- data/lib/ngi/utils/utils.rb +4 -21
- data/lib/ngi/version.rb +1 -1
- data/ngi.gemspec +2 -1
- data/test/config/config.components.aliases.yml +3 -0
- data/test/config/config.components.yml +55 -0
- data/test/config/config.configurable.yml +2 -0
- data/test/config/config.languages.yml +5 -0
- data/test/config/config.yml +4 -0
- data/test/finished_files/script/coffee/directive.finished.coffee +20 -0
- data/test/finished_files/script/es5/controller.finished.js +13 -0
- data/test/finished_files/script/es5/directive.finished.js +25 -0
- data/test/finished_files/script/es5/filter.finished.js +18 -0
- data/test/templates/markup/html/default/index.html +11 -0
- data/test/templates/script/coffee/default/basic.js +23 -0
- data/test/templates/script/coffee/default/config.js +12 -0
- data/test/templates/script/coffee/default/constant.js +7 -0
- data/test/templates/script/coffee/default/module.js +7 -0
- data/test/templates/script/es5/default/basic.js +29 -0
- data/test/templates/script/es5/default/config.js +13 -0
- data/test/templates/script/es5/default/constant.js +7 -0
- data/test/templates/script/es5/default/module.js +7 -0
- data/test/test_ngi.rb +274 -56
- data/test/testing_utils.rb +26 -0
- metadata +78 -36
- data/lib/dep/json.rb +0 -62
- data/lib/dep/json/add/bigdecimal.rb +0 -28
- data/lib/dep/json/add/complex.rb +0 -28
- data/lib/dep/json/add/core.rb +0 -11
- data/lib/dep/json/add/date.rb +0 -34
- data/lib/dep/json/add/date_time.rb +0 -50
- data/lib/dep/json/add/exception.rb +0 -31
- data/lib/dep/json/add/ostruct.rb +0 -31
- data/lib/dep/json/add/range.rb +0 -29
- data/lib/dep/json/add/rational.rb +0 -27
- data/lib/dep/json/add/regexp.rb +0 -30
- data/lib/dep/json/add/struct.rb +0 -30
- data/lib/dep/json/add/symbol.rb +0 -25
- data/lib/dep/json/add/time.rb +0 -38
- data/lib/dep/json/common.rb +0 -484
- data/lib/dep/json/ext.rb +0 -21
- data/lib/dep/json/ext/.keep +0 -0
- data/lib/dep/json/generic_object.rb +0 -70
- data/lib/dep/json/pure.rb +0 -21
- data/lib/dep/json/pure/generator.rb +0 -522
- data/lib/dep/json/pure/parser.rb +0 -359
- data/lib/dep/json/version.rb +0 -8
- 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
|
data/lib/ngi/utils/jser.rb
CHANGED
@@ -3,44 +3,57 @@
|
|
3
3
|
# github.com/joshbeam/angular_init
|
4
4
|
# MIT License
|
5
5
|
|
6
|
-
#
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# {
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
34
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/ngi/utils/utils.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
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
|
data/lib/ngi/version.rb
CHANGED
data/ngi.gemspec
CHANGED
@@ -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,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,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,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,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}}'));
|