cyborg 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/cyborg +70 -0
- data/cyborg.gemspec +32 -0
- data/lib/cyborg.rb +125 -0
- data/lib/cyborg/assets.rb +8 -0
- data/lib/cyborg/command.rb +60 -0
- data/lib/cyborg/command/compress.rb +24 -0
- data/lib/cyborg/command/help.rb +50 -0
- data/lib/cyborg/command/npm.rb +77 -0
- data/lib/cyborg/command/scaffold.rb +281 -0
- data/lib/cyborg/helpers/asset_helpers.rb +32 -0
- data/lib/cyborg/helpers/layout_helpers.rb +28 -0
- data/lib/cyborg/middleware.rb +18 -0
- data/lib/cyborg/plugin.rb +152 -0
- data/lib/cyborg/plugin/assets/asset.rb +93 -0
- data/lib/cyborg/plugin/assets/javascripts.rb +21 -0
- data/lib/cyborg/plugin/assets/stylesheets.rb +54 -0
- data/lib/cyborg/plugin/assets/svgs.rb +35 -0
- data/lib/cyborg/version.rb +3 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb4524ebfdca3bce452a04d08624ecb65db305a0
|
4
|
+
data.tar.gz: 2d37268d99e57c8314d10123fd506a017f8752e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88efddc99a5dbfe2b0bc956bc120a8915efc964ddc7093ac1f4a6f5d67030d062cdc9eb34da62071cfde495bd0a871cde501ea4b98bbd1b9091893b8ce4cee0e
|
7
|
+
data.tar.gz: 9eddae1c70b7eeecb80bb782f9bb9a8c4c4e71f2ea8b66f2c28ab6fa65a4dc6333bcc35df214204db7099e4b027a26651a3dde0b64dad3baa316a6d98d2c9a4c
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at brandon@imathis.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Brandon Mathis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Cyborg
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cyborg`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'cyborg'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install cyborg
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cyborg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/cyborg
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'cyborg'
|
7
|
+
|
8
|
+
options = {assets: []}
|
9
|
+
|
10
|
+
def next_arg
|
11
|
+
if ARGV.first && !ARGV.first.match(/^-/)
|
12
|
+
ARGV.shift
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
OptionParser.new do |opts|
|
17
|
+
|
18
|
+
options[:help] = ARGV.shift if ARGV.first == 'help'
|
19
|
+
|
20
|
+
if ARGV.empty?
|
21
|
+
options[:help] = 'help' # show help as default subcommand
|
22
|
+
else
|
23
|
+
options[:command] = next_arg
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.banner = Cyborg::Help.banner(options[:command])
|
27
|
+
|
28
|
+
if options[:command] == 'new'
|
29
|
+
options[:name] = next_arg
|
30
|
+
|
31
|
+
opts.on("-f", "--force", "overwrite existing files") do |val|
|
32
|
+
options[:force] = true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if options[:command] == 'npm'
|
37
|
+
options[:cli_path] = next_arg || Dir.pwd
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on("-v", "--version", "Print version") do |version|
|
41
|
+
options[:version] = true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-h", "--help", "Print this message") do |version|
|
45
|
+
options[:help] = opts
|
46
|
+
options[:command] = 'help'
|
47
|
+
end
|
48
|
+
|
49
|
+
if options[:help] == 'help'
|
50
|
+
options[:help] = opts
|
51
|
+
end
|
52
|
+
end.parse!
|
53
|
+
|
54
|
+
if options[:version]
|
55
|
+
puts "Cyborg version #{Cyborg::VERSION}"
|
56
|
+
elsif options[:help]
|
57
|
+
|
58
|
+
if options[:help]
|
59
|
+
puts "Cyborg version #{Cyborg::VERSION}\n\n"
|
60
|
+
puts options[:help]
|
61
|
+
|
62
|
+
# Use this if commands get long
|
63
|
+
#IO.popen("less", "w") do |f|
|
64
|
+
#f.puts "Cyborg version #{Cyborg::VERSION}"
|
65
|
+
#f.puts options[:help]
|
66
|
+
#end
|
67
|
+
end
|
68
|
+
else
|
69
|
+
Cyborg::Command.run(options)
|
70
|
+
end
|
data/cyborg.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'cyborg/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "cyborg"
|
7
|
+
spec.version = Cyborg::VERSION
|
8
|
+
spec.authors = ["Brandon Mathis"]
|
9
|
+
spec.email = ["brandon@imathis.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Build style-guide plugins Rails (and humans).}
|
12
|
+
spec.description = %q{Build style-guide plugins Rails (and humans).}
|
13
|
+
spec.homepage = "https://github.com/compose-ui/cyborg"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "sass"
|
22
|
+
spec.add_runtime_dependency "esvg", "~> 2.8.10"
|
23
|
+
spec.add_runtime_dependency "listen", "~> 3.0"
|
24
|
+
spec.add_runtime_dependency 'block_helpers', '~> 0.3.3'
|
25
|
+
spec.add_runtime_dependency 'colorize'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "rails", "~> 4"
|
28
|
+
spec.add_dependency 'rack-cors'
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
end
|
data/lib/cyborg.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "json"
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
require "cyborg/command"
|
6
|
+
require "cyborg/version"
|
7
|
+
require "cyborg/plugin"
|
8
|
+
require "cyborg/assets"
|
9
|
+
|
10
|
+
module Cyborg
|
11
|
+
extend self
|
12
|
+
autoload :Application, "cyborg/middleware"
|
13
|
+
|
14
|
+
def production?
|
15
|
+
ENV['CI'] || ENV['RAILS_ENV'] == 'production'
|
16
|
+
end
|
17
|
+
|
18
|
+
def plugins
|
19
|
+
@plugins ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
def register(plugin_module, options={})
|
23
|
+
plugins << plugin_module.new(options)
|
24
|
+
patch_rails
|
25
|
+
end
|
26
|
+
|
27
|
+
def patch_rails
|
28
|
+
load_rake_tasks
|
29
|
+
load_helpers
|
30
|
+
end
|
31
|
+
|
32
|
+
def dispatch(command)
|
33
|
+
@threads = []
|
34
|
+
send(command)
|
35
|
+
@threads.each { |thr| thr.join }
|
36
|
+
end
|
37
|
+
|
38
|
+
def build
|
39
|
+
puts 'Building…'
|
40
|
+
|
41
|
+
Cyborg.plugins.each do |plugin|
|
42
|
+
@threads.concat plugin.build
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def watch
|
47
|
+
build
|
48
|
+
require 'listen'
|
49
|
+
|
50
|
+
trap("SIGINT") {
|
51
|
+
puts "\nCyborg watcher stopped. Have a nice day!"
|
52
|
+
exit!
|
53
|
+
}
|
54
|
+
|
55
|
+
Cyborg.plugins.each do |plugin|
|
56
|
+
@threads.concat plugin.watch
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def server
|
61
|
+
@threads << Thread.new { system 'rails server' }
|
62
|
+
watch
|
63
|
+
end
|
64
|
+
|
65
|
+
def load_rake_tasks
|
66
|
+
return if @tasks_loaded
|
67
|
+
plugins.first.engine.rake_tasks do
|
68
|
+
namespace :cyborg do
|
69
|
+
desc "Cyborg build task"
|
70
|
+
task :build do
|
71
|
+
Cyborg.dispatch(:build)
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Watch assets for build"
|
75
|
+
task :watch do
|
76
|
+
Cyborg.dispatch(:watch)
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Start rails and watch assets for build"
|
80
|
+
task :server do
|
81
|
+
Cyborg.dispatch(:server)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
@tasks_loaded = true
|
87
|
+
end
|
88
|
+
|
89
|
+
def load_helpers
|
90
|
+
require "cyborg/helpers/asset_helpers"
|
91
|
+
require "cyborg/helpers/layout_helpers"
|
92
|
+
|
93
|
+
Cyborg::Helpers.constants.each do |c|
|
94
|
+
helper = Cyborg::Helpers.const_get(c)
|
95
|
+
ActionView::Base.send :include, helper if defined? ActionView::Base
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def at_rails_root
|
100
|
+
File.exist?("bin/rails")
|
101
|
+
end
|
102
|
+
|
103
|
+
def at_gem_root
|
104
|
+
!Dir['*.gemspec'].empty?
|
105
|
+
end
|
106
|
+
|
107
|
+
def gem_path
|
108
|
+
if at_gem_root
|
109
|
+
Dir.pwd
|
110
|
+
elsif at_rails_root
|
111
|
+
"../"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def rails_path
|
116
|
+
if at_rails_root
|
117
|
+
Dir.pwd
|
118
|
+
else
|
119
|
+
dir = Dir["**/bin/rails"]
|
120
|
+
if !dir.empty?
|
121
|
+
dir.first.split('/').first
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "cyborg/command/help"
|
2
|
+
require "cyborg/command/npm"
|
3
|
+
require "cyborg/command/scaffold"
|
4
|
+
|
5
|
+
module Cyborg
|
6
|
+
module Command
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def run(options)
|
10
|
+
|
11
|
+
case options[:command]
|
12
|
+
when 'new'
|
13
|
+
Scaffold.new(options[:name])
|
14
|
+
when 'npm'
|
15
|
+
from_root { NPM.setup }
|
16
|
+
when 'build'
|
17
|
+
from_rails "bundle exec rake cyborg:build"
|
18
|
+
when 'watch'
|
19
|
+
from_rails "rake cyborg:watch"
|
20
|
+
when 'server'
|
21
|
+
from_rails "rake cyborg:server"
|
22
|
+
when 'rails'
|
23
|
+
from_rails "rails s"
|
24
|
+
else
|
25
|
+
puts "Command `#{options[:command]}` not recognized"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def from_rails(command=nil, &blk)
|
30
|
+
unless dir = Cyborg.rails_path
|
31
|
+
abort "Command must be run from the root of a Cyborg Plugin project, or in its Rails 'site' directory."
|
32
|
+
end
|
33
|
+
|
34
|
+
Dir.chdir(dir) do
|
35
|
+
if command
|
36
|
+
system command
|
37
|
+
else
|
38
|
+
blk.call
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def from_root(command=nil, &blk)
|
44
|
+
unless dir = Cyborg.gem_path
|
45
|
+
abort "Command must be run from the root of a Cyborg Plugin (adjacent to the gemspec)."
|
46
|
+
end
|
47
|
+
|
48
|
+
Dir.chdir(dir) do
|
49
|
+
if command
|
50
|
+
system command
|
51
|
+
else
|
52
|
+
blk.call
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|