coherent 0.2.0 → 0.2.1

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.
data/Rakefile CHANGED
@@ -12,7 +12,8 @@ begin
12
12
  gem.authors = ["Jeff Watkins"]
13
13
  gem.files= Dir['lib/**/*', 'app_generators/**/*', 'generators/**/*', 'bin/*', '[A-Za-z]*', 'vendor/**/*']
14
14
  gem.files.reject! { |f| File.directory?(f) }
15
- gem.add_dependency('distil', '>= 0.8.0')
15
+ gem.add_dependency('distil', '>= 0.8.4')
16
+ gem.add_dependency('rubigen', '>= 1.5.2')
16
17
  # gem.extensions= ['vendor/extconf.rb']
17
18
 
18
19
  # gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -2,10 +2,20 @@ name: <%=name%>
2
2
  version: 1.0.0
3
3
  notice: src/NOTICE
4
4
  output folder: build/res/latest
5
+
6
+ # When copying or linking to the source in the build, remove this folder prefix
7
+ # before copying or linking.
5
8
  remove prefix: src
9
+
10
+ # Need to include the coherent extensions for Distil.
11
+ distilery: coherent
12
+
13
+ # Set up external projects.
6
14
  external projects:
7
15
  ext/coherent: http://coherent.googlecode.com/svn/trunk
8
16
 
17
+
18
+
9
19
  # This is the main target for your application. This target will yield optimised
10
20
  # CSS and Javascript files for all of your assets. In addition, it will emit
11
21
  # uncompressed and debug versions which are useful during development.
@@ -10,16 +10,8 @@
10
10
  </head>
11
11
  <body>
12
12
  <script>
13
- var viewController= new coherent.ViewController({
14
- nibUrl: "res/latest/<%=nib_name%>.jsnib"
15
- });
16
- var d= viewController.loadView();
17
-
18
- function viewLoaded(whatever)
19
- {
20
- document.body.appendChild(viewController.view().node);
21
- }
22
- d.addCallback(viewLoaded);
13
+ coherent.Application.shared.setAssetLocation("res/latest");
14
+ coherent.Application.shared.setMainBundle("<%=nib_name%>");
23
15
  </script>
24
16
  </body>
25
17
  </html>
data/bin/coherent CHANGED
@@ -13,7 +13,8 @@ def find_app_root
13
13
  end
14
14
  end
15
15
 
16
- if ('app'==ARGV[0])
16
+ case ARGV[0]
17
+ when 'app'
17
18
  # pull off app "command"
18
19
  ARGV.shift
19
20
 
@@ -23,6 +24,17 @@ if ('app'==ARGV[0])
23
24
  RubiGen::Base.append_sources source
24
25
 
25
26
  RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'coherent')
27
+ when 'demo'
28
+ # pull off app "command"
29
+ ARGV.shift
30
+
31
+ source = RubiGen::PathSource.new(:application,
32
+ File.join(File.dirname(__FILE__), "../demo_generators"))
33
+ RubiGen::Base.reset_sources
34
+ RubiGen::Base.append_sources source
35
+
36
+ generator= ARGV.shift
37
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => generator)
26
38
  else
27
39
  APP_ROOT= find_app_root || Dir.pwd
28
40
 
data/coherent.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{coherent}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Watkins"]
12
- s.date = %q{2009-12-22}
12
+ s.date = %q{2010-01-17}
13
13
  s.default_executable = %q{coherent}
14
14
  s.description = %q{Tools for building Coherent application or modules.}
15
15
  s.email = %q{jeff@metrocat.org}
@@ -54,7 +54,11 @@ Gem::Specification.new do |s|
54
54
  "generators/nib/templates/@name@.css.erb",
55
55
  "generators/nib/templates/@name@.html.erb",
56
56
  "generators/nib/templates/@name@.jsnib.erb",
57
- "lib/coherent.rb"
57
+ "lib/coherent.rb",
58
+ "lib/distilery.rb",
59
+ "lib/distilery/coherent-asset-filter.rb",
60
+ "lib/distilery/nib-file.rb",
61
+ "lib/distilery/nib-task.rb"
58
62
  ]
59
63
  s.homepage = %q{http://coherentjs.org}
60
64
  s.rdoc_options = ["--charset=UTF-8"]
@@ -67,12 +71,15 @@ Gem::Specification.new do |s|
67
71
  s.specification_version = 3
68
72
 
69
73
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
70
- s.add_runtime_dependency(%q<distil>, [">= 0.8.0"])
74
+ s.add_runtime_dependency(%q<distil>, [">= 0.8.4"])
75
+ s.add_runtime_dependency(%q<rubigen>, [">= 1.5.2"])
71
76
  else
72
- s.add_dependency(%q<distil>, [">= 0.8.0"])
77
+ s.add_dependency(%q<distil>, [">= 0.8.4"])
78
+ s.add_dependency(%q<rubigen>, [">= 1.5.2"])
73
79
  end
74
80
  else
75
- s.add_dependency(%q<distil>, [">= 0.8.0"])
81
+ s.add_dependency(%q<distil>, [">= 0.8.4"])
82
+ s.add_dependency(%q<rubigen>, [">= 1.5.2"])
76
83
  end
77
84
  end
78
85
 
@@ -0,0 +1,65 @@
1
+ require "#{$script_dir}/filters/file-reference-filter"
2
+
3
+ $include_regex= /NIB\.asset\(['"]([^)]+)['"]\)/
4
+ $include_regex_old= /INC\(['"]([^)]+)['"]\)/
5
+
6
+ class CoherentAssetFilter < FileReferenceFilter
7
+
8
+ def handles_file(file)
9
+ return ["js"].include?(file.content_type)
10
+ end
11
+
12
+ def preprocess_content(file, content)
13
+ content= content.split("\n")
14
+
15
+ line_num=0
16
+
17
+ content.each { |line|
18
+
19
+ line_num+=1
20
+
21
+ line.gsub!($include_regex) { |match|
22
+
23
+ import_file= File.expand_path(File.join(file.parent_folder, $1))
24
+
25
+ if (!File.exists?(import_file))
26
+ file.error "Missing import file: #{$1}", line_num
27
+ "NIB.asset('#{$1}')"
28
+ else
29
+ asset= SourceFile.from_path(import_file)
30
+ file.add_asset(asset);
31
+ if (file.can_embed_as_content(asset))
32
+ "NIB.asset('#{file_reference(asset)}','#{content_reference(asset)}')"
33
+ else
34
+ "NIB.asset('#{file_reference(asset)}')"
35
+ end
36
+ end
37
+
38
+ }
39
+
40
+ line.gsub!($include_regex_old) { |match|
41
+
42
+ import_file= File.expand_path(File.join(file.parent_folder, $1))
43
+
44
+ if (!File.exists?(import_file))
45
+ file.error "Missing import file: #{$1}", line_num
46
+ "INC('#{$1}')"
47
+ else
48
+ asset= SourceFile.from_path(import_file)
49
+ file.add_asset(asset);
50
+ if (file.can_embed_as_content(asset))
51
+ "INC('#{file_reference(asset)}','#{content_reference(asset)}')"
52
+ else
53
+ "INC('#{file_reference(asset)}')"
54
+ end
55
+ end
56
+
57
+ }
58
+
59
+ }
60
+
61
+ content.join("\n")
62
+ end
63
+
64
+ end
65
+
@@ -0,0 +1,13 @@
1
+ require "#{$script_dir}/file-types/javascript-file.rb"
2
+
3
+ class NibFile < JavascriptFile
4
+
5
+ def self.extension
6
+ ".jsnib"
7
+ end
8
+
9
+ def content_type
10
+ "js"
11
+ end
12
+
13
+ end
@@ -0,0 +1,83 @@
1
+ require "#{$script_dir}/tasks/multiple-output-task.rb"
2
+ require "#{$script_dir}/tasks/javascript-task.rb"
3
+
4
+ class NibTask < MultipleOutputTask
5
+
6
+ def self.task_name
7
+ "jsnib"
8
+ end
9
+
10
+ def source_type
11
+ "js"
12
+ end
13
+
14
+ def output_type
15
+ "jsnib"
16
+ end
17
+
18
+ # NibTask handles files that end in .jsnib
19
+ def handles_file?(file_name)
20
+ "#{file_name}"[/\.jsnib$/]
21
+ end
22
+
23
+ def validate_file(file)
24
+
25
+ return if (!File.exists?($lint_command))
26
+
27
+ tmp= Tempfile.new("jsl.conf")
28
+
29
+ conf_files= [ "jsl.conf",
30
+ "#{ENV['HOME']}/.jsl.conf",
31
+ @options.jsl_conf
32
+ ]
33
+
34
+ jsl_conf= conf_files.find { |f| File.exists?(f) }
35
+
36
+ tmp << File.read(jsl_conf)
37
+ tmp << "\n"
38
+
39
+ external_projects.each { |project|
40
+ tmp << "+include #{project["include"]}\n"
41
+ }
42
+
43
+ file.dependencies.each { |f|
44
+ tmp << "+process #{f}\n"
45
+ }
46
+
47
+ tmp << "+process #{file}\n"
48
+
49
+ tmp.close()
50
+
51
+ command= "#{$lint_command} -nologo -nofilelisting -conf #{tmp.path}"
52
+
53
+ stdin, stdout, stderr= Open3.popen3(command)
54
+ stdin.close
55
+ output= stdout.read
56
+ errors= stderr.read
57
+
58
+ tmp.delete
59
+
60
+ output= output.split("\n")
61
+ summary= output.pop
62
+ match= summary.match(/(\d+)\s+error\(s\), (\d+)\s+warning\(s\)/)
63
+ if (match)
64
+ @target.error_count+= match[1].to_i
65
+ @target.warning_count+= match[2].to_i
66
+ end
67
+
68
+ output= output.join("\n")
69
+
70
+ if (!output.empty?)
71
+ puts output
72
+ puts
73
+ end
74
+
75
+ end
76
+
77
+ def validate_files
78
+ @included_files.each { |f|
79
+ validate_file(f)
80
+ }
81
+ end
82
+
83
+ end
data/lib/distilery.rb ADDED
@@ -0,0 +1,5 @@
1
+ script_dir=File.join(File.dirname(__FILE__), "distilery")
2
+
3
+ require "#{script_dir}/nib-file.rb"
4
+ require "#{script_dir}/nib-task.rb"
5
+ require "#{script_dir}/coherent-asset-filter.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coherent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Watkins
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 -08:00
12
+ date: 2010-01-17 00:00:00 -08:00
13
13
  default_executable: coherent
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,17 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.8.0
23
+ version: 0.8.4
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rubigen
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.2
24
34
  version:
25
35
  description: Tools for building Coherent application or modules.
26
36
  email: jeff@metrocat.org
@@ -68,6 +78,10 @@ files:
68
78
  - generators/nib/templates/@name@.html.erb
69
79
  - generators/nib/templates/@name@.jsnib.erb
70
80
  - lib/coherent.rb
81
+ - lib/distilery.rb
82
+ - lib/distilery/coherent-asset-filter.rb
83
+ - lib/distilery/nib-file.rb
84
+ - lib/distilery/nib-task.rb
71
85
  has_rdoc: true
72
86
  homepage: http://coherentjs.org
73
87
  licenses: []