cyborg 0.0.1 → 0.0.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: bb4524ebfdca3bce452a04d08624ecb65db305a0
4
- data.tar.gz: 2d37268d99e57c8314d10123fd506a017f8752e7
3
+ metadata.gz: a7ea5f2b2cb3f2391a7da731bcf7d97c0f93c540
4
+ data.tar.gz: 638b2e89fc41f7e18dc62fe4570c27ccc97edfee
5
5
  SHA512:
6
- metadata.gz: 88efddc99a5dbfe2b0bc956bc120a8915efc964ddc7093ac1f4a6f5d67030d062cdc9eb34da62071cfde495bd0a871cde501ea4b98bbd1b9091893b8ce4cee0e
7
- data.tar.gz: 9eddae1c70b7eeecb80bb782f9bb9a8c4c4e71f2ea8b66f2c28ab6fa65a4dc6333bcc35df214204db7099e4b027a26651a3dde0b64dad3baa316a6d98d2c9a4c
6
+ metadata.gz: ef66830311d58f2a3c5890d1e7d2796f85c404b6b1a1071630efe7a1ba2b1d877dc6d3c64966c81269891266b840d225c654bf437f3939e2ca8f788d314f76ba
7
+ data.tar.gz: c3c43450e044f052b072ef7fad2f1d9b262fabaa6b746d8a18936b1165350fe669de99672cc5539da9b0d04aa43314128aeb7c819b5a0cd1411c491c07ea9dc3
@@ -9,18 +9,19 @@ require "cyborg/assets"
9
9
 
10
10
  module Cyborg
11
11
  extend self
12
+ attr_accessor :plugin
12
13
  autoload :Application, "cyborg/middleware"
13
14
 
14
15
  def production?
15
16
  ENV['CI'] || ENV['RAILS_ENV'] == 'production'
16
17
  end
17
18
 
18
- def plugins
19
- @plugins ||= []
19
+ def plugin
20
+ @plugin
20
21
  end
21
22
 
22
23
  def register(plugin_module, options={})
23
- plugins << plugin_module.new(options)
24
+ @plugin = plugin_module.new(options)
24
25
  patch_rails
25
26
  end
26
27
 
@@ -37,10 +38,7 @@ module Cyborg
37
38
 
38
39
  def build
39
40
  puts 'Building…'
40
-
41
- Cyborg.plugins.each do |plugin|
42
- @threads.concat plugin.build
43
- end
41
+ @threads.concat plugin.build
44
42
  end
45
43
 
46
44
  def watch
@@ -52,9 +50,7 @@ module Cyborg
52
50
  exit!
53
51
  }
54
52
 
55
- Cyborg.plugins.each do |plugin|
56
- @threads.concat plugin.watch
57
- end
53
+ @threads.concat plugin.watch
58
54
  end
59
55
 
60
56
  def server
@@ -63,8 +59,7 @@ module Cyborg
63
59
  end
64
60
 
65
61
  def load_rake_tasks
66
- return if @tasks_loaded
67
- plugins.first.engine.rake_tasks do
62
+ plugin.engine.rake_tasks do
68
63
  namespace :cyborg do
69
64
  desc "Cyborg build task"
70
65
  task :build do
@@ -82,8 +77,6 @@ module Cyborg
82
77
  end
83
78
  end
84
79
  end
85
-
86
- @tasks_loaded = true
87
80
  end
88
81
 
89
82
  def load_helpers
@@ -2,27 +2,41 @@ module Cyborg
2
2
  module Helpers
3
3
  module AssetsHelper
4
4
 
5
- def get_asset_path(asset)
6
- host = Cyborg.production? ? ENV['ASSETS_CDN'] || config[:assets_cdn] : '/'
5
+ def stylesheet_tag(*args)
6
+ options = args.last.is_a?(Hash) ? args.pop : {}
7
+ tags = ''
8
+
9
+ stylesheet_url(args).each do |url|
10
+ tags += stylesheet_link_tag(url, options)
11
+ end
7
12
 
8
- File.join(host, asset)
13
+ tags.html_safe
9
14
  end
10
15
 
