sprockets_fs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +113 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/mount_sprockets_rails +27 -0
- data/bin/sprockets_fs +17 -0
- data/lib/sprockets_fs/log.rb +184 -0
- data/lib/sprockets_fs.rb +135 -0
- data/spec/data/parent/double.js.coffee +1 -0
- data/spec/data/parent/main.js +1 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/sprockets_fs_spec.rb +173 -0
- data/spec/support/setup_dir.rb +12 -0
- data/spec/support/spec_forks.rb +45 -0
- data/sprockets_fs.gemspec +163 -0
- data/vol/env_explore.rb +30 -0
- data/vol/mongo_test.rb +24 -0
- data/vol/mount_app/.gitignore +15 -0
- data/vol/mount_app/Gemfile +55 -0
- data/vol/mount_app/Gemfile.lock +174 -0
- data/vol/mount_app/README.rdoc +261 -0
- data/vol/mount_app/Rakefile +7 -0
- data/vol/mount_app/app/assets/images/rails.png +0 -0
- data/vol/mount_app/app/assets/javascripts/application.js +15 -0
- data/vol/mount_app/app/assets/javascripts/main.js +1 -0
- data/vol/mount_app/app/assets/javascripts/widgets.js.coffee +1 -0
- data/vol/mount_app/app/assets/stylesheets/application.css +13 -0
- data/vol/mount_app/app/assets/stylesheets/widgets.css.scss +3 -0
- data/vol/mount_app/app/controllers/application_controller.rb +3 -0
- data/vol/mount_app/app/controllers/widgets_controller.rb +2 -0
- data/vol/mount_app/app/helpers/application_helper.rb +2 -0
- data/vol/mount_app/app/helpers/widgets_helper.rb +2 -0
- data/vol/mount_app/app/mailers/.gitkeep +0 -0
- data/vol/mount_app/app/models/.gitkeep +0 -0
- data/vol/mount_app/app/models/widget.rb +3 -0
- data/vol/mount_app/app/views/layouts/application.html.erb +14 -0
- data/vol/mount_app/config/application.rb +62 -0
- data/vol/mount_app/config/boot.rb +6 -0
- data/vol/mount_app/config/database.yml +25 -0
- data/vol/mount_app/config/environment.rb +5 -0
- data/vol/mount_app/config/environments/development.rb +37 -0
- data/vol/mount_app/config/environments/production.rb +67 -0
- data/vol/mount_app/config/environments/test.rb +37 -0
- data/vol/mount_app/config/initializers/backtrace_silencers.rb +7 -0
- data/vol/mount_app/config/initializers/inflections.rb +15 -0
- data/vol/mount_app/config/initializers/mime_types.rb +5 -0
- data/vol/mount_app/config/initializers/secret_token.rb +7 -0
- data/vol/mount_app/config/initializers/session_store.rb +8 -0
- data/vol/mount_app/config/initializers/wrap_parameters.rb +14 -0
- data/vol/mount_app/config/locales/en.yml +5 -0
- data/vol/mount_app/config/routes.rb +61 -0
- data/vol/mount_app/config.ru +4 -0
- data/vol/mount_app/db/migrate/20130429140835_create_widgets.rb +8 -0
- data/vol/mount_app/db/seeds.rb +7 -0
- data/vol/mount_app/lib/assets/.gitkeep +0 -0
- data/vol/mount_app/lib/tasks/.gitkeep +0 -0
- data/vol/mount_app/log/.gitkeep +0 -0
- data/vol/mount_app/public/404.html +26 -0
- data/vol/mount_app/public/422.html +26 -0
- data/vol/mount_app/public/500.html +25 -0
- data/vol/mount_app/public/favicon.ico +0 -0
- data/vol/mount_app/public/index.html +241 -0
- data/vol/mount_app/public/robots.txt +5 -0
- data/vol/mount_app/script/rails +6 -0
- data/vol/mount_app/test/fixtures/.gitkeep +0 -0
- data/vol/mount_app/test/fixtures/widgets.yml +11 -0
- data/vol/mount_app/test/functional/.gitkeep +0 -0
- data/vol/mount_app/test/functional/widgets_controller_test.rb +7 -0
- data/vol/mount_app/test/integration/.gitkeep +0 -0
- data/vol/mount_app/test/performance/browsing_test.rb +12 -0
- data/vol/mount_app/test/test_helper.rb +13 -0
- data/vol/mount_app/test/unit/.gitkeep +0 -0
- data/vol/mount_app/test/unit/helpers/widgets_helper_test.rb +4 -0
- data/vol/mount_app/test/unit/widget_test.rb +7 -0
- data/vol/mount_app/traces.txt +120 -0
- data/vol/mount_app/vendor/assets/javascripts/.gitkeep +0 -0
- data/vol/mount_app/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vol/mount_app/vendor/plugins/.gitkeep +0 -0
- data/vol/mount_app_runner.rb +12 -0
- data/vol/mount_rails.rb +16 -0
- metadata +290 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.8.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", ">= 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.8.4"
|
13
|
+
#gem "rcov", ">= 0"
|
14
|
+
end
|
15
|
+
|
16
|
+
gem 'mharris_ext'
|
17
|
+
gem 'lre'
|
18
|
+
gem 'guard'
|
19
|
+
gem 'activesupport'
|
20
|
+
gem 'rfusefs'
|
21
|
+
|
22
|
+
gem 'coffee-script'
|
23
|
+
gem 'therubyracer'
|
24
|
+
|
25
|
+
gem 'mongo'
|
26
|
+
gem 'bson_ext'
|
27
|
+
|
28
|
+
gem 'sprockets','2.2.2', :path => '/mnt/hgfs/Code/read/sprockets'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /mnt/hgfs/Code/read/sprockets
|
3
|
+
specs:
|
4
|
+
sprockets (2.2.2)
|
5
|
+
hike (~> 1.2)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
rack (~> 1.0)
|
8
|
+
tilt (~> 1.1, != 1.3.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (3.2.13)
|
14
|
+
i18n (= 0.6.1)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
bson (1.8.5)
|
17
|
+
bson_ext (1.8.5)
|
18
|
+
bson (~> 1.8.5)
|
19
|
+
coderay (1.0.9)
|
20
|
+
coffee-script (2.2.0)
|
21
|
+
coffee-script-source
|
22
|
+
execjs
|
23
|
+
coffee-script-source (1.6.2)
|
24
|
+
diff-lcs (1.1.3)
|
25
|
+
execjs (1.4.0)
|
26
|
+
multi_json (~> 1.0)
|
27
|
+
facets (2.9.3)
|
28
|
+
fattr (2.2.1)
|
29
|
+
ffi (1.8.1)
|
30
|
+
formatador (0.2.4)
|
31
|
+
git (1.2.5)
|
32
|
+
guard (1.8.0)
|
33
|
+
formatador (>= 0.2.4)
|
34
|
+
listen (>= 1.0.0)
|
35
|
+
lumberjack (>= 1.0.2)
|
36
|
+
pry (>= 0.9.10)
|
37
|
+
thor (>= 0.14.6)
|
38
|
+
hike (1.2.2)
|
39
|
+
i18n (0.6.1)
|
40
|
+
jeweler (1.8.4)
|
41
|
+
bundler (~> 1.0)
|
42
|
+
git (>= 1.2.5)
|
43
|
+
rake
|
44
|
+
rdoc
|
45
|
+
json (1.7.7)
|
46
|
+
libv8 (3.11.8.17)
|
47
|
+
listen (1.0.2)
|
48
|
+
rb-fsevent (>= 0.9.3)
|
49
|
+
rb-inotify (>= 0.9)
|
50
|
+
rb-kqueue (>= 0.2)
|
51
|
+
lre (0.3.0)
|
52
|
+
fattr
|
53
|
+
mharris_ext
|
54
|
+
watchr
|
55
|
+
lumberjack (1.0.3)
|
56
|
+
method_source (0.8.1)
|
57
|
+
mharris_ext (1.7.0)
|
58
|
+
facets
|
59
|
+
fattr
|
60
|
+
mongo (1.8.5)
|
61
|
+
bson (~> 1.8.5)
|
62
|
+
multi_json (1.7.2)
|
63
|
+
pry (0.9.12.1)
|
64
|
+
coderay (~> 1.0.5)
|
65
|
+
method_source (~> 0.8)
|
66
|
+
slop (~> 3.4)
|
67
|
+
rack (1.4.5)
|
68
|
+
rake (10.0.4)
|
69
|
+
rb-fsevent (0.9.3)
|
70
|
+
rb-inotify (0.9.0)
|
71
|
+
ffi (>= 0.5.0)
|
72
|
+
rb-kqueue (0.2.0)
|
73
|
+
ffi (>= 0.5.0)
|
74
|
+
rdoc (3.12.2)
|
75
|
+
json (~> 1.4)
|
76
|
+
ref (1.0.4)
|
77
|
+
rfuse (1.0.3)
|
78
|
+
rfusefs (1.0.0)
|
79
|
+
rfuse (~> 1.0)
|
80
|
+
rspec (2.8.0)
|
81
|
+
rspec-core (~> 2.8.0)
|
82
|
+
rspec-expectations (~> 2.8.0)
|
83
|
+
rspec-mocks (~> 2.8.0)
|
84
|
+
rspec-core (2.8.0)
|
85
|
+
rspec-expectations (2.8.0)
|
86
|
+
diff-lcs (~> 1.1.2)
|
87
|
+
rspec-mocks (2.8.0)
|
88
|
+
slop (3.4.4)
|
89
|
+
therubyracer (0.11.4)
|
90
|
+
libv8 (~> 3.11.8.12)
|
91
|
+
ref
|
92
|
+
thor (0.18.1)
|
93
|
+
tilt (1.3.7)
|
94
|
+
watchr (0.7)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
activesupport
|
101
|
+
bson_ext
|
102
|
+
bundler (>= 1.0.0)
|
103
|
+
coffee-script
|
104
|
+
guard
|
105
|
+
jeweler (~> 1.8.4)
|
106
|
+
lre
|
107
|
+
mharris_ext
|
108
|
+
mongo
|
109
|
+
rdoc (~> 3.12)
|
110
|
+
rfusefs
|
111
|
+
rspec (~> 2.8.0)
|
112
|
+
sprockets (= 2.2.2)!
|
113
|
+
therubyracer
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Mike Harris
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= sprockets_fs
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to sprockets_fs
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2013 Mike Harris. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "sprockets_fs"
|
18
|
+
gem.homepage = "http://github.com/mharris717/sprockets_fs"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{sprockets_fs}
|
21
|
+
gem.description = %Q{sprockets_fs}
|
22
|
+
gem.email = "mharris717@gmail.com"
|
23
|
+
gem.authors = ["Mike Harris"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "sprockets_fs #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
50
|
+
|
51
|
+
task :mount do
|
52
|
+
load File.dirname(__FILE__) + "/lib/sprockets_fs.rb"
|
53
|
+
|
54
|
+
gem_name = "sprockets_fs"
|
55
|
+
parent_dir = "/code/orig/sprockets_fs/spec/data/parent"
|
56
|
+
mount_dir = "/tmp/mount_sp"
|
57
|
+
|
58
|
+
exec "ruby /code/orig/#{gem_name}/bin/#{gem_name} #{parent_dir} #{mount_dir}"
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,27 @@
|
|
1
|
+
if ARGV.first == 'r'
|
2
|
+
load File.dirname(__FILE__) + "/../lib/sprockets_fs.rb"
|
3
|
+
|
4
|
+
parent_dir = File.expand_path(".")
|
5
|
+
mount_dir = "#{parent_dir}/asset_fs"
|
6
|
+
|
7
|
+
puts "parent is #{parent_dir}"
|
8
|
+
|
9
|
+
FileUtils.mkdir(mount_dir) unless FileTest.exist?(mount_dir)
|
10
|
+
|
11
|
+
app_name = parent_dir.split("/").last.split("_").map do |w|
|
12
|
+
w[0..0].upcase + w[1..-1]
|
13
|
+
end.join("")
|
14
|
+
|
15
|
+
app_name = File.read("#{parent_dir}/config/environment.rb").scan(/([a-z]+)::Application/i).flatten.first
|
16
|
+
|
17
|
+
env = eval(app_name)::Application.assets
|
18
|
+
dir = SprocketsFS::SprocketsDir.new(:parent_dir => "#{parent_dir}/app/assets", :env => env, :mount_dir => mount_dir)
|
19
|
+
|
20
|
+
FuseFS.start(dir,mount_dir)
|
21
|
+
else
|
22
|
+
here = File.expand_path(__FILE__)
|
23
|
+
puts "exec"
|
24
|
+
cmd = "rails runner #{here} r"
|
25
|
+
puts cmd
|
26
|
+
exec cmd
|
27
|
+
end
|
data/bin/sprockets_fs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
10.times { puts "" }
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rfusefs'
|
5
|
+
|
6
|
+
load File.dirname(__FILE__) + "/../lib/sprockets_fs.rb"
|
7
|
+
|
8
|
+
parent_dir, mount_dir, app_type = *ARGV
|
9
|
+
|
10
|
+
dir = SprocketsFS::SprocketsDir.new(:parent_dir => parent_dir, :mount_dir => mount_dir)
|
11
|
+
FuseFS.start(dir,mount_dir)
|
12
|
+
|
13
|
+
# ruby /code/orig/file_tag/bin/file_tag_fs /code/orig/ember_examples/container/ember_examples /tmp/ft
|
14
|
+
|
15
|
+
# \curl -L https://get.rvm.io | bash
|
16
|
+
|
17
|
+
# ruby /code/orig/file_tag/bin/file_tag_fs /tmp/test_parent /tmp/test
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
require 'mharris_ext'
|
3
|
+
|
4
|
+
module LogMethods
|
5
|
+
def calling_lines
|
6
|
+
raise 'foo'
|
7
|
+
rescue => exp
|
8
|
+
base = test = other = nil
|
9
|
+
dir = File.expand_path(File.dirname(__FILE__) + "/../..")
|
10
|
+
|
11
|
+
File.append "traces.txt", exp.backtrace.join("\n") + "\n\n\n"
|
12
|
+
|
13
|
+
exp.backtrace[3..-1].each do |line|
|
14
|
+
if line =~ /rspec-core/
|
15
|
+
# do nothing
|
16
|
+
elsif line.starts_with?(dir)
|
17
|
+
short = line.gsub("#{dir}/","")
|
18
|
+
if short.starts_with? "lib"
|
19
|
+
base ||= short
|
20
|
+
elsif short.starts_with? "spec"
|
21
|
+
test ||= short
|
22
|
+
else
|
23
|
+
raise "unknown #{line} | #{short}"
|
24
|
+
end
|
25
|
+
elsif line =~ /fattr/ || line.starts_with?("(eval):")
|
26
|
+
# do nothing
|
27
|
+
else
|
28
|
+
other ||= line
|
29
|
+
end
|
30
|
+
if base && test && other
|
31
|
+
test = "#{test} #{get_spec_name(test)}"
|
32
|
+
return [base,test,other]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
return [base,test,other] if base && test
|
36
|
+
raise 'end'
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_spec_name(desc)
|
40
|
+
file,line,junk = *desc.split(" ").first.split(":")
|
41
|
+
lines = File.read(file).split("\n")[0...(line.to_i)].reverse
|
42
|
+
lines.each do |line|
|
43
|
+
if line =~ /it\s+['"]([a-z _0-9]+)['"]\s+do/
|
44
|
+
return $1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
raise 'no spec name'
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_fattr_name(desc)
|
51
|
+
file,line,junk = *desc.split(" ").first.split(":")
|
52
|
+
lines = File.read(file).split("\n")[0...(line.to_i)].reverse
|
53
|
+
lines.each do |line|
|
54
|
+
if line =~ /fattr\(:([a-z0-9_]+)\)\s+do/
|
55
|
+
return $1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
raise 'no fattr name'
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
def log_special(obj,&b)
|
64
|
+
dt = Time.now
|
65
|
+
|
66
|
+
lines = calling_lines
|
67
|
+
line = lines.join(" | ")
|
68
|
+
|
69
|
+
raise "bad line, cant find calling function #{lines.first}" unless lines.first =~ /in `([a-z0-9_ <>:]+)'/i
|
70
|
+
caller = $1
|
71
|
+
|
72
|
+
if caller.starts_with?("block in <")
|
73
|
+
caller = get_fattr_name(lines.first)
|
74
|
+
elsif caller.starts_with?("block in")
|
75
|
+
raise "bad line, cant find calling function #{caller}" unless caller =~ /block in ([a-z0-9_!]+)/i
|
76
|
+
caller = $1
|
77
|
+
end
|
78
|
+
|
79
|
+
library = nil
|
80
|
+
if lines.last
|
81
|
+
if lines.last =~ /in `([a-z0-9_ <>:]+)'/i
|
82
|
+
library = $1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
res = nil
|
87
|
+
message = obj.inspect
|
88
|
+
if block_given?
|
89
|
+
res = yield
|
90
|
+
message += " RES: #{res.inspect}"
|
91
|
+
end
|
92
|
+
|
93
|
+
make :dt => dt, :base_line => lines.first, :spec_line => lines[1], :spec => get_spec_name(lines[1]), :message => message, :caller => caller, :library => library, :library_line => lines.last
|
94
|
+
|
95
|
+
File.append "log_special.log","#{dt} from #{line}\n#{obj.inspect}\n\n"
|
96
|
+
|
97
|
+
res
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class Time
|
102
|
+
def short
|
103
|
+
t = self - 60*60*4
|
104
|
+
t.strftime "%H:%M:%S:%L"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
class MongoLog
|
109
|
+
include LogMethods
|
110
|
+
fattr(:db) do
|
111
|
+
Mongo::Connection.new.db('mongo_log')
|
112
|
+
end
|
113
|
+
fattr(:coll) do
|
114
|
+
db.collection('entries')
|
115
|
+
end
|
116
|
+
def rows(ops={})
|
117
|
+
coll.find(ops).map { |x| LogRow.new(x) }.sort
|
118
|
+
end
|
119
|
+
|
120
|
+
def make(ops)
|
121
|
+
coll.save(ops)
|
122
|
+
end
|
123
|
+
|
124
|
+
class << self
|
125
|
+
fattr(:instance) { new }
|
126
|
+
def log(obj='',&b)
|
127
|
+
return yield if block_given?
|
128
|
+
return
|
129
|
+
instance.log_special(obj,&b)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
ML = MongoLog
|
135
|
+
|
136
|
+
class LogRow
|
137
|
+
include FromHash
|
138
|
+
attr_accessor :dt, :base_line, :spec_line, :spec, :message, :caller, :_id, :library_line, :library
|
139
|
+
|
140
|
+
def to_ss
|
141
|
+
c = [caller,library].select { |x| x }.join(" ").rpad(25)
|
142
|
+
"#{dt.short} From #{c} | #{spec.rpad(20)}: #{message[0...18000]}"
|
143
|
+
end
|
144
|
+
|
145
|
+
def <=>(r)
|
146
|
+
dt <=> r.dt
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_opt_args
|
151
|
+
require 'optparse'
|
152
|
+
|
153
|
+
options = {}
|
154
|
+
OptionParser.new do |opts|
|
155
|
+
opts.on("-s","--s SPEC") do |v|
|
156
|
+
v = /#{v[1..-1]}/i if v[0..0] == '/'
|
157
|
+
options[:spec] = v
|
158
|
+
end
|
159
|
+
|
160
|
+
opts.on("-c","--c CALLER") do |v|
|
161
|
+
v = /#{v[1..-1]}/i if v[0..0] == '/'
|
162
|
+
options[:caller] = v
|
163
|
+
end
|
164
|
+
end.parse!
|
165
|
+
|
166
|
+
puts "options #{options.inspect}"
|
167
|
+
|
168
|
+
options
|
169
|
+
end
|
170
|
+
|
171
|
+
if __FILE__==$0
|
172
|
+
m = MongoLog.instance
|
173
|
+
puts m.coll.count
|
174
|
+
arr = m.rows(get_opt_args)
|
175
|
+
|
176
|
+
arr.each do |row|
|
177
|
+
#puts "Row: " + row.inspect
|
178
|
+
end
|
179
|
+
|
180
|
+
arr.each do |row|
|
181
|
+
puts row.to_ss
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
data/lib/sprockets_fs.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sprockets'
|
3
|
+
require 'mharris_ext'
|
4
|
+
require 'rfusefs'
|
5
|
+
require 'coffee-script'
|
6
|
+
|
7
|
+
class String
|
8
|
+
def starts_with?(str)
|
9
|
+
sub = self[0...(str.length)]
|
10
|
+
sub == str
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
module SprocketsFS
|
17
|
+
class SprocketsDir
|
18
|
+
include FromHash
|
19
|
+
attr_accessor :parent_dir, :mount_dir
|
20
|
+
fattr(:env) do
|
21
|
+
ML.log "Made Env"
|
22
|
+
res = Sprockets::Environment.new
|
23
|
+
res.append_path parent_dir
|
24
|
+
res
|
25
|
+
end
|
26
|
+
def files
|
27
|
+
res = []
|
28
|
+
env.each_file do |f|
|
29
|
+
res << f.to_s.gsub("#{parent_dir}/","")
|
30
|
+
end
|
31
|
+
# puts "got files #{res.size}"
|
32
|
+
#puts res.inspect
|
33
|
+
res
|
34
|
+
end
|
35
|
+
def dirs
|
36
|
+
res = []
|
37
|
+
files.each do |f|
|
38
|
+
if f.split("/").size > 1
|
39
|
+
res << File.dirname(f)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
res
|
43
|
+
end
|
44
|
+
|
45
|
+
def file?(path)
|
46
|
+
files.each do |f|
|
47
|
+
return true if f == path[1..-1]
|
48
|
+
if f.split(".").size > 2
|
49
|
+
short = f.split(".")[0..-2].join(".")
|
50
|
+
return true if short == path[1..-1]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
false
|
54
|
+
end
|
55
|
+
def directory?(path)
|
56
|
+
path == "/" || dirs.include?(path[1..-1])
|
57
|
+
end
|
58
|
+
|
59
|
+
def contents(path)
|
60
|
+
# puts "contents for #{path} #{env.class}"
|
61
|
+
#puts env.inspect
|
62
|
+
all = files
|
63
|
+
res = if path == '/'
|
64
|
+
all.select { |x| x.split("/").size == 1 } + dirs.select { |x| x.split("/").size == 1 }
|
65
|
+
else
|
66
|
+
all.select do |f|
|
67
|
+
f.starts_with?(path[1..-1])
|
68
|
+
end.map { |f| f.gsub("#{path[1..-1]}/","") }
|
69
|
+
end.uniq
|
70
|
+
|
71
|
+
res = res.map do |f|
|
72
|
+
if f =~ /\.coffee$/
|
73
|
+
[f,f.gsub(/\.coffee$/,"")]
|
74
|
+
elsif f =~ /\.erb$/
|
75
|
+
[f,f.gsub(/\.erb$/,"")]
|
76
|
+
else
|
77
|
+
f
|
78
|
+
end
|
79
|
+
end.flatten
|
80
|
+
|
81
|
+
puts "contents #{res.size}"
|
82
|
+
|
83
|
+
res
|
84
|
+
end
|
85
|
+
|
86
|
+
def read_file(path)
|
87
|
+
ML.log("path #{path}") do
|
88
|
+
base = "#{parent_dir}#{path}"
|
89
|
+
res = if FileTest.exist?(base)
|
90
|
+
puts "Read_file #{path} exists"
|
91
|
+
File.read(base).strip
|
92
|
+
|
93
|
+
else
|
94
|
+
asset = env.find_asset(path[1..-1])
|
95
|
+
# ML.log "asset type: #{asset.content_type} #{asset.inspect}"
|
96
|
+
text = asset.to_s.strip
|
97
|
+
|
98
|
+
if text.blank?
|
99
|
+
self.env!
|
100
|
+
p = path[1..-1]+".coffee"
|
101
|
+
puts "finding #{path} #{p} with coffee added"
|
102
|
+
text = env.find_asset(p).to_s.strip
|
103
|
+
puts "got text #{text}"
|
104
|
+
end
|
105
|
+
|
106
|
+
text
|
107
|
+
|
108
|
+
end
|
109
|
+
#puts "Read_file #{path} #{res}"
|
110
|
+
res
|
111
|
+
end
|
112
|
+
end
|
113
|
+
def size(path)
|
114
|
+
read_file(path).size
|
115
|
+
end
|
116
|
+
|
117
|
+
def can_write?(path)
|
118
|
+
base = "#{parent_dir}#{path}.coffee"
|
119
|
+
if FileTest.exist?(base)
|
120
|
+
false
|
121
|
+
else
|
122
|
+
true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def write_to(path,contents)
|
127
|
+
full = "#{parent_dir}#{path}"
|
128
|
+
File.create full, contents
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
%w(log).each do |f|
|
134
|
+
load File.dirname(__FILE__) + "/sprockets_fs/#{f}.rb"
|
135
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
double = (x) -> x * 2
|
@@ -0,0 +1 @@
|
|
1
|
+
var abc = 42;
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'sprockets_fs'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
|
9
|
+
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.fail_fast = true
|
13
|
+
files = {"main.js" => "var abc = 42;", "widgets/stuff.js" => "var widget = 'Green'"}
|
14
|
+
parent_dir = setup_dir(files)
|
15
|
+
|
16
|
+
mount_dir = "/tmp/test_sp9"
|
17
|
+
gem_name = "sprockets_fs"
|
18
|
+
|
19
|
+
#SpecForks.add "ruby ~/code/orig/#{gem_name}/bin/#{gem_name} #{parent_dir} #{mount_dir}"
|
20
|
+
|
21
|
+
config.before(:all) do
|
22
|
+
File.create("log_special.log","Make #{Time.now}\n")
|
23
|
+
MongoLog.instance.coll.remove
|
24
|
+
|
25
|
+
FileUtils.rm_r mount_dir if FileTest.exist?(mount_dir)
|
26
|
+
`mkdir #{mount_dir}`
|
27
|
+
|
28
|
+
SpecForks.start!
|
29
|
+
end
|
30
|
+
config.after(:all) do
|
31
|
+
SpecForks.kill!
|
32
|
+
end
|
33
|
+
end
|