svelte-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 29347bbb2cb9144b3d09e4ad503babeb82db95ca
4
+ data.tar.gz: 5b3b84f1532c3dcacbe81549e258351535238e74
5
+ SHA512:
6
+ metadata.gz: 42f26d03a191ab8d38ff0e2d6de5f0a9663a4ba3b7f5b8e316aa3048028e205afd09ee90653d8deaa678cea1c636a03844f1696e8e6b10c908cd7c89bf030e1d
7
+ data.tar.gz: 3c656a265dfe0a1d87f049cf0efa4518ce6819cbb4e451e8568dcfa461df0b5238596d4ac8da91c41dadbee6f92f7e4b780bfdc004bc99bf53baae0af402cc0a
data/.autotest ADDED
@@ -0,0 +1,25 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.testlib = "minitest/unit"
7
+ #
8
+ # at.extra_files << "../some/external/dependency.rb"
9
+ #
10
+ # at.libs << ":../some/external"
11
+ #
12
+ # at.add_exception "vendor"
13
+ #
14
+ # at.add_mapping(/dependency.rb/) do |f, _|
15
+ # at.files_matching(/test_.*rb$/)
16
+ # end
17
+ #
18
+ # %w(TestA TestB).each do |klass|
19
+ # at.extra_class_map[klass] = "test/test_misc.rb"
20
+ # end
21
+ # end
22
+
23
+ # Autotest.add_hook :run_command do |at|
24
+ # system "rake build"
25
+ # end
data/.gitignore ADDED
@@ -0,0 +1,54 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ .DS_Store
53
+ *.swp
54
+ *.swo
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "svelte"]
2
+ path = svelte
3
+ url = https://github.com/awesome/svelte.git
data/.hoeignore ADDED
@@ -0,0 +1,10 @@
1
+ svelte/*
2
+ .git/*
3
+
4
+ *.swp
5
+ .*.swp
6
+ **/*.swp
7
+ **/.*.swp
8
+
9
+ .DS_Store
10
+ **/.DS_Store
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+
3
+ # DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
4
+
5
+ source "https://rubygems.org/"
6
+
7
+ gem "execjs", "2.7.0"
8
+
9
+ gem "minitest", "~>5.10", :group => [:development, :test]
10
+ gem "hoe-yard", ">=0.1.3", :group => [:development, :test]
11
+ gem "hoe-bundler", ">=1.2", :group => [:development, :test]
12
+ gem "hoe-gemspec", ">=1.0", :group => [:development, :test]
13
+ gem "hoe-git", ">=1.6", :group => [:development, :test]
14
+ gem "yard", "~>0.8", :group => [:development, :test]
15
+ gem "redcarpet", "~>3.3", :group => [:development, :test]
16
+ gem "hoe", "~>3.16", :group => [:development, :test]
17
+
18
+ # vim: syntax=ruby
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 0.0.1 / 2017-03-20
2
+
3
+ * It's alive!
4
+
5
+ * Bornday!
6
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Bordee Inc.
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,23 @@
1
+ .autotest
2
+ .gitignore
3
+ .gitmodules
4
+ .hoeignore
5
+ Gemfile
6
+ History.txt
7
+ LICENSE
8
+ Manifest.txt
9
+ README.md
10
+ Rakefile
11
+ bin/svelte
12
+ lib/core_ext/array/extract_options.rb
13
+ lib/rollup/rollup.config.ruby.js
14
+ lib/svelte.js
15
+ lib/svelte.js.map
16
+ lib/svelte.rb
17
+ lib/svelte/version.rb
18
+ lib/tasks/svelte.rake
19
+ svelte-ruby.gemspec
20
+ test/files/hello_world.html
21
+ test/files/hello_world_output.txt
22
+ test/files/hello_world_output_iife.txt
23
+ test/test_svelte.rb
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # svelte-ruby
2
+
3
+ Ruby Gem wrapper for the [Svelte compiler][svelte_compiler]
4
+
5
+ [svelte_compiler]: https://github.com/sveltejs/svelte
6
+
7
+ ## Usage
8
+
9
+ ```
10
+ require 'svelte'
11
+
12
+ Svelte.exec_eval('svelte.VERSION')
13
+ # => '1.12.1'
14
+
15
+ Svelte.exec_method('svelte.compile', '<h1>Hello {{name}}</h1>')
16
+ # => {code: 'function renderMainFragment ( root, component ) { [...], map: [...]}
17
+ ```
18
+
19
+ ## Installation
20
+
21
+ Command Line
22
+
23
+ ```
24
+ gem install svelte-ruby
25
+ ```
26
+
27
+ Gemfile
28
+
29
+ ```
30
+ gem "svelte-ruby", "~>0.1"
31
+ ```
32
+
33
+ ## Development
34
+
35
+ ### Svelte Source
36
+
37
+ https://svelte.technology
38
+
39
+ The svelte-ruby gem ships with a working svelte source: `lib/svelte.js`. No need to regenerate it except for development or configuration.
40
+
41
+ The rollup task transpiles the svelte source to a format that's compatible with Execjs. The result is written to `lib/svelte.js` with these commands: `cd svelte && rollup -c rollup/rollup.config.ruby.js`
42
+
43
+ Copy config to svelte repo
44
+
45
+ ```
46
+ rake svelte:copy_config
47
+ ```
48
+
49
+ Transpile to Execjs compatible
50
+
51
+ ```
52
+ rake svelte:rollup
53
+ ```
54
+
55
+ ### Dev Requirements
56
+
57
+ * [hoe](https://github.com/seattlerb/hoe) gem manager
58
+ * [hoe-bundler] may need `gem install hoe-bundler` installation before using `rake bundler:gemfile`
59
+ * [YARD](http://yardoc.org) docs
60
+ * [redcarpet](https://github.com/vmg/redcarpet) for yardoc
61
+ * [npm rollup] is needed locally to regenerate the svelte source for Execjs
62
+
63
+ [hoe-bundler]: https://github.com/flavorjones/hoe-bundler
64
+ [npm rollup]: https://www.npmjs.com/package/rollup
65
+
66
+ ### Testing
67
+
68
+ Tests written with [minitest]
69
+
70
+ ```
71
+ rake test
72
+ ```
73
+
74
+ [minitest]: https://github.com/seattlerb/minitest
75
+
76
+ ### Contributing
77
+
78
+ Send tested code.
79
+ Thank you, [contributors]!
80
+
81
+ [contributors]: https://github.com/bordeeinc/svelte-ruby/graphs/contributors
82
+
83
+ ### To Do
84
+
85
+ * Finish command line `bin/svelte`
86
+
87
+ ## License
88
+
89
+ MIT License
90
+
91
+ Copyright (c) 2017 Bordee Inc.
92
+
93
+ Permission is hereby granted, free of charge, to any person obtaining
94
+ a copy of this software and associated documentation files (the
95
+ 'Software'), to deal in the Software without restriction, including
96
+ without limitation the rights to use, copy, modify, merge, publish,
97
+ distribute, sublicense, and/or sell copies of the Software, and to
98
+ permit persons to whom the Software is furnished to do so, subject to
99
+ the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be
102
+ included in all copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
105
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
106
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
107
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
108
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
109
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
110
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
111
+
112
+ ## About
113
+
114
+ ![bordee](http://bordee.com/src/img/surf-with-bordee-github.png)
115
+
116
+ svelte-ruby is maintained and funded by Bordee Inc.
117
+ The names and logos for Bordee are trademarks of [Bordee Inc.][bordeeinc]
118
+
119
+ [bordeeinc]: http://bordee.com
120
+
121
+ We love open source software!
122
+ See [our other projects][bordee-github]
123
+ and [check out Seattle.rb!][community]
124
+
125
+ [bordee-github]: https://github.com/bordeeinc
126
+ [community]: https://seattlerb.org
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ # -*- ruby -*-
2
+
3
+ require "rubygems"
4
+ require "hoe"
5
+ require './lib/svelte/version.rb'
6
+
7
+ Hoe.plugin :gemspec
8
+ Hoe.plugin :minitest
9
+ Hoe.plugin :yard
10
+ Hoe.plugin :bundler
11
+ Hoe.plugin :git
12
+ Hoe.plugin :ignore
13
+
14
+ Hoe.spec "svelte" do
15
+ developer("So Awesome Man", "callme@1800aweso.me")
16
+ license "MIT" # this should match the license in the README
17
+
18
+ self.name = 'svelte-ruby'
19
+ self.version = Svelte::VERSION
20
+ self.summary = 'Ruby Gem wrapper for the Svelte compiler'
21
+ self.email = 'support@bordee.com'
22
+ self.description = self.summary
23
+ self.urls = ['https://github.com/bordeeinc/svelte-ruby']
24
+ self.testlib = :minitest
25
+ self.readme_file = 'README.md'
26
+ self.history_file = 'History.txt'
27
+
28
+ # third-party
29
+ self.yard_title = self.name
30
+ self.yard_markup = 'markdown'
31
+
32
+ self.extra_deps += [
33
+ ['execjs', '2.7.0']
34
+ ]
35
+
36
+ self.extra_dev_deps += [
37
+ ["hoe-bundler", ">= 1.2"],
38
+ ["hoe-gemspec", ">= 1.0"],
39
+ ["hoe-git", ">= 1.6"],
40
+ ["minitest", "~> 5.9.0"],
41
+ ["yard", "~> 0.8"],
42
+ ["redcarpet", "~> 3.3"] # yard/markdown
43
+ ]
44
+
45
+ self.clean_globs += [
46
+ '.yardoc',
47
+ 'vendor',
48
+ 'Gemfile.lock',
49
+ '.bundle',
50
+ ]
51
+
52
+ self.spec_extras = {
53
+ :required_ruby_version => '>= 1.9.2'
54
+ }
55
+ end
56
+
57
+ # require rake tasks
58
+ current_dir = File.expand_path(File.dirname(__FILE__))
59
+ Dir.glob(File.join(current_dir, 'lib/tasks/*.rake')).each {|r| import r}
60
+
61
+ # vim: syntax=ruby
data/bin/svelte ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
+ require 'svelte'
7
+
8
+ help =<<-EOS.gsub(/^\s*\|/, '').chomp
9
+ |
10
+ |svelte-ruby
11
+ |------------------------------------------
12
+ | Ruby Gem wrapper for the Svelte compiler
13
+ | Gem #{Svelte::VERSION}
14
+ | JS #{Svelte::VERSION_JS}
15
+ EOS
16
+
17
+
18
+ ARGV << '-h' if ARGV.empty?
19
+ options = {}
20
+
21
+ parser = OptionParser.new do |opts|
22
+ opts.banner = help + "\n\n usage: svelte [options]"
23
+
24
+ opts.on('-f', '--format format', 'Format') do |format|
25
+ options[:format] = format;
26
+ end
27
+
28
+ opts.on('-g', '--global global', 'Global') do |global|
29
+ options[:global] = global;
30
+ end
31
+
32
+ opts.on('-i', '--input input', 'Input') do |input|
33
+ options[:input] = input;
34
+ end
35
+
36
+ opts.on('-m', '--sourcemap sourcemap', 'Sourcemap') do |sourcemap|
37
+ options[:sourcemap] = sourcemap;
38
+ end
39
+
40
+ opts.on('-n', '--name name', 'Name') do |name|
41
+ options[:name] = name;
42
+ end
43
+
44
+ opts.on('-o', '--output output', 'Output') do |output|
45
+ options[:output] = output;
46
+ end
47
+
48
+ opts.on('-d', '--dev dev', 'Dev') do |dev|
49
+ options[:dev] = dev;
50
+ end
51
+
52
+ opts.on_tail("-h", "--help", "Show this message") do
53
+ puts opts
54
+ puts
55
+ puts
56
+ exit
57
+ end
58
+ end
59
+
60
+ parser.parse!
61
+
62
+ p options
@@ -0,0 +1,31 @@
1
+ # @note copied from the main Rails repo instead of adding via active_support
2
+ # @see https://github.com/rails/rails/blob/794a70f94485fb64ed1c49ba8532895306e2001c/activesupport/lib/active_support/core_ext/array/extract_options.rb
3
+ class Hash
4
+ # By default, only instances of Hash itself are extractable.
5
+ # Subclasses of Hash may implement this method and return
6
+ # true to declare themselves as extractable. If a Hash
7
+ # is extractable, Array#extract_options! pops it from
8
+ # the Array when it is the last element of the Array.
9
+ def extractable_options?
10
+ instance_of?(Hash)
11
+ end
12
+ end
13
+
14
+ class Array
15
+ # Extracts options from a set of arguments. Removes and returns the last
16
+ # element in the array if it's a hash, otherwise returns a blank hash.
17
+ #
18
+ # def options(*args)
19
+ # args.extract_options!
20
+ # end
21
+ #
22
+ # options(1, 2) # => {}
23
+ # options(1, 2, a: :b) # => {:a=>:b}
24
+ def extract_options!
25
+ if last.is_a?(Hash) && last.extractable_options?
26
+ pop
27
+ else
28
+ {}
29
+ end
30
+ end
31
+ end