pbl 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.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ rspec_options = {
2
+ all_on_start: false,
3
+ notification: false,
4
+ cli: '--drb --color --format documentation',
5
+ version: 2
6
+ }
7
+
8
+ guard 'rspec', rspec_options do
9
+ watch(%r{^spec/.+_spec\.rb})
10
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ end
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- # Pbl
1
+ # Pbl (Pinboard line)
2
+ [![Build Status](https://secure.travis-ci.org/glidenote/pbl.png)](http://travis-ci.org/glidenote/pbl)
2
3
 
3
- A command line tool for Pinboard to search your bookmarks.
4
+ A command line tool for [Pinboard](http://pinboard.in/) to search your bookmarks.
4
5
 
5
6
  ## Installation
6
7
 
@@ -20,6 +21,12 @@ Or install it yourself as:
20
21
 
21
22
  $ pbl word
22
23
 
24
+ ## Examples
25
+
26
+ $ pbl ruby
27
+ $ pbl mysql
28
+ $ pbl rails
29
+
23
30
  ## Contributing
24
31
 
25
32
  1. Fork it
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
9
+
10
+ RSpec::Core::RakeTask.new(:spec) do |spec|
11
+ spec.pattern = FileList['spec/**/*_spec.rb']
12
+ end
data/lib/pbl/cli.rb CHANGED
@@ -1,40 +1,36 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require 'pbl'
4
3
  require 'pit'
5
4
  require 'pinboard'
6
5
  require 'colored'
7
6
 
8
7
  module Pbl
9
8
  class CLI
10
- def initialize(*args)
11
- config = Pit.get("pinboard",
9
+ def initialize
10
+ config = Pit.get(:pinboard,
12
11
  require: {
13
- "username" => "your account in pinboard",
14
- "password" => "your password in pinboard"
15
- }
16
- )
12
+ username: "your_account_in_pinboard",
13
+ password: "your_password_in_pinboard"
14
+ }
15
+ )
17
16
 
18
- @username = config['username']
19
- @passowrd = config['password']
17
+ @pinboard = Pinboard::Client.new(
18
+ username: config[:username],
19
+ password: config[:password]
20
+ )
21
+
22
+ @argv = ARGV || []
20
23
  end
21
24
 
22
- def self.run(*args)
23
- self.new(*args).run
25
+ def self.run
26
+ self.new.run
24
27
  end
25
28
 
26
29
  def run
27
- unless ARGV.empty?
28
- pinboard = Pinboard::Client.new(:username => "#{@username}", :password => "#{@passowrd}")
29
- posts = pinboard.posts
30
- data = pinboard.posts(:tag => ARGV[0]) #all posts tagged 'ruby'
31
- for i in 1..data.size
32
- num = i - 1
33
- print "#{data[num][1]} || "
34
- print "#{data[num][0]}".green,"\n"
35
- end
30
+ abort "Usage: pbl TAG" if @argv.empty?
31
+ @pinboard.posts(:tag => @argv.join(',')).each do |post|
32
+ puts "%s || %s" % [post[1], post[0].green]
36
33
  end
37
34
  end
38
-
39
35
  end
40
36
  end
data/lib/pbl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pbl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/pbl.gemspec CHANGED
@@ -2,10 +2,10 @@
2
2
  require File.expand_path('../lib/pbl/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Akira Maeda"]
5
+ gem.authors = ["Akira Maeda,Kohei Hasegawa"]
6
6
  gem.email = ["glidenote@gmail.com"]
7
- gem.description = %q{show pinboard list on command line}
8
- gem.summary = %q{show pinboard list on command line}
7
+ gem.description = %q{A command line tool for Pinboard to search your bookmarks.}
8
+ gem.summary = %q{A command line tool for Pinboard to search your bookmarks.}
9
9
  gem.homepage = "https://github.com/glidenote/pbl"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
@@ -14,7 +14,13 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "pbl"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Pbl::VERSION
17
+
17
18
  gem.add_dependency 'pinboard'
18
19
  gem.add_dependency 'pit'
19
20
  gem.add_dependency 'colored'
21
+ gem.add_dependency 'rake'
22
+
23
+ gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'guard-rspec'
25
+ gem.add_development_dependency 'rb-fsevent'
20
26
  end
@@ -0,0 +1,79 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.expand_path('../../spec_helper', __FILE__)
4
+
5
+ describe Pbl::CLI do
6
+ before do
7
+ @config = { username: "foo", password: "bar" }
8
+ Pit.stub(:get).and_return(@config)
9
+ end
10
+
11
+ describe "#initialize" do
12
+ subject { described_class.new }
13
+
14
+ it { expect(subject).to be_an_instance_of(Pbl::CLI) }
15
+
16
+ it "should invoked Pit.get" do
17
+ Pit.should_receive(:get)
18
+ .with(:pinboard, {:require=>{:username=>"your_account_in_pinboard", :password=>"your_password_in_pinboard"}})
19
+ .and_return({username: "foo", password: "bar"})
20
+ subject
21
+ end
22
+
23
+ it "should invoked Pinboard::Client.new" do
24
+ Pit.stub(:get).and_return(@config)
25
+ Pinboard::Client.should_receive(:new).with(@config)
26
+ subject
27
+ end
28
+
29
+ it "should assign @pinboard" do
30
+ Pit.stub(:get).and_return(@config)
31
+ expect(subject.instance_eval { @pinboard }).to be_an_instance_of(Pinboard::Client)
32
+ end
33
+ end
34
+
35
+ describe ".run" do
36
+ subject { described_class.run }
37
+
38
+ it "should invoked Pbl::Cli.new.run" do
39
+ described_class.any_instance.should_receive(:run)
40
+ subject
41
+ end
42
+ end
43
+
44
+ describe "#run" do
45
+ before do
46
+ @subject = described_class.new
47
+ end
48
+
49
+ context "when ARGV is empty" do
50
+ before do
51
+ @subject.instance_variable_set(:@argv, [])
52
+ end
53
+
54
+ it "should raise SystemExit error" do
55
+ expect {
56
+ @subject.run
57
+ }.to raise_error SystemExit
58
+ end
59
+ end
60
+
61
+ context "when ARGV is not empty" do
62
+ before do
63
+ @subject.instance_variable_set(:@argv, ["ruby"])
64
+ end
65
+
66
+ # should not call api actually
67
+ pending "should not raise SystemExit error" do
68
+ expect {
69
+ @subject.run
70
+ }.to_not raise_error SystemExit
71
+ end
72
+
73
+ # should not call api actually
74
+ pending "should invoked @pinboard.posts" do
75
+ @subject.run
76
+ end
77
+ end
78
+ end
79
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format document
3
+ --loadby mtime
4
+ --backtrace
5
+ --reverse
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'pbl'
5
+ require 'rspec'
6
+
7
+ RSpec.configure do |config|
8
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Akira Maeda
8
+ - Akira Maeda,Kohei Hasegawa
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-02 00:00:00.000000000 Z
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pinboard
@@ -59,7 +59,71 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- description: show pinboard list on command line
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: guard-rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rb-fsevent
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: A command line tool for Pinboard to search your bookmarks.
63
127
  email:
64
128
  - glidenote@gmail.com
65
129
  executables:
@@ -68,7 +132,9 @@ extensions: []
68
132
  extra_rdoc_files: []
69
133
  files:
70
134
  - .gitignore
135
+ - .travis.yml
71
136
  - Gemfile
137
+ - Guardfile
72
138
  - LICENSE
73
139
  - README.md
74
140
  - Rakefile
@@ -77,6 +143,9 @@ files:
77
143
  - lib/pbl/cli.rb
78
144
  - lib/pbl/version.rb
79
145
  - pbl.gemspec
146
+ - spec/pbl/cli_spec.rb
147
+ - spec/spec.opts
148
+ - spec/spec_helper.rb
80
149
  homepage: https://github.com/glidenote/pbl
81
150
  licenses: []
82
151
  post_install_message:
@@ -100,6 +169,9 @@ rubyforge_project:
100
169
  rubygems_version: 1.8.23
101
170
  signing_key:
102
171
  specification_version: 3
103
- summary: show pinboard list on command line
104
- test_files: []
172
+ summary: A command line tool for Pinboard to search your bookmarks.
173
+ test_files:
174
+ - spec/pbl/cli_spec.rb
175
+ - spec/spec.opts
176
+ - spec/spec_helper.rb
105
177
  has_rdoc: