Class: IRuby::Dependencies::Dsl
- Inherits:
-
Bundler::Dsl
- Object
- Bundler::Dsl
- IRuby::Dependencies::Dsl
- Defined in:
- lib/iruby/dependencies/dsl.rb
Instance Method Summary collapse
- #config(hash) ⇒ Object
- #css(*paths) ⇒ Object
- #define(hash) ⇒ Object
- #eval(string) ⇒ Object
- #exec(string) ⇒ Object
- #gem(name, *args) ⇒ Object
- #script(*paths) ⇒ Object
- #url(url) ⇒ Object
Instance Method Details
#config(hash) ⇒ Object
6 7 8 9 10 |
# File 'lib/iruby/dependencies/dsl.rb', line 6 def config hash hash.each do |key,value| Bundler.settings[key] = value end end |
#css(*paths) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/iruby/dependencies/dsl.rb', line 29 def css *paths paths.each do |path| url = full_url path html = "<link rel='stylesheet' href='#{url}'>" IRuby.display IRuby.html(html) end end |
#define(hash) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/iruby/dependencies/dsl.rb', line 37 def define hash mapped = hash.map do |mod,path| [mod, full_url(path)] end.to_h js = <<-JS requirejs.config({ map: { '*': #{MultiJson.dump(mapped)} } }); JS IRuby.display IRuby.javascript(js) end |
#eval(string) ⇒ Object
25 26 27 |
# File 'lib/iruby/dependencies/dsl.rb', line 25 def eval string super string end |
#exec(string) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/iruby/dependencies/dsl.rb', line 12 def exec string stdout, stderr, exit_status = Open3.capture3(string) if exit_status.success? Bundler.ui.info stdout unless stdout.empty? Bundler.ui.warn stderr unless stderr.empty? else puts stdout unless stdout.empty? warn stderr unless stderr.empty? raise "\"exec '#{string}'\" failed on dependency installation" end end |
#gem(name, *args) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/iruby/dependencies/dsl.rb', line 65 def gem name, *args if version = ACTIVE_GEMS[name] = args.last.is_a?(Hash) ? args.pop.dup : {} unless args.empty? or args == [version] raise GemfileError, "The IRuby runtime has already loaded #{name}-#{version}. If you need a different version, you'll need to install it manually and restart IRuby." else super name, [version], end else super name, *args end end |
#script(*paths) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/iruby/dependencies/dsl.rb', line 53 def script *paths paths.each do |path| url = full_url path html = "<script src='#{url}'></script>" IRuby.display IRuby.html(html) end end |
#url(url) ⇒ Object
61 62 63 |
# File 'lib/iruby/dependencies/dsl.rb', line 61 def url url @url = url end |