rollup-rails 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,95 @@
1
+ require 'shellwords'
2
+ require 'sprockets'
3
+ require 'ostruct'
4
+
5
+ module Sprockets
6
+ class Rollup
7
+
8
+ class << self
9
+
10
+ attr_accessor :configuration
11
+
12
+ def configuration_hash
13
+ configuration.to_h.reduce({}) do |hash, (key, val)|
14
+ hash[key.to_s] = val
15
+ hash
16
+ end
17
+ end
18
+
19
+ def instance
20
+ @instance ||= new
21
+ end
22
+
23
+ def configure
24
+ self.configuration ||= OpenStruct.new
25
+ yield configuration
26
+ end
27
+
28
+ def reset_configuration
29
+ self.configuration = OpenStruct.new
30
+ end
31
+
32
+ def call(input)
33
+ instance.call(input)
34
+ end
35
+
36
+ def cache_key
37
+ instance.cache_key
38
+ end
39
+
40
+ end
41
+
42
+ attr_reader :cache_key
43
+
44
+ def configuration_hash
45
+ self.class.configuration_hash
46
+ end
47
+
48
+ def initialize(options = {})
49
+ @options = configuration_hash.merge(options).freeze
50
+ end
51
+
52
+ def call(input)
53
+ transform input
54
+ end
55
+
56
+ def transform(input)
57
+ compile(rollup(input))
58
+ end
59
+
60
+ def rollup(input)
61
+ path_to_rollup = File.join File.dirname(__FILE__), "rollup.js"
62
+ output = `node #{path_to_rollup} #{input[:filename].shellescape}`
63
+ raise ArgumentError, output if $? != 0
64
+ output
65
+ end
66
+
67
+ def compile(input)
68
+ path_to_buble = File.join File.dirname(__FILE__), "buble.js"
69
+ output = nil
70
+
71
+ IO.popen(['node', path_to_buble], 'r+') do |pipe|
72
+ pipe.write(input)
73
+ pipe.close_write
74
+ output = pipe.read
75
+ end
76
+
77
+ raise ArgumentError, output if $? != 0
78
+ output
79
+ end
80
+
81
+ end
82
+
83
+ if respond_to?(:register_transformer)
84
+ register_mime_type 'text/ecmascript-6', extensions: ['.es'], charset: :unicode
85
+ register_transformer 'text/ecmascript-6', 'application/javascript', Rollup
86
+ register_preprocessor 'text/ecmascript-6', DirectiveProcessor
87
+ end
88
+
89
+ if respond_to?(:register_engine)
90
+ args = ['.es', Rollup]
91
+ args << { mime_type: 'text/ecmascript-6', silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
92
+ register_engine(*args)
93
+ end
94
+
95
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollup-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - snuggs
@@ -46,19 +46,13 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
50
- - .travis.yml
51
- - CODE_OF_CONDUCT.md
52
- - Gemfile
53
- - README.md
54
- - Rakefile
55
- - bin/console
56
- - bin/setup
57
- - lib/rollup/rails.rb
58
- - lib/rollup/rails/version.rb
59
- - rollup-rails.gemspec
49
+ - lib/sprockets/buble.js
50
+ - lib/sprockets/rollup.rb
51
+ - lib/sprockets/rollup.js
52
+ - LICENSE
60
53
  homepage: http://devpunks.com
61
- licenses: []
54
+ licenses:
55
+ - MIT
62
56
  metadata:
63
57
  allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
64
58
  post_install_message:
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
data/CODE_OF_CONDUCT.md DELETED
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rollup-rails.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,39 +0,0 @@
1
- # Rollup::Rails
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rollup/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'rollup-rails'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install rollup-rails
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- 1. Fork it ( https://github.com/[my-github-username]/rollup-rails/fork )
36
- 2. Create your feature branch (`git checkout -b my-new-feature`)
37
- 3. Commit your changes (`git commit -am 'Add some feature'`)
38
- 4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create a new Pull Request
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "rollup/rails"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -1,5 +0,0 @@
1
- module Rollup
2
- module Rails
3
- VERSION = '0.0.1'
4
- end
5
- end
data/lib/rollup/rails.rb DELETED
@@ -1,7 +0,0 @@
1
- require "rollup/rails/version"
2
-
3
- module Rollup
4
- module Rails
5
- # Your code goes here...
6
- end
7
- end
data/rollup-rails.gemspec DELETED
@@ -1,31 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rollup/rails/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "rollup-rails"
8
- spec.version = Rollup::Rails::VERSION
9
- spec.authors = ["snuggs", "pachonk"]
10
- spec.email = ["rashaunstovall@gmail.com"]
11
-
12
- spec.summary = %q{Rollup.js assets for Rails}
13
- spec.description = %q{Rollup.js assets for Rails}
14
- spec.homepage = "http://devpunks.com"
15
-
16
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
- # delete this section to allow pushing this gem to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
- else
21
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
- end
23
-
24
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- spec.bindir = "exe"
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
28
-
29
- spec.add_development_dependency "bundler"
30
- spec.add_development_dependency "rake"
31
- end