ae_page_objects 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,16 +5,12 @@ require 'active_support/core_ext/module/delegation'
5
5
  require 'active_support/core_ext/hash/keys'
6
6
  require 'active_support/core_ext/object/try'
7
7
  require 'active_support/core_ext/class'
8
- require 'active_support/dependencies'
8
+ require 'active_support/core_ext/module/introspection'
9
9
 
10
10
  require 'ae_page_objects/version'
11
11
 
12
12
  module AePageObjects
13
13
  autoload :Universe, 'ae_page_objects/core/universe'
14
- autoload :ConstantResolver, 'ae_page_objects/core/constant_resolver'
15
- autoload :DependenciesHook, 'ae_page_objects/core/dependencies_hook'
16
- autoload :Installable, 'ae_page_objects/core/installable'
17
- autoload :Configuration, 'ae_page_objects/core/configuration'
18
14
  autoload :Singleton, 'ae_page_objects/core/singleton'
19
15
  autoload :Application, 'ae_page_objects/core/application'
20
16
  autoload :ApplicationRouter, 'ae_page_objects/core/application_router'
@@ -44,8 +40,6 @@ module AePageObjects
44
40
  autoload :Checkbox, 'ae_page_objects/elements/checkbox'
45
41
  end
46
42
 
47
- ActiveSupport::Dependencies.extend AePageObjects::DependenciesHook
48
-
49
43
 
50
44
 
51
45
 
@@ -5,19 +5,11 @@ module AePageObjects
5
5
  class << self
6
6
  private :new
7
7
 
8
- attr_accessor :called_from
9
-
10
- delegate :initialize!, :to => :instance
11
- delegate :config, :to => :instance
8
+ delegate :initialize!, :router=, :to => :instance
12
9
 
13
10
  def inherited(application_class)
14
11
  super
15
12
 
16
- application_class.called_from = begin
17
- call_stack = caller.map { |p| p.sub(/:\d+.*/, '') }
18
- File.dirname(call_stack.detect { |p| p !~ %r[railties[\w.-]*/lib/rails|rack[\w.-]*/lib/rack] })
19
- end
20
-
21
13
  application_class.universe.send(:include, Universe)
22
14
  application_class.universe.page_objects_application_class = application_class
23
15
  end
@@ -39,44 +31,18 @@ module AePageObjects
39
31
  end
40
32
  end
41
33
 
42
- delegate :universe, :to => 'self.class'
34
+ attr_writer :router
43
35
 
44
- delegate :paths, :to => :config
45
- delegate :router, :to => :config
36
+ delegate :universe, :to => 'self.class'
46
37
 
47
38
  delegate :path_recognizes_url?, :to => :router
48
39
  delegate :generate_path, :to => :router
49
40
 
50
- def config
51
- @config ||= Configuration.new(self)
41
+ def router
42
+ @router ||= ApplicationRouter.new
52
43
  end
53
44
 
54
45
  def initialize!
55
- ActiveSupport::Dependencies.autoload_paths.unshift(*paths)
56
- eager_load!
57
- end
58
-
59
- def resolve_constant(from_mod, const_name)
60
- resolver = ConstantResolver.new(self, from_mod, const_name)
61
-
62
- resolved = nil
63
- paths.each do |path|
64
- break if resolved = resolver.load_constant_from_path(path)
65
- end
66
- resolved
67
- end
68
-
69
- private
70
-
71
- def eager_load!
72
- paths.each do |path|
73
- matcher = /\A#{Regexp.escape(path)}\/(.*)\.rb\Z/
74
-
75
- Dir.glob("#{path}/**/*.rb").sort.each do |file|
76
- dependency_name = file.sub(matcher, '\1')
77
- require_dependency dependency_name
78
- end
79
- end
80
46
  end
81
47
  end
82
48
  end
@@ -1,3 +1,3 @@
1
1
  module AePageObjects
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_page_objects
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Donnie Tognazzini
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-12 00:00:00 Z
18
+ date: 2013-07-05 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime
@@ -23,14 +23,13 @@ dependencies:
23
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - ">="
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  hash: 7
29
29
  segments:
30
30
  - 3
31
31
  - 0
32
- - 0
33
- version: 3.0.0
32
+ version: "3.0"
34
33
  requirement: *id001
35
34
  prerelease: false
36
35
  - !ruby/object:Gem::Dependency
@@ -126,9 +125,6 @@ files:
126
125
  - lib/ae_page_objects/concerns/visitable.rb
127
126
  - lib/ae_page_objects/core/application.rb
128
127
  - lib/ae_page_objects/core/application_router.rb
129
- - lib/ae_page_objects/core/configuration.rb
130
- - lib/ae_page_objects/core/constant_resolver.rb
131
- - lib/ae_page_objects/core/dependencies_hook.rb
132
128
  - lib/ae_page_objects/core/dsl/collection.rb
133
129
  - lib/ae_page_objects/core/dsl/element.rb
134
130
  - lib/ae_page_objects/core/dsl/form_for.rb
@@ -1,15 +0,0 @@
1
- module AePageObjects
2
- class Configuration
3
- attr_accessor :router, :paths
4
-
5
- def initialize(application)
6
- @application = application
7
- @paths = [application.class.called_from]
8
- end
9
-
10
- def router
11
- @router ||= ApplicationRouter.new
12
- end
13
- end
14
- end
15
-
@@ -1,38 +0,0 @@
1
- module AePageObjects
2
- class ConstantResolver
3
- def initialize(application, from_mod, const_name)
4
- @application = application
5
- @from_mod = from_mod
6
- @const_name = const_name
7
-
8
- @path_for_constant = path_for_constant
9
- end
10
-
11
- def load_constant_from_path(path)
12
- file_path = File.join(path, "#{@path_for_constant}.rb").sub(/(\.rb)?$/, ".rb")
13
-
14
- if File.file?(file_path) && ! ActiveSupport::Dependencies.loaded.include?(File.expand_path(file_path))
15
- ActiveSupport::Dependencies.require_or_load file_path
16
-
17
- unless ActiveSupport::Dependencies.local_const_defined?(@from_mod, @const_name)
18
- qualified_name = ActiveSupport::Dependencies.qualified_name_for(@from_mod, @const_name)
19
- raise LoadError, "Expected #{@file_path} to define #{qualified_name}"
20
- end
21
-
22
- @from_mod.const_get(@const_name)
23
- end
24
- end
25
-
26
- private
27
-
28
- def path_for_constant
29
- name_within_universe = ""
30
- if @application.universe != @from_mod
31
- name_within_universe = @from_mod.name.split("#{@application.universe.name}::")[1]
32
- end
33
-
34
- name_within_universe += "::#{@const_name}"
35
- name_within_universe.underscore
36
- end
37
- end
38
- end
@@ -1,7 +0,0 @@
1
- module AePageObjects
2
- module DependenciesHook
3
- def load_missing_constant(from_mod, const_name)
4
- Application.from(from_mod).try(:resolve_constant, from_mod, const_name) || super
5
- end
6
- end
7
- end