jspreprocessor 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/JSPreprocessor.gemspec +23 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +8 -0
- data/example_js/lib/morestuff.js +3 -0
- data/example_js/lib/other.js +5 -0
- data/example_js/lib/stuff.js +8 -0
- data/example_js/main.js +6 -0
- data/lib/JSPreprocessor.rb +17 -0
- data/spec/jspreprocessor_spec.rb +14 -0
- data/spec/spec_helper.rb +13 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e1d55e3120cf8e8cdbfc90f37a860937196ab10
|
4
|
+
data.tar.gz: 1a4acb9054f3baaf2af73b196958f9e14d5c90d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3dab0fb30a16d23b639365563eba102fb16ae5c31f572750294a3333a3e0a44d9247e5e68549b3eb0da089430555b32c5ef834d48a7b718c84000241c48bbfc1
|
7
|
+
data.tar.gz: b3bd449a877f29d9eafa2b291a8a63b7e38045ae4365b726ddd13718cf83238980c8e6e7033e3fbf21ebb77ab439ae2e223ca59acce5c3a3ca5340211fe7bed4
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store
|
24
|
+
vendor/
|
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "jspreprocessor"
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["Caleb Albritton"]
|
9
|
+
spec.email = ["ithinkincode@gmail.com"]
|
10
|
+
spec.summary = %q{Like Browserify but the C way.}
|
11
|
+
spec.description = %q{Include JavaScript files directly into your source code using #include 'somefile'}
|
12
|
+
spec.homepage = "https://github.com/C0deMaver1ck/JSPreprocessor"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 2.14'
|
23
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# JSPreprocessor
|
2
|
+
|
3
|
+
Like Browserify but the C way.
|
4
|
+
Include JavaScript files directly into your source code using #include 'somefile'
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'jspreprocessor'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install jspreprocessor
|
19
|
+
|
20
|
+
## Gem Usage
|
21
|
+
|
22
|
+
@pre = JSPreprocessor.new
|
23
|
+
processed_file = @pre.process './folder_with_all_your_javascript/', 'entry_point.js'
|
24
|
+
|
25
|
+
File.open 'processed.js', 'w' do |file|
|
26
|
+
file.write processed_file
|
27
|
+
end
|
28
|
+
|
29
|
+
## JavaScript Usage
|
30
|
+
|
31
|
+
#include 'lib/stuff'
|
32
|
+
|
33
|
+
var s = new Stuff();
|
34
|
+
s.doStuff();
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it ( https://github.com/C0deMaver1ck/JSPreprocessor/fork )
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/example_js/main.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class JSPreprocessor
|
2
|
+
|
3
|
+
def process(cwd, main_file)
|
4
|
+
main = File.open(cwd + main_file).read.split "\n"
|
5
|
+
compiled_file = recurse_includes(cwd, main).join "\n"
|
6
|
+
end
|
7
|
+
|
8
|
+
def recurse_includes(cwd, file)
|
9
|
+
file.each_with_index do |line, index|
|
10
|
+
if line.include? '#include'
|
11
|
+
to_include = cwd + line[10..-2] + '.js'
|
12
|
+
next_wd = Pathname.new(to_include).dirname.to_s + '/'
|
13
|
+
file[index] = recurse_includes next_wd, File.open(to_include).read.split("\n")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JSPreprocessor do
|
4
|
+
before(:all) do
|
5
|
+
@pre = JSPreprocessor.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should process files' do #huehue
|
9
|
+
processed_file = @pre.process "#{Dir.pwd}/example_js/", 'main.js'
|
10
|
+
File.open 'processed.js', 'w' do |file|
|
11
|
+
file.write processed_file
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'jspreprocessor'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
|
8
|
+
# Run specs in random order to surface order dependencies. If you find an
|
9
|
+
# order dependency and want to debug it, you can fix the order by providing
|
10
|
+
# the seed, which is printed after each run.
|
11
|
+
# --seed 1234
|
12
|
+
config.order = 'random'
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jspreprocessor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Caleb Albritton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
description: 'Include JavaScript files directly into your source code using #include
|
56
|
+
''somefile'''
|
57
|
+
email:
|
58
|
+
- ithinkincode@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- JSPreprocessor.gemspec
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- example_js/lib/morestuff.js
|
70
|
+
- example_js/lib/other.js
|
71
|
+
- example_js/lib/stuff.js
|
72
|
+
- example_js/main.js
|
73
|
+
- lib/JSPreprocessor.rb
|
74
|
+
- spec/jspreprocessor_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
homepage: https://github.com/C0deMaver1ck/JSPreprocessor
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.0.14
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Like Browserify but the C way.
|
100
|
+
test_files:
|
101
|
+
- spec/jspreprocessor_spec.rb
|
102
|
+
- spec/spec_helper.rb
|