susanoo 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c60da5900b89568fe851951a06b0f6cc876e055d
4
- data.tar.gz: b095140999ff6f4ede405579b6d9417c06eae6b2
3
+ metadata.gz: 2210077ec0c7b3d0def8270a6b8b778af3dba460
4
+ data.tar.gz: 15011c0daec98a25102da19518cc50fb34031e86
5
5
  SHA512:
6
- metadata.gz: 49f9e95ee26f5611e4484e0dae27c53ebee56a0979aee7fb5b8587d3f7f7ad7c3afd2716d7ba40086ee0e124d6ea2a70bfd95690a637aef10786e029d18f141b
7
- data.tar.gz: 75a117a6d0a344f90484ff92774527d520039b84524e5f8d068ee6310cce20323870877a8369b43807a497ccbdcaef914ef3b5a2a8d310122d470edb01208d53
6
+ metadata.gz: 93fb8c1e3a99c0a7af1766f0ff21ddba4763cbd98b2e2b5a2526937aefb57e31315991aa2a4c89a9c3369f4776a485a46c257ca85ca1c449b0e82ec2ed6435e5
7
+ data.tar.gz: 841998856f7b967e9c420de47e755a24b37d6eda51ccf8da4f26985a90452252c0421d4db2f00a874c7e5462043ae2ecac3ebc4ec6645260b160f0e71002181e
@@ -12,3 +12,4 @@ end
12
12
  require 'susanoo/controllers/index'
13
13
  require 'susanoo/controllers/views'
14
14
  require 'susanoo/controllers/assets'
15
+ require 'susanoo/controllers/static'
@@ -14,12 +14,19 @@ module Susanoo
14
14
  map 'g' => :generate
15
15
  map 'r' => :run_in
16
16
  map 'd' => :destroy
17
+ map 'b' => :build
17
18
 
19
+ # Set the project root
18
20
  def self.root=(path)
19
21
  @@root = path
20
22
  Susanoo::Project.path = path
21
23
  end
22
24
 
25
+ # Set source paths for current generator
26
+ def self.source_root
27
+ "#{@@root}/src"
28
+ end
29
+
23
30
  desc 'generate GENERATOR [options]', 'Run the given generator'
24
31
  def generate(generator_name = nil, *options)
25
32
  generator = get_the_generator_class generator_name
@@ -68,6 +75,8 @@ module Susanoo
68
75
 
69
76
  require File.join(project_root, 'config/routes')
70
77
 
78
+ router = ROUTER.instance_variable_get('@router')
79
+
71
80
  build_dir = File.join(project_root, 'www')
72
81
  # setup build directory
73
82
 
@@ -80,15 +89,16 @@ module Susanoo
80
89
  # and we can't change it as far as I know
81
90
  empty_directory build_dir
82
91
 
83
- Susanoo::StaticGenerator.classes.each do |klass|
84
- instance = klass.new
85
- if instance.respond_to? :build
86
- instance.build(self)
92
+ router.routes.each do |route|
93
+ controller = route.dest
94
+ if controller.respond_to? :build
95
+ say_status 'build', "Controller: #{controller.__getobj__.class}"
96
+ controller.build(self, route.dup)
87
97
  else
88
- puts "[Warning]: '#{instance.class.to_s}' does not have 'build' method."
98
+ say_status 'warning', "#{controller.__getobj__.class.to_s}' does not have 'build' method.",
99
+ :yellow
89
100
  end
90
101
  end
91
-
92
102
  end
93
103
 
94
104
  desc 'run PLATFORM', 'Run application on PLATFORM.'
@@ -117,8 +127,8 @@ module Susanoo
117
127
  generator = Susanoo::Generators.const_get(klass)
118
128
 
119
129
  rescue NameError
120
- print '[Error]:'.colorize(:red)
121
- say "Generator `#{generator}` not found."
130
+ say_status 'Error', "Generator `#{generator_name}` not found.",
131
+ :red
122
132
  exit 1
123
133
  end
124
134
  generator
@@ -31,6 +31,5 @@ module Susanoo
31
31
  @static_compile
32
32
  end
33
33
 
34
-
35
34
  end
36
35
  end
@@ -11,7 +11,7 @@ class Susanoo::Application
11
11
  run environment
12
12
  end
13
13
 
14
- def build(generator)
14
+ def build(generator, route)
15
15
  assets = Sprockets::Environment.new
16
16
  assets.append_path File.join(project_root,
17
17
  'src/assets/javascripts')
@@ -42,7 +42,7 @@ class Susanoo::Application
42
42
  if File.exist? File.join(project_root,
43
43
  'src/assets/fonts')
44
44
  generator.say_status 'copy', 'src/assets/fonts'
45
- `cp #{project_root}/src/assets/fonts #{project_root}/www/assets/fonts -rv`
45
+ `cp #{project_root}/src/assets/fonts #{project_root}/www/assets/fonts -r`
46
46
  end
47
47
  end
48
48
  end
@@ -10,11 +10,12 @@ class Susanoo::Application
10
10
  [200, {'Content-Type' => 'text/html'}, [template.render(self)]]
11
11
  end
12
12
 
