commandc 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ca86d81eecabeb0d8b052a37129c23217681062
4
- data.tar.gz: 9527f15b82981e02a45ff454245874ffd8f24144
3
+ metadata.gz: f09cbc441f107c34987a2be820bc6e6f3fa5f8e0
4
+ data.tar.gz: 494694cf40cea5dbd52a37016d19e8422fae7bd4
5
5
  SHA512:
6
- metadata.gz: 624f65306bd9b584c9091163da033a43f0fe35d6a6d991d0ac865c633916ad6d6025e7b7c26cdd2c458e464d05c79110ece54ba1c3a0764718a3343d6b37e79b
7
- data.tar.gz: f520c4645dd3e15d8c0d5741baeed316b8c304cbb08c173ce6017fd925820f54d80250b0878101aaffa1ff855e42a8d24bad987151302ae72c3c9ebb5385bfcd
6
+ metadata.gz: 7910f7450759b7904b162b9697d967ec30990e4c4a3f0e2d0c0b7ae4203a2b8f2a7fa6c765d784a754bf154f96adc65a036ca8040363f0b92bfe85f63c55fc5c
7
+ data.tar.gz: d9b61344f87d222d2327d5591d38bdc0c684e67b58629f118bb6d0d963000742de138b755e41bdfec158245487cfcef3af8caee6f5c29996552d776a70c2073e
data/bin/commandc CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'commandc'
4
+
5
+ Commandc::Cli.start(ARGV)
data/commandc.gemspec CHANGED
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency 'thor'
24
25
  end
@@ -0,0 +1,39 @@
1
+ require 'thor'
2
+ require 'commandc/text'
3
+
4
+ # @author "Brandon Pittman"
5
+ module Commandc
6
+ # @author "Brandon Pittman"
7
+ # Inherits from Thor in order to create CLI
8
+ class Cli < Thor
9
+ desc 'copy --text TEXT --to DEVICE [--open]',
10
+ 'copy TEXT to DEVICE'
11
+ # @param text [String] the text to copy
12
+ # @option device [String] the device to copy the text to
13
+ # @example commandc copy
14
+ # commandc copy --text "This is some text" --to iPhone --open
15
+ # commandc copy --to iPhone --open
16
+ option :to,
17
+ type: :string,
18
+ required: true,
19
+ banner: 'Device to copy text to'
20
+ option :text,
21
+ type: :string,
22
+ default: `pbpaste`,
23
+ required: false,
24
+ banner: 'Text to copy (defaults to system clipboard)'
25
+ option :open,
26
+ type: :boolean,
27
+ required: false,
28
+ default: false,
29
+ banner: 'Open copied URL on destination device (if a Mac)'
30
+ def copy
31
+ output = Commandc::Text.new(
32
+ options[:text],
33
+ options[:to],
34
+ options[:open]
35
+ )
36
+ output.copy
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ require 'uri'
2
+
3
+ # @since since 0.0.1
4
+ module Commandc
5
+ # @since since 0.0.1
6
+ class Text
7
+ attr_accessor :text, :device, :open
8
+
9
+ def initialize(text, device, open)
10
+ @text = text
11
+ @device = escape_device_name(device)
12
+ @open = open
13
+ end
14
+
15
+ def copy
16
+ if open
17
+ `open "command-c://x-callback-url/copyText?text=#{text}&deviceName=#{device}"`
18
+ else
19
+ `open "command-c://x-callback-url/copyAndOpenURL?url=#{text}&deviceName=#{device}"`
20
+ end
21
+ end
22
+
23
+ def escape_device_name(device_name)
24
+ URI.escape(device_name)
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,4 @@
1
+ # Module
1
2
  module Commandc
2
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
3
4
  end
data/lib/commandc.rb CHANGED
@@ -1,5 +1,3 @@
1
- require "commandc/version"
2
-
3
- module Commandc
4
- # Your code goes here...
5
- end
1
+ require 'commandc/text'
2
+ require 'commandc/cli'
3
+ require 'commandc/version'
@@ -4,8 +4,4 @@ describe Commandc do
4
4
  it 'has a version number' do
5
5
  expect(Commandc::VERSION).not_to be nil
6
6
  end
7
-
8
- it 'does something useful' do
9
- expect(false).to eq(true)
10
- end
11
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commandc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - brandonpittman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: A CLI for Command-C on OS X.
56
70
  email:
57
71
  - brandonpittman@gmail.com
@@ -69,6 +83,8 @@ files:
69
83
  - bin/commandc
70
84
  - commandc.gemspec
71
85
  - lib/commandc.rb
86
+ - lib/commandc/cli.rb
87
+ - lib/commandc/text.rb
72
88
  - lib/commandc/version.rb
73
89
  - spec/commandc_spec.rb
74
90
  - spec/spec_helper.rb