ngi 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ngi +4 -2
- data/lib/ngi/configure.rb +122 -70
- data/lib/ngi/generator.rb +11 -22
- data/lib/ngi/version.rb +1 -1
- data/ngi.gemspec +2 -1
- data/test/sup/test.config.json +100 -0
- data/test/test_ngi.rb +91 -0
- metadata +21 -7
- data/.gitignore +0 -23
- data/README.md +0 -208
- data/lib/config/backup.angular_init.config.json +0 -72
- data/ngi_example.gif +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a59338ccc566495d2d77474f11a156be3eb2f94
|
4
|
+
data.tar.gz: 7981be7a346fb035357d197964f8e798612414cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae746334de0c717fb963b9af9bd41757bed32be13a7e4e5a50676141ea55c1de45d6e1da4bb506eeef3d173cc5d30f3bf7dac900304a1181a1cb87bebddf4ed6
|
7
|
+
data.tar.gz: bf02f0b2d863130e0f7c2e790f1af3348c0d1f47a1bf85ba28b28e86ff7d8e037ee5dfc0ba4889b0506cc2e8ebc9d0bec64baa790ab67a8f1a82b24fbc400d81
|
data/bin/ngi
CHANGED
@@ -12,9 +12,11 @@ require_relative '../lib/ngi/utils/utils'
|
|
12
12
|
# This class is just a wrapper for the main process
|
13
13
|
# of ngi
|
14
14
|
class Parser
|
15
|
+
CURRENT_DIR = File.dirname(__FILE__)
|
15
16
|
def self.parse(args)
|
16
17
|
p = Utils::CommandParser.new do |parser|
|
17
|
-
|
18
|
+
config_file = "#{CURRENT_DIR}/../lib/config/angular_init.config.json"
|
19
|
+
config = Ngi::Delegate::Configure.new(config_file).from_json
|
18
20
|
components = config['global']['components'].collect { |t| t['name'] }
|
19
21
|
types = Ngi::UserInput.new(valid_inputs: components)
|
20
22
|
|
@@ -27,7 +29,7 @@ class Parser
|
|
27
29
|
end
|
28
30
|
|
29
31
|
parser.on(['-o', '--options'], 'Configure ngi') do
|
30
|
-
Ngi::Delegate::Configure.run
|
32
|
+
Ngi::Delegate::Configure.run(write: true, file_path: config_file)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
data/lib/ngi/configure.rb
CHANGED
@@ -5,8 +5,7 @@
|
|
5
5
|
|
6
6
|
# CURRENT_DIR is defined in angualr_init.rb
|
7
7
|
|
8
|
-
|
9
|
-
require 'json'
|
8
|
+
require_relative '../dep/json'
|
10
9
|
require_relative 'utils/utils'
|
11
10
|
|
12
11
|
# Run the user through an interactive
|
@@ -18,6 +17,44 @@ class Configure
|
|
18
17
|
JSArray = Utils::JSArray
|
19
18
|
JSHash = Utils::JSHash
|
20
19
|
|
20
|
+
# Here, we implement the virtual class "Utils::AskLoop"
|
21
|
+
# (see src/ruby/utils/utils.rb)
|
22
|
+
# This implementation just creates a loop that asks
|
23
|
+
# for user input
|
24
|
+
class AskLoop < Utils::AskLoop
|
25
|
+
def self.ask(args)
|
26
|
+
puts "\nChoose from: #{args[:valid]}"
|
27
|
+
answer = $stdin.gets.strip
|
28
|
+
|
29
|
+
loop do
|
30
|
+
break if args[:check].include?(answer)
|
31
|
+
puts "Choose from: #{args[:valid]}\n(or press ctrl+c to exit)"
|
32
|
+
answer = $stdin.gets.strip
|
33
|
+
end
|
34
|
+
answer
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Holds all the configure functions for the properties
|
39
|
+
# that are configurable
|
40
|
+
class Configurable
|
41
|
+
def self.language(config)
|
42
|
+
v = JSArray.new(config.lang_types).to_str
|
43
|
+
type = AskLoop.ask(check: config.lang_types, valid: v)
|
44
|
+
|
45
|
+
curr_lang = config.global['language'][type]
|
46
|
+
lang_opts = config.languages[type].reject { |l| l if curr_lang == l }
|
47
|
+
|
48
|
+
v = JSArray.new(lang_opts).to_str
|
49
|
+
language = AskLoop.ask(check: lang_opts, valid: v)
|
50
|
+
|
51
|
+
answer = config.global['language']
|
52
|
+
answer[type] = language
|
53
|
+
|
54
|
+
answer
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
21
58
|
# Make Questioner accesible as in: Configure::Questioner.run()
|
22
59
|
# "Questioner" simply starts an interactive prompt to guide
|
23
60
|
# the user in configuring src/config/agular_init.config.json,
|
@@ -25,104 +62,95 @@ class Configure
|
|
25
62
|
# options (like language to use, templates, etc.)
|
26
63
|
class Questioner
|
27
64
|
attr_accessor :file
|
65
|
+
attr_reader :configurable_properties,
|
66
|
+
:languages, :global,
|
67
|
+
:configurable, :lang_types
|
28
68
|
|
29
69
|
def initialize(file)
|
30
70
|
@file = file
|
31
71
|
|
32
|
-
@
|
72
|
+
@global = @file['global']
|
33
73
|
# TODO: extend array with this inject function?
|
34
74
|
|
35
75
|
# The options for languages to use
|
36
|
-
@
|
76
|
+
@languages = @global['languages']
|
77
|
+
|
78
|
+
language_types = @languages.select do |type, languages|
|
79
|
+
type if languages.size > 1
|
80
|
+
end
|
81
|
+
# For example, ['script','markup']
|
82
|
+
@lang_types = language_types.collect { |type, _| type }.flatten
|
37
83
|
|
38
|
-
# The properties in key => value format
|
39
|
-
|
84
|
+
# The properties in key => value format
|
85
|
+
# of the properties the user can configure
|
86
|
+
@configurable = @global['configurable']
|
40
87
|
|
41
88
|
# An array of the properties that the user is allowed to configure,
|
42
89
|
# according to src/config/angular_init.config.json
|
43
|
-
@
|
90
|
+
@configurable_properties = @configurable.collect { |_k, v| v }
|
44
91
|
|
45
92
|
yield(self) if block_given?
|
46
93
|
end
|
47
94
|
|
48
95
|
def choose_configurable_property
|
49
|
-
|
50
|
-
|
51
|
-
puts "\nCurrent settings #{line_break}"
|
52
|
-
@CONFIGURABLE.each_with_index do |(_k, v), i|
|
53
|
-
puts "#{i + 1}) " + v.capitalize + ': ' + JSHash.new(@GLOBAL[v]).to_str
|
96
|
+
@configurable_properties.each_with_index do |p, i|
|
97
|
+
puts "#{i + 1}) #{p.capitalize}: #{JSHash.new(@global[p]).to_str}"
|
54
98
|
end
|
55
99
|
|
100
|
+
valid = JSArray.new(@configurable_properties).to_str
|
56
101
|
# return
|
57
|
-
AskLoop.ask(check: @
|
102
|
+
AskLoop.ask(check: @configurable_properties, valid: valid)
|
58
103
|
end
|
59
104
|
|
105
|
+
# This method delegates to the appropriate
|
106
|
+
# Configurable#<method> based on the property
|
107
|
+
# that the user has chosen to configure
|
108
|
+
# Returns: a Hash of the object, based on the
|
109
|
+
# from_json config object from config/angular_init.config.json
|
60
110
|
def configure_property(property)
|
61
111
|
case property
|
62
|
-
when @
|
63
|
-
|
64
|
-
|
65
|
-
type = AskLoop.ask(check: language_types, valid: JSArray.new(language_types).to_str)
|
66
|
-
|
67
|
-
language_opts = @LANGUAGES.reject { |t, languages| languages if t != type }[type].reject { |l| l == @GLOBAL['language'][type] }
|
68
|
-
|
69
|
-
language = AskLoop.ask(check: language_opts, valid: JSArray.new(language_opts).to_str)
|
70
|
-
|
71
|
-
answer = @GLOBAL['language']
|
72
|
-
|
73
|
-
answer[type] = language
|
112
|
+
when @configurable['language']
|
113
|
+
return Configurable.language(self)
|
74
114
|
end
|
75
|
-
|
76
|
-
# TODO: add ability to add templates
|
77
|
-
|
78
|
-
answer
|
79
115
|
end
|
80
116
|
|
81
117
|
def self.run(file)
|
82
118
|
questioner = Questioner.new(file) do |q|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
119
|
+
# First, the user chooses a property
|
120
|
+
# to configure (from a list of available
|
121
|
+
# properties that *can* be configured)
|
122
|
+
property = q.choose_configurable_property
|
123
|
+
|
124
|
+
# #configure_property spits out a hash
|
125
|
+
# as the result
|
126
|
+
result = q.configure_property(property)
|
127
|
+
|
128
|
+
# The hash that was spit out as the
|
129
|
+
# result is "merged" into the original
|
130
|
+
# Hash from_json object that came from
|
131
|
+
# config/angular_init.config.json
|
132
|
+
# and is inside of this instance of Questioner
|
133
|
+
q.file['global'][property] = result
|
134
|
+
|
135
|
+
# This just tells the user that we were
|
136
|
+
# successful
|
137
|
+
result_string_hash = JSHash.new(result).to_str
|
138
|
+
puts "#{property.capitalize} set to: #{result_string_hash}"
|
90
139
|
end
|
91
140
|
|
141
|
+
# Returns the file so that it can be used
|
142
|
+
# (For example, Configure might write this
|
143
|
+
# new hash as a JSON file to
|
144
|
+
# config/angular_init.config.json)
|
92
145
|
questioner.file
|
93
146
|
end
|
94
147
|
end
|
95
148
|
|
96
|
-
# Here, we implement the virtual class "Utils::AskLoop"
|
97
|
-
# (see src/ruby/utils/utils.rb)
|
98
|
-
# This implementation just creates a loop that asks
|
99
|
-
# for user input
|
100
|
-
class AskLoop < Utils::AskLoop
|
101
|
-
def self.ask(args)
|
102
|
-
puts "\n"
|
103
|
-
puts 'Choose from: ' + args[:valid]
|
104
|
-
|
105
|
-
answer = $stdin.gets.strip
|
106
|
-
|
107
|
-
loop do
|
108
|
-
if args[:check].include?(answer)
|
109
|
-
break
|
110
|
-
else
|
111
|
-
puts 'Choose from: ' + args[:valid]
|
112
|
-
puts '(or press ctrl+c to exit)'
|
113
|
-
answer = $stdin.gets.strip
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
answer
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
149
|
# The only thing we do here is load the JSON config file basically
|
122
150
|
# as just a string in JSON format.
|
123
151
|
# It will be converted to a Ruby hash in from_json below
|
124
|
-
def initialize
|
125
|
-
@location =
|
152
|
+
def initialize(location)
|
153
|
+
@location = location
|
126
154
|
@file = IO.read(@location)
|
127
155
|
|
128
156
|
yield(self) if block_given?
|
@@ -136,11 +164,15 @@ class Configure
|
|
136
164
|
# Generate a "prettified" JSON version of our
|
137
165
|
# newly updated Ruby hash with the user's options
|
138
166
|
def to_json
|
139
|
-
|
167
|
+
if @file.is_a? Hash
|
168
|
+
JSON.pretty_generate(@file)
|
169
|
+
else
|
170
|
+
@file
|
171
|
+
end
|
140
172
|
end
|
141
173
|
|
142
174
|
# Here we actually write the new JSON config file
|
143
|
-
# to
|
175
|
+
# to config/angular_init.config.json
|
144
176
|
def write
|
145
177
|
new_file = to_json
|
146
178
|
|
@@ -150,11 +182,31 @@ class Configure
|
|
150
182
|
end
|
151
183
|
end
|
152
184
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
185
|
+
# All this method does is handle retrieving
|
186
|
+
# the file from config/angular_init.config.json
|
187
|
+
# so that it can pass it off to Questioner,
|
188
|
+
# which can in turn change the Hash and pass it
|
189
|
+
# *back* to Configure, which can then choose
|
190
|
+
# to actually write the file in JSON format
|
191
|
+
# to config/angular_init.config.json
|
192
|
+
def self.run(args)
|
193
|
+
Configure.new(args[:file_path]) do |c|
|
194
|
+
# Get the JSON file as a Ruby Hash
|
195
|
+
json_file = c.from_json
|
196
|
+
|
197
|
+
# Pass it off to Questioner so that
|
198
|
+
# we can interact with the user and
|
199
|
+
# have the user configure the Hash.
|
200
|
+
# Then, we set the Configure file
|
201
|
+
# to the output of however the user
|
202
|
+
# configured it with Questioner
|
203
|
+
c.file = Configure::Questioner.run(json_file)
|
204
|
+
|
205
|
+
# We'll write the hash to
|
206
|
+
# config/angular_init.config.json.
|
207
|
+
# Configure#write converts the Hash
|
208
|
+
# to JSON and then uses File.write
|
209
|
+
c.write if args[:write] == true
|
158
210
|
end
|
159
211
|
end
|
160
212
|
end
|
data/lib/ngi/generator.rb
CHANGED
@@ -9,20 +9,18 @@ require_relative 'utils/utils'
|
|
9
9
|
class Generator
|
10
10
|
Utils = ::Utils
|
11
11
|
|
12
|
+
# Here we just implement
|
13
|
+
# the virtual class Utils::AskLoop
|
12
14
|
class AskLoop < Utils::AskLoop
|
13
15
|
def self.ask(args)
|
14
|
-
|
15
|
-
print args[:prompt]
|
16
|
+
print "\n#{args[:prompt]}"
|
16
17
|
|
17
18
|
answer = $stdin.gets.strip.downcase
|
18
19
|
|
19
20
|
loop do
|
20
|
-
if args[:check] == answer
|
21
|
-
|
22
|
-
|
23
|
-
puts 'Exited!'
|
24
|
-
exit
|
25
|
-
end
|
21
|
+
break if args[:check] == answer
|
22
|
+
puts 'Exited!'
|
23
|
+
exit
|
26
24
|
end
|
27
25
|
|
28
26
|
answer
|
@@ -39,18 +37,15 @@ class Generator
|
|
39
37
|
# Generator.new (the initialization function) is called in self.run
|
40
38
|
|
41
39
|
def initialize(args)
|
42
|
-
@type = args[:type]
|
43
|
-
@config = args[:config]['global']
|
40
|
+
@type, @config = args[:type], args[:config]['global']
|
44
41
|
|
45
|
-
|
46
|
-
component = all_components.find { |t| t['name'] == @type }
|
42
|
+
component = @config['components'].find { |t| t['name'] == @type }
|
47
43
|
|
48
44
|
# basically just rebuilding the object so we can use it here
|
49
45
|
@component = {
|
50
46
|
of_type: component['type'],
|
51
47
|
language: @config['language'][component['type']],
|
52
|
-
using: component['using'],
|
53
|
-
template: component['template']
|
48
|
+
using: component['using'], template: component['template']
|
54
49
|
}
|
55
50
|
|
56
51
|
template_dir = "#{CURRENT_DIR}/../templates/"
|
@@ -85,14 +80,8 @@ class Generator
|
|
85
80
|
# REVIEW: use symbols instead of strings?
|
86
81
|
special = %w(routes controller).include?(@type)
|
87
82
|
auto_injections = [
|
88
|
-
{
|
89
|
-
|
90
|
-
service: '$routeProvider'
|
91
|
-
},
|
92
|
-
{
|
93
|
-
for_type: 'controller',
|
94
|
-
service: '$scope'
|
95
|
-
}
|
83
|
+
{ for_type: 'routes', service: '$routeProvider' },
|
84
|
+
{ for_type: 'controller', service: '$scope' }
|
96
85
|
]
|
97
86
|
|
98
87
|
injection = special ? auto_injections.select { |inj| inj[:for_type] == @type }[0][:service] : nil
|
data/lib/ngi/version.rb
CHANGED
data/ngi.gemspec
CHANGED
@@ -14,11 +14,12 @@ 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")
|
17
|
+
spec.files = `git ls-files -z`.split("\x0") - %w(.gitignore ngi_example.gif pkg README.md)
|
18
18
|
spec.executables = ["ngi"]
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "minitest"
|
24
25
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
{
|
2
|
+
"global": {
|
3
|
+
"configurable": {
|
4
|
+
"language": "language"
|
5
|
+
},
|
6
|
+
"menus": {
|
7
|
+
"options": "-options"
|
8
|
+
},
|
9
|
+
"languages": {
|
10
|
+
"script": [
|
11
|
+
"es5",
|
12
|
+
"coffee"
|
13
|
+
],
|
14
|
+
"markup": [
|
15
|
+
"html"
|
16
|
+
]
|
17
|
+
},
|
18
|
+
"language": {
|
19
|
+
"script": "es5",
|
20
|
+
"markup": "html"
|
21
|
+
},
|
22
|
+
"types": {
|
23
|
+
"script": "script",
|
24
|
+
"markup": "markup"
|
25
|
+
},
|
26
|
+
"components": [
|
27
|
+
{
|
28
|
+
"name": "directive",
|
29
|
+
"type": "script",
|
30
|
+
"using": "default",
|
31
|
+
"template": "basic.js"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"name": "controller",
|
35
|
+
"type": "script",
|
36
|
+
"using": "default",
|
37
|
+
"template": "basic.js"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "factory",
|
41
|
+
"type": "script",
|
42
|
+
"using": "default",
|
43
|
+
"template": "basic.js"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "service",
|
47
|
+
"type": "script",
|
48
|
+
"using": "default",
|
49
|
+
"template": "basic.js"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"name": "config",
|
53
|
+
"type": "script",
|
54
|
+
"using": "default",
|
55
|
+
"template": "config.js"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"name": "run",
|
59
|
+
"type": "script",
|
60
|
+
"using": "default",
|
61
|
+
"template": "config.js"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"name": "routes",
|
65
|
+
"type": "script",
|
66
|
+
"using": "default",
|
67
|
+
"template": "config.js"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"name": "filter",
|
71
|
+
"type": "script",
|
72
|
+
"using": "default",
|
73
|
+
"template": "basic.js"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"name": "module",
|
77
|
+
"type": "script",
|
78
|
+
"using": "default",
|
79
|
+
"template": "module.js"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"name": "constant",
|
83
|
+
"type": "script",
|
84
|
+
"using": "default",
|
85
|
+
"template": "constant.js"
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"name": "index",
|
89
|
+
"type": "markup",
|
90
|
+
"using": "default",
|
91
|
+
"template": "index.html"
|
92
|
+
}
|
93
|
+
],
|
94
|
+
"aliases": {
|
95
|
+
"config": [
|
96
|
+
"routes"
|
97
|
+
]
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
data/test/test_ngi.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../lib/ngi'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
describe Ngi do
|
6
|
+
DIR = File.dirname(__FILE__)
|
7
|
+
|
8
|
+
describe Ngi::Delegate::Configure do
|
9
|
+
before do
|
10
|
+
@path = "#{DIR}/sup/test.config.json"
|
11
|
+
@config = Ngi::Delegate::Configure.new(@path)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'when initialized' do
|
15
|
+
it 'must read the file given from the path' do
|
16
|
+
@config.file.must_equal IO.read(@path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#from_json' do
|
21
|
+
it 'must convert the file to a Ruby hash' do
|
22
|
+
file_parsed_from_json_to_ruby = @config.from_json
|
23
|
+
regular_file = IO.read(@path)
|
24
|
+
|
25
|
+
file_parsed_from_json_to_ruby.must_equal JSON.parse(regular_file)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# describe '#self.run' do
|
30
|
+
# it 'must create an instance of Configure' do
|
31
|
+
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
|
35
|
+
describe '#to_json' do
|
36
|
+
it 'must convert the file to a prettified JSON file if file is a hash' do
|
37
|
+
regular_file = IO.read(@path)
|
38
|
+
|
39
|
+
# set the file to a Ruby hash version of the JSON file
|
40
|
+
@config.file = @config.from_json
|
41
|
+
|
42
|
+
# convert the file back to a prettified JSON representation
|
43
|
+
# if the file was a Ruby hash
|
44
|
+
back_to_json = @config.to_json
|
45
|
+
|
46
|
+
back_to_json.must_equal regular_file
|
47
|
+
|
48
|
+
# set the file to a JSON version
|
49
|
+
@config.file = regular_file
|
50
|
+
attempt_to_generate_json = @config.to_json
|
51
|
+
|
52
|
+
attempt_to_generate_json.must_equal regular_file
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '::Configurable' do
|
57
|
+
before do
|
58
|
+
c = Ngi::Delegate::Configure
|
59
|
+
@hash_config_file = @config.from_json
|
60
|
+
@questioner = c::Questioner.new(@hash_config_file)
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#language' do
|
64
|
+
it 'must output a hash' do
|
65
|
+
output = Configure::Configurable.language(@questioner)
|
66
|
+
|
67
|
+
output.must_be_instance_of Hash
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '::Questioner' do
|
73
|
+
before do
|
74
|
+
c = Ngi::Delegate::Configure
|
75
|
+
@hash_config_file = @config.from_json
|
76
|
+
@configurable_properties = @hash_config_file['global']['configurable'].collect { |_, v| v }
|
77
|
+
@questioner = c::Questioner.new(@hash_config_file)
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#initialize' do
|
81
|
+
it 'must set its file in JSON format' do
|
82
|
+
@questioner.file.must_equal @config.from_json
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'must collect all the configurable properties in an array' do
|
86
|
+
@questioner.configurable_properties.must_equal @configurable_properties
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ngi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Beam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: This tool can make (for example) an AngularJS controller template file
|
42
56
|
for you (.js), so that whenever you want to make a new controller for your app,
|
43
57
|
you don't have to type the same starting code over and over again (by the way, this
|
@@ -53,14 +67,11 @@ executables:
|
|
53
67
|
extensions: []
|
54
68
|
extra_rdoc_files: []
|
55
69
|
files:
|
56
|
-
- ".gitignore"
|
57
70
|
- Gemfile
|
58
71
|
- LICENSE.txt
|
59
|
-
- README.md
|
60
72
|
- Rakefile
|
61
73
|
- bin/ngi
|
62
74
|
- lib/config/angular_init.config.json
|
63
|
-
- lib/config/backup.angular_init.config.json
|
64
75
|
- lib/dep/json.rb
|
65
76
|
- lib/dep/json/add/bigdecimal.rb
|
66
77
|
- lib/dep/json/add/complex.rb
|
@@ -101,7 +112,8 @@ files:
|
|
101
112
|
- lib/templates/script/es5/default/constant.js
|
102
113
|
- lib/templates/script/es5/default/module.js
|
103
114
|
- ngi.gemspec
|
104
|
-
-
|
115
|
+
- test/sup/test.config.json
|
116
|
+
- test/test_ngi.rb
|
105
117
|
homepage: https://github.com/joshbeam/angular_init
|
106
118
|
licenses:
|
107
119
|
- MIT
|
@@ -127,4 +139,6 @@ signing_key:
|
|
127
139
|
specification_version: 4
|
128
140
|
summary: Speed up AngularJS development by creating templates for all your components
|
129
141
|
from the command line.
|
130
|
-
test_files:
|
142
|
+
test_files:
|
143
|
+
- test/sup/test.config.json
|
144
|
+
- test/test_ngi.rb
|
data/.gitignore
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
23
|
-
.DS_Store
|
data/README.md
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
# angular_init 0.2.2
|
2
|
-
|
3
|
-
## Quick Start
|
4
|
-
|
5
|
-
ngi creates AngularJS templates for you from the command line.
|
6
|
-
|
7
|
-
**Get up and running in seconds:**
|
8
|
-
|
9
|
-
[![Gem Version](https://badge.fury.io/rb/ngi.svg)](http://badge.fury.io/rb/ngi)
|
10
|
-
|
11
|
-
```shell
|
12
|
-
$ gem install ngi
|
13
|
-
$ cd ~/MyAwesomeApp # => go to your app
|
14
|
-
$ ngi controller # => creates a new AngularJS controller
|
15
|
-
```
|
16
|
-
|
17
|
-
## Know everything
|
18
|
-
|
19
|
-
<a href="http://joshbeam.github.io/angular_init">Website</a>
|
20
|
-
|
21
|
-
**Having issues?** Email me (Josh) at <a href="mailto:frontendcollisionblog@gmail.com">frontendcollisionblog@gmail.com</a>. I'll usually respond within an hour or so. You can also report a bug by opening a new issue through GitHub, or if you want to add a feature yourself, just fork and submit a pull request!
|
22
|
-
|
23
|
-
**What's new in 0.2.x?**
|
24
|
-
- Install it as a gem (`gem install ngi`)
|
25
|
-
- You can now make an `index` boilerplate HTML page (`ngi index`)
|
26
|
-
- Use `ngi -h` to see all commands
|
27
|
-
|
28
|
-
## In simple terms:
|
29
|
-
|
30
|
-
This tool (`ngi`) can make (for example) an AngularJS controller template file for you (`.js`), so that **whenever you want to make a new controller for your app, you don't have to type the same starting code over and over again** (by the way, this tool doesn't only create controllers. It does directives, filters... almost anything).
|
31
|
-
|
32
|
-
## Why use `ngi` (and not something else)?
|
33
|
-
|
34
|
-
**`ngi` has one task, and one task only, which makes it lightweight and specialized**. Most AngularJS developers are probably using the command line already (Gulp, Bower, npm, Git, etc.), so why not use the command line to streamline your code-writing too?
|
35
|
-
|
36
|
-
Type less, write more AngularJS! Use `ngi`, the simple template generator.
|
37
|
-
|
38
|
-
![Example](https://github.com/joshbeam/angular_init/blob/master/ngi_example.gif "Example")
|
39
|
-
|
40
|
-
# Table of Contents
|
41
|
-
|
42
|
-
- [Sample Usage][sample-usage]
|
43
|
-
- [Features][features]
|
44
|
-
- [Install in 1 step][install]
|
45
|
-
- [How to use it (docs)][commands]
|
46
|
-
- [FAQ][faq]
|
47
|
-
- [Technical Info][tech-info]
|
48
|
-
|
49
|
-
# Sample Usage
|
50
|
-
|
51
|
-
After you [do the 1-step installation][install] of `ngi` (the short-name for the shell script of `angular_init`), go to where your site is at (in this case, `~/MyAwesomeApp`). When you're in your site's project directory, just type `ngi <component>` to create a new JavaScript file for you!
|
52
|
-
|
53
|
-
## Command line
|
54
|
-
|
55
|
-
```shell
|
56
|
-
~/MyAwesomeApp $ ngi controller # this will create a controller!
|
57
|
-
|
58
|
-
# you'll be prompted for some quick info
|
59
|
-
[?] New file name: myAwesome.controller.js
|
60
|
-
[?] Module name: myModule
|
61
|
-
[?] Controller name: MyAwesomeController
|
62
|
-
[?] Inject (already injected $scope): $route
|
63
|
-
|
64
|
-
# all done!
|
65
|
-
```
|
66
|
-
|
67
|
-
## Output (new boilerplate code)
|
68
|
-
|
69
|
-
```javascript
|
70
|
-
// ~/MyAwesomeApp/myAwesome.controller.js
|
71
|
-
|
72
|
-
;(function(app) {
|
73
|
-
|
74
|
-
'use strict';
|
75
|
-
|
76
|
-
app.controller('MyAwesomeController',MyAwesomeController);
|
77
|
-
|
78
|
-
MyAwesomeController.$inject = ['$route', '$scope'];
|
79
|
-
|
80
|
-
function MyAwesomeController($route, $scope) {
|
81
|
-
|
82
|
-
}
|
83
|
-
|
84
|
-
})(angular.module('myModule'));
|
85
|
-
```
|
86
|
-
|
87
|
-
By the way, the output of this little tool is meant to follow [John Papa's AngularJS Style Guide][style-guide].
|
88
|
-
|
89
|
-
# Features
|
90
|
-
|
91
|
-
## Current features
|
92
|
-
|
93
|
-
- Create a module, directive, controller, filter, run, config, "routes" config, constant, service, factory, or index HTML page by saying `ngi <component>`, where `<component>` is any of the above types (module, directive, etc.)
|
94
|
-
- Current languages that have default templates: CoffeeScript, ECMAScript5 (choose your language with `ngi --config (or -c)`)
|
95
|
-
|
96
|
-
## Coming soon
|
97
|
-
|
98
|
-
- Add custom templates and languages
|
99
|
-
- Possible Node.js version
|
100
|
-
|
101
|
-
Feel free to fork the project or get <a href="http://frontendcollisionblog.com/about">in touch with Josh (me)</a> with any feature requests!
|
102
|
-
|
103
|
-
# Installation (in 1 step)
|
104
|
-
|
105
|
-
**Dependencies** [Ruby 2.1.0][ruby] and [RubyGems][rubygems] (optional [Bundler][bundler])
|
106
|
-
|
107
|
-
Add this line to your application's Gemfile:
|
108
|
-
|
109
|
-
gem 'ngi'
|
110
|
-
|
111
|
-
And then execute:
|
112
|
-
|
113
|
-
$ bundle
|
114
|
-
|
115
|
-
Or install it yourself as:
|
116
|
-
|
117
|
-
$ gem install ngi
|
118
|
-
|
119
|
-
# Commands
|
120
|
-
|
121
|
-
```shell
|
122
|
-
~/MyAwesomeApp $ ngi controller # => controller
|
123
|
-
~/MyAwesomeApp $ ngi directive # => directive
|
124
|
-
~/MyAwesomeApp $ ngi factory # => factory
|
125
|
-
~/MyAwesomeApp $ ngi service # => service (same as factory)
|
126
|
-
~/MyAwesomeApp $ ngi constant # => constant
|
127
|
-
~/MyAwesomeApp $ ngi run # => a run block
|
128
|
-
~/MyAwesomeApp $ ngi config # => a config block
|
129
|
-
~/MyAwesomeApp $ ngi routes # => a config block with $routeProvider injected
|
130
|
-
~/MyAwesomeApp $ ngi module # => module (you can inject dependencies too)
|
131
|
-
~/MyAwesomeApp $ ngi filter # => filter
|
132
|
-
|
133
|
-
# or
|
134
|
-
|
135
|
-
~/MyAwesomeApp $ ngi index # => an index page in HTML
|
136
|
-
|
137
|
-
# or
|
138
|
-
|
139
|
-
# use either --options or -o
|
140
|
-
~/MyAwesomeApp $ ngi --options # => choose your language to use (CoffeeScript or ECMAScript5)
|
141
|
-
```
|
142
|
-
|
143
|
-
# FAQ
|
144
|
-
|
145
|
-
**1. Can you explain why the module name is passed as the argument to the IIFE (in the default template)?**
|
146
|
-
|
147
|
-
- If you're using a JSHint plug-in, it will only say 'angular is not defined' in one place
|
148
|
-
- Eliminates the clutter of declaring something like `var app = angular.module('myModule')`
|
149
|
-
- Something like `angular.module('myModule')` cannot be minified, but the argument `app` can (only an issue if the full module getter happens multiple time)
|
150
|
-
- Streamlines the pattern across all of the templates
|
151
|
-
|
152
|
-
**2. Why are you using `$inject`?**
|
153
|
-
|
154
|
-
Check out [John Papa's Style Guide][style-guide].
|
155
|
-
|
156
|
-
**3. Why are you following the snake-case convention (`angular_init`) and not camelCase (`angularInit`) if this is a JavaScript project?**
|
157
|
-
|
158
|
-
The command line tool itself is written in <a href="https://www.ruby-lang.org/en/">Ruby</a>, and the <a href="https://github.com/bbatsov/ruby-style-guide#snake-case-files">convention</a> is to use snake-case for class file naming.
|
159
|
-
|
160
|
-
*For other questions and comments, check out this <a href="http://www.reddit.com/r/angularjs/comments/30ydha/command_line_tool_to_create_angularjs_controllers/">Reddit discussion</a> about `ngi` (feel free to post your own question too). Or, open a new issue on GitHub.*
|
161
|
-
|
162
|
-
# Technical Information
|
163
|
-
|
164
|
-
**Version** 0.2.2 (uses <a href="http://semver.org/">Semantic Versioning</a>)
|
165
|
-
|
166
|
-
**Language** Ruby
|
167
|
-
|
168
|
-
**Requirements** Only tested with `ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]`. Compatibility with previous versions of Ruby cannot be guaranteed.
|
169
|
-
|
170
|
-
<hr>
|
171
|
-
|
172
|
-
**Disclaimer**
|
173
|
-
|
174
|
-
`angular_init` and `ngi` and the author (Joshua Beam) are not directly associated with <a href="http://angularjs.org">AngularJS</a>.
|
175
|
-
|
176
|
-
**Copyright (c) 2015 Joshua Beam** — <a href="http://frontendcollisionblog.com">Front End Collision</a>
|
177
|
-
|
178
|
-
MIT License
|
179
|
-
|
180
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
181
|
-
a copy of this software and associated documentation files (the
|
182
|
-
"Software"), to deal in the Software without restriction, including
|
183
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
184
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
185
|
-
permit persons to whom the Software is furnished to do so, subject to
|
186
|
-
the following conditions:
|
187
|
-
|
188
|
-
The above copyright notice and this permission notice shall be
|
189
|
-
included in all copies or substantial portions of the Software.
|
190
|
-
|
191
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
192
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
193
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
194
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
195
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
196
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
197
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
198
|
-
|
199
|
-
[install]: #installation-in-1-step
|
200
|
-
[sample-usage]: #sample-usage
|
201
|
-
[features]: #features
|
202
|
-
[commands]: #commands
|
203
|
-
[faq]: #faq
|
204
|
-
[tech-info]: #technical-information
|
205
|
-
[style-guide]: https://github.com/johnpapa/angular-styleguide
|
206
|
-
[rubygems]: https://rubygems.org/pages/download
|
207
|
-
[ruby]: https://www.ruby-lang.org/en/downloads/
|
208
|
-
[bundler]: http://bundler.io/
|
@@ -1,72 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"global": {
|
3
|
-
"configurable": {
|
4
|
-
"language": "language"
|
5
|
-
},
|
6
|
-
"menus": {
|
7
|
-
"options": "-options"
|
8
|
-
},
|
9
|
-
"languages": [
|
10
|
-
"es5",
|
11
|
-
"coffee"
|
12
|
-
],
|
13
|
-
"language": "es5",
|
14
|
-
"types": [
|
15
|
-
{
|
16
|
-
"name": "directive",
|
17
|
-
"source": "default",
|
18
|
-
"template": "basic.js"
|
19
|
-
},
|
20
|
-
{
|
21
|
-
"name": "controller",
|
22
|
-
"source": "default",
|
23
|
-
"template": "basic.js"
|
24
|
-
},
|
25
|
-
{
|
26
|
-
"name": "factory",
|
27
|
-
"source": "default",
|
28
|
-
"template": "basic.js"
|
29
|
-
},
|
30
|
-
{
|
31
|
-
"name": "service",
|
32
|
-
"source": "default",
|
33
|
-
"template": "basic.js"
|
34
|
-
},
|
35
|
-
{
|
36
|
-
"name": "config",
|
37
|
-
"source": "default",
|
38
|
-
"template": "config.js"
|
39
|
-
},
|
40
|
-
{
|
41
|
-
"name": "run",
|
42
|
-
"source": "default",
|
43
|
-
"template": "config.js"
|
44
|
-
},
|
45
|
-
{
|
46
|
-
"name": "routes",
|
47
|
-
"source": "default",
|
48
|
-
"template": "config.js"
|
49
|
-
},
|
50
|
-
{
|
51
|
-
"name": "filter",
|
52
|
-
"source": "default",
|
53
|
-
"template": "basic.js"
|
54
|
-
},
|
55
|
-
{
|
56
|
-
"name": "module",
|
57
|
-
"source": "default",
|
58
|
-
"template": "module.js"
|
59
|
-
},
|
60
|
-
{
|
61
|
-
"name": "constant",
|
62
|
-
"source": "default",
|
63
|
-
"template": "constant.js"
|
64
|
-
}
|
65
|
-
],
|
66
|
-
"aliases": {
|
67
|
-
"config": [
|
68
|
-
"routes"
|
69
|
-
]
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
data/ngi_example.gif
DELETED
Binary file
|