arethusa-cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 217c5ae86d522ea8ac29f3156d9b550ad1fa375e
4
+ data.tar.gz: 123fc0bca8f6823a192555b76e98126ab7dded3b
5
+ SHA512:
6
+ metadata.gz: ebd2477b7d10ea17a75601ae85973d74eceb025825c889f536d7fcd6a8adf122215198ef682938f5c327b61240418395e60208fbf4cfb8a07f9f20525b35ab5d
7
+ data.tar.gz: 079dd82eb262800464a8c28e927fe6bd7af0252582c51051e12cb19f7b1cf57ca1e65341ac67c2c5908fd756e483376709ba5d46b821d2efeec94540478337dd
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ ---
2
+ language: ruby
3
+ before_script:
4
+ - export JRUBY_OPTS=--2.0
5
+ rvm:
6
+ - 2.1.0
7
+ - 2.0.0
8
+ - jruby-1.7.8
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in arethusa_plugin_generator.gemspec
4
+ gemspec
5
+ gem 'coveralls', require: false
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 LFDM
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Arethusa::CLI
2
+
3
+ [![Version](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/badge_fury.png)](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/badge_fury)
4
+ [![Dependencies](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/gemnasium.png)](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/gemnasium)
5
+ [![Build Status](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/travis.png)](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/travis)
6
+ [![Coverage](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/coveralls.png)](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/coveralls)
7
+ [![Code Climate](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/code_climate.png)](http://allthebadges.io/latin-language-toolkit/arethusa_plugin_generator/code_climate)
8
+
9
+ Command line tools for [Arethusa](http://github.com/latin-language-toolkit/arethusa)
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ gem install arethusa-cli
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ - Plugin generator
20
+
21
+ If you want to create a new plugin, go to you Arethusa directory and
22
+ then run
23
+
24
+ ```
25
+ arethusa generate plugin NAME
26
+ ```
27
+
28
+ This will create all files and make all changes you need to get started with your plugin. Also check out `arethusa generate help plugin` to learn about additional options.
29
+
30
+
31
+ - Deployment and build helpers
32
+
33
+ If you plan to deploy Arethusa on a webserver like Apache, the `arethusa build`
34
+ command will help you bundle up all needed files and `arethusa deploy`
35
+ will make it easy to deploy Arethusa on a remote server.
36
+
37
+ Use the usage descriptions (`arethusa help build` and `arethusa help
38
+ deploy`) for more detailed instructions.
39
+
40
+
41
+ ## Disclaimer
42
+
43
+ Make sure you're running the latest version of this gem at all times. It
44
+ might change frequently, as Arethusa is continuing to make progress.
45
+
46
+ All commands have to be called from within your Arethusa directory.
47
+
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/[my-github-username]/arethusa-cli/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'arethusa/cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "arethusa-cli"
8
+ spec.version = Arethusa::CLI::VERSION
9
+ spec.authors = ["LFDM"]
10
+ spec.email = ["1986gh@gmail.com"]
11
+ spec.summary = %q{Command line tools for Arethusa}
12
+ spec.description = spec.summary
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "simplecov", "~> 0.7"
25
+ spec.add_dependency "thor"
26
+ end
data/bin/arethusa ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'arethusa'
7
+ Arethusa::CLI.start
@@ -0,0 +1,151 @@
1
+ require 'thor'
2
+
3
+ class Arethusa::CLI
4
+ class Generator < Subcommand
5
+ as_subcommand :generate
6
+
7
+ def self.source_root
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ include Thor::Actions
12
+ attr_reader :namespace, :name
13
+
14
+ desc 'plugin NAME', 'Creates a new Arethusa plugin skeleton'
15
+ method_option :namespace, aliases: '-n', default: 'arethusa',
16
+ desc: 'Namespace of the new plugin'
17
+ method_option :commit, type: :boolean, aliases: '-c',
18
+ desc: 'Commit the skeleton with git'
19
+ def plugin(name)
20
+ @name = name
21
+ @namespace = options[:namespace]
22
+
23
+ create_directories
24
+ create_files
25
+
26
+ try('insert module into arethusa', :add_module)
27
+ try('add minification routine', :add_minification)
28
+ try('add minification task', :add_minification_task)
29
+ try('add module to index.html', :add_to_index)
30
+
31
+ commit_changes if options[:commit]
32
+
33
+ puts
34
+ say_status(:success, "Created #{namespaced_name}")
35
+ give_conf_instructions
36
+ end
37
+
38
+ no_commands do
39
+ def try(message, method)
40
+ puts
41
+ say_status('trying', "to #{message}...", :yellow)
42
+ send(method)
43
+ end
44
+
45
+ def namespaced_name
46
+ [namespace, name].compact.join('.')
47
+ end
48
+
49
+ DIRECTORIES = %w{ plugin_dir template_dir }
50
+ def create_directories
51
+ DIRECTORIES.each { |dir| empty_directory(send(dir)) }
52
+ end
53
+
54
+ def create_files
55
+ create_module
56
+ create_service
57
+ create_html_template
58
+ end
59
+
60
+ def create_module
61
+ template('templates/module.tt', js_dir("#{namespaced_name}.js"))
62
+ end
63
+
64
+ def create_service
65
+ template('templates/service.tt', plugin_dir("#{name}.js"))
66
+ end
67
+
68
+ def create_html_template
69
+ template('templates/html_template.tt', html_template_file)
70
+ end
71
+
72
+ def add_module
73
+ insert_into_file(arethusa_main, before: /\n\]/, force: false) do
74
+ ",\n '#{namespaced_name}'"
75
+ end
76
+ end
77
+
78
+ def arethusa_main
79
+ js_dir('arethusa.js')
80
+ end
81
+
82
+ def add_minification
83
+ insert_into_file(gruntfile, after: /pluginFiles\(.*?core.*?\).*?\n/, force: false) do
84
+ %[ #{name}: { files: pluginFiles('#{namespaced_name}') },\n]
85
+ end
86
+ end
87
+
88
+ def add_minification_task
89
+ insert_into_file(gruntfile, after: /registerTask.*?minify.*?\n/, force: false) do
90
+ %{ 'uglify:#{name}',\n}
91
+ end
92
+ end
93
+
94
+ def gruntfile
95
+ File.join(destination_root, 'Gruntfile.js')
96
+ end
97
+
98
+ def add_to_index
99
+ insert_into_file(index_file, after: /script.*?core.*?script>\n/) do
100
+ %{ <script src="../dist/#{namespaced_name}.min.js"></script>\n}
101
+ end
102
+ end
103
+
104
+ def index_file
105
+ File.join(destination_root, 'app', 'index.html')
106
+ end
107
+
108
+ def give_conf_instructions
109
+ text = <<-EOF
110
+ Now add your new #{name} plugin to a conf file and add a configuration for it.
111
+ It could look like this:
112
+
113
+ "#{name}" : {
114
+ "name" : "#{name}",
115
+ "template" : "#{html_template_file.slice(/template.*/)}"
116
+ }
117
+ EOF
118
+ puts text.lines.map { |line| "\t#{line}" }.join
119
+ end
120
+
121
+ def plugin_dir(file = '')
122
+ File.join(js_dir, namespaced_name, file)
123
+ end
124
+
125
+ def template_dir(file = '')
126
+ File.join(temp_dir, namespaced_name, file)
127
+ end
128
+
129
+ def html_template_file
130
+ template_dir("#{name}.html")
131
+ end
132
+
133
+ def js_dir(file = '')
134
+ File.join(destination_root, 'app/js', file)
135
+ end
136
+
137
+ def temp_dir
138
+ File.join(destination_root, 'app/templates')
139
+ end
140
+
141
+ def commit_changes
142
+ message = %{"Add skeleton for #{namespaced_name}"}
143
+ `git add -A`
144
+ `git commit -m #{message}`
145
+ sha = `git rev-parse --short HEAD`.chomp
146
+ puts
147
+ say_status(:commited, %(#{sha} #{message}))
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,11 @@
1
+ class Arethusa::CLI
2
+ class Subcommand < Thor
3
+ def self.as_subcommand(subcommand)
4
+ namespace(subcommand)
5
+
6
+ def self.banner(command, namespace = nil, subcommand = false)
7
+ "#{basename} #{@namespace} #{command.usage}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ This is the HTML template for <%= namespaced_name %>
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ angular.module('<%= namespaced_name %>', ['arethusa.core']);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ angular.module('<%= namespaced_name %>').service('<%= name %>', [
4
+ 'state',
5
+ 'configurator',
6
+ function(state, configurator) {
7
+ var self = this;
8
+
9
+ function configure() {
10
+ configurator.getConfAndDelegate('<%= name %>', self);
11
+ }
12
+
13
+ configure();
14
+
15
+ this.init = function() {
16
+ configure();
17
+ };
18
+ }
19
+ ]);
@@ -0,0 +1,5 @@
1
+ module Arethusa
2
+ class CLI
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,121 @@
1
+ require 'thor'
2
+
3
+ module Arethusa
4
+ class CLI < Thor
5
+ require 'arethusa/cli/version'
6
+ require 'arethusa/cli/subcommand'
7
+
8
+ require 'arethusa/cli/generator'
9
+
10
+ include Thor::Actions
11
+
12
+ register(Generator, Generator.namespace, "#{Generator.namespace} [ACTION]", 'Generates Arethusa files. Call "arethusa generate" to learn more')
13
+
14
+ desc 'build', 'Creates a tar archive to be used for deployment'
15
+ method_option :minify, aliases: '-m', type: :boolean, default: true,
16
+ desc: 'Minifies Arethusa before building'
17
+ def build
18
+ minify if options[:minify]
19
+ empty_directory('deployment')
20
+ @filename = "#{tar_name}#{ending}"
21
+ create_tgz
22
+ say_status(:built, archive_path)
23
+ end
24
+
25
+ desc 'deploy ADDRESS DIRECTORY', 'Deploys an Arethusa archive through ssh'
26
+ long_desc <<-EOF
27
+ Uses ssh to deploy Arethus on a remote server.
28
+
29
+ By default a new Arethusa archive file will get created in the process
30
+ (overridden by -f), which will be transferred through ssh to its remote
31
+ location, where the files are decompressed.
32
+
33
+ A regular ssh connection is used. If you need to specify additional options
34
+ to the ssh command (like using a specific identity file), use -o and
35
+ pass them as a string. Here's a rather complex usage example:
36
+
37
+ arethusa deploy user@hostname /var/www -f arethusa-1.0.0.tgz -o "-i key.pem"
38
+ EOF
39
+ method_option :options, aliases: '-o',
40
+ desc: 'Options to pass to the ssh command'
41
+ method_option :file, aliases: '-f',
42
+ desc: 'Archive file to use - builds a new one by default'
43
+ method_option :minify, aliases: '-m', type: :boolean, default: true,
44
+ desc: 'Minifies Arethusa before building'
45
+ def deploy(address, directory)
46
+ @address = address
47
+ @directory = directory
48
+ @ssh_options = options[:options]
49
+ @archive = options[:file]
50
+
51
+ minify if options[:minify] &! @archive
52
+ execute
53
+ say_status(:deployed, "at #{@address} - #{@directory}")
54
+ end
55
+
56
+ no_commands do
57
+ def minify
58
+ `grunt minify`
59
+ say_status(:success, 'minified Arethusa')
60
+ end
61
+
62
+ # For deploy command
63
+ def execute
64
+ `#{archive_to_use} | #{ssh} #{decompress}`
65
+ end
66
+
67
+ def compress
68
+ "tar -zc #{folders_to_deploy.join(' ')}"
69
+ end
70
+
71
+ def archive_to_use
72
+ @archive ? "cat #{@archive}" : compress
73
+ end
74
+
75
+ def ssh
76
+ "ssh #{@ssh_options} #{@address}"
77
+ end
78
+
79
+ def decompress
80
+ "tar -zxC #{@directory}"
81
+ end
82
+
83
+ # For build command
84
+ def create_tgz
85
+ `tar -zcf #{archive_path} #{folders_to_deploy.join(' ')}`
86
+ end
87
+
88
+ def folders_to_deploy
89
+ %w{ app bower_components dist vendor }
90
+ end
91
+
92
+ def archive_path
93
+ "deployment/#{@filename}"
94
+ end
95
+
96
+ def tar_name
97
+ [tar_namespace, timestamp, git_branch, commit_sha].join('-')
98
+ end
99
+
100
+ def ending
101
+ '.tgz'
102
+ end
103
+
104
+ def tar_namespace
105
+ 'arethusa'
106
+ end
107
+
108
+ def git_branch
109
+ `git rev-parse --abbrev-ref HEAD`.strip
110
+ end
111
+
112
+ def timestamp
113
+ Time.now.to_i
114
+ end
115
+
116
+ def commit_sha
117
+ `git rev-parse --short HEAD`.strip
118
+ end
119
+ end
120
+ end
121
+ end
data/lib/arethusa.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Arethusa
2
+ require 'arethusa/cli'
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Arethusa::CLI do
4
+ it 'has a version number' do
5
+ expect(Arethusa::CLI::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ Coveralls.wear!
5
+
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+
11
+ SimpleCov.start do
12
+ add_filter '/spec/'
13
+ end
14
+
15
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
16
+ require 'arethusa'
17
+
18
+ RSpec.configure do |config|
19
+ config.treat_symbols_as_metadata_keys_with_true_values = true
20
+ config.run_all_when_everything_filtered = true
21
+ config.filter_run :focus
22
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arethusa-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - LFDM
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Command line tools for Arethusa
84
+ email:
85
+ - 1986gh@gmail.com
86
+ executables:
87
+ - arethusa
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - arethusa-cli.gemspec
99
+ - bin/arethusa
100
+ - lib/arethusa.rb
101
+ - lib/arethusa/cli.rb
102
+ - lib/arethusa/cli/generator.rb
103
+ - lib/arethusa/cli/subcommand.rb
104
+ - lib/arethusa/cli/templates/html_template.tt
105
+ - lib/arethusa/cli/templates/module.tt
106
+ - lib/arethusa/cli/templates/service.tt
107
+ - lib/arethusa/cli/version.rb
108
+ - spec/lib/arethusa_cli_spec.rb
109
+ - spec/spec_helper.rb
110
+ homepage: ''
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.2.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Command line tools for Arethusa
134
+ test_files:
135
+ - spec/lib/arethusa_cli_spec.rb
136
+ - spec/spec_helper.rb