ichiban 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df9160a6af9ff5f9c21a2e6a5ca27f7488de6055
4
- data.tar.gz: 9091f8368c5e34f12471910c537ab2e45ea1317d
3
+ metadata.gz: a67d27e89bd72f4afd96687d4bdd0497433fc4c4
4
+ data.tar.gz: 725e54db4c392ce2437c7499aa6674733f7abbf5
5
5
  SHA512:
6
- metadata.gz: 2faa7ec8f821e61c0d39dad65ee70354ddcee0bf5c338a355c6ef901c0ffe5784717b99a0501e97eaca4e3c8bef096dd1d5e97609e5f14d957ce781f140c5b81
7
- data.tar.gz: de957b1070e3f0f85f03065135c10660bf3e049749bcbadc3db593e6c26ce8fbfdeef7e21483d7822f21d7e694c2ed29b791d5f7cb148970bbc3263569b867e2
6
+ metadata.gz: b95a07d33bb48d4c6f8b36272d011c661e5253dc578935573fade28f8dc28f26784fe5da7ace00b3cb369942e9c38cbbacd8c94369c24bb760e2cc383ae7efeb
7
+ data.tar.gz: ec539fd3c4224f33112b85fdff5efe33d4e535d58c53783a6f9dfae15f7055e5e3aa25b2345e96b788bf45a8ef03df725286da3c3eebeede684e644d6da24e18
@@ -1,8 +1,9 @@
1
1
  module Ichiban
2
2
  class Command
3
- def initialize(args)
3
+ def initialize(args, dev = false)
4
4
  @task = args.shift
5
5
  @args = args
6
+ @dev = dev
6
7
  end
7
8
 
8
9
  def print_usage
@@ -10,6 +11,7 @@ module Ichiban
10
11
  "\nUsage: ichiban [command]\n" +
11
12
  "Available commands: \n" +
12
13
  " watch\n" +
14
+ " compile [-a] [path]\n" +
13
15
  " new [path]\n" +
14
16
  " help\n\n" +
15
17
  "https://github.com/jarrett/ichiban\n\n"
@@ -20,8 +22,15 @@ module Ichiban
20
22
  case @task
21
23
  when 'watch'
22
24
  Ichiban.project_root = Dir.getwd
23
- Ichiban.load_bundle
24
25
  Ichiban::Watcher.new.start
26
+ when 'compile'
27
+ Ichiban.project_root = Dir.getwd
28
+ compiler = Ichiban::ManualCompiler.new
29
+ if @args.first == '-a'
30
+ compiler.all
31
+ else
32
+ compiler.paths @args
33
+ end
25
34
  when 'new'
