nx-file-utils 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14943cada5928bdf23eba35e7b7a949690547366aee95d3da31d134874531c4b
4
- data.tar.gz: e7092980388f7fe16202f4287b2e78d6389c9cf653b8886e062a82b9dc616b05
3
+ metadata.gz: 697647b2f9798c925ecaf90920b3a823b4ab15386c69a5d3d8b484e58109350e
4
+ data.tar.gz: 035e2f75c2dcf1132f40f7ca9766600565a1677f15e753f916e1618aaa5b6809
5
5
  SHA512:
6
- metadata.gz: 36eb8218768edf016dc65026649dd72f0236846008b207a26b77153119a7a81042ccd4804bcddc4e430764ea5ad6c9eacb685bc06c588a7263949a3357f0a91f
7
- data.tar.gz: b3d840dde0be55df41d3b40ae3a24ad4d635be167d50240e70c5d8ce04cdbd41a196ed56be78d65ff618cddfacc3db4d8b8f90147fb9578572f3e05841af8ec9
6
+ metadata.gz: 62608c3861eb7b6ef31a5b9bcad4419b4707b28388155986302dbe6501b4a4e2cfe0cec1a794f250abbc1806bc00aabb739c847bf0dc8be6bad492239dc28111
7
+ data.tar.gz: 9d11cacaf60dff67a1ec9d4c23734cf0db0ec81e3f0730b3e914491215454ec9b0d0cdac7ce26dece9fa434a8a62623ebf09c9260ad1a4ae50cbb53cd2fd0540
data/.gitignore ADDED
@@ -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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in templates.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # nx-file-utils
2
+ > File utils for nx.
3
+
4
+ ## installation
5
+ ```rb
6
+ # from gem
7
+ gem 'nx-file-utils'
8
+ # from git
9
+ gem 'nx-file-utils', git: 'git@github.com:afeiship/nx-file-utils.git'
10
+ ```
11
+
12
+ ## usage
13
+ ```rb
14
+ require "nx-file-utils"
15
+
16
+ puts Nx::FileUtils.sanitize("HTML5 Canvas核心技术/图形、动画与游戏开发.pdf")
17
+ puts Nx::FileUtils.ordinal("HTML5 Canvas核心技术/图形、动画与游戏开发.pdf")
18
+
19
+ # HTML5Canvas核心技术_图形_动画与游戏开发.pdf
20
+ # 000_HTML5 Canvas核心技术/图形、动画与游戏开发.pdf
21
+ ```
22
+
23
+ ## build/publish
24
+ ```shell
25
+ # build
26
+ gem build nx-file-utils.gemspec
27
+
28
+ # publish
29
+ gem push nx-file-utils-0.1.0.gem
30
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/__tests__/api.rb ADDED
@@ -0,0 +1,6 @@
1
+ require_relative "../lib/nx-file-utils"
2
+
3
+ puts Nx::FileUtils.sanitize("HTML5 Canvas核心技术/图形、动画与游戏开发.pdf")
4
+ puts Nx::FileUtils.ordinal("HTML5 Canvas核心技术/图形、动画与游戏开发.pdf")
5
+ # HTML5Canvas核心技术_图形_动画与游戏开发.pdf
6
+ # 000_HTML5 Canvas核心技术/图形、动画与游戏开发.pdf
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nx-file-utils"
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__)
data/bin/setup ADDED
@@ -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,26 @@
1
+ require "pathname"
2
+
3
+ module Nx
4
+ class FileUtils
5
+ class << self
6
+ def sanitize(in_name)
7
+ bad_chars = ["/", '\\', "?", "%", "*", "|", '"', "<", ">", "-", "(", "(", ")", ")", "、"]
8
+ bad_chars.each do |char|
9
+ in_name.gsub!(" ", "")
10
+ in_name.gsub!(":", ":")
11
+ in_name.gsub!(",", ",")
12
+ in_name.gsub!(char, "_")
13
+ end
14
+ yield(in_name) if block_given?
15
+ in_name
16
+ end
17
+
18
+ def ordinal(in_name, in_options = {})
19
+ default_options = { number: 0, width: 3, char: "0", separator: "_" }
20
+ options = default_options.merge(in_options)
21
+ prefix = options[:number].to_s.rjust(options[:width], options[:char])
22
+ prefix + options[:separator] + in_name
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/nx/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Nx
2
+ class FileUtils
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
Binary file
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nx/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nx-file-utils"
8
+ spec.version = Nx::FileUtils::VERSION
9
+ spec.licenses = ["MIT"]
10
+ spec.authors = ["afeiship"]
11
+ spec.email = ["1290657123@qq.com"]
12
+
13
+ spec.summary = %q{File utils.}
14
+ spec.description = %q{File utils for nx.}
15
+ spec.homepage = "https://github.com/afeiship/nx-file-utils"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.14"
34
+ spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
35
+ end
data/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "nx-file-utils",
3
+ "version": "1.0.0",
4
+ "description": "File utils for nx.",
5
+ "directories": {
6
+ "lib": "lib"
7
+ },
8
+ "scripts": {
9
+ "clean": "rm -rf *.gem",
10
+ "build": "gem build *.gemspec",
11
+ "pubpush": "gem push *.gem",
12
+ "unpublish":"gem yank nx-http -v '0.1.0'"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/afeiship/nx-file-utils.git"
17
+ },
18
+ "author": "afei",
19
+ "license": "MIT",
20
+ "bugs": {
21
+ "url": "https://github.com/afeiship/nx-file-utils/issues"
22
+ },
23
+ "homepage": "https://github.com/afeiship/nx-file-utils#readme"
24
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nx-file-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - afeiship
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-15 00:00:00.000000000 Z
11
+ date: 2020-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,7 +51,19 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
+ - ".gitignore"
55
+ - Gemfile
56
+ - README.md
57
+ - Rakefile
58
+ - __tests__/api.rb
59
+ - bin/console
60
+ - bin/setup
54
61
  - lib/nx-file-utils.rb
62
+ - lib/nx/file-utils.rb
63
+ - lib/nx/version.rb
64
+ - nx-file-utils-0.1.0.gem
65
+ - nx-file-utils.gemspec
66
+ - package.json
55
67
  homepage: https://github.com/afeiship/nx-file-utils
56
68
  licenses:
57
69
  - MIT