xteam_schedule 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,8 +21,6 @@ I am in no way associated with adnX. I work for an agile development company tha
21
21
 
22
22
  It is not required that you have [xTeam](http://www.adnx.com/i/apps/xteam4mac) installed. However, you will not be able to visualise your schedules otherwise.
23
23
 
24
- At present, the gem is incompatible with existing database connections (rails, for example). This will change soon.
25
-
26
24
  **Install the gem:**
27
25
 
28
26
  ```ruby
@@ -3,6 +3,13 @@ require 'active_record'
3
3
  require 'sqlite3'
4
4
  require 'xteam_schedule/core'
5
5
 
6
+ require 'xteam_schedule/facilitation/schema'
7
+ require 'xteam_schedule/facilitation/base'
8
+ require 'xteam_schedule/facilitation/parser'
9
+ require 'xteam_schedule/facilitation/composer'
10
+ require 'xteam_schedule/facilitation/io'
11
+ require 'xteam_schedule/facilitation/lmc_patch'
12
+
6
13
  require 'xteam_schedule/models/assignment'
7
14
  require 'xteam_schedule/models/assignment_group'
8
15
  require 'xteam_schedule/models/interface'
@@ -13,10 +20,4 @@ require 'xteam_schedule/models/weekly_working_schedule'
13
20
  require 'xteam_schedule/models/working_day'
14
21
  require 'xteam_schedule/models/working_time'
15
22
 
16
- require 'xteam_schedule/facilitation/composer'
17
- require 'xteam_schedule/facilitation/base'
18
- require 'xteam_schedule/facilitation/io'
19
- require 'xteam_schedule/facilitation/parser'
20
-
21
- XTeamSchedule::Base.connect
22
23
  XTeamSchedule::Base.build_schema
@@ -22,6 +22,10 @@ class XTeamSchedule
22
22
  @schedule.send(*args)
23
23
  end
24
24
 
25
+ def self.inspect
26
+ XTeamSchedule::Schedule.inspect
27
+ end
28
+
25
29
  def inspect
26
30
  stats = [:resource_groups, :resources, :assignment_groups, :assignments, :working_times].map { |s| [s, send(s).count] }
27
31
  stats_string = stats.map { |s| "#{s.first}(#{s.second})" }.join(', ')
@@ -1,22 +1,16 @@
1
- class XTeamSchedule::Base
2
-
3
- def self.connect
4
- ActiveRecord::Base.establish_connection(
5
- :adapter => 'sqlite3',
6
- :database => ':memory:'
7
- )
8
- end
1
+ class XTeamSchedule::Base < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ establish_connection(:adapter => 'sqlite3', :database => ':memory:')
9
4
 
10
5
  def self.build_schema
11
- ActiveRecord::Schema.verbose = false
12
- ActiveRecord::Schema.define do
6
+ XTeamSchedule::Schema.define do
13
7
 
14
- create_table :schedules do |table|
8
+ create_table :schedules, :force => true do |table|
15
9
  table.column :begin_date, :date, :default => 10.years.ago.to_date
16
10
  table.column :end_date, :date, :default => 10.years.from_now.to_date
17
11
  end
18
12
 
19
- create_table :interfaces do |table|
13
+ create_table :interfaces, :force => true do |table|
20
14
  table.column :schedule_id, :integer
21
15
  table.column :display_assignments_name, :boolean, :default => true
22
16
  table.column :display_resources_name, :boolean, :default => false
@@ -28,11 +22,11 @@ class XTeamSchedule::Base
28
22
  table.column :time_granularity, :integer, :default => XTeamSchedule::Interface::TIME_GRANULARITIES[:month]
29
23
  end
30
24
 
31
- create_table :weekly_working_schedules do |table|
25
+ create_table :weekly_working_schedules, :force => true do |table|
32
26
  table.column :schedule_id, :integer
33
27
  end
34
28
 
35
- create_table :working_days do |table|
29
+ create_table :working_days, :force => true do |table|
36
30
  table.column :weekly_working_schedule_id, :integer
37
31
  table.column :name, :string
38
32
  table.column :day_begin, :string
@@ -41,13 +35,13 @@ class XTeamSchedule::Base
41
35
  table.column :break_end, :string
42
36
  end
43
37
 
44
- create_table :resource_groups do |table|
38
+ create_table :resource_groups, :force => true do |table|
45
39
  table.column :schedule_id, :integer
46
40
  table.column :expanded_in_library, :boolean, :default => true
47
41
  table.column :name, :string
48
42
  end
49
43
 
50
- create_table :resources do |table|
44
+ create_table :resources, :force => true do |table|
51
45
  table.column :resource_group_id, :integer
52
46
  table.column :displayed_in_planning, :boolean, :default => true
53
47
  table.column :email, :string
@@ -57,27 +51,25 @@ class XTeamSchedule::Base
57
51
  table.column :phone, :string
58
52
  end
59
53
 
60
- create_table :assignment_groups do |table|
54
+ create_table :assignment_groups, :force => true do |table|
61
55
  table.column :schedule_id, :integer
62
56
  table.column :expanded_in_library, :boolean, :default => true
63
57
  table.column :name, :string
64
58
  end
65
59
 
66
- create_table :assignments do |table|
60
+ create_table :assignments, :force => true do |table|
67
61
  table.column :assignment_group_id, :integer
68
62
  table.column :name, :string
69
63
  table.column :colour, :string
70
64
  end
71
65
 
72
- create_table :working_times do |table|
66
+ create_table :working_times, :force => true do |table|
73
67
  table.column :resource_id, :integer
74
68
  table.column :assignment_id, :integer
75
69
  table.column :begin_date, :date
76
70
  table.column :duration, :integer
77
71
  table.column :notes, :string
78
72
  end
79
-
80
73
  end
81
74
  end
82
-
83
75
  end
@@ -0,0 +1,22 @@
1
+ # http://tinyurl.com/73s9drr
2
+ module ActiveSupport
3
+ module Dependencies
4
+ extend self
5
+
6
+ #def load_missing_constant(from_mod, const_name)
7
+
8
+ def forgiving_load_missing_constant( from_mod, const_name )
9
+ begin
10
+ old_load_missing_constant(from_mod, const_name)
11
+ rescue ArgumentError => arg_err
12
+ if arg_err.message == "#{from_mod} is not missing constant #{const_name}!"
13
+ return from_mod.const_get(const_name)
14
+ else
15
+ raise
16
+ end
17
+ end
18
+ end
19
+ alias :old_load_missing_constant :load_missing_constant
20
+ alias :load_missing_constant :forgiving_load_missing_constant
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ class XTeamSchedule::Schema
2
+
3
+ def self.define(&block)
4
+ instance_eval(&block)
5
+ end
6
+
7
+ def self.method_missing(method, *args, &block)
8
+ XTeamSchedule::Base.connection.send(method, *args, &block)
9
+ end
10
+
11
+ end
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::Assignment < ActiveRecord::Base
1
+ class XTeamSchedule::Assignment < XTeamSchedule::Base
2
2
  belongs_to :assignment_group
3
3
  has_many :working_times, :dependent => :destroy
4
4
  delegate :schedule, :to => :assignment_group
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::AssignmentGroup < ActiveRecord::Base
1
+ class XTeamSchedule::AssignmentGroup < XTeamSchedule::Base
2
2
  belongs_to :schedule
3
3
  has_many :assignments, :dependent => :destroy
4
4
 
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::Interface < ActiveRecord::Base
1
+ class XTeamSchedule::Interface < XTeamSchedule::Base
2
2
  belongs_to :schedule
3
3
 
4
4
  alias_attribute :display_assignment_names, :display_assignments_name
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::Resource < ActiveRecord::Base
1
+ class XTeamSchedule::Resource < XTeamSchedule::Base
2
2
  belongs_to :resource_group
3
3
  has_many :working_times, :dependent => :destroy
4
4
  delegate :schedule, :to => :resource_group
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::ResourceGroup < ActiveRecord::Base
1
+ class XTeamSchedule::ResourceGroup < XTeamSchedule::Base
2
2
  belongs_to :schedule
3
3
  has_many :resources, :dependent => :destroy
4
4
 
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::Schedule < ActiveRecord::Base
1
+ class XTeamSchedule::Schedule < XTeamSchedule::Base
2
2
  has_many :resource_groups, :dependent => :destroy
3
3
  has_many :resources, :through => :resource_groups
4
4
  has_many :assignment_groups, :dependent => :destroy
@@ -35,7 +35,7 @@ private
35
35
  end
36
36
 
37
37
  def set_default_weekly_working_schedule
38
- self.weekly_working_schedule = XTeamSchedule::WeeklyWorkingSchedule.new
38
+ self.weekly_working_schedule ||= XTeamSchedule::WeeklyWorkingSchedule.new
39
39
  end
40
40
 
41
41
  end
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::WeeklyWorkingSchedule < ActiveRecord::Base
1
+ class XTeamSchedule::WeeklyWorkingSchedule < XTeamSchedule::Base
2
2
  belongs_to :schedule
3
3
  has_many :working_days, :dependent => :destroy
4
4
 
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::WorkingDay < ActiveRecord::Base
1
+ class XTeamSchedule::WorkingDay < XTeamSchedule::Base
2
2
  belongs_to :weekly_working_schedule
3
3
  delegate :schedule, :to => :weekly_working_schedule
4
4
 
@@ -1,4 +1,4 @@
1
- class XTeamSchedule::WorkingTime < ActiveRecord::Base
1
+ class XTeamSchedule::WorkingTime < XTeamSchedule::Base
2
2
  belongs_to :resource
3
3
  belongs_to :assignment
4
4
  delegate :resource_group, :to => :resource
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xteam_schedule
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Patuzzo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-15 00:00:00 Z
18
+ date: 2012-03-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: plist
@@ -91,20 +91,6 @@ dependencies:
91
91
  version: 2.2.0
92
92
  type: :development
93
93
  version_requirements: *id005
94
- - !ruby/object:Gem::Dependency
95
- name: database_cleaner
96
- prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
106
- type: :development
107
- version_requirements: *id006
108
94
  description: Full control over schedules for use with adnX's xTeam software
109
95
  email: chris.patuzzo@gmail.com
110
96
  executables: []
@@ -119,7 +105,9 @@ files:
119
105
  - lib/xteam_schedule/facilitation/base.rb
120
106
  - lib/xteam_schedule/facilitation/composer.rb
121
107
  - lib/xteam_schedule/facilitation/io.rb
108
+ - lib/xteam_schedule/facilitation/lmc_patch.rb
122
109
  - lib/xteam_schedule/facilitation/parser.rb
110
+ - lib/xteam_schedule/facilitation/schema.rb
123
111
  - lib/xteam_schedule/models/assignment.rb
124
112
  - lib/xteam_schedule/models/assignment_group.rb
125
113
  - lib/xteam_schedule/models/interface.rb