Class: Jqp::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/jqp/cli.rb

Class Method Summary collapse

Class Method Details

.execute(stdout, arguments = []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/jqp/cli.rb', line 5

def self.execute(stdout, arguments=[])

  options = {
    :project     => 'jqplugin',
    :version     => '0.0.1'
  }
  mandatory_options = %w(project)

  parser = OptionParser.new do |opts|
    opts.banner = <<-BANNER.gsub(/^          /,'')
      jQuery plugin generator to help you kick start your plugin development with the following structure:
      
       plugin
         /src
           /css
           /images
           query.plugin.js
         /test
           spec_plugin.js
           acceptance_plugin.js
           specs.html
           acceptance.html
         /lib
          /jsspec
          jquery.min.js
          jquery-ui.js
          /themes
            /base
         example.html
         Rakefile
         History.txt
         README.txt

      Usage: #{File.basename($0)} [options]

      Options are:
    BANNER
    opts.separator ""
    opts.on("-p", "--project=Name", String,
            "The project name should be simple eg 'widget'",
            "And it will be transformed to jquery.widget.js - there is currently no override feature on this naming convention",
            "Default: ~jq-plugin") { |arg| options[:project] = arg }
    opts.on("-v", "--version=x.x.x", String,
            "Default: 0.0.1") { |arg| options[:version] = arg }
    opts.on("-h", "--help",
            "Show this help message.") { stdout.puts opts; exit }
    opts.parse!(arguments)

    if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
      stdout.puts opts; exit
    end
  end

  JqueryPluginGen::Generator.execute(options)
  
  stdout.puts <<-MSG
  
**********************************************************

Now include the jQuery libraries with:

  cd <jq-plugin>
  rake first_time

First time will:
 - add jquery core, ui and base themes
 - compile js to a packed version (see build directory)
 - load three html files in your browser to demon
1. Acceptance tests
2. Spec tests
3. Example page

Note: you don't have to add jquery core, ui and themes.
However, if you don't you will need to update the html 
pages (example.html, test/spec.html). To see other options
use rake -T

**********************************************************

MSG
end