Class: Cup::CommandLine::Helper
- Inherits:
-
Object
- Object
- Cup::CommandLine::Helper
- Defined in:
- lib/cup/command_line.rb
Constant Summary collapse
- JasmineStandaloneDistributionURL =
'http://pivotal.github.com/jasmine/downloads/jasmine-standalone-1.1.0.zip'
- JQueryURL =
'http://code.jquery.com/jquery.min.js'
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #cupfile ⇒ Object
- #cupfile? ⇒ Boolean
- #cupfile_default_content(name) ⇒ Object
- #download_jasmine ⇒ Object
- #extra_matchers_file ⇒ Object
- #get_extra_matchers ⇒ Object
- #get_jquery ⇒ Object
- #get_licence ⇒ Object
-
#initialize(path) ⇒ Helper
constructor
A new instance of Helper.
- #jquery_file ⇒ Object
- #licence_file ⇒ Object
- #rackup_file ⇒ Object
- #standard_directories ⇒ Object
Constructor Details
#initialize(path) ⇒ Helper
Returns a new instance of Helper.
21 22 23 |
# File 'lib/cup/command_line.rb', line 21 def initialize (path) @root = Pathname.new(path). end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
19 20 21 |
# File 'lib/cup/command_line.rb', line 19 def root @root end |
Instance Method Details
#cupfile ⇒ Object
25 26 27 |
# File 'lib/cup/command_line.rb', line 25 def cupfile root + 'Cupfile' end |
#cupfile? ⇒ Boolean
63 64 65 |
# File 'lib/cup/command_line.rb', line 63 def cupfile? File.exists?(root + 'Cupfile') end |
#cupfile_default_content(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cup/command_line.rb', line 29 def cupfile_default_content(name) <<-CUPFILE # This file describes the javascript project # see: https://github.com/sjltaylor/cup Cup.define do |cup| name '#{name}' version '0.0.1' licence 'licence.txt' javascripts do spec 'env/jasmine.js', 'env/jasmine-html.js', :* end end CUPFILE end |
#download_jasmine ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cup/command_line.rb', line 104 def download_jasmine %x{ set -o errexit # exit if it hits the fan set -o nounset # using unset variables is an error cd #{root + 'spec/env'} curl --silent #{JasmineStandaloneDistributionURL} > jasmine.zip unzip jasmine.zip -d jasmine cd jasmine cp `find . | grep -E '.*\.(css|js)'` .. cd .. rm -rf jasmine rm jasmine.zip } $?.exitstatus == 0 end |
#extra_matchers_file ⇒ Object
55 56 57 |
# File 'lib/cup/command_line.rb', line 55 def extra_matchers_file root + 'spec/env' + 'extra_matchers.js' end |
#get_extra_matchers ⇒ Object
100 101 102 |
# File 'lib/cup/command_line.rb', line 100 def get_extra_matchers File.read(File.('../../../js/extra_matchers.js', __FILE__)) end |
#get_jquery ⇒ Object
71 72 73 74 |
# File 'lib/cup/command_line.rb', line 71 def get_jquery jquery = `curl --silent #{JQueryURL}` return jquery if $?.exitstatus == 0 end |
#get_licence ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cup/command_line.rb', line 76 def get_licence <<-LICENSE Copyright (C) #{Time.now.year} by #{ENV['USER'] || 'THE_MAN'} Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. LICENSE end |
#jquery_file ⇒ Object
51 52 53 |
# File 'lib/cup/command_line.rb', line 51 def jquery_file root + 'vendor' + 'jquery.min.js' end |
#licence_file ⇒ Object
67 68 69 |
# File 'lib/cup/command_line.rb', line 67 def licence_file root + 'licence.txt' end |
#rackup_file ⇒ Object
59 60 61 |
# File 'lib/cup/command_line.rb', line 59 def rackup_file root + 'config.ru' end |
#standard_directories ⇒ Object
47 48 49 |
# File 'lib/cup/command_line.rb', line 47 def standard_directories %w|src lib vendor spec spec/visual spec/env|.map {|dir| root + dir} end |