trax_core 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/Guardfile +38 -0
- data/README.md +39 -1
- data/lib/trax/array.rb +7 -0
- data/lib/trax/core/eager_autoload_namespace.rb +43 -0
- data/lib/trax/core.rb +10 -0
- data/lib/trax.rb +5 -0
- data/lib/trax_core/version.rb +1 -1
- data/lib/trax_core.rb +2 -3
- data/spec/spec_helper.rb +18 -0
- data/spec/support/ecom/widget.rb +5 -0
- data/spec/support/ecom/widget_category.rb +5 -0
- data/spec/support/ecom.rb +3 -0
- data/spec/trax/array_spec.rb +16 -0
- data/spec/trax/core/eager_autoload_namespace_spec.rb +10 -0
- data/spec/trax/core_spec.rb +7 -0
- data/trax_core.gemspec +15 -2
- metadata +196 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e445cef91099b94410262c1bcacbd332020b4b3
|
4
|
+
data.tar.gz: 94411509e7f8e87b77e62fe293849daeff10c12e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de6b9a2c9ba0edda25b94cf3600ffe939b348e75ce75dc58fb6a03bbde0c1ab24ac7b95faccfac82c5709dd11721ac13deb11b25df113b877881d48a3ef38de0
|
7
|
+
data.tar.gz: 78dd67036e2eb2660e0d9898333abf9f295cd115339358c7577032dd9566673efbb341eff4d75a7b728a0480b22117165d70fa82612851211a5b391e4620a7f7
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Guardfile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :bundler do
|
5
|
+
watch('Gemfile')
|
6
|
+
# Uncomment next line if your Gemfile contains the `gemspec' command.
|
7
|
+
# watch(/^.+\.gemspec/)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
11
|
+
# rspec may be run, below are examples of the most common uses.
|
12
|
+
# * bundler: 'bundle exec rspec'
|
13
|
+
# * bundler binstubs: 'bin/rspec'
|
14
|
+
# * spring: 'bin/rsspec' (This will use spring if running and you have
|
15
|
+
# installed the spring binstubs per the docs)
|
16
|
+
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
17
|
+
# * 'just' rspec: 'rspec'
|
18
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
19
|
+
watch(%r{^spec/.+_spec\.rb$})
|
20
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
21
|
+
watch('spec/spec_helper.rb') { "spec" }
|
22
|
+
|
23
|
+
# Rails example
|
24
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
25
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
26
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
27
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
28
|
+
watch('config/routes.rb') { "spec/routing" }
|
29
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
30
|
+
watch('spec/rails_helper.rb') { "spec" }
|
31
|
+
|
32
|
+
# Capybara features specs
|
33
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
34
|
+
|
35
|
+
# Turnip features and steps
|
36
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
37
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
38
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,44 @@
|
|
1
1
|
# TraxCore
|
2
2
|
|
3
|
-
|
3
|
+
The active support for Trax / Trax components.
|
4
|
+
|
5
|
+
### EagerAutoloadNamespace
|
6
|
+
|
7
|
+
Wish you could eager load all of the paths in a particular namespace directory,
|
8
|
+
eagerly? Say you have the following directory tree you're trying to autoload:
|
9
|
+
|
10
|
+
whatever.rb
|
11
|
+
``` ruby
|
12
|
+
module Whatever
|
13
|
+
extend ::ActiveSupport::Autoload
|
14
|
+
|
15
|
+
eager_autoload do
|
16
|
+
autoload :Widget
|
17
|
+
autoload :Thing
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Whatever.eager_load!
|
22
|
+
```
|
23
|
+
whatever/widget.rb
|
24
|
+
``` ruby
|
25
|
+
module Whatever
|
26
|
+
module Widget
|
27
|
+
end
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
Now you just have to do:
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
module Whatever
|
35
|
+
include ::Trax::Core::EagerAutoloadNamespace
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
Note, it cant handle all caps namespaces, i.e. it would break if namespace were WIDGETS,
|
40
|
+
as it just uses classify on the file base name to define the autoload block.
|
41
|
+
|
4
42
|
|
5
43
|
## Installation
|
6
44
|
|
data/lib/trax/array.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Trax
|
2
|
+
module Core
|
3
|
+
module EagerAutoloadNamespace
|
4
|
+
extend ::ActiveSupport::Autoload
|
5
|
+
|
6
|
+
def self.extended(base)
|
7
|
+
source_file_path = caller[0].partition(":")[0]
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
extend ::ActiveSupport::Autoload
|
11
|
+
|
12
|
+
@eager_autoload_filepath = source_file_path
|
13
|
+
end
|
14
|
+
|
15
|
+
base.autoload_class_names.each do |klass|
|
16
|
+
base.eager_autoload do
|
17
|
+
autoload :"#{klass}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
base.eager_load!
|
22
|
+
end
|
23
|
+
|
24
|
+
def autoload_file_paths
|
25
|
+
@autoload_file_paths = ::Dir[module_path.join('*.rb')]
|
26
|
+
end
|
27
|
+
|
28
|
+
def autoload_class_names
|
29
|
+
@autoload_class_names = autoload_file_paths.map do |path|
|
30
|
+
::File.basename(path.to_s).split(".rb").shift.try(:classify)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def eager_autoload_filepath
|
35
|
+
@eager_autoload_filepath
|
36
|
+
end
|
37
|
+
|
38
|
+
def module_path
|
39
|
+
@module_path ||= ::Pathname.new(::File.path(eager_autoload_filepath).gsub(".rb", ""))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/trax/core.rb
ADDED
data/lib/trax_core/version.rb
CHANGED
data/lib/trax_core.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'simplecov'
|
4
|
+
require 'pry'
|
5
|
+
require 'trax_core'
|
6
|
+
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter '/spec/'
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.before(:suite) do
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Bundler.require(:default, :development, :test)
|
17
|
+
|
18
|
+
::Dir["#{::File.dirname(__FILE__)}/support/*.rb"].each {|f| require f }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::Array do
|
4
|
+
subject do
|
5
|
+
[
|
6
|
+
{:name => "something", :price => 40},
|
7
|
+
{:name => "else", :price => 50}
|
8
|
+
]
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#to_proc" do
|
12
|
+
it{
|
13
|
+
subject.map(&[:name, :price]).map(&:last).sum.should eq 90
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::Trax::Core::EagerAutoloadNamespace do
|
4
|
+
subject { ::Ecom }
|
5
|
+
|
6
|
+
its('autoload_class_names.length') { should eq 2 }
|
7
|
+
its('autoload_file_paths.length') { should eq 2 }
|
8
|
+
its(:eager_autoload_filepath) { should include('ecom') }
|
9
|
+
its(:module_path) { should be_a(::Pathname) }
|
10
|
+
end
|
data/trax_core.gemspec
CHANGED
@@ -18,8 +18,21 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
-
spec.add_development_dependency "rake"
|
23
21
|
spec.add_dependency "hashie"
|
24
22
|
spec.add_dependency "activesupport"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rspec-pride"
|
29
|
+
spec.add_development_dependency "pry-nav"
|
30
|
+
spec.add_development_dependency "simplecov"
|
31
|
+
spec.add_development_dependency 'rspec-its', '~> 1'
|
32
|
+
spec.add_development_dependency 'rspec-collection_matchers', '~> 1'
|
33
|
+
spec.add_development_dependency 'guard', '~> 2'
|
34
|
+
spec.add_development_dependency 'guard-rspec', '~> 4'
|
35
|
+
spec.add_development_dependency 'guard-bundler', '~> 2'
|
36
|
+
spec.add_development_dependency 'rb-fsevent'
|
37
|
+
spec.add_development_dependency 'terminal-notifier-guard'
|
25
38
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trax_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Ayre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hashie
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,13 +67,13 @@ dependencies:
|
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
70
|
+
name: sqlite3
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - ">="
|
46
74
|
- !ruby/object:Gem::Version
|
47
75
|
version: '0'
|
48
|
-
type: :
|
76
|
+
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
@@ -53,13 +81,153 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rspec
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
89
|
version: '0'
|
62
|
-
type: :
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-pride
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-nav
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-its
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec-collection_matchers
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: guard-rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '4'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '4'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: guard-bundler
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '2'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '2'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rb-fsevent
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: terminal-notifier-guard
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
63
231
|
prerelease: false
|
64
232
|
version_requirements: !ruby/object:Gem::Requirement
|
65
233
|
requirements:
|
@@ -74,12 +242,25 @@ extensions: []
|
|
74
242
|
extra_rdoc_files: []
|
75
243
|
files:
|
76
244
|
- ".gitignore"
|
245
|
+
- ".rspec"
|
77
246
|
- Gemfile
|
247
|
+
- Guardfile
|
78
248
|
- LICENSE.txt
|
79
249
|
- README.md
|
80
250
|
- Rakefile
|
251
|
+
- lib/trax.rb
|
252
|
+
- lib/trax/array.rb
|
253
|
+
- lib/trax/core.rb
|
254
|
+
- lib/trax/core/eager_autoload_namespace.rb
|
81
255
|
- lib/trax_core.rb
|
82
256
|
- lib/trax_core/version.rb
|
257
|
+
- spec/spec_helper.rb
|
258
|
+
- spec/support/ecom.rb
|
259
|
+
- spec/support/ecom/widget.rb
|
260
|
+
- spec/support/ecom/widget_category.rb
|
261
|
+
- spec/trax/array_spec.rb
|
262
|
+
- spec/trax/core/eager_autoload_namespace_spec.rb
|
263
|
+
- spec/trax/core_spec.rb
|
83
264
|
- trax_core.gemspec
|
84
265
|
homepage: http://github.com/jasonayre/trax_core
|
85
266
|
licenses:
|
@@ -101,8 +282,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
282
|
version: '0'
|
102
283
|
requirements: []
|
103
284
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
285
|
+
rubygems_version: 2.4.3
|
105
286
|
signing_key:
|
106
287
|
specification_version: 4
|
107
288
|
summary: Core Trax Dependencies
|
108
|
-
test_files:
|
289
|
+
test_files:
|
290
|
+
- spec/spec_helper.rb
|
291
|
+
- spec/support/ecom.rb
|
292
|
+
- spec/support/ecom/widget.rb
|
293
|
+
- spec/support/ecom/widget_category.rb
|
294
|
+
- spec/trax/array_spec.rb
|
295
|
+
- spec/trax/core/eager_autoload_namespace_spec.rb
|
296
|
+
- spec/trax/core_spec.rb
|