clevic 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
8
+
9
+ desc 'Generate website files'
10
+ task :website_generate => :ruby_env do
11
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
12
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
13
+ end
14
+ end
15
+
16
+ desc 'Upload website files to rubyforge'
17
+ task :website_upload do
18
+ host = "#{rubyforge_username}@rubyforge.org"
19
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
20
+ local_dir = 'website'
21
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
22
+ end
23
+
24
+ desc 'Generate and upload website files'
25
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -1,12 +1,11 @@
1
1
  require 'clevic.rb'
2
2
 
3
3
  # db connection options
4
- $options ||= {}
5
- $options[:database] ||= $options[:debug] ? 'times_test' : 'times'
6
- $options[:adapter] ||= 'postgresql'
7
- $options[:host] ||= 'localhost'
8
- $options[:username] ||= 'panic'
9
- $options[:password] ||= ''
4
+ Clevic::DbOptions.connect( $options ) do
5
+ database( debug? ? :times_test : :times )
6
+ adapter :postgresql
7
+ username 'panic'
8
+ end
10
9
 
11
10
  # model definitions
12
11
  class Entry < ActiveRecord::Base
@@ -0,0 +1,32 @@
1
+ require 'clevic.rb'
2
+
3
+ # db connection
4
+ Clevic::DbOptions.connect( $options ) do
5
+ database :accounts_test
6
+ adapter :postgresql
7
+ username 'panic'
8
+ end
9
+
10
+ # This is a read-only view, which is currently not implemented
11
+ class Values < ActiveRecord::Base
12
+ include ActiveRecord::Dirty
13
+ set_table_name 'values'
14
+ has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
15
+ has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
16
+ def self.ui( parent )
17
+ Clevic::TableView.new( self, parent ).create_model do
18
+ readonly
19
+ plain :date
20
+ plain :description
21
+ plain :debit
22
+ plain :credit
23
+ plain :pre_vat_amount
24
+ plain :cheque_number
25
+ plain :vat, :label => 'VAT'
26
+ plain :financial_year
27
+ plain :month
28
+
29
+ records :order => 'date'
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,147 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <title>
8
+ Clevic
9
+ </title>
10
+ <style>
11
+
12
+ </style>
13
+ <script type="text/javascript">
14
+ window.onload = function() {
15
+ settings = {
16
+ tl: { radius: 10 },
17
+ tr: { radius: 10 },
18
+ bl: { radius: 10 },
19
+ br: { radius: 10 },
20
+ antiAlias: true,
21
+ autoPad: true,
22
+ validTags: ["div"]
23
+ }
24
+ }
25
+ </script>
26
+ </head>
27
+ <body>
28
+ <div id="main">
29
+ <h1>Clevic</h1>
30
+ <p><a href="rdoc">RDoc</a> | <a href="http://rubyforge.org/projects/clevic/">Rubyforge Project</a></p>
31
+
32
+
33
+ <p>Screenshot of a table with the foreign-key dropdown in place. Tabs contain
34
+ the two tables, model definition file is below the screenshot. The Entry
35
+ model has some code to do update the credit and debit fields when
36
+ the new item description is found in the table.</p>
37
+
38
+
39
+ <p><img src="screenshot.png" title="Screenshot" alt="Screenshot" /></p>
40
+ </div>
41
+
42
+ <pre><code>
43
+ require 'clevic.rb'
44
+
45
+ # db connection options
46
+ $options ||= {}
47
+ $options[:database] ||= $options[:debug] ? 'accounts_test' : 'accounts'
48
+ $options[:adapter] ||= 'postgresql'
49
+ $options[:host] ||= 'localhost'
50
+ $options[:username] ||= 'panic'
51
+ $options[:password] ||= ''
52
+
53
+ class Entry < ActiveRecord::Base
54
+ include ActiveRecord::Dirty
55
+ belongs_to :debit, :class_name => 'Account', :foreign_key => 'debit_id'
56
+ belongs_to :credit, :class_name => 'Account', :foreign_key => 'credit_id'
57
+
58
+ # define how fields will be displayed
59
+ def self.ui( parent )
60
+ Clevic::TableView.new( self, parent ).create_model do
61
+ plain :date, :sample => '88-WWW-99'
62
+ distinct :description, :conditions => "now() - date <= '1 year'", :sample => 'm' * 26, :frequency => true
63
+ relational :debit, 'name', :class_name => 'Account', :conditions => 'active = true', :order => 'lower(name)', :sample => 'Leilani Member Loan'
64
+ relational :credit, 'name', :class_name => 'Account', :conditions => 'active = true', :order => 'lower(name)', :sample => 'Leilani Member Loan'
65
+ plain :amount, :sample => 999999.99
66
+ distinct :category
67
+ plain :cheque_number
68
+ plain :active, :sample => 'WW'
69
+ plain :vat, :label => 'VAT', :sample => 'WW', :tooltip => 'Does this include VAT?'
70
+
71
+ records :order => 'date, id'
72
+ end
73
+ end
74
+
75
+ # called when data is changed in the UI
76
+ def self.data_changed( top_left, bottom_right, view )
77
+ if top_left == bottom_right
78
+ update_credit_debit( top_left, view )
79
+ else
80
+ puts "top_left: #{top_left.inspect}"
81
+ puts "bottom_right: #{bottom_right.inspect}"
82
+ puts "can't do data_changed for a range"
83
+ end
84
+ end
85
+
86
+ # check that the current field is :descriptions, then
87
+ # copy the values for the credit and debit fields
88
+ # from the previous similar entry
89
+ def self.update_credit_debit( current_index, view )
90
+ return if !current_index.valid?
91
+ current_field = current_index.attribute
92
+ if current_field == :description
93
+ # most recent entry, ordered in reverse
94
+ similar = self.find(
95
+ :first,
96
+ :conditions => ["#{current_field} = ?", current_index.attribute_value],
97
+ :order => 'date desc'
98
+ )
99
+ if similar != nil
100
+ # set the values
101
+ current_index.entity.debit = similar.debit
102
+ current_index.entity.credit = similar.credit
103
+ current_index.entity.category = similar.category
104
+
105
+ # emit signal to update view from top_left to bottom_right
106
+ model = current_index.model
107
+ top_left_index = model.create_index( current_index.row, 0 )
108
+ bottom_right_index = model.create_index( current_index.row, view.builder.fields.size )
109
+ view.dataChanged( top_left_index, bottom_right_index )
110
+
111
+ # move edit cursor to amount field
112
+ view.selection_model.clear
113
+ view.override_next_index( model.create_index( current_index.row, view.builder.index( :amount ) ) )
114
+ end
115
+ end
116
+ end
117
+ end
118
+
119
+ class Account < ActiveRecord::Base
120
+ include ActiveRecord::Dirty
121
+ has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
122
+ has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
123
+
124
+ # define how fields are displayed
125
+ def self.ui( parent )
126
+ Clevic::TableView.new( self, parent ).create_model do
127
+ plain :name
128
+ restricted :vat, :label => 'VAT', :set => %w{ yes no all }
129
+ plain :account_type
130
+ plain :pastel_number, :alignment => Qt::AlignRight, :label => 'Pastel'
131
+ plain :fringe, :format => "%.1f"
132
+ plain :active
133
+
134
+ records :order => 'name,account_type'
135
+ end
136
+ end
137
+ end
138
+
139
+ # order of tab display
140
+ $options[:models] = [ Entry, Account ]
141
+
142
+ </code></pre>
143
+
144
+ <!-- insert site tracking codes here, like Google Urchin -->
145
+
146
+ </body>
147
+ </html>
@@ -0,0 +1,10 @@
1
+ h1. Clevic
2
+
3
+ "RDoc":rdoc | "Rubyforge Project":http://rubyforge.org/projects/clevic/
4
+
5
+ Screenshot of a table with the foreign-key dropdown in place. Tabs contain
6
+ the two tables, model definition file is below the screenshot. The Entry
7
+ model has some code to do update the credit and debit fields when
8
+ the new item description is found in the table.
9
+
10
+ !screenshot.png(Screenshot)!
Binary file
@@ -0,0 +1,131 @@
1
+ body {
2
+ font-family: "Georgia", sans-serif;
3
+ font-size: 16px;
4
+ line-height: 1.6em;
5
+ padding: 1.6em 0 0 0;
6
+ color: #333;
7
+ }
8
+ h1, h2, h3, h4, h5, h6 {
9
+ color: #444;
10
+ }
11
+ h1 {
12
+ font-family: sans-serif;
13
+ font-weight: normal;
14
+ font-size: 4em;
15
+ line-height: 0.8em;
16
+ letter-spacing: -0.1ex;
17
+ margin: 5px;
18
+ }
19
+ li {
20
+ padding: 0;
21
+ margin: 0;
22
+ list-style-type: square;
23
+ }
24
+ blockquote {
25
+ font-size: 90%;
26
+ font-style: italic;
27
+ border-left: 1px solid #111;
28
+ padding-left: 1em;
29
+ }
30
+ .caps {
31
+ font-size: 80%;
32
+ }
33
+
34
+ #main {
35
+ width: 45em;
36
+ padding: 0;
37
+ margin: 0 auto;
38
+ }
39
+ .coda {
40
+ text-align: right;
41
+ color: #77f;
42
+ font-size: smaller;
43
+ }
44
+
45
+ table {
46
+ font-size: 90%;
47
+ line-height: 1.4em;
48
+ color: #ff8;
49
+ background-color: #111;
50
+ padding: 2px 10px 2px 10px;
51
+ border-style: dashed;
52
+ }
53
+
54
+ th {
55
+ color: #fff;
56
+ }
57
+
58
+ td {
59
+ padding: 2px 10px 2px 10px;
60
+ }
61
+
62
+ .success {
63
+ color: #0CC52B;
64
+ }
65
+
66
+ .failed {
67
+ color: #E90A1B;
68
+ }
69
+
70
+ .unknown {
71
+ color: #995000;
72
+ }
73
+ pre, code {
74
+ font-family: monospace;
75
+ font-size: 90%;
76
+ line-height: 1.4em;
77
+ color: #ff8;
78
+ background-color: #111;
79
+ padding: 2px 10px 2px 10px;
80
+ }
81
+ .comment { color: #aaa; font-style: italic; }
82
+ .keyword { color: #eff; font-weight: bold; }
83
+ .punct { color: #eee; font-weight: bold; }
84
+ .symbol { color: #0bb; }
85
+ .string { color: #6b4; }
86
+ .ident { color: #ff8; }
87
+ .constant { color: #66f; }
88
+ .regex { color: #ec6; }
89
+ .number { color: #F99; }
90
+ .expr { color: #227; }
91
+
92
+ #version {
93
+ float: right;
94
+ text-align: right;
95
+ font-family: sans-serif;
96
+ font-weight: normal;
97
+ background-color: #B3ABFF;
98
+ color: #141331;
99
+ padding: 15px 20px 10px 20px;
100
+ margin: 0 auto;
101
+ margin-top: 15px;
102
+ border: 3px solid #141331;
103
+ }
104
+
105
+ #version .numbers {
106
+ display: block;
107
+ font-size: 4em;
108
+ line-height: 0.8em;
109
+ letter-spacing: -0.1ex;
110
+ margin-bottom: 15px;
111
+ }
112
+
113
+ #version p {
114
+ text-decoration: none;
115
+ color: #141331;
116
+ background-color: #B3ABFF;
117
+ margin: 0;
118
+ padding: 0;
119
+ }
120
+
121
+ #version a {
122
+ text-decoration: none;
123
+ color: #141331;
124
+ background-color: #B3ABFF;
125
+ }
126
+
127
+ .clickable {
128
+ cursor: pointer;
129
+ cursor: hand;
130
+ }
131
+
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <title>
8
+ <%= title %>
9
+ </title>
10
+ <style>
11
+
12
+ </style>
13
+ <script type="text/javascript">
14
+ window.onload = function() {
15
+ settings = {
16
+ tl: { radius: 10 },
17
+ tr: { radius: 10 },
18
+ bl: { radius: 10 },
19
+ br: { radius: 10 },
20
+ antiAlias: true,
21
+ autoPad: true,
22
+ validTags: ["div"]
23
+ }
24
+ }
25
+ </script>
26
+ </head>
27
+ <body>
28
+ <div id="main">
29
+ <h1><%= title %></h1>
30
+ <%= body %>
31
+ </div>
32
+
33
+ <pre><code>
34
+ <%= File.read 'accounts_models.rb' %>
35
+ </code></pre>
36
+
37
+ <!-- insert site tracking codes here, like Google Urchin -->
38
+
39
+ </body>
40
+ </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clevic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Anderson
@@ -9,12 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-04 00:00:00 +02:00
12
+ date: 2008-07-07 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: qtext
17
- type: :runtime
18
17
  version_requirement:
19
18
  version_requirements: !ruby/object:Gem::Requirement
20
19
  requirements:
@@ -24,7 +23,6 @@ dependencies:
24
23
  version:
25
24
  - !ruby/object:Gem::Dependency
26
25
  name: activerecord
27
- type: :runtime
28
26
  version_requirement:
29
27
  version_requirements: !ruby/object:Gem::Requirement
30
28
  requirements:
@@ -32,35 +30,32 @@ dependencies:
32
30
  - !ruby/object:Gem::Version
33
31
  version: 2.0.2
34
32
  version:
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.7.0
44
- version:
45
- description: Database framework and Qt Model/View GUI for data capture and editing of tables in a pre-existing relational DBMS. Thanks to ActiveRecord, Postgresql, Mysql and so on are supported. Has only been tested with Postgres. There is a mild focus on reducing keystrokes for repetitive data capture, so it provides nice keyboard shortcuts for all sorts of things. Model (table) objects are extensible to allow for model (table) specific cleverness, like auto-filling-in of fields.
46
- email: john at semiosix dot com
33
+ description: SQL table GUI with Qt
34
+ email:
35
+ - panic@semiosix.com
47
36
  executables:
48
37
  - clevic
38
+ - import-times
49
39
  extensions: []
50
40
 
51
41
  extra_rdoc_files:
52
42
  - History.txt
53
43
  - Manifest.txt
54
44
  - README.txt
45
+ - website/index.txt
55
46
  files:
56
47
  - History.txt
57
- - INSTALL
58
48
  - Manifest.txt
59
49
  - README.txt
60
50
  - Rakefile
61
51
  - TODO
62
52
  - accounts_models.rb
63
53
  - bin/clevic
54
+ - bin/import-times
55
+ - config/hoe.rb
56
+ - config/jamis.rb
57
+ - config/requirements.rb
58
+ - env.sh
64
59
  - lib/active_record/dirty.rb
65
60
  - lib/clevic.rb
66
61
  - lib/clevic/browser.rb
@@ -80,13 +75,24 @@ files:
80
75
  - lib/clevic/ui/icon.png
81
76
  - lib/clevic/ui/search_dialog.ui
82
77
  - lib/clevic/ui/search_dialog_ui.rb
78
+ - lib/clevic/version.rb
79
+ - script/console
80
+ - script/destroy
81
+ - script/generate
82
+ - script/txt2html
83
83
  - sql/accounts.sql
84
84
  - sql/times.sql
85
- - template/jamis.rb
85
+ - tasks/website.rake
86
86
  - times_models.rb
87
+ - values_models.rb
88
+ - website/index.html
89
+ - website/index.txt
90
+ - website/screenshot.png
91
+ - website/stylesheets/screen.css
92
+ - website/template.html.erb
87
93
  has_rdoc: true
88
- homepage: http://www.rubyforge.org/clevic
89
- post_install_message:
94
+ homepage: http://clevic.rubyforge.org
95
+ post_install_message: ""
90
96
  rdoc_options:
91
97
  - --main
92
98
  - README.txt
@@ -107,9 +113,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
113
  requirements: []
108
114
 
109
115
  rubyforge_project: clevic
110
- rubygems_version: 1.2.0
116
+ rubygems_version: 1.1.1
111
117
  signing_key:
112
118
  specification_version: 2
113
- summary: Database framework and Qt Model/View GUI for data capture and editing of tables in a pre-existing relational DBMS
119
+ summary: SQL table GUI with Qt
114
120
  test_files: []
115
121