11
- def asset_tags
16
+ def javascript_tag(*args)
17
+ options = args.last.is_a?(Hash) ? args.pop : {}
12
18
  tags = ''
13
19
 
14
- Cyborg.plugins.each do |plugin|
15
- plugin.javascripts.urls.each do |url|
16
- tags += javascript_include_tag(url)
17
- end
18
- plugin.stylesheets.urls.each do |url|
19
- tags += stylesheet_link_tag(url)
20
- end
20
+ puts "searching for: #{javascript_url(args)}"
21
+ javascript_url(args).each do |url|
22
+ tags += javascript_include_tag(url, options)
21
23
  end
22
24
 
23
25
  tags.html_safe
24
26
  end
25
27
 
28
+ def stylesheet_url(*args)
29
+ Cyborg.plugin.stylesheets.urls(args)
30
+ end
31
+
32
+ def javascript_url(*args)
33
+ Cyborg.plugin.javascripts.urls(args)
34
+ end
35
+
36
+ def asset_tags
37
+ stylesheet_tag + javascript_tag
38
+ end
39
+
26
40
  def pin_tab_icon(path)
27
41
  %Q{<link rel="mask-icon" mask href="#{path}" color="black">}.html_safe
28
42
  end
@@ -1,6 +1,6 @@
1
1
  module Cyborg
2
2
  class Plugin
3
- attr_reader :module_name, :gem, :engine,
3
+ attr_reader :module_name, :gem, :engine, :name,
4
4
  :stylesheets, :javascripts, :svgs, :destination
5
5
 
6
6
  def initialize(options)
@@ -20,6 +20,7 @@ module Cyborg
20
20
  def create_engine
21
21
  # Create a new Rails::Engine
22
22
  return parent_module.const_set('Engine', Class.new(Rails::Engine) do
23
+
23
24
  def get_plugin_path
24
25
  parent = Object.const_get(self.class.to_s.split('::').first)
25
26
  path = parent.instance_variable_get("@gem_path")
@@ -9,10 +9,31 @@ module Cyborg
9
9
  end
10
10
 
11
11
  def find_files
12
- files = Dir[File.join(base, "*.#{ext}")]
12
+ if @files
13
+ @files
14
+ else
15
+ files = Dir[File.join(base, "*.#{ext}")].reject do |f|
16
+ # Filter out partials
17
+ File.basename(f).start_with?('_')
18
+ end
19
+
20
+ @files = files if Cyborg.production?
21
+ files
22
+ end
23
+ end
13
24
 
14
- # Filter out partials
15
- files.reject { |f| File.basename(f).start_with?('_') }
25
+ def filter_files(names=nil)
26
+ names = [names].flatten.compact.map do |n|
27
+ File.basename(n).sub(/(\..+)$/,'')
28
+ end
29
+
30
+ if !names.empty?
31
+ find_files.select do |f|
32
+ names.include? File.basename(f).sub(/(\..+)$/,'')
33
+ end
34
+ else
35
+ find_files
36
+ end
16
37
  end
17
38
 
18
39
  def versioned(path)
@@ -56,8 +77,8 @@ module Cyborg
56
77
  File.join(plugin.asset_root, versioned(path))
57
78
  end
58
79
 
59
- def urls
60
- find_files.map{ |file| url(file) }
80
+ def urls(names=nil)
81
+ filter_files(names).map{ |file| url(file) }
61
82
  end
62
83
 
63
84
  def watch
@@ -5,6 +5,10 @@ module Cyborg
5
5
  "js"
6
6
  end
7
7
 
8
+ def asset_tag(*args)
9
+ javascript_include_tag(args)
10
+ end
11
+
8
12
  def build
9
13
  if find_node_module "browserify"
10
14
  find_files.each do |file|
@@ -6,6 +6,10 @@ module Cyborg
6
6
  "*[ca]ss"
7
7
  end
8
8
 
9
+ def asset_tag(*args)
10
+ stylesheet_link_tag(args)
11
+ end
12
+
9
13
  def build(ext=nil)
10
14
  files = find_files
11
15
  files = files.reject {|f| !f.match(/\.#{ext}/) } if ext
@@ -1,3 +1,3 @@
1
1
  module Cyborg
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyborg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass