rugui 1.6.0 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/README.rdoc +48 -23
  2. data/Rakefile +3 -10
  3. data/bin/rugui +4 -1
  4. data/lib/rugui/base_view.rb +5 -5
  5. data/lib/rugui/configuration.rb +1 -29
  6. data/lib/rugui/entity_registration_support.rb +17 -2
  7. data/lib/rugui/framework_adapters/GTK.rb +15 -32
  8. data/lib/rugui/framework_adapters/Qt4.rb +22 -3
  9. data/lib/rugui/generators/rugui/rugui_generator.rb +3 -9
  10. data/lib/rugui/generators/rugui/templates/Gemfile.tt +20 -0
  11. data/lib/rugui/generators/rugui/templates/Rakefile +0 -4
  12. data/lib/rugui/generators/rugui/templates/app/main.rb +1 -1
  13. data/lib/rugui/generators/rugui/templates/config/boot.rb +5 -78
  14. data/lib/rugui/generators/rugui/templates/config/environment.rb.tt +7 -7
  15. data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/xml/main_view.xml +43 -0
  16. data/lib/rugui/generators/rugui/templates/spec/spec_helper.rb +0 -2
  17. data/lib/rugui/initializer.rb +3 -60
  18. data/lib/rugui/observable_property_support.rb +5 -1
  19. data/lib/rugui/property_changed_support.rb +1 -1
  20. data/lib/rugui/signal_support.rb +2 -2
  21. data/lib/rugui/tasks/rugui.rb +1 -1
  22. data/lib/rugui/tasks/runner_application.rake +1 -1
  23. data/lib/rugui/tasks/spec_application.rake +5 -44
  24. data/lib/rugui/tasks/spec_framework.rake +3 -25
  25. data/lib/rugui/version.rb +1 -7
  26. data/lib/rugui.rb +0 -3
  27. data/spec/framework/base_controller_spec.rb +7 -14
  28. data/spec/framework/base_model_spec.rb +1 -3
  29. data/spec/framework/base_view_helper_spec.rb +1 -3
  30. data/spec/framework/base_view_spec.rb +2 -5
  31. data/spec/framework/log_support_spec.rb +2 -2
  32. data/spec/framework/observable_property_proxy_spec.rb +13 -14
  33. data/spec/framework/observable_property_support_spec.rb +8 -10
  34. data/spec/framework/property_observer_spec.rb +20 -22
  35. data/spec/helpers/controllers.rb +3 -3
  36. data/spec/helpers/helper_manager.rb +9 -0
  37. data/spec/helpers/observables.rb +40 -52
  38. data/spec/helpers/views.rb +15 -15
  39. data/spec/resource_files/my_other_view.xml +53 -0
  40. data/spec/resource_files/my_view.xml +53 -0
  41. data/spec/spec_helper.rb +9 -3
  42. metadata +98 -84
  43. data/lib/rugui/gem_builder.rb +0 -21
  44. data/lib/rugui/gem_dependency.rb +0 -282
  45. data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/glade/main_view.glade +0 -33
  46. data/lib/rugui/generators/rugui/templates/spec/rcov.opts +0 -1
  47. data/lib/rugui/generators/rugui/templates/spec/spec.opts +0 -4
  48. data/lib/rugui/generators/rugui/templates/test/test_helper.rb +0 -12
  49. data/lib/rugui/plugin/loader.rb +0 -77
  50. data/lib/rugui/tasks/gems_application.rake +0 -71
  51. data/lib/rugui/tasks/test_application.rake +0 -77
  52. data/lib/rugui/vendor_gem_source_index.rb +0 -140
  53. data/spec/rcov.opts +0 -1
  54. data/spec/spec.opts +0 -5
