opal-file 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cdaf48c60594a394f17039dd51c54f6f84e3311
4
+ data.tar.gz: 4935595496fbe84a04aff2b1955ce29f5a2608d6
5
+ SHA512:
6
+ metadata.gz: 4e6da2e9346f5ee018e1a8482456acf0f09abdf9327cbe4c9bccb4af670532b88dd9f48ecc0e3d64718420b2a401220583cbacd09c6efb6aa7388876117ed1d6
7
+ data.tar.gz: d12a6a647a146f9ebdbba4e0f3fdc19b149d037492fa7abac6c76cb9862ebfd62ccf397b8a2b8f85e0d8be6fa258914fb46ae6dcc3d2851cec920a46dc101bcd
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in opal-file.gemspec
6
+ gemspec
@@ -0,0 +1,63 @@
1
+ # opal-file
2
+
3
+ native File.read, File.write etc... for Opal
4
+
5
+ ## What is this?
6
+
7
+ Opal's File class does not have methods for file IO but this module provides them.
8
+
9
+ ### Limitation
10
+
11
+ This provides only methods listed below.
12
+
13
+ - read
14
+ - write
15
+ - unlink
16
+
17
+ Pull requests are welcome!
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'opal-file'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install opal-file
34
+
35
+ ## Usage
36
+
37
+ write foo.rb
38
+
39
+ ```ruby
40
+ require "opal-file"
41
+
42
+ puts File.read("./foo")
43
+ ```
44
+
45
+ and compile
46
+
47
+ ```bash
48
+ opal --gem opal-file foo.rb > foo.js
49
+ ```
50
+
51
+ and run!
52
+
53
+ ```bash
54
+ node foo.js
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Narazaka/opal-file.
60
+
61
+ ## License
62
+
63
+ This is released under [MIT License](https://narazaka.net/license/MIT?2017)
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "opal/file"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ unless RUBY_ENGINE == "opal"
2
+ require "opal"
3
+ Opal.append_path File.expand_path("..", __FILE__).untaint
4
+ end
5
+
6
+ require "opal-file/version"
7
+
8
+ if RUBY_ENGINE == "opal"
9
+ require "native"
10
+
11
+ class File
12
+ class << self
13
+ def read(filename, options)
14
+ _fs.JS.readFileSync(filename, { encoding: "utf8" }.to_n)
15
+ end
16
+
17
+ def write(filename, content)
18
+ _fs.JS.writeFileSync(filename, content.to_s)
19
+ end
20
+
21
+ def unlink(*filename)
22
+ filename.each do |f|
23
+ _fs.JS.unlinkSync(f.to_s)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def _fs
30
+ @_fs ||= `require("fs")`
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module OpalFile
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1 @@
1
+ require "opal-file"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "opal-file/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "opal-file"
8
+ spec.version = OpalFile::VERSION
9
+ spec.authors = ["Narazaka"]
10
+ spec.email = ["info@narazaka.net"]
11
+
12
+ spec.summary = "native File.read, File.write etc... for Opal"
13
+ spec.homepage = "https://github.com/Narazaka/opal-file"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.15"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "opal"
25
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opal-file
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Narazaka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-28 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: opal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - info@narazaka.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - bin/console
67
+ - bin/setup
68
+ - lib/opal-file.rb
69
+ - lib/opal-file/version.rb
70
+ - lib/opal/file.rb
71
+ - opal-file.gemspec
72
+ homepage: https://github.com/Narazaka/opal-file
73
+ licenses: []
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.14
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: native File.read, File.write etc... for Opal
95
+ test_files: []
96
+ has_rdoc: