arethusa-cli 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5c2ac3469acd770f86bb5129dc61fb5aa88f5e9
4
- data.tar.gz: a9436334a79adc249731d5a827c696db057e61dc
3
+ metadata.gz: 9eb723e4851d58b50e479cec50f01c0f71d039f9
4
+ data.tar.gz: 51265087589544548b7d211fbd18df685083af46
5
5
  SHA512:
6
- metadata.gz: 90e7a1fe4479bfcfe24f45a317901943e072c934d9550d2479e43bf49536d720cf4a6eaa5a3b76d5fbfabe8663bea0f0b7f9e3dbdc82dbc0f955f8e8a085d383
7
- data.tar.gz: 39fa70bfcf8b020fc89fc0589972eac5127fa37a639e75a5cdb7978dac6a3a6ca3e8edda366190bcde9ec869a55702fe4e46b079bcffaa94c706bf3d7dd3aaa8
6
+ metadata.gz: 2cfe9c23328d69e48b8eca723754462e1239e9c3997250ea2887bfd4bc5178da148466fbe3025e6cd93407df5e240b1583d3fabff3feda846dc8fb5d5fc7b88e
7
+ data.tar.gz: b8ddfc16ffec9107f8865932f958ca78aa39dfeb63e559bcc54d61540cb071690321989d085cf6eae2fd66e39f8eb38a5992cd519abb9131951af9faebce2c51
@@ -9,7 +9,6 @@ class Arethusa::CLI
9
9
  end
10
10
 
11
11
  include Thor::Actions
12
- attr_reader :namespace
13
12
 
14
13
  desc 'plugin NAME', 'Creates a new Arethusa plugin skeleton'
15
14
  method_option :namespace, aliases: '-n', default: 'arethusa',
@@ -23,7 +22,6 @@ class Arethusa::CLI
23
22
  create_directories
24
23
  create_files
25
24
 
26
- try('insert module into arethusa', :add_module)
27
25
  try('add to Gruntfile', :add_to_gruntfile)
28
26
  try('add module to index.html', :add_to_index)
29
27
 
@@ -43,26 +41,25 @@ class Arethusa::CLI
43
41
  @name = name
44
42
  @namespace = options[:namespace]
45
43
 
46
- create_spec_file
44
+ empty_directory(spec_dir)
45
+ create_spec
47
46
 
48
47
  commit_changes if options[:commit]
49
48
  say_status(:success, "Created spec file for #{namespaced_name}")
50
49
  end
51
50
 
52
- no_commands do
53
- def name(js = false)
54
- if js
55
- to_camelcase(@name)
56
- else
57
- @name
58
- end
59
- end
51
+ desc 'retriever MODULE NAME', 'Create a new Arethusa retriever skeleton'
52
+ def retriever(mod, name)
53
+ @module = mod
54
+ @name = name
60
55
 
61
- def to_camelcase(str)
62
- parts = str.split('_')
63
- first = parts.shift
64
- "#{first}#{parts.map(&:capitalize).join}"
65
- end
56
+ create_retriever
57
+ create_retriever_spec
58
+ end
59
+
60
+ no_commands do
61
+ include Helpers::NameHandler
62
+ include Helpers::DirectoriesAndFiles
66
63
 
67
64
  def try(message, method)
68
65
  puts
@@ -70,10 +67,6 @@ class Arethusa::CLI
70
67
  send(method)
71
68
  end
72
69
 
73
- def namespaced_name(js = false)
74
- [namespace, name(js)].compact.join('.')
75
- end
76
-
77
70
  DIRECTORIES = %w{ plugin_dir template_dir }
78
71
  def create_directories
79
72
  DIRECTORIES.each { |dir| empty_directory(send(dir)) }
@@ -85,33 +78,6 @@ class Arethusa::CLI
85
78
  create_html_template
86
79
  end
87
80
 
