loadable_component 0.0.3 → 0.1.0

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Jari Bakken
1
+ Copyright (c) 2011-2012 Jari Bakken
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -21,4 +21,4 @@ Note on Patches/Pull Requests
21
21
  Copyright
22
22
  ---------
23
23
 
24
- Copyright (c) 2011 Jari Bakken. See LICENSE for details.
24
+ Copyright (c) 2011-2012 Jari Bakken. See LICENSE for details.
@@ -6,7 +6,7 @@ require "loadable_component/version"
6
6
  # http://code.google.com/p/selenium/wiki/LoadableComponent
7
7
  #
8
8
 
9
- class LoadableComponent
9
+ module LoadableComponent
10
10
 
11
11
  class UnableToLoadComponent < StandardError; end
12
12
  class SubclassResponsibility < StandardError; end
@@ -37,10 +37,9 @@ class LoadableComponent
37
37
 
38
38
  end
39
39
 
40
- class SlowLoadableComponent < LoadableComponent
41
- def initialize(timeout)
42
- @timeout = timeout
43
- end
40
+ module SlowLoadableComponent
41
+ include LoadableComponent
42
+ attr_accessor :timeout
44
43
 
45
44
  def get
46
45
  if loaded?
@@ -49,7 +48,9 @@ class SlowLoadableComponent < LoadableComponent
49
48
 
50
49
  load
51
50
 
52
- end_time = Time.now + @timeout
51
+ end_time = Time.now
52
+ end_time += @timeout if @timeout
53
+
53
54
  until Time.now >= end_time
54
55
  return self if loaded?
55
56
  check_error
@@ -1,3 +1,3 @@
1
- class LoadableComponent
2
- VERSION = "0.0.3"
1
+ module LoadableComponent
2
+ VERSION = "0.1.0"
3
3
  end
@@ -2,7 +2,9 @@ require 'rspec'
2
2
  require 'loadable_component'
3
3
  require 'timecop'
4
4
 
5
- class DetonatingComponent < LoadableComponent
5
+ class DetonatingComponent
6
+ include LoadableComponent
7
+
6
8
  def load
7
9
  raise "should never be called"
8
10
  end
@@ -13,7 +15,9 @@ class DetonatingComponent < LoadableComponent
13
15
  end
14
16
  end
15
17
 
16
- class LoadsOk < LoadableComponent
18
+ class LoadsOk
19
+ include LoadableComponent
20
+
17
21
  def initialize(second_load_call_passes)
18
22
  @second_load_call_passes = second_load_call_passes
19
23
  @load_called = false
@@ -40,9 +44,11 @@ class LoadsOk < LoadableComponent
40
44
  end
41
45
  end
42
46
 
43
- class SlowlyDetonatingComponent < SlowLoadableComponent
47
+ class SlowlyDetonatingComponent
48
+ include SlowLoadableComponent
49
+
44
50
  def initialize
45
- super(1)
51
+ @timeout = 1
46
52
  end
47
53
 
48
54
  def load
@@ -54,13 +60,14 @@ class SlowlyDetonatingComponent < SlowLoadableComponent
54
60
  end
55
61
  end
56
62
 
57
- class SlowLoading < SlowLoadableComponent
63
+ class SlowLoading
64
+ include SlowLoadableComponent
65
+
58
66
  attr_reader :load_called
59
67
 
60
68
  def initialize
61
69
  @load_called = false
62
-
63
- super(1)
70
+ @timeout = 1
64
71
  end
65
72
 
66
73
  def load
@@ -83,7 +90,13 @@ class OnlyOneLoad < SlowLoading
83
90
  end
84
91
  end
85
92
 
86
- class BasicSlowLoader < SlowLoadableComponent
93
+ class BasicSlowLoader
94
+ include SlowLoadableComponent
95
+
96
+ def initialize(timeout)
97
+ @timeout = timeout
98
+ end
99
+
87
100
  def load
88
101
  # does nothing
89
102
  end
@@ -94,9 +107,14 @@ class BasicSlowLoader < SlowLoadableComponent
94
107
  end
95
108
  end
96
109
 
97
- class HasError < SlowLoadableComponent
110
+ class HasError
111
+ include SlowLoadableComponent
98
112
  class CustomError < StandardError; end
99
113
 
114
+ def initialize(timeout)
115
+ @timeout = timeout
116
+ end
117
+
100
118
  def load
101
119
  # does nothing
102
120
  end
metadata CHANGED
@@ -1,75 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: loadable_component
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jari Bakken
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-12-30 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :development
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- prerelease: false
12
+ date: 2012-03-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
32
15
  name: rake
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- type: :development
36
- requirement: &id002 !ruby/object:Gem::Requirement
16
+ requirement: &2152153900 !ruby/object:Gem::Requirement
37
17
  none: false
38
- requirements:
39
- - - ~>
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 2
44
- - 0
45
- version: "2.0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
46
23
  prerelease: false
24
+ version_requirements: *2152153900
25
+ - !ruby/object:Gem::Dependency
47
26
  name: rspec
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- type: :development
51
- requirement: &id003 !ruby/object:Gem::Requirement
27
+ requirement: &2152138740 !ruby/object:Gem::Requirement
52
28
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ type: :development
60
34
  prerelease: false
35
+ version_requirements: *2152138740
36
+ - !ruby/object:Gem::Dependency
61
37
  name: timecop
62
- version_requirements: *id003
38
+ requirement: &2152137860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2152137860
63
47
  description: Ruby implementation of http://code.google.com/p/selenium/wiki/LoadableComponent
64
- email:
48
+ email:
65
49
  - jari.bakken@gmail.com
66
50
  executables: []
67
-
68
51
  extensions: []
69
-
70
52
  extra_rdoc_files: []
71
-
72
- files:
53
+ files:
73
54
  - .gitignore
74
55
  - Gemfile
75
56
  - LICENSE
@@ -83,38 +64,30 @@ files:
83
64
  - spec/spec_helper.rb
84
65
  homepage: http://github.com/jarib/loadable_component
85
66
  licenses: []
86
-
87
67
  post_install_message:
88
68
  rdoc_options: []
89
-
90
- require_paths:
69
+ require_paths:
91
70
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
71
+ required_ruby_version: !ruby/object:Gem::Requirement
93
72
  none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
- version: "0"
101
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
78
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
110
83
  requirements: []
111
-
112
84
  rubyforge_project: loadable_component
113
85
  rubygems_version: 1.8.10
114
86
  signing_key:
115
87
  specification_version: 3
116
88
  summary: Ruby implementation of http://code.google.com/p/selenium/wiki/LoadableComponent
117
- test_files:
89
+ test_files:
118
90
  - spec/loadable_component_spec.rb
119
91
  - spec/slow_loadable_component_spec.rb
120
92
  - spec/spec_helper.rb
93
+ has_rdoc: