xmvc 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,11 +11,10 @@ begin
11
11
  gem.homepage = "http://github.com/christocracy/extjs-core"
12
12
  gem.authors = ["Ed Spencer and Chris Scott"]
13
13
 
14
- gem.add_dependency "extlib", ">=0.9.14"
15
- gem.add_dependency "thor", ">=0.13.4"
16
- gem.add_dependency "jammit-core", ">=0.1.0"
17
- gem.add_dependency "whorm", ">=0.1.0"
18
- gem.add_dependency "hpricot", ">=0.8.2"
14
+ gem.add_dependency "extlib", ">= 0.9.14"
15
+ gem.add_dependency "thor", ">= 0.13.4"
16
+ gem.add_dependency "whorm", ">= 0.1.0"
17
+ gem.add_dependency "hpricot", ">= 0.8.2"
19
18
  gem.add_dependency "sprockets"
20
19
 
21
20
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
data/bin/xmvc CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  # Check if an older version of extjs-mvc is installed
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
5
- $LOAD_PATH.unshift("/Users/chris/workspace/extjs/extjs-mvc/lib")
6
5
 
7
6
  require 'xmvc'
8
7
  require 'xmvc/cli'
data/lib/xmvc/cli.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  require 'thor'
2
2
  require 'thor/group'
3
-
4
- require 'jammit-core'
5
- require 'jammit-core/cli'
6
3
 
7
4
  module Xmvc
8
5
  class CLI < Thor
@@ -0,0 +1,118 @@
1
+ module Xmvc
2
+ module Helpers
3
+ module Sprockets
4
+ class << self
5
+ def included(klass)
6
+ klass.send(:extend, ClassMethods)
7
+ klass.send(:include, InstanceMethods)
8
+ end
9
+ end
10
+
11
+ module InstanceMethods
12
+ ##
13
+ # Convenience method simply delegates to ClassMethod
14
+ #
15
+ def xmvc_asset(vid, format)
16
+ self.class.xmvc_asset(vid, format)
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+ ##
22
+ # Define the available vendors with Thor task API
23
+ # xmvc_vendors :extjs => ExtJS::API, :"extjs-mvc" => ExtJS::MVC::API
24
+ #
25
+ def xmvc_vendors(vendors)
26
+ @vendors = vendors
27
+
28
+ # Add the Xmvc API
29
+ @vendors[:app] = Xmvc::API
30
+ end
31
+
32
+ ##
33
+ # Defines the Sprockets root param
34
+ # xmvc_root File.join(MyApp::ROOT, "subfolder")
35
+ #
36
+ def xmvc_root(root)
37
+ @xmvc_root = root
38
+ end
39
+
40
+ ##
41
+ # Defines teh Sprockets asset_root param where concatenation files will be created.
42
+ #
43
+ def xmvc_asset_root(asset_root)
44
+ @xmvc_asset_root = asset_root
45
+ end
46
+
47
+ ##
48
+ # Request a Sprockets::Concatenation file
49
+ # @param {Symbol} vid Vendor-id
50
+ # @param {Symbol} format :js, :css, :sass, etc
51
+ #
52
+ def xmvc_asset(vid, format)
53
+ sec = secretary(vid.to_sym, format)
54
+ filename = File.join(@xmvc_root, @xmvc_asset_root, "javascripts", vid.to_s, "#{vid}-all.#{format.to_s}")
55
+ unless source_is_unchanged?(sec)
56
+ sec.concatenation.save_to(filename)
57
+ end
58
+ filename
59
+ end
60
+
61
+ private
62
+ ##
63
+ # Define a list of vendor-id -> Thor module
64
+ #
65
+ def vendor(vid)
66
+ @vendors[vid]
67
+ end
68
+
69
+ ##
70
+ # return last modified time of Secretary concatenation
71
+ # @param {Sprockets::Secretary}
72
+ #
73
+ def source_last_modified(sec)
74
+ @last_modified ||= {}
75
+ @last_modified[sec.object_id]
76
+ end
77
+
78
+ ##
79
+ # cache the last-modified time of a Sprockets::Secretary concatenation
80
+ #
81
+ def record_source_last_modified (sec)
82
+ @last_modified ||= {}
83
+ @last_modified[sec.object_id] = sec.source_last_modified
84
+ end
85
+
86
+ ##
87
+ # return associated vendor's Sprockets::Secretary.
88
+ # @param {String} vid Vendor-ID
89
+ # @param {Symbol} format :js, :ccs, :sass, :images
90
+ #
91
+ def secretary(vid, format)
92
+ @secretary ||= {}
93
+ unless @secretary[vid]
94
+ begin
95
+ @secretary[vid] = vendor(vid).new([], {
96
+ :format => :js,
97
+ :root => (vid == :app) ? @xmvc_root : File.join(@xmvc_root, "vendor"),
98
+ }).invoke(:secretary, [])
99
+ rescue Xmvc::Error => e
100
+ halt e.message
101
+ end
102
+ end
103
+ @secretary[vid]
104
+ end
105
+
106
+ ##
107
+ # returns true if a Sprocket::Secretary's source has changed since last-modified
108
+ #
109
+ def source_is_unchanged? (sec)
110
+ sec.reset!
111
+ previous_source_last_modified = source_last_modified(sec)
112
+ record_source_last_modified(sec)
113
+ previous_source_last_modified == source_last_modified(sec)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ module Xmvc
3
+ module Helpers
4
+ autoload :Sprockets, 'helpers/sprockets'
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module Xmvc
2
+ class Vendor
3
+ class Plugin < Thor
4
+
5
+ def initialize(args, options, config)
6
+ puts "options: #{options}, config: #{config}"
7
+ say_status("Xmvc::Vendor::Plugin initialized, load teh config file")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+
3
+ module Xmvc
4
+
5
+ class Vendor < Thor
6
+ autoload :Plugin, 'vendor/plugin'
7
+
8
+ #CONFIG_PATH = File.join(ROOT, "vendor.yml")
9
+ #ROOT = File.dirname(__FILE__)
10
+ #class << self
11
+ # def config(root)
12
+ # @config ||= YAML.load(File.read(File.join(root, "vendor.yml", ))).to_mash
13
+ # end
14
+ #end
15
+
16
+ def initialize(args, options, config)
17
+ puts "options: #{options}, config: #{config}"
18
+ say_status("Xmvc::Vendor initialized, load teh config file")
19
+ end
20
+ end
21
+ end
data/lib/xmvc.rb CHANGED
@@ -1,5 +1,3 @@
1
- #$LOAD_PATH.unshift(File.dirname(__FILE__))
2
-
3
1
  require 'fileutils'
