sozdat 0.0.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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## Gem bundler
22
+ vendor/gems
23
+ !vendor/gems/cache
24
+
25
+ ## PROJECT::SPECIFIC
26
+ vendor/rgtk
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ #gem 'rgtk', :path => 'vendor/rgtk'
2
+ gem 'activesupport'
3
+ gem 'activerecord'
4
+ gem 'ZenTest'
5
+ gem 'autotest-rails'
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Alexander Semyonov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = sozdat
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Alexander Semyonov. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "sozdat"
8
+ gem.summary = %Q{Rails IDE}
9
+ gem.description = %Q{Rails IDE from Tokak Studio}
10
+ gem.email = 'rotuka@tokak.ru'
11
+ gem.homepage = 'http://github.com/krasivotokak/sozdat'
12
+ gem.authors = ['Alexander Semyonov']
13
+ gem.add_development_dependency 'shoulda', '>= 0'
14
+ gem.add_development_dependency 'yard', '>= 0'
15
+ gem.add_dependency 'activesupport', '2.3.4'
16
+ gem.add_dependency 'activerecord', '2.3.4'
17
+ gem.add_dependency 'ZenTest', '4.1.4'
18
+ gem.add_dependency 'autotest-rails', '4.1.0'
19
+ gem.bindir = 'bin'
20
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+ rescue LoadError
42
+ task :rcov do
43
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
+ end
45
+ end
46
+
47
+ task :test => :check_dependencies
48
+
49
+ task :default => :test
50
+
51
+ begin
52
+ require 'yard'
53
+ YARD::Rake::YardocTask.new
54
+ rescue LoadError
55
+ task :yardoc do
56
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
57
+ end
58
+ end
59
+
60
+
61
+ task :environment do
62
+ require "#{File.dirname(__FILE__)}/config/environment"
63
+ end
64
+
65
+ desc "Migrate DB"
66
+ task :migrate => :environment do
67
+ App.connect_db
68
+ ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
69
+ end
70
+
71
+ desc "Bump gem version, release and install"
72
+ task :push => %w(version:bump:patch release gemcutter:release install)
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,2 @@
1
+ class AboutController < Rgtk::Controller::About
2
+ end
@@ -0,0 +1,96 @@
1
+ require 'tab_controller'
2
+
3
+ class BrowserController < TabController
4
+ def initialize(main)
5
+ super
6
+ @main = main
7
+ @loading = false
8
+ @current_uri = nil
9
+ end
10
+
11
+ def open(new_project)
12
+ unless project?
13
+ self.project = new_project
14
+ open_url("http://127.0.0.1:#{project.port}/")
15
+ end
16
+ end
17
+
18
+ def open_url(url)
19
+ address(url)
20
+ webview.open(url)
21
+ end
22
+
23
+ protected
24
+ signals_for(:browser) do
25
+ # address entry
26
+ activate(:address) { webview.open(address_entry.text) }
27
+ # buttons
28
+ activate(:go_forward) { webview.go_forward }
29
+ activate(:go_back) { webview.go_back }
30
+ activate(:stop_or_reload) do
31
+ if @loading
32
+ webview.stop_loading
33
+ else
34
+ webview.reload
35
+ end
36
+ end
37
+ changed(:title) do |widget, frame, title|
38
+ address(frame.uri)
39
+ end
40
+ changed(:load_progress) do |widget, progress|
41
+ progress("%s%s loaded" % [progress, "%"])
42
+ end
43
+ on(:load_started) do |webview, frame|
44
+ title("%s loading…" % [webview.uri])
45
+ loading(true)
46
+ end
47
+ on(:load_finished) do |webview, frame|
48
+ title(webview.title)
49
+ loading(false)
50
+ end
51
+ on(:hovering_over_link) do |webview, title, url|
52
+ status(webview && url ? url : '')
53
+ end
54
+ end
55
+
56
+ def address(url)
57
+ address_entry.text = url
58
+ @current_uri = url
59
+ end
60
+
61
+ def loading(loading)
62
+ @loading = loading
63
+
64
+ if @loading
65
+ browser_show_stop_icon
66
+ else
67
+ browser_show_reload_icon
68
+ end
69
+
70
+ update_navigation_buttons
71
+ end
72
+
73
+ def progress(progress)
74
+ status(progress)
75
+ end
76
+
77
+ def status(text, context = nil)
78
+ main.browser_statusbar.text = text
79
+ end
80
+
81
+ def browser_show_stop_icon
82
+ stop_or_reload_button.stock_id = Gtk::Stock::CANCEL
83
+ stop_or_reload_button.set_tooltip_text('Stop')
84
+ end
85
+
86
+ def browser_show_reload_icon
87
+ stop_or_reload_button.stock_id = Gtk::Stock::REFRESH
88
+ stop_or_reload_button.set_tooltip_text('Reload')
89
+ end
90
+
91
+ def update_navigation_buttons
92
+ go_back.sensitive = webview.can_go_back?
93
+ go_forward.sensitive = webview.can_go_forward?
94
+ end
95
+
96
+ end
@@ -0,0 +1,23 @@
1
+ require 'vte_controller'
2
+
3
+ class EditorController < VteController
4
+ def initialize(main)
5
+ super(main)
6
+ @role = 'Editor'
7
+ end
8
+
9
+ def open(new_project)
10
+ unless project?
11
+ self.project = new_project
12
+ echo("#{project} is open")
13
+ exec("cd #{project.path}")
14
+ exec("vim config/environment.rb")
15
+ end
16
+ end
17
+
18
+ def close
19
+ puts "Editor project is closed"
20
+ exec(":q")
21
+ project = nil
22
+ end
23
+ end
@@ -0,0 +1,133 @@
1
+ class MainController < Rgtk::Controller::Base
2
+ module Perspective
3
+ BROWSER = 4
4
+ EDITOR = 1
5
+ TESTS = 3
6
+ SERVER = 2
7
+ end
8
+
9
+ def initialize
10
+ super
11
+ @tabs = {}
12
+ projects_liststore = Gtk::ListStore.new(String, Project)
13
+ Project.find_each do |project|
14
+ iter = projects_liststore.append
15
+ iter[0] = project.name
16
+ iter[1] = project
17
+ end
18
+ project_selector_combobox.model = projects_liststore
19
+ renderer = Gtk::CellRendererText.new
20
+ project_selector_combobox.pack_start(renderer, true)
21
+ project_selector_combobox.set_attributes(renderer, :text => 0)
22
+ end
23
+
24
+ def open_project(project)
25
+ @project = project
26
+ editor.open(@project)
27
+ end
28
+
29
+ def close_project
30
+ if @project
31
+ if @project.new_record?
32
+ #TODO: show_project and add data
33
+ end
34
+ @project.save!
35
+ end
36
+ end
37
+
38
+ protected
39
+ on :application_quit do
40
+ close_project
41
+ App.destroy
42
+ end
43
+ on :preferences
44
+ on :about do
45
+ @about ||= AboutController.new
46
+ @about.show
47
+ end
48
+
49
+ signals_for(:project) do
50
+ activate :create
51
+ activate :open do
52
+ if project_directory = open_project_dialog
53
+ project = Project.find_or_create_by_path(project_directory)
54
+ open_project(project)
55
+ end
56
+ end
57
+ activate :save
58
+ activate :save_as
59
+ changed :selector_combobox do
60
+ open_project(project_selector_combobox.active_iter[1])
61
+ end
62
+ end
63
+
64
+ changed :action do |radio, group|
65
+ if radio == group
66
+ if @project
67
+ self.current_perspective = group.current_value
68
+ else
69
+ puts "No project is open"
70
+ end
71
+ end
72
+ end
73
+
74
+ def current_perspective=(perspective)
75
+ case perspective
76
+ when Perspective::BROWSER
77
+ server.open(@project) unless @project.server_started?
78
+ browser.open(@project)
79
+ when Perspective::EDITOR
80
+ editor.open(@project)
81
+ when Perspective::TESTS
82
+ tests.open(@project)
83
+ when Perspective::SERVER
84
+ server.open(@project)
85
+ else
86
+ p perspective
87
+ end
88
+ end
89
+
90
+ def tab(kind, active = true)
91
+ unless @tabs[kind]
92
+ controller = "#{kind}_controller".classify.constantize.new(self)
93
+ project_notebook.append_page(controller.container, controller.tab_label)
94
+ @tabs[kind] = {
95
+ :controller => controller,
96
+ :page_num => project_notebook.page_num(controller.container)
97
+ }
98
+ end
99
+ if active
100
+ self[:editor].current_value = Perspective.const_get(kind.upcase)
101
+ project_notebook.page = @tabs[kind][:page_num]
102
+ end
103
+ @tabs[kind][:controller]
104
+ end
105
+
106
+ %w(browser editor server tests).each do |method|
107
+ define_method(method) { |*args| tab(method, *args) }
108
+ end
109
+
110
+ def open_project_dialog
111
+ project_directory = nil
112
+ dialog = Gtk::FileChooserDialog.new(
113
+ 'Open Project',
114
+ container,
115
+ Gtk::FileChooser::ACTION_OPEN,
116
+ 'gnome-vfs',
117
+ [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT],
118
+ [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL]
119
+ )
120
+ file_filter = Gtk::FileFilter.new
121
+ file_filter.name = 'Projects'
122
+ file_filter.add_pattern('Rakefile')
123
+ dialog.add_filter(file_filter)
124
+ dialog.add_shortcut_folder(App.config.projects_directory)
125
+ dialog.run do |response|
126
+ if response == Gtk::Dialog::RESPONSE_ACCEPT
127
+ project_directory = File.dirname(dialog.filename)
128
+ end
129
+ end
130
+ dialog.destroy
131
+ project_directory
132
+ end
133
+ end
@@ -0,0 +1,21 @@
1
+ require 'vte_controller'
2
+
3
+ class ServerController < VteController
4
+ def initialize(main)
5
+ super(main)
6
+ @role = 'Server'
7
+ end
8
+
9
+ def open(new_project)
10
+ close if project
11
+
12
+ project = new_project
13
+ exec("cd #{project.path}")
14
+ exec("ruby script/server -p #{project.port}")
15
+ project.start_server!
16
+ end
17
+
18
+ def close
19
+ flunk "not implemented"
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ class TabController < Rgtk::Controller::Base
2
+ attr_accessor :project, :role, :tab_label, :main
3
+
4
+ def initialize(main)
5
+ @main = main
6
+ super()
7
+ end
8
+
9
+ def role
10
+ @role ||= controller_name.humanize
11
+ end
12
+
13
+ def tab_label
14
+ @tab_label ||= Gtk::Label.new(full_title(role))
15
+ end
16
+
17
+ def title(new_title = nil)
18
+ tab_label.text = full_title(new_title) unless new_title.nil?
19
+ tab_label.text
20
+ end
21
+ alias_method :title=, :title
22
+
23
+ protected
24
+ def full_title(title)
25
+ if project?
26
+ "#{project.name}: #{title}"
27
+ else
28
+ title
29
+ end
30
+ end
31
+
32
+ def project?
33
+ @project.present?
34
+ end
35
+ end