26
35
  Ichiban::ProjectGenerator.new(
27
36
  File.expand_path(@args[0])
@@ -0,0 +1,27 @@
1
+ module Ichiban
2
+ class ManualCompiler
3
+ def all
4
+ paths(
5
+ Dir.glob(File.join(Ichiban.project_root, 'html', '**', '*')) +
6
+ Dir.glob(File.join(Ichiban.project_root, 'assets', '**', '*')) +
7
+ Dir.glob(File.join(Ichiban.project_root, 'scripts', '**', '*')) +
8
+ Dir.glob(File.join(Ichiban.project_root, 'webserver', '**', '*'))
9
+ )
10
+ end
11
+
12
+ def paths(paths_to_compile)
13
+ paths_to_compile.each do |path|
14
+ unless path.start_with? Ichiban.project_root
15
+ path = File.join(Ichiban.project_root, path)
16
+ end
17
+ begin
18
+ if project_file = Ichiban::ProjectFile.from_abs(path)
19
+ project_file.update
20
+ end
21
+ rescue Exception => exc
22
+ Ichiban.logger.exception(exc)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,6 +2,9 @@ module Ichiban
2
2
  module NavHelper
3
3
 
4
4
  def nav(items, options = {})
5
+ unless items.is_a?(Array)
6
+ raise "Expected first parameter of NavHelper#nav to be an Array, but got: #{items.inspect}"
7
+ end
5
8
  Nav.new(items, options, self).to_html
6
9
  end
7
10
 
@@ -28,15 +31,7 @@ module Ichiban
28
31
  def current_path_starts_with?(path)
29
32
  @ctx.path_with_slashes(@ctx.current_path).start_with?(@ctx.path_with_slashes(path))
30
33
  end
31
-
32
-
33
-
34
- #def merge_classes(current_classes, added_classes)
35
- # current_classes = current_classes.split(/ +/)
36
- # added_classes = added_classes.split(/ +/)
37
- # (current_classes + added_classes).uniq.join(' ')
38
- #end
39
-
34
+
40
35
  # Recursive. Checks whether any item in the menu, or any item in any of its descendant
41
36
  # menus, has a path that *starts with* the current path. E.g. if a menu or its descendants
42
37
  # have a link to '/a/b/c/', and we're at '/a/b/c/d/e/f/', then this method returns true.
@@ -50,26 +45,11 @@ module Ichiban
50
45
  # If an item has a sub-menu, then that menu must be the third element of the array.
51
46
  # (The format is [text, path, sub_menu, li_options].) So we recursively search the
52
47
  # descendant menu(s) of this item.
53
- menu_matches_current_path?(items[2])
48
+ menu_matches_current_path?(item[2])
54
49
  end
55
50
  end.nil?
56
51
  end
57
52
 
58
- # Recursive
59
- #def sub_menu_contains_current_path?(items)
60
- # !items.detect do |item|
61
- # if current_path?(item[1])
62
- # true
63
- # elsif item[2].is_a?(Array)
64
- # sub_menu_contains_current_path?(item[2])
65
- # elsif item[3].is_a?(Array)
66
- # sub_menu_contains_current_path?(item[3])
67
- # else
68
- # false
69
- # end
70
- # end.nil?
71
- #end
72
-
73
53
  # Recursive
74
54
  def ul(items, depth)
75
55
  # If we're in the outermost menu, add any passed-in <ul> attributes
@@ -152,20 +132,6 @@ module Ichiban
152
132
  li_inner_html
153
133
  end
154
134
 
155
- #lis << @ctx.content_tag('li', li_attrs) do
156
- # in_sub_path = (path != '/' and @options[:consider_sub_paths] and @ctx.path_with_slashes(@ctx.current_path).start_with?(@ctx.path_with_slashes(path)))
157
- # if current_path?(path)
158
- # li_inner_html = @ctx.content_tag('span', text, 'class' => 'selected')
159
- # elsif (sub_menu and sub_menu_contains_current_path?(sub_menu)) or in_sub_path
160
- # li_inner_html = @ctx.link_to(text, path, 'class' => 'ancestor_of_selected')
161
- # else
162
- # li_inner_html = @ctx.link_to(text, path)
163
- # end
164
- # if sub_menu and (current_path?(path) or sub_menu_contains_current_path?(sub_menu) or in_sub_path)
165
- # li_inner_html << ul(sub_menu, depth + 1)
166
- # end
167
- # li_inner_html
168
- #end
169
135
  lis
170
136
  end
171
137
  end
data/lib/ichiban.rb CHANGED
@@ -18,7 +18,6 @@ require 'therubyracer'
18
18
  require 'source_map'
19
19
 
20
20
  # Ichiban files. Order matters!
21
- require 'ichiban/bundle'
22
21
  require 'ichiban/config'
23
22
  require 'ichiban/logger'
24
23
  require 'ichiban/command'
@@ -26,6 +25,7 @@ require 'ichiban/project_generator'
26
25
  require 'ichiban/dependencies'
27
26
  require 'ichiban/loader'
28
27
  require 'ichiban/watcher'
28
+ require 'ichiban/manual_compiler'
29
29
  require 'ichiban/deleter'
30
30
  require 'ichiban/project_file'
31
31
  require 'ichiban/helpers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ichiban
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Colby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-03 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ejs
@@ -331,7 +331,6 @@ files:
331
331
  - empty_project/webserver/htaccess.txt
332
332
  - lib/ichiban.rb
333
333
  - lib/ichiban/asset_compiler.rb
334
- - lib/ichiban/bundle.rb
335
334
  - lib/ichiban/command.rb
336
335
  - lib/ichiban/config.rb
337
336
  - lib/ichiban/deleter.rb
@@ -342,6 +341,7 @@ files:
342
341
  - lib/ichiban/js_compiler.rb
343
342
  - lib/ichiban/loader.rb
344
343
  - lib/ichiban/logger.rb
344
+ - lib/ichiban/manual_compiler.rb
345
345
  - lib/ichiban/markdown.rb
346
346
  - lib/ichiban/nav_helper.rb
347
347
  - lib/ichiban/project_file.rb
@@ -1,7 +0,0 @@
1
- module Ichiban
2
- def self.load_bundle
3
- if Ichiban.project_root and File.exists?(File.join(Ichiban.project_root, 'Gemfile'))
4
- Bundler.require
5
- end
6
- end
7
- end