4
2
  require 'pathname'
5
3
  require 'yaml'
@@ -30,11 +28,11 @@ module Xmvc
30
28
  require 'xmvc/builder'
31
29
  require 'xmvc/config'
32
30
  #require 'xmvc/api' # <-- autoloadable ?? check with Sinatra handlers "sprockets"
33
-
31
+ autoload :Vendor, 'xmvc/vendor'
32
+ autoload :Helpers, 'xmvc/helpers'
34
33
  autoload :API, 'xmvc/api'
35
34
  autoload :UI, 'xmvc/ui'
36
35
  autoload :Generator, 'xmvc/generator'
37
- autoload :Environment, 'xmvc/environment'
38
36
  autoload :Plugin, 'xmvc/plugin'
39
37
  autoload :Stats, 'xmvc/stats'
40
38
  autoload :Test, 'xmvc/test'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ed Spencer and Chris Scott
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: jammit-core
49
+ name: whorm
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  requirements:
@@ -59,24 +59,10 @@ dependencies:
59
59
  version: 0.1.0
60
60
  type: :runtime
61
61
  version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: whorm
64
- prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- - 1
72
- - 0
73
- version: 0.1.0
74
- type: :runtime
75
- version_requirements: *id004
76
62
  - !ruby/object:Gem::Dependency
77
63
  name: hpricot
78
64
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
80
66
  requirements:
81
67
  - - ">="
82
68
  - !ruby/object:Gem::Version
@@ -86,11 +72,11 @@ dependencies:
86
72
  - 2
87
73
  version: 0.8.2
88
74
  type: :runtime
89
- version_requirements: *id005
75
+ version_requirements: *id004
90
76
  - !ruby/object:Gem::Dependency
91
77
  name: sprockets
92
78
  prerelease: false
93
- requirement: &id006 !ruby/object:Gem::Requirement
79
+ requirement: &id005 !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - ">="
96
82
  - !ruby/object:Gem::Version
@@ -98,11 +84,11 @@ dependencies:
98
84
  - 0
99
85
  version: "0"
100
86
  type: :runtime
101
- version_requirements: *id006
87
+ version_requirements: *id005
102
88
  - !ruby/object:Gem::Dependency
103
89
  name: thoughtbot-shoulda
104
90
  prerelease: false
105
- requirement: &id007 !ruby/object:Gem::Requirement
91
+ requirement: &id006 !ruby/object:Gem::Requirement
106
92
  requirements:
107
93
  - - ">="
108
94
  - !ruby/object:Gem::Version
@@ -110,7 +96,7 @@ dependencies:
110
96
  - 0
111
97
  version: "0"
112
98
  type: :development
113
- version_requirements: *id007
99
+ version_requirements: *id006
114
100
  description: A full-stack, full-stack MVC framework generator geared towards generating towards the Ext JS framework. The actual javascript framework implementation is provided by the Gem extjs-mvc. This gem contains a series of builders and erb-templates for auto-generating javascript model, view and controller class-files.
115
101
  email: christocracy@gmail.com
116
102
  executables:
@@ -140,7 +126,6 @@ files:
140
126
  - lib/xmvc/builders/vendor.rb
141
127
  - lib/xmvc/cli.rb
142
128
  - lib/xmvc/config.rb
143
- - lib/xmvc/environment.rb
144
129
  - lib/xmvc/generator.rb
145
130
  - lib/xmvc/generators/app.rb
146
131
  - lib/xmvc/generators/boot.rb
@@ -191,12 +176,16 @@ files:
191
176
  - lib/xmvc/generators/templates/layout.html.erb
192
177
  - lib/xmvc/generators/templates/scaffold/ScaffoldController.js
193
178
  - lib/xmvc/generators/view.rb
179
+ - lib/xmvc/helpers.rb
180
+ - lib/xmvc/helpers/sprockets.rb
194
181
  - lib/xmvc/plugin.rb
195
182
  - lib/xmvc/stats.rb
196
183
  - lib/xmvc/test.rb
197
184
  - lib/xmvc/testserver.ru
198
185
  - lib/xmvc/ui.rb
199
186
  - lib/xmvc/update.rb
187
+ - lib/xmvc/vendor.rb
188
+ - lib/xmvc/vendor/plugin.rb
200
189
  - test/helper.rb
201
190
  - test/test_extjs-core.rb
202
191
  has_rdoc: true
@@ -1,92 +0,0 @@
1
- module Xmvc
2
- module Environment
3
-
4
- DEFAULT_ENVIRONMENT = File.join(Xmvc::CONFIG_PATH, "environment")
5
- ENVIRONMENT_PATH = File.join(Xmvc::CONFIG_PATH, "environments")
6
-
7
- class FileNotFound < Xmvc::Error; status_code(10) ; end
8
-
9
- class << self
10
-
11
- ##
12
- # TODO implement development/production environments
13
- #
14
- def load(environment)
15
- @environment = environment
16
- @config = load_environment(environment)
17
- self
18
- end
19
-
20
- def get(key)
21
- config[key]
22
- end
23
-
24
- def set(key, value)
25
- config[key] = value
26
- save
27
- end
28
-
29
- ##
30
- # write a newly generated controller, model or view to environment.json
31
- # Unfortunately, we cannot JSON.parse the entire config/environment.json, since it contains comments
32
- # and such. Have to RegExp, pick-out the requested key, and JSON.parse the returned chunk.
33
- # Is this Regexp satisfactory?? Could probably be made better.
34
- #
35
- def add (key, item)
36
- key = key.to_s
37
- config[key] = [] unless config[key] && config[key].kind_of?(Array)
38
-
39
- unless key == "views"
40
- config[key] << item
41
- else
42
- if controller = config[key].find {|i| i[item[:package]]}
43
- controller[item[:package]] << item[:filename]
44
- else
45
- config[key] << {
46
- item[:package] => [
47
- item[:filename]
48
- ]
49
- }
50
- end
51
- end
52
- save
53
- end
54
-
55
- def render
56
- File.open("#{DEFAULT_ENVIRONMENT}.json", "w") {|file|
57
- file << config.to_json
58
- }
59
- end
60
-
61
- def config
62
- @config ||= load_environment(:development)
63
- end
64
-
65
- private
66
-
67
- ##
68
- # TODO: load and merge! specific environemnt.
69
- #
70
- def load_environment(environment)
71
- # When generating a new app, there is no environment yet
72
- #
73
- #unless File.exists?("#{DEFAULT_ENVIRONMENT}.yml")
74
- # raise FileNotFound.new("Failed to load environment #{DEFAULT_ENVIRONMENT}.yml")
75
- #end
76
- if File.exists? "#{DEFAULT_ENVIRONMENT}.yml"
77
- YAML.load_file("#{DEFAULT_ENVIRONMENT}.yml")
78
- end
79
- end
80
-
81
- def save
82
- File.open("#{DEFAULT_ENVIRONMENT}.yml", "w") {|file|
83
- file << config.to_yaml
84
- }
85
- File.open("#{DEFAULT_ENVIRONMENT}.json", "w") {|file|
86
- file << config.to_json
87
- }
88
- end
89
- end
90
- end
91
- end
92
-