88
- def create_module
89
- template('templates/module.tt', js_dir("#{namespaced_name}.js"))
90
- end
91
-
92
- def create_service
93
- template('templates/service.tt', plugin_dir("#{name}.js"))
94
- end
95
-
96
- def create_html_template
97
- template('templates/html_template.tt', html_template_file)
98
- end
99
-
100
- def create_spec_file
101
- empty_directory(spec_dir)
102
- template('templates/plugin_spec.tt', spec_dir("#{name}_spec.js"))
103
- end
104
-
105
- def add_module
106
- insert_into_file(arethusa_main, after: /arethusa\.core',\n/, force: false) do
107
- " '#{namespaced_name(true)}',\n"
108
- end
109
- end
110
-
111
- def arethusa_main
112
- js_dir('arethusa.js')
113
- end
114
-
115
81
  def add_to_gruntfile
116
82
  insert_into_file(gruntfile, after: /var arethusaModules.*?\n/, force: false) do
117
83
  %[ "#{namespaced_name}",\n]
@@ -145,30 +111,6 @@ It could look like this:
145
111
  puts text.lines.map { |line| "\t#{line}" }.join
146
112
  end
147
113
 
148
- def plugin_dir(file = '')
149
- File.join(js_dir, namespaced_name, file)
150
- end
151
-
152
- def template_dir(file = '')
153
- File.join(temp_dir, namespaced_name, file)
154
- end
155
-
156
- def html_template_file
157
- template_dir("#{name}.html")
158
- end
159
-
160
- def js_dir(file = '')
161
- File.join(destination_root, 'app/js', file)
162
- end
163
-
164
- def temp_dir
165
- File.join(destination_root, 'app/templates')
166
- end
167
-
168
- def spec_dir(file = '')
169
- File.join(destination_root, 'spec', namespaced_name, file)
170
- end
171
-
172
114
  def commit_changes(spec = false)
173
115
  sp = spec ? "spec " : ""
174
116
 
@@ -0,0 +1,101 @@
1
+ class Arethusa::CLI
2
+ module Helpers
3
+ module DirectoriesAndFiles
4
+ def template_path(name)
5
+ File.join(File.expand_path('../../templates/', __FILE__), name)
6
+ end
7
+
8
+ def plugin_dir(file = '')
9
+ File.join(js_dir, namespaced_name, file)
10
+ end
11
+
12
+ def template_dir(file = '')
13
+ File.join(temp_dir, namespaced_name, file)
14
+ end
15
+
16
+ def html_template_file
17
+ template_dir("#{name}.html")
18
+ end
19
+
20
+ def js_dir(file = '')
21
+ File.join(destination_root, 'app/js', file)
22
+ end
23
+
24
+ def temp_dir
25
+ File.join(destination_root, 'app/templates')
26
+ end
27
+
28
+ def spec_dir(file = '')
29
+ File.join(destination_root, 'spec', mod || namespaced_name, file)
30
+ end
31
+
32
+ def css_dir(file = '')
33
+ File.join(destination_root, 'app/css', file)
34
+ end
35
+
36
+ def conf_dir(file = '')
37
+ File.join(destination_root, 'app/static', 'configs', file)
38
+ end
39
+
40
+ def dist_dir(file = '')
41
+ File.join(destination_root, 'dist', file)
42
+ end
43
+
44
+ def create_module
45
+ template(template_path('module'), js_dir("#{namespaced_name}.js"))
46
+ end
47
+
48
+ def create_service
49
+ template(template_path('service'), plugin_dir("#{name}.js"))
50
+ end
51
+
52
+ def create_html_template
53
+ template(template_path('html_template'), html_template_file)
54
+ end
55
+
56
+ def create_spec
57
+ template(template_path('plugin_spec'), spec_dir("#{name}_spec.js"))
58
+ end
59
+
60
+ def create_gitignore
61
+ template(template_path('gitignore'), '.gitignore')
62
+ end
63
+
64
+ def create_jshintrc
65
+ template(template_path('jshintrc'), '.jshintrc')
66
+ end
67
+
68
+ def create_package
69
+ template(template_path('package'), 'package.json')
70
+ end
71
+
72
+ def create_bower
73
+ template(template_path('bower'), 'bower.json')
74
+ end
75
+
76
+ def create_gruntfile
77
+ template(template_path('gruntfile'), 'Gruntfile.js')
78
+ end
79
+
80
+ def create_scss
81
+ template(template_path('scss'), css_dir("#{namespaced_name}.scss"))
82
+ end
83
+
84
+ def create_index_file
85
+ template(template_path('index'), "app/index.html")
86
+ end
87
+
88
+ def create_conf_file
89
+ template(template_path('conf'), conf_dir('staging.json'))
90
+ end
91
+
92
+ def create_retriever
93
+ template(template_path('retriever'), js_dir(File.join(mod, "#{name}.js")))
94
+ end
95
+
96
+ def create_retriever_spec
97
+ template(template_path('retriever_spec'), spec_dir("#{name}_spec.js"))
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,30 @@
1
+ class Arethusa::CLI
2
+ module Helpers
3
+ module NameHandler
4
+ def namespaced_name(js = false, no_default = false)
5
+ ns = namespace(js);
6
+ ns = nil if no_default && @namespace == 'arethusa'
7
+ [ns, name(js)].compact.join('.')
8
+ end
9
+
10
+ def namespace(js = false)
11
+ js ? to_camelcase(@namespace) : @namespace
12
+ end
13
+
14
+ def name(js = false, capitalize = false)
15
+ js ? to_camelcase(@name, capitalize) : @name
16
+ end
17
+
18
+ def mod(js = false)
19
+ js ? to_camelcase(@module) : @module
20
+ end
21
+
22
+ def to_camelcase(str, capitalize = false)
23
+ parts = str.split('_')
24
+ first = parts.shift
25
+ first.capitalize! if capitalize
26
+ "#{first}#{parts.map(&:capitalize).join}"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ {
2
+ "name" : "<%= namespaced_name %>",
3
+ "version" : "0.0.1",
4
+ "dependencies": {
5
+ "arethusa" : "latin-language-toolkit/arethusa#master"
6
+ },
7
+ "resolutions" : {
8
+ "angular" : "1.2.17"
9
+ }
10
+ }
@@ -0,0 +1,127 @@
1
+ {
2
+ "main" : {
3
+ "debug" : true,
4
+ "showKeys" : true,
5
+ "template" : "templates/main_grid.html",
6
+ "retrievers" : {
7
+ "TreebankRetriever" : {
8
+ "resource" : "fakePerseids",
9
+ "docIdentifier" : "treebank",
10
+ "preselector" : "w"
11
+ }
12
+ },
13
+ "persisters" : {
14
+ "TreebankPersister" : {
15
+ "resource" : "fakePerseids",
16
+ "docIdentifier" : "treebank"
17
+ }
18
+ },
19
+ "plugins" : [
20
+ "text",
21
+ "artificialToken",
22
+ "search",
23
+ "morph",
24
+ "relation",
25
+ "depTree",
26
+ "review",
27
+ "history",
28
+ "comments"
29
+ ]
30
+ },
31
+
32
+ "navbar" : {
33
+ "template" : "templates/navbar1.html",
34
+ "search" : true,
35
+ "navigation" : true
36
+ },
37
+
38
+ "notifier" : {
39
+ "duration" : "5000",
40
+ "maxMessages" : 7
41
+ },
42
+
43
+ "resources" : {
44
+ "@include" : "../../../bower_components/arethusa/app/static/configs/resources/dev.json"
45
+ },
46
+
47
+ "plugins" : {
48
+ "text" : {
49
+ "main" : true,
50
+ "template" : "templates/text2.html"
51
+ },
52
+
53
+ "depTree" : {
54
+ "main" : true,
55
+ "contextMenu" : true,
56
+ "contextMenuTemplate": "templates/arethusa.dep_tree/context_menu.html",
57
+ "template" : "templates/dep_tree.html"
58
+ },
59
+
60
+ "search" : {
61
+ "template" : "templates/search.html"
62
+ },
63
+
64
+ "morph" : {
65
+ "retrievers" : {
66
+ "BspMorphRetriever" : {
67
+ "resource" : "morphologyServiceLat"
68
+ }
69
+ },
70
+ "template" : "templates/morph3.html",
71
+ "contextMenu" : true,
72
+ "contextMenuTemplate": "templates/arethusa.morph/context_menu.html",
73
+ "lexicalInventory" : {
74
+ "retriever" : {
75
+ "LexicalInventoryRetriever" : {
76
+ "resource" : "lexInvFusekiEndpoint"
77
+ }
78
+ }
79
+ },
80
+ "@include" : "../../../bower_components/arethusa/app/static/configs/morph/lat_attributes.json"
81
+ },
82
+
83
+ "relation" : {
84
+ "template" : "templates/relation.html",
85
+ "advancedMode" : true,
86
+ "contextMenu" : true,
87
+ "contextMenuTemplate": "templates/arethusa.relation/context_menu.html",
88
+ "@include" : "../../../bower_components/arethusa/app/static/configs/relation/relations.json"
89
+ },
90
+
91
+ "review" : {
92
+ "template" : "templates/arethusa.review/review.html",
93
+ "retrievers" : {
94
+ "TreebankRetriever" : {
95
+ "resource" : "fakeGold"
96
+ }
97
+ }
98
+ },
99
+
100
+ "history" : {
101
+ "maxSize" : 5,
102
+ "template" : "templates/history.html"
103
+ },
104
+
105
+ "artificialToken" : {
106
+ "template" : "templates/arethusa.artificial_token/artificial_token.html"
107
+ },
108
+
109
+ "comments" : {
110
+ "retriever" : {
111
+ "CommentsRetriever" : {
112
+ "resource" : "fakePerseidsComments"
113
+ }
114
+ }
115
+ }
116
+ },
117
+
118
+ "exitHandler" : {
119
+ "title" : "somewhere",
120
+ "route" : "http://www.:x.com",
121
+ "params" : ["x", "q"]
122
+ },
123
+
124
+ "keyCapture" : {
125
+ "@include" : "../../../bower_components/arethusa/app/static/configs/keyboard/key_map.json"
126
+ }
127
+ }
@@ -0,0 +1,8 @@
1
+ node_modules/*
2
+ bower_components/*
3
+ *.swp
4
+ coverage
5
+ dist/
6
+ deployment/
7
+ .sass-cache
8
+ app/css/*.css*
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+
3
+ var srcFiles = 'app/**/*.js';
4
+ var htmlFiles = 'app/**/*.html';
5
+ var cssFiles = 'app/**/*.scss';
6
+ var specFiles = 'spec/**/*.js';
7
+ var devServerPort = 8081;
8
+ var reloadPort = 35279;
9
+ var confPath = 'app/static/configs';
10
+ var arethusaPackages = 'bower_components/arethusa/dist/arethusa_packages.min.js';
11
+ var arethusaFiles = 'bower_components/arethusa/dist/arethusa.min.js';
12
+ var specHelpers = 'bower_components/arethusa/spec/helpers/**/*';
13
+
14
+ module.exports = function(grunt) {
15
+ require('load-grunt-tasks')(grunt);
16
+
17
+ function confFiles() {
18
+ return grunt.file.expand(confPath + '/*.json');
19
+ }
20
+
21
+ function confMergeCommands() {
22
+ var file, target, cmd, cmds = [];
23
+ var files = confFiles();
24
+ for (var i = files.length - 1; i >= 0; i--){
25
+ file = files[i];
26
+ target = file.replace(confPath, 'dist/configs');
27
+ cmd = 'arethusa merge ' + file + ' -m > ' + target;
28
+ cmds.push(cmd);
29
+ }
30
+ return cmds;
31
+ }
32
+
33
+ grunt.initConfig({
34
+ pkg: grunt.file.readJSON('package.json'),
35
+ jasmine: {
36
+ src: srcFiles,
37
+ options: {
38
+ specs: specFiles
39
+ }
40
+ },
41
+ karma: {
42
+ spec: {
43
+ autoWatch: false,
44
+ singleRun: true,
45
+ options: {
46
+ files : [
47
+ arethusaPackages,
48
+ 'bower_components/angular-mocks/angular-mocks.js',
49
+ specHelpers,
50
+ arethusaFiles,
51
+ srcFiles,
52
+ specFiles
53
+ ],
54
+ frameworks: ['jasmine'],
55
+ browsers : ['PhantomJS'],
56
+ plugins : [
57
+ 'karma-chrome-launcher',
58
+ 'karma-phantomjs-launcher',
59
+ 'karma-firefox-launcher',
60
+ 'karma-jasmine',
61
+ 'karma-coverage'
62
+ ],
63
+ reporters: ['progress', 'coverage'],
64
+ preprocessors: {
65
+ 'app/**/*.js': ['coverage']
66
+ },
67
+ coverageReporter: {
68
+ reporters: [
69
+ {type: 'html', dir:'coverage/'},
70
+ {type: 'lcov'},
71
+ ]
72
+ }
73
+ }
74
+ },
75
+ },
76
+ coveralls: {
77
+ src: 'coverage/**/lcov.info'
78
+ },
79
+ uglify: {
80
+ options: {
81
+ sourceMap: true
82
+ },
83
+ '<%= namespaced_name %>' : {
84
+ files: {
85
+ 'dist/<%= namespaced_name %>.min.js' : [
86
+ 'app/js/<%= namespaced_name %>.js',
87
+ 'app/js/<%= namespaced_name %>/**/*.js',
88
+ 'app/templates/<%= namespaced_name %>/compiled/<%= namespaced_name %>.templates.js'
89
+ ]
90
+ }
91
+ }
92
+ },
93
+ sass: {
94
+ dist: {
95
+ options: {
96
+ sourcemap: true
97
+ },
98
+ files: {
99
+ 'app/css/<%= namespaced_name %>.css': 'app/css/<%= namespaced_name %>.scss'
100
+ }
101
+ }
102
+ },
103
+ cssmin: {
104
+ css: {
105
+ src: 'app/css/**/*.css',
106
+ dest: 'dist/<%= namespaced_name %>.min.css'
107
+ }
108
+ },
109
+ ngtemplates : {
110
+ '<%= namespaced_name %>' : {
111
+ cwd: 'app',
112
+ src: 'templates/**/*.html',
113
+ dest: 'app/templates/<%= namespaced_name %>/compiled/<%= namespaced_name %>.templates.js'
114
+ }
115
+ },
116
+ connect: {
117
+ devServer: {
118
+ options: {
119
+ port: devServerPort,
120
+ debug: true,
121
+ keepalive: true,
122
+ livereload: reloadPort,
123
+ middleware: function(connect) {
124
+ return [
125
+ require('connect-livereload')(),
126
+ connect.static(require('path').resolve('./'))
127
+ ];
128
+ }
129
+ }
130
+ },
131
+ },
132
+ watch: {
133
+ spec: {
134
+ files: [srcFiles, htmlFiles, specFiles],
135
+ tasks: 'karma:spec'
136
+ },
137
+ server: {
138
+ files: [srcFiles, htmlFiles, cssFiles],
139
+ tasks: 'minify',
140
+ options: {
141
+ spawn: false,
142
+ livereload: reloadPort
143
+ }
144
+ },
145
+ },
146
+ jshint: {
147
+ options: {
148
+ jshintrc: true,
149
+ },
150
+ all: ['*.js', srcFiles, specFiles]
151
+ },
152
+ shell: {
153
+ minifyConfs: {
154
+ command: confMergeCommands().join('&')
155
+ }
156
+ },
157
+ concurrent: {
158
+ minify: {
159
+ tasks: [ 'minify:src', 'minify:css', 'minify:conf' ]
160
+ },
161
+ server: {
162
+ tasks: ['watch:server', 'server'],
163
+ options: {
164
+ logConcurrentOutput: true
165
+ }
166
+ }
167
+ }
168
+ });
169
+
170
+ grunt.registerTask('minify:src', ['ngtemplates', 'uglify']);
171
+ grunt.registerTask('minify:css', ['sass', 'cssmin']);
172
+ grunt.registerTask('minify:conf', 'shell:minifyConfs');
173
+ grunt.registerTask('minify', ['concurrent:minify']);
174
+
175
+ grunt.registerTask('spec', 'watch:spec');
176
+ grunt.registerTask('server', ['minify', 'connect:devServer']);
177
+ grunt.registerTask('reload-server', 'concurrent:server');
178
+ grunt.registerTask('default', ['karma:spec', 'jshint']);
179
+ };
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html ng-app="arethusa" ng-di-strict>
3
+ <head>
4
+ <link rel="stylesheet" href="../bower_components/arethusa/dist/arethusa.min.css">
5
+ <link rel="stylesheet" href="../bower_components/arethusa/vendor/foundation-icons/foundation-icons.css">
6
+ <link rel="stylesheet" href="../bower_components/arethusa/vendor/font-awesome-4.1.0/css/font-awesome.min.css">
7
+
8
+ <script src="../bower_components/arethusa/dist/arethusa_packages.min.js"></script>
9
+ <script src="../bower_components/arethusa/dist/arethusa.min.js"></script>
10
+
11
+ <script>
12
+ arethusa.setBasePath('../bower_components/arethusa')
13
+ </script>
14
+
15
+ <meta charset="UTF-8">
16
+ <title></title>
17
+ </head>
18
+ <body key-capture>
19
+ <div id="arethusa-main-view" class="fade very-slow" ng-view></div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,33 @@
1
+ {
2
+ "globalstrict" : true,
3
+ "browser" : true,
4
+ "jquery" : true,
5
+ "undef" : true,
6
+ "multistr" : true,
7
+ "globals" : {
8
+ "angular" : false,
9
+ "d3" : false,
10
+ "lunr" : true,
11
+ "arethusaUtil" : true,
12
+ "aU": true,
13
+ "arethusaMocks" : true,
14
+ "arethusaLogger" : true,
15
+ "UserVoice" : true,
16
+ "inject" : false,
17
+ "module" : false,
18
+ "require" : false,
19
+ "describe" : false,
20
+ "ddescribe" : false,
21
+ "xdescribe" : false,
22
+ "beforeEach" : false,
23
+ "afterEach" : false,
24
+ "it" : false,
25
+ "iit" : false,
26
+ "xit" : false,
27
+ "expect" : false,
28
+ "browser" : false,
29
+ "by" : false,
30
+ "element" : false,
31
+ "process" : false
32
+ }
33
+ }
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- angular.module('<%= namespaced_name(true) %>', ['arethusa.core']);
2
+ angular.module('<%= namespaced_name(true) %>', []);
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "<%= namespaced_name %>",
3
+ "version": "0.0.1",
4
+ "dependencies" : {},
5
+ "devDependencies": {
6
+ "grunt-cli": "0.1.13",
7
+ "grunt-angular-templates": "0.5.6",
8
+ "grunt-contrib-jasmine": "0.6.3",
9
+ "grunt-contrib-watch": "0.6.1",
10
+ "grunt-contrib-jshint": "0.10.0",
11
+ "grunt-contrib-connect": "~0.7.1",
12
+ "grunt-coveralls": "0.3.0",
13
+ "grunt-karma": "0.8.0",
14
+ "grunt-contrib-uglify": "0.4.0",
15
+ "grunt-contrib-cssmin": "0.10.0",
16
+ "grunt-concurrent": "0.5.0",
17
+ "karma-chrome-launcher": "0.1.3",
18
+ "karma-phantomjs-launcher": "0.1.4",
19
+ "karma-firefox-launcher": "0.1.3",
20
+ "karma-jasmine": "0.1.5",
21
+ "karma-coverage": "0.2.1",
22
+ "bower": "1.3.8",
23
+ "connect-livereload": "0.4.0",
24
+ "execSync": "latest",
25
+ "load-grunt-tasks": "^0.6.0",
26
+ "grunt-contrib-sass": "0.7.3",
27
+ "grunt-shell": "0.7.0",
28
+ "grunt-contrib-concat": "~0.5.0"
29
+ }
30
+ }
@@ -1,21 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  describe('<%= name(true) %>', function() {
4
- var <%= name(true) %>, state;
4
+ var <%= name(true) %>;
5
+
6
+ var conf = {};
5
7
 
6
8
  beforeEach(function() {
7
- module("arethusa.core", function($provide) {
8
- $provide.value('configurator', arethusaMocks.configurator());
9
- });
9
+ module("arethusa.core");
10
10
 
11
- module("<%= namespaced_name(true) %>");
11
+ module('<%= namespaced_name(true) %>');
12
12
 
13
- inject(function(_<%= name(true) %>_, _state_) {
13
+ inject(function(_<%= name(true) %>_, configurator) {
14
14
  <%= name(true) %> = _<%= name(true) %>_;
15
- state = _state_;
16
- state.tokens = arethusaMocks.tokens();
15
+ configurator.defineConfiguration(conf);
16
+ <%= name(true) %>.init();
17
17
  });
18
18
  });
19
19
 
20
20
  // Write your specs here!
21
+ it('succeeds to load the plugin', function() {
22
+ expect(<%= name(true) %>).toBeDefined();
23
+ });
21
24
  });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ angular.module('<%= mod(true) %>').factory('<%= name(true, true) %>', [
4
+ 'configurator',
5
+ function(configurator) {
6
+ return function(conf) {
7
+ var self = this;
8
+ var resource = configurator.provideResource(conf.resource);
9
+
10
+ this.get = function(callback) {
11
+ resource.get().then(function(res) {
12
+ var data = res.data;
13
+ callback(data);
14
+ });
15
+ };
16
+ };
17
+ }
18
+ ]);
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ describe('<%= name(true, true) %>', function() {
4
+ var retriever, backend;
5
+
6
+ var backendUrl = '';
7
+
8
+ var conf = {
9
+ resources: {
10
+ testResource: {
11
+ route: backendUrl
12
+ }
13
+ }
14
+ };
15
+
16
+ beforeEach(function() {
17
+ module('arethusa.core');
18
+ module('<%= mod(true) %>');
19
+
20
+ inject(function($httpBackend, configurator, locator) {
21
+ backend = $httpBackend;
22
+ configurator.defineConfiguration(conf);
23
+ retriever = configurator.getRetriever({
24
+ <%= name(true, true) %> : {
25
+ resource: 'testResource'
26
+ }
27
+ });
28
+ locator.watchUrl(false);
29
+ locator.set({});
30
+ });
31
+ });
32
+
33
+ describe('get', function() {
34
+ it('...', function() {
35
+ var response = {};
36
+
37
+ backend.when('GET', backendUrl).respond(response);
38
+
39
+ // Your GET code goes here!
40
+
41
+ backend.flush();
42
+
43
+ // Your first expectation goes here!
44
+ });
45
+ });
46
+ });
@@ -0,0 +1 @@
1
+ @import '../../bower_components/bourbon/dist/bourbon';
@@ -5,18 +5,16 @@ angular.module('<%= namespaced_name(true) %>').service('<%= name(true) %>', [
5
5
  'configurator',
6
6
  function(state, configurator) {
7
7
  var self = this;
8
+ this.name = '<%= namespaced_name(true, true) %>';
8
9
 
9
10
  this.defaultConf = {
10
- name: '<%= name(true) %>',
11
- template: 'templates/<%= namespaced_name %>/<%= name %>.html'
12
- }
11
+ template: 'templates/<%= namespaced_name(false, true) %>/<%= name %>.html'
12
+ };
13
13
 
14
14
  function configure() {
15
- configurator.getConfAndDelegate('<%= name(true) %>', self);
15
+ configurator.getConfAndDelegate(self);
16
16
  }
17
17
 
18
- configure();
19
-
20
18
  this.init = function() {
21
19
  configure();
22
20
  };
@@ -1,5 +1,5 @@
1
1
  module Arethusa
2
2
  class CLI
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/lib/arethusa/cli.rb CHANGED
@@ -4,6 +4,8 @@ require 'json'
4
4
  module Arethusa
5
5
  class CLI < Thor
6
6
  require 'arethusa/cli/version'
7
+ require 'arethusa/cli/helpers/name_handler'
8
+ require 'arethusa/cli/helpers/directories_and_files'
7
9
  require 'arethusa/cli/subcommand'
8
10
 
9
11
  require 'arethusa/cli/generator'
@@ -11,6 +13,10 @@ module Arethusa
11
13
 
12
14
  include Thor::Actions
13
15
 
16
+ def self.source_root
17
+ File.join(File.dirname(__FILE__), 'cli')
18
+ end
19
+
14
20
  register(Generator, Generator.namespace, "#{Generator.namespace} [ACTION]", 'Generates Arethusa files. Call "arethusa generate" to learn more')
15
21
  register(Transformer, Transformer.namespace, "#{Transformer.namespace} [ACTION]", 'Tranforms Alpheios conf files. Call "arethusa transform" to learn more')
16
22
 
@@ -77,7 +83,69 @@ EOF
77
83
  end
78
84
  end
79
85
 
86
+ desc 'init NAMESPACE NAME', 'Initializes a new git repo for plugin development'
87
+ def init(namespace, name)
88
+ @name = name
89
+ @namespace = namespace
90
+
91
+ inside namespaced_name do
92
+ init_git
93
+ create_folder_hierarchy
94
+ create_templates
95
+ initial_commit
96
+ install
97
+ end
98
+ end
99
+
80
100
  no_commands do
101
+ include Helpers::NameHandler
102
+ include Helpers::DirectoriesAndFiles
103
+
104
+ def init_git
105
+ if `git init`
106
+ say_status(:success, "Initialized new repo in #{namespaced_name}")
107
+ end
108
+ end
109
+
110
+ def initial_commit
111
+ `git add -A`
112
+ `git commit -m 'Initial commit'`
113
+ end
114
+
115
+ def create_folder_hierarchy
116
+ dirs = [
117
+ plugin_dir, template_dir, template_dir('compiled'),
118
+ css_dir, conf_dir, dist_dir, dist_dir('configs')
119
+ ]
120
+ dirs.each { |dir| empty_directory(dir) }
121
+ end
122
+
123
+ def create_templates
124
+ create_module
125
+ create_service
126
+ create_html_template
127
+ create_spec
128
+ create_scss
129
+ create_gitignore
130
+ create_jshintrc
131
+ create_package
132
+ create_bower
133
+ create_gruntfile
134
+ create_index_file
135
+ create_conf_file
136
+ end
137
+
138
+ def install
139
+ `npm install && bower install && gem install sass -v 3.3.14`
140
+
141
+ # We have to minify Arethusa by hand for now - this won't be needed
142
+ # at a later stage.
143
+ inside 'bower_components/arethusa' do
144
+ `npm install && bower install`
145
+ `grunt minify:all`
146
+ end
147
+ end
148
+
81
149
  def minify
82
150
  if `grunt minify:all`
83
151
  say_status(:success, 'minified Arethusa')
@@ -168,14 +236,20 @@ EOF
168
236
  elsif key == '@include'
169
237
  additional_conf = read_conf(value)
170
238
  conf.delete(key)
171
- conf.merge!(additional_conf)
172
- traverse(additional_conf)
239
+ if additional_conf
240
+ conf.merge!(additional_conf)
241
+ traverse(additional_conf)
242
+ end
173
243
  end
174
244
  end
175
245
  end
176
246
 
177
247
  def read_conf(path)
178
- JSON.parse(File.read(path))
248
+ begin
249
+ JSON.parse(File.read(path))
250
+ rescue
251
+ nil
252
+ end
179
253
  end
180
254
  end
181
255
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arethusa-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LFDM
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2014-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,10 +114,22 @@ files:
114
114
  - lib/arethusa.rb
115
115
  - lib/arethusa/cli.rb
116
116
  - lib/arethusa/cli/generator.rb
117
+ - lib/arethusa/cli/helpers/directories_and_files.rb
118
+ - lib/arethusa/cli/helpers/name_handler.rb
117
119
  - lib/arethusa/cli/subcommand.rb
120
+ - lib/arethusa/cli/templates/bower.tt
121
+ - lib/arethusa/cli/templates/conf.tt
122
+ - lib/arethusa/cli/templates/gitignore.tt
123
+ - lib/arethusa/cli/templates/gruntfile.tt
118
124
  - lib/arethusa/cli/templates/html_template.tt
125
+ - lib/arethusa/cli/templates/index.tt
126
+ - lib/arethusa/cli/templates/jshintrc.tt
119
127
  - lib/arethusa/cli/templates/module.tt
128
+ - lib/arethusa/cli/templates/package.tt
120
129
  - lib/arethusa/cli/templates/plugin_spec.tt
130
+ - lib/arethusa/cli/templates/retriever.tt
131
+ - lib/arethusa/cli/templates/retriever_spec.tt
132
+ - lib/arethusa/cli/templates/scss.tt
121
133
  - lib/arethusa/cli/templates/service.tt
122
134
  - lib/arethusa/cli/transformer.rb
123
135
  - lib/arethusa/cli/version.rb