Module: Xmvc

Defined in:
lib/xmvc/stats.rb,
lib/xmvc.rb,
lib/xmvc/ui.rb,
lib/xmvc/api.rb,
lib/xmvc/cli.rb,
lib/xmvc/test.rb,
lib/xmvc/config.rb,
lib/xmvc/update.rb,
lib/xmvc/vendor.rb,
lib/xmvc/builder.rb,
lib/xmvc/helpers.rb,
lib/xmvc/generator.rb,
lib/xmvc/vendor/plugin.rb,
lib/xmvc/generators/app.rb,
lib/xmvc/generators/boot.rb,
lib/xmvc/generators/view.rb,
lib/xmvc/generators/model.rb,
lib/xmvc/generators/layout.rb,
lib/xmvc/helpers/sprockets.rb,
lib/xmvc/generators/scaffold.rb,
lib/xmvc/generators/controller.rb,
lib/xmvc/generators/environment.rb

Overview

run ruby script/update to update MVC files used inside the baseapp, such as ensuring the files in the ‘script’ folder are up to date`

Defined Under Namespace

Modules: Builder, Generator, Helpers, Stats, Update Classes: API, AppAlreadyExists, AppNotFound, ArgumentError, BuilderError, CLI, Config, Error, FileExists, HostError, NoFramework, Test, UI, Vendor, VendorFileNotFound

Constant Summary collapse

VERSION =
"0.4.0.a"
ROOT =
File.dirname(__FILE__)
CONFIG_PATH =
"config"
TEMPLATE_PATH =
File.join(ROOT, "xmvc", "generators", "templates")
PUBLIC_PATH =
"public"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Xmvc


82
83
84
# File 'lib/xmvc.rb', line 82

def config
  @config
end

.environmentObject Also known as: env

The Xmvc::Environemnt instance



64
65
66
# File 'lib/xmvc.rb', line 64

def environment
  @environment
end

.hostObject

An instance of supplied framework plugin, eg ExtJS::MVC::CLI deprecate



71
72
73
# File 'lib/xmvc.rb', line 71

def host
  @host
end

.public_pathObject

Returns the value of attribute public_path.



78
79
80
# File 'lib/xmvc.rb', line 78

def public_path
  @public_path
end

.uiObject



152
153
154
# File 'lib/xmvc.rb', line 152

def ui
  @ui ||= UI.new
end

.vendorsObject

Thor


76
77
78
# File 'lib/xmvc.rb', line 76

def vendors
  @vendors
end

Class Method Details

.asset_dir(type) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/xmvc.rb', line 122

def asset_dir(type)
  case type
  when :js
    "javascripts"
  when :css
    "stylesheets"
  when :images
    "images"
  when :sass
    "sass"
  end
end

.asset_mgr(options = {}) ⇒ Object



147
148
149
150
# File 'lib/xmvc.rb', line 147

def asset_mgr(options={})
  warn("Xmvc.asset_mgr is disabled")
  #@asset_mgr ||= Jammit::CLI.new([], options)
end

.build_cachefly_url(host, name, version, file) ⇒ Object



112
113
114
# File 'lib/xmvc.rb', line 112

def build_cachefly_url(host, name, version, file)
  File.join(host, "#{name}-#{version}", file)
end

.build_name(environment, name, version, ext) ⇒ Object



116
117
118
119
120
# File 'lib/xmvc.rb', line 116

def build_name(environment, name, version, ext)
  suffix    = (environment == :development) ? "-all-debug" : "-all"
  version   = (version.nil? or version.empty?) ? "" : "-#{version}"
  name.to_s+version.to_s+suffix+'.'+ext.to_s
end

.build_path(environment, host, name, version, ext) ⇒ Object

builds a public asset-path for a single asset-path

Parameters:

  • environment (Symbol)
  • vendor (String)

    name

  • version (String)
  • ext (String)

    The file-extension :js, :css, :sass, etc.



105
106
107
108
109
110
# File 'lib/xmvc.rb', line 105

def build_path(environment, host, name, version, ext)
  unless host.include? "http://"
    host = (host == PUBLIC_PATH) ? "/#{host}/#{asset_dir(ext)}" : "/#{host}"
  end
  File.join(host, name.to_s, build_name(environment, name, version, ext))
end

.ensure_in_appObject

Ensure we’re running within a rails app unless generating a new app ($ xmvc generate app foo)



138
139
140
141
142
143
144
145
# File 'lib/xmvc.rb', line 138

def ensure_in_app
  
  # Check for existence of arbitrary app files...see if it *looks* like we're in an Xmvc app.
  unless ARGV.empty? || ARGV.first == "help" || (File.exists?("config") && File.exists?("config/environment.yml"))
    raise Xmvc::AppNotFound.new("This command must be executed from the root of an xmvc application")
  end
  
end

.public_build_paths(environment, vendor, ext) ⇒ Object

Parameters:

  • type (Symbol)

    :js, :css, :image

  • vendor (Xmvc::Vendor)
  • type (Symbol)

    :js|:css|:sass|:haml, etc

  • environment (Symbol)

    :development|:production



90
91
92
93
94
95
96
# File 'lib/xmvc.rb', line 90

def public_build_paths(environment, vendor, ext)
  vspec = vendor.config
  @rs = []
  vendor.config[asset_dir(ext)].each do |file|
    @rs << build_path(environment, vspec["host"], vspec["name"], vspec["version"], ext)
  end
end