gemoji 3.0.0.rc2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/emoji/cli.rb +27 -6
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2962c3dbfa8c4208c93ba5f64c9f39601c7045a2
4
- data.tar.gz: 94b8bc5ab26209fabaf4cc7a9bde753e7aa40478
3
+ metadata.gz: 129cc87f6beaf861e6f886c5d2db15562225dde5
4
+ data.tar.gz: 9b310aaf5a6522824af665e8b88c04a023d2b708
5
5
  SHA512:
6
- metadata.gz: cf4e7bc02484ebd18cebd9140371baa0580d16f70bc866aff6d0d5a666fe1ea10ebaa00632212ec02781203fe90316168376a271dfbbbcb05e95024bb073516f
7
- data.tar.gz: dd7f42d8693152b2f876f3a7a4b2fb4635039b35757619d106bd3efbab4abab029dcc1861fbf4919cc3876d3ca0089a22887f1c43a698776d67a0c6c50829382
6
+ metadata.gz: c011fa25acb8922733993c64811adfac911e5661bf1ea587ea655e9ce28a82bdac5788c61fda8c3977dd2ee7938b462c95f1f839ed2b0a8f647d6692ff5f1bb3
7
+ data.tar.gz: 49cea6f72f419949b1e5b4b3d8199e48f96d9da92a338ac7d87bc337a0722f62d80da02ae3abe2af8f4a1bb1688c52473fa912e6a0c40accdbf28a9eadd46eca
@@ -1,10 +1,13 @@
1
1
  require 'emoji/extractor'
2
2
  require 'fileutils'
3
+ require 'optparse'
3
4
 
4
5
  module Emoji
5
6
  module CLI
6
7
  extend self
7
8
 
9
+ InvalidUsage = Class.new(RuntimeError)
10
+
8
11
  def dispatch(argv)
9
12
  cmd = argv[0]
10
13
  argv = argv[1..-1]
@@ -15,11 +18,15 @@ module Emoji
15
18
  when "help", "--help", "-h"
16
19
  help
17
20
  else
18
- raise ArgumentError
21
+ raise InvalidUsage
19
22
  end
20
23
 
21
24
  return 0
22
- rescue ArgumentError
25
+ rescue InvalidUsage, OptionParser::InvalidArgument, OptionParser::InvalidOption => err
26
+ unless err.message == err.class.to_s
27
+ $stderr.puts err.message
28
+ $stderr.puts
29
+ end
23
30
  $stderr.puts usage_text
24
31
  return 1
25
32
  end
@@ -28,11 +35,25 @@ module Emoji
28
35
  puts usage_text
29
36
  end
30
37
 
38
+ VALID_SIZES = [ 20, 32, 40, 48, 64, 96, 160 ]
39
+
31
40
  def extract(argv)
32
- path = argv.shift
33
- raise ArgumentError if path.to_s.empty?
41
+ size = 64
42
+
43
+ OptionParser.new do |opts|
44
+ opts.on("--size=#{size}", Integer) do |val|
45
+ if VALID_SIZES.include?(val)
46
+ size = val
47
+ else
48
+ raise InvalidUsage, "size should be one of: #{VALID_SIZES.join(', ')}"
49
+ end
50
+ end
51
+ end.parse!(argv)
52
+
53
+ raise InvalidUsage unless argv.size == 1
54
+ path = argv[0]
34
55
 
35
- Emoji::Extractor.new(64, path).extract!
56
+ Emoji::Extractor.new(size, path).extract!
36
57
  Dir["#{Emoji.images_path}/*.png"].each do |png|
37
58
  FileUtils.cp(png, File.join(path, File.basename(png)))
38
59
  end
@@ -40,7 +61,7 @@ module Emoji
40
61
 
41
62
  def usage_text
42
63
  <<EOF
43
- Usage: gemoji extract <path>
64
+ Usage: gemoji extract <path> [--size=64]
44
65
  EOF
45
66
  end
46
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Character information and metadata for standard and custom emoji.
14
14
  email: support@github.com
@@ -58,9 +58,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  version: '1.9'
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">"
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 1.3.1
63
+ version: '0'
64
64
  requirements: []
65
65
  rubyforge_project:
66
66
  rubygems_version: 2.4.5.1