@@ -1,77 +0,0 @@
1
- module RuGUI
2
- module Plugin
3
- class Loader
4
- attr_accessor :initializer
5
- attr_accessor :configurations
6
- cattr_accessor :located_plugins
7
-
8
- def initialize(initializer, configurations)
9
- self.initializer = initializer
10
- self.configurations = configurations
11
- @@located_plugins ||= []
12
- end
13
-
14
- def load_plugins
15
- plugins.each do |plugin|
16
- plugin.load unless plugin.loaded?
17
- register_as_loaded(plugin)
18
- end
19
- end
20
-
21
- def plugins
22
- @plugins ||= locate_plugins
23
- end
24
-
25
- protected
26
- # Locate all plugins in APPLICATION_ROOT/vendor/plugins
27
- def locate_plugins
28
- Dir.glob(File.join(APPLICATION_ROOT, "vendor", "plugins", "*")).each do |dir|
29
- @@located_plugins << Location.new(dir)
30
- end
31
- @@located_plugins
32
- end
33
-
34
- # Register plugins as loaded.
35
- def register_as_loaded(plugin)
36
- plugin.loaded = true
37
- end
38
- end
39
-
40
- # This class is a representation of RuGUI plugins.
41
- class Location
42
- attr_accessor :plugin_name
43
- attr_accessor :dir
44
- attr_accessor :loaded
45
-
46
- include RuGUI::LogSupport
47
-
48
- def initialize(dir)
49
- self.dir = dir
50
- self.plugin_name = dir.split(File::SEPARATOR).last
51
- end
52
-
53
- # Load plugins.
54
- def load
55
- $LOAD_PATH.unshift(File.join(self.dir, "lib")) if File.directory?(self.dir)
56
- $LOAD_PATH.uniq!
57
-
58
- init_file = File.expand_path(File.join(self.dir, "init.rb"))
59
- if File.exist?(init_file)
60
- require_for init_file
61
- else
62
- logger.warn "The init file for (#{self.plugin_name}) was not found."
63
- end
64
- end
65
-
66
- def require_for(init_file)
67
- require init_file
68
- rescue Exception
69
- logger.error "An error occurred while loading #{self.plugin_name}. Checks its init file: #{$!}"
70
- end
71
-
72
- def loaded?
73
- self.loaded ||= false
74
- end
75
- end
76
- end
77
- end
@@ -1,71 +0,0 @@
1
- task :rake_environment do
2
- $rails_rake_task = true
3
- require(File.join(APPLICATION_ROOT, 'config', 'environment'))
4
- RuGUI.configuration.logger[:level] = :error
5
- end
6
-
7
- desc "List the gems that this RuGUI application depends on"
8
- task :gems => 'gems:base' do
9
- RuGUI.configuration.gems.each do |gem|
10
- print_gem_status(gem)
11
- end
12
- puts
13
- puts "I = Installed"
14
- puts "F = Frozen"
15
- puts "R = Framework (loaded before RuGUI starts)"
16
- end
17
-
18
- namespace :gems do
19
- task :base do
20
- $gems_rake_task = true
21
- require 'rubygems'
22
- require 'rubygems/gem_runner'
23
- Rake::Task[:rake_environment].invoke
24
- end
25
-
26
- desc "Build any native extensions for unpacked gems"
27
- task :build do
28
- $gems_build_rake_task = true
29
- Rake::Task['gems:unpack'].invoke
30
- current_gems.each &:build
31
- end
32
-
33
- desc "Installs all required gems."
34
- task :install => :base do
35
- current_gems.each &:install
36
- end
37
-
38
- desc "Unpacks all required gems into vendor/gems."
39
- task :unpack => :install do
40
- current_gems.each &:unpack
41
- end
42
-
43
- namespace :unpack do
44
- desc "Unpacks all required gems and their dependencies into vendor/gems."
45
- task :dependencies => :install do
46
- current_gems.each { |gem| gem.unpack(:recursive => true) }
47
- end
48
- end
49
-
50
- desc "Regenerate gem specifications in correct format."
51
- task :refresh_specs => :base do
52
- current_gems.each &:refresh
53
- end
54
- end
55
-
56
- def current_gems
57
- gems = RuGUI.configuration.gems
58
- gems = gems.select { |gem| gem.name == ENV['GEM'] } unless ENV['GEM'].blank?
59
- gems
60
- end
61
-
62
- def print_gem_status(gem, indent=1)
63
- code = case
64
- when gem.framework_gem? then 'R'
65
- when gem.frozen? then 'F'
66
- when gem.installed? then 'I'
67
- else ' '
68
- end
69
- puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
70
- gem.dependencies.each { |g| print_gem_status(g, indent+1) }
71
- end
@@ -1,77 +0,0 @@
1
- TEST_CHANGES_SINCE = Time.now - 600
2
-
3
- # Look up tests for recently modified sources.
4
- def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
5
- FileList[source_pattern].map do |path|
6
- if File.mtime(path) > touched_since
7
- tests = []
8
- source_dir = File.dirname(path).split("/")
9
- source_file = File.basename(path, '.rb')
10
-
11
- # Support subdirs in app/models and app/controllers
12
- modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
13
-
14
- # For modified files in app/ run the tests for it. ex. /test/models/account_controller.rb
15
- test = "#{modified_test_path}/#{source_file}_test.rb"
16
- tests.push test if File.exist?(test)
17
-
18
- # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
19
- test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
20
- FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
21
-
22
- return tests
23
-
24
- end
25
- end.flatten.compact
26
- end
27
-
28
- desc 'Run all models, controllers and libs tests'
29
- task :test do
30
- errors = %w(test:models test:controllers test:libs).collect do |task|
31
- begin
32
- Rake::Task[task].invoke
33
- nil
34
- rescue => e
35
- task
36
- end
37
- end.compact
38
- abort "Errors running #{errors.to_sentence}!" if errors.any?
39
- end
40
-
41
- namespace :test do
42
-
43
- Rake::TestTask.new(:recent) do |t|
44
- since = TEST_CHANGES_SINCE
45
- touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
46
- recent_tests('app/models/**/*.rb', 'test/models', since) +
47
- recent_tests('app/controllers/**/*.rb', 'test/controllers', since) +
48
- recent_tests('lib/**/*.rb', 'test/libs', since)
49
-
50
- t.libs << 'test'
51
- t.verbose = true
52
- t.test_files = touched.uniq
53
- end
54
- Rake::Task['test:recent'].comment = "Test recent changes"
55
-
56
- Rake::TestTask.new(:models) do |t|
57
- t.libs << "test"
58
- t.pattern = 'test/models/**/*_test.rb'
59
- t.verbose = true
60
- end
61
- Rake::Task['test:models'].comment = "Run the models tests in test/models"
62
-
63
- Rake::TestTask.new(:controllers) do |t|
64
- t.libs << "test"
65
- t.pattern = 'test/controllers/**/*_test.rb'
66
- t.verbose = true
67
- end
68
- Rake::Task['test:controllers'].comment = "Run the controllers tests in test/unit"
69
-
70
- Rake::TestTask.new(:libs) do |t|
71
- t.libs << "test"
72
- t.pattern = 'test/lib/**/*_test.rb'
73
- t.verbose = true
74
- end
75
- Rake::Task['test:libs'].comment = "Run the libs tests in test/unit"
76
-
77
- end
@@ -1,140 +0,0 @@
1
- require 'rubygems'
2
- require 'yaml'
3
-
4
- module RuGUI
5
-
6
- class VendorGemSourceIndex
7
- # VendorGemSourceIndex acts as a proxy for the Gem source index, allowing
8
- # gems to be loaded from vendor/gems. Rather than the standard gem repository format,
9
- # vendor/gems contains unpacked gems, with YAML specifications in .specification in
10
- # each gem directory.
11
- include Enumerable
12
-
13
- attr_reader :installed_source_index
14
- attr_reader :vendor_source_index
15
-
16
- @@silence_spec_warnings = false
17
-
18
- def self.silence_spec_warnings
19
- @@silence_spec_warnings
20
- end
21
-
22
- def self.silence_spec_warnings=(v)
23
- @@silence_spec_warnings = v
24
- end
25
-
26
- def initialize(installed_index, vendor_dir=RuGUI::GemDependency.unpacked_path)
27
- @installed_source_index = installed_index
28
- @vendor_dir = vendor_dir
29
- refresh!
30
- end
31
-
32
- def refresh!
33
- # reload the installed gems
34
- @installed_source_index.refresh!
35
- vendor_gems = {}
36
-
37
- # handle vendor RuGUI gems - they are identified by having loaded_from set to ""
38
- # we add them manually to the list, so that other gems can find them via dependencies
39
- Gem.loaded_specs.each do |n, s|
40
- next unless s.loaded_from.empty?
41
- vendor_gems[s.full_name] = s
42
- end
43
-
44
- # load specifications from vendor/gems
45
- Dir[File.join(RuGUI::GemDependency.unpacked_path, '*')].each do |d|
46
- dir_name = File.basename(d)
47
- dir_version = version_for_dir(dir_name)
48
- spec = load_specification(d)
49
- if spec
50
- if spec.full_name != dir_name
51
- # mismatched directory name and gem spec - produced by 2.1.0-era unpack code
52
- if dir_version
53
- # fix the spec version - this is not optimal (spec.files may be wrong)
54
- # but it's better than breaking apps. Complain to remind users to get correct specs.
55
- # use ActiveSupport::Deprecation.warn, as the logger is not set yet
56
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has a mismatched specification file."+
57
- " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings
58
- spec.version = dir_version
59
- else
60
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems is not in a versioned directory"+
61
- "(should be #{spec.full_name}).") unless @@silence_spec_warnings
62
- # continue, assume everything is OK
63
- end
64
- end
65
- else
66
- # no spec - produced by early-2008 unpack code
67
- # emulate old behavior, and complain.
68
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems has no specification file."+
69
- " Run 'rake gems:refresh_specs' to fix this.") unless @@silence_spec_warnings
70
- if dir_version
71
- spec = Gem::Specification.new
72
- spec.version = dir_version
73
- spec.require_paths = ['lib']
74
- ext_path = File.join(d, 'ext')
75
- spec.require_paths << 'ext' if File.exist?(ext_path)
76
- spec.name = /^(.*)-[^-]+$/.match(dir_name)[1]
77
- files = ['lib']
78
- # set files to everything in lib/
79
- files += Dir[File.join(d, 'lib', '*')].map { |v| v.gsub(/^#{d}\//, '') }
80
- files += Dir[File.join(d, 'ext', '*')].map { |v| v.gsub(/^#{d}\//, '') } if ext_path
81
- spec.files = files
82
- else
83
- $stderr.puts("config.gem: Unpacked gem #{dir_name} in vendor/gems not in a versioned directory."+
84
- " Giving up.") unless @@silence_spec_warnings
85
- next
86
- end
87
- end
88
- spec.loaded_from = File.join(d, '.specification')
89
- # finally, swap out full_gem_path
90
- # it would be better to use a Gem::Specification subclass, but the YAML loads an explicit class
91
- class << spec
92
- def full_gem_path
93
- path = File.join installation_path, full_name
94
- return path if File.directory? path
95
- File.join installation_path, original_name
96
- end
97
- end
98
- vendor_gems[File.basename(d)] = spec
99
- end
100
- @vendor_source_index = Gem::SourceIndex.new(vendor_gems)
101
- end
102
-
103
- def version_for_dir(d)
104
- matches = /-([^-]+)$/.match(d)
105
- Gem::Version.new(matches[1]) if matches
106
- end
107
-
108
- def load_specification(gem_dir)
109
- spec_file = File.join(gem_dir, '.specification')
110
- YAML.load_file(spec_file) if File.exist?(spec_file)
111
- end
112
-
113
- def find_name(*args)
114
- @installed_source_index.find_name(*args) + @vendor_source_index.find_name(*args)
115
- end
116
-
117
- def search(*args)
118
- # look for vendor gems, and then installed gems - later elements take priority
119
- @installed_source_index.search(*args) + @vendor_source_index.search(*args)
120
- end
121
-
122
- def each(&block)
123
- @vendor_source_index.each(&block)
124
- @installed_source_index.each(&block)
125
- end
126
-
127
- def add_spec(spec)
128
- @vendor_source_index.add_spec spec
129
- end
130
-
131
- def remove_spec(spec)
132
- @vendor_source_index.remove_spec spec
133
- end
134
-
135
- def size
136
- @vendor_source_index.size + @installed_source_index.size
137
- end
138
-
139
- end
140
- end
data/spec/rcov.opts DELETED
@@ -1 +0,0 @@
1
- --exclude "spec/*,gems/*"
data/spec/spec.opts DELETED
@@ -1,5 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
5
- --debugger