13
- def build(generator)
13
+ def build(generator, route)
14
14
  # Configure Sprockets::Helpers (if necessary)
15
15
  Sprockets::Helpers.configure do |config|
16
16
  config.environment = @environment
17
17
  config.prefix = 'assets'
18
+ config.debug = false
18
19
  end
19
20
 
20
21
  template = Tilt.new(File.join(project_root, 'src/index.html.erb'))
@@ -0,0 +1,29 @@
1
+ require 'rack'
2
+
3
+ class Susanoo::Application
4
+
5
+ # This controller is responsible for serving/building static files.
6
+ # It does not supports regex at this time.
7
+ class Static < Susanoo::Controller
8
+ # TODO: Add regext support to this controller
9
+ def call(env)
10
+ path = env['REQUEST_PATH']
11
+ file = ::File.join(project_root, 'src', path)
12
+ if ::File.exist? file
13
+ [200,
14
+ {'Content-Type' => 'text/plain'},
15
+ [::File.new(file).read]]
16
+ else
17
+ [404,
18
+ {},
19
+ ['Can not find the file']]
20
+ end
21
+ end
22
+
23
+ def build(generator, route)
24
+ file = route.path_for_generation[1..-1]
25
+ generator.copy_file file, "www/#{route.path_for_generation}"
26
+ end
27
+ end
28
+
29
+ end
@@ -15,7 +15,7 @@ class Susanoo::Application
15
15
  [200, {'Content-Type' => 'text/html'}, [template.render(self)]]
16
16
  end
17
17
 
18
- def build(generator)
18
+ def build(generator, route)
19
19
  file_pattern = File.join(project_root, 'src/views/**/*.{html,html.erb}')
20
20
  dest_path = File.join(project_root, 'www')
21
21
  src_path = File.join(project_root, 'src')
@@ -0,0 +1,65 @@
1
+ module Susanoo
2
+ module Generators
3
+ class NgModule < Thor::Group
4
+ include Thor::Actions
5
+
6
+ desc 'Create an AngularJS directive.'
7
+
8
+ argument :name, type: :string, desc: 'Name of AngularJS directive'
9
+ class_option :deps, type: :string, default: '',
10
+ desc: 'Dependencies of Angularjs module, comma separated'
11
+
12
+ class_option :restrict, type: :string, default: 'E',
13
+ desc: 'AngularJS directive restriction types'
14
+
15
+ class_option :replace, type: :boolean, default: true,
16
+ desc: 'AngularJS directive replace option'
17
+
18
+ # TODO: Add an append class option to allow user
19
+ # to append the directive to already defined
20
+ # modules
21
+
22
+ def self.source_root
23
+ File.join(File.dirname(__FILE__),
24
+ '../templates/generators/ng_directive')
25
+ end
26
+
27
+ def self.global_generator?
28
+ false
29
+ end
30
+
31
+ def setup_directories
32
+ empty_directory "src/views/directives/#{directive_name}"
33
+
34
+ mpath = 'src/assets/javascripts/modules/directives'
35
+ empty_directory "#{mpaath}" unless directory_name.nil?
36
+ end
37
+
38
+ def install_js_module
39
+ template 'directive.js.erb',
40
+ "src/assets/javascripts/modules/#{directory_name}#{directive_name}.js"
41
+ end
42
+
43
+ def install_view
44
+ template('index.html.erb',
45
+ "src/views/#{directory_name}#{directive_name}/#{directive_name}.html")
46
+ end
47
+
48
+ private
49
+
50
+ def directory_name
51
+ dir_name = name.split('/')[0..-2].join('/')
52
+ return dir_name + '/' unless dir_name.empty?
53
+ nil
54
+ end
55
+
56
+ def directive_name
57
+ name.split('/')[-1].underscore
58
+ end
59
+
60
+ def dependencies
61
+ options[:deps].split(',')
62
+ end
63
+ end
64
+ end
65
+ end
@@ -5,7 +5,7 @@ module Susanoo
5
5
 
6
6
  desc 'Create an AngularJS module.'
7
7
 
8
- argument :name, type: :string, desc: 'Name of AngularJS'
8
+ argument :name, type: :string, desc: 'Name of AngularJS module'
9
9
  class_option :deps, type: :string, default: '', desc: 'Dependencies of Angularjs module, comma separated'
10
10
 
11
11
  def self.source_root
@@ -1,3 +1,3 @@
1
1
  module Susanoo
2
- VERSION = '0.8.0'
2
+ VERSION = '0.10.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: susanoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Rahmani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -263,10 +263,12 @@ files:
263
263
  - lib/susanoo/controller.rb
264
264
  - lib/susanoo/controllers/assets.rb
265
265
  - lib/susanoo/controllers/index.rb
266
+ - lib/susanoo/controllers/static.rb
266
267
  - lib/susanoo/controllers/views.rb
267
268
  - lib/susanoo/generators.rb
268
269
  - lib/susanoo/generators/cordova.rb
269
270
  - lib/susanoo/generators/frameworks.rb
271
+ - lib/susanoo/generators/ng_directive.rb
270
272
  - lib/susanoo/generators/ng_module.rb
271
273
  - lib/susanoo/generators/scaffold.rb
272
274
  - lib/susanoo/project.rb