fbcli 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'koala'
4
+ gem 'commander'
5
+ gem 'awesome_print'
6
+
7
+
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler"
12
+ gem "jeweler", "~> 1.8.4"
13
+ gem "simplecov"
14
+ end
@@ -0,0 +1,50 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ awesome_print (1.1.0)
5
+ commander (4.1.2)
6
+ highline (~> 1.6.11)
7
+ diff-lcs (1.1.3)
8
+ faraday (0.8.4)
9
+ multipart-post (~> 1.1)
10
+ git (1.2.5)
11
+ highline (1.6.15)
12
+ jeweler (1.8.4)
13
+ bundler (~> 1.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ rdoc
17
+ json (1.7.5)
18
+ koala (1.5.0)
19
+ faraday (~> 0.7)
20
+ multi_json (~> 1.3)
21
+ multi_json (1.3.7)
22
+ multipart-post (1.1.5)
23
+ rake (10.0.0)
24
+ rdoc (3.12)
25
+ json (~> 1.4)
26
+ rspec (2.8.0)
27
+ rspec-core (~> 2.8.0)
28
+ rspec-expectations (~> 2.8.0)
29
+ rspec-mocks (~> 2.8.0)
30
+ rspec-core (2.8.0)
31
+ rspec-expectations (2.8.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.8.0)
34
+ simplecov (0.7.1)
35
+ multi_json (~> 1.0)
36
+ simplecov-html (~> 0.7.1)
37
+ simplecov-html (0.7.1)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ awesome_print
44
+ bundler
45
+ commander
46
+ jeweler (~> 1.8.4)
47
+ koala
48
+ rdoc (~> 3.12)
49
+ rspec (~> 2.8.0)
50
+ simplecov
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Ian Morgan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ = fbcli
2
+
3
+ Command line access to Facebook Graph API.
4
+
5
+
6
+ == Install
7
+
8
+ gem install fbcli
9
+
10
+
11
+ == Configure
12
+
13
+ Obtain key here: https://developers.facebook.com/tools/explorer
14
+
15
+ fbcli configure
16
+
17
+
18
+ == Use
19
+
20
+ fbcli my_friends
21
+
22
+
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2012 Ian Morgan. See LICENSE.txt for
27
+ further details.
28
+
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fbcli"
18
+ gem.homepage = "http://github.com/seeingidog/fbcli"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Command line interface to the Facebook graph API}
21
+ gem.description = %Q{Command line interface to the Facebook graph API}
22
+ gem.email = "ian@ruby-code.com"
23
+ gem.default_executable = "fbcli"
24
+ gem.require_path = 'lib'
25
+ gem.executables << "fbcli"
26
+ gem.authors = ["Ian Morgan"]
27
+ # dependencies defined in Gemfile
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rspec/core'
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
38
+ spec.pattern = 'spec/**/*_spec.rb'
39
+ spec.rcov = true
40
+ end
41
+
42
+ task :default => :spec
43
+
44
+ require 'rdoc/task'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "fbcli #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'commander/import'
6
+
7
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fbcli'))
8
+
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fbcli"
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ian Morgan"]
12
+ s.date = "2012-11-15"
13
+ s.description = "Command line interface to the Facebook graph API"
14
+ s.email = "ian@ruby-code.com"
15
+ s.executables = ["fbcli", "fbcli"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/fbcli",
30
+ "fbcli.gemspec",
31
+ "lib/fbcli.rb",
32
+ "lib/fbcli/actions.rb",
33
+ "lib/fbcli/cli.rb",
34
+ "lib/fbcli/configure.rb",
35
+ "lib/fbcli/constants.rb",
36
+ "lib/fbcli/formatters.rb",
37
+ "spec/fbcli_spec.rb",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+ s.homepage = "http://github.com/seeingidog/fbcli"
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = "1.8.24"
44
+ s.summary = "Command line interface to the Facebook graph API"
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<koala>, [">= 0"])
51
+ s.add_runtime_dependency(%q<commander>, [">= 0"])
52
+ s.add_runtime_dependency(%q<awesome_print>, [">= 0"])
53
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
54
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_development_dependency(%q<bundler>, [">= 0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
57
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<koala>, [">= 0"])
60
+ s.add_dependency(%q<commander>, [">= 0"])
61
+ s.add_dependency(%q<awesome_print>, [">= 0"])
62
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
63
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
64
+ s.add_dependency(%q<bundler>, [">= 0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
66
+ s.add_dependency(%q<simplecov>, [">= 0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<koala>, [">= 0"])
70
+ s.add_dependency(%q<commander>, [">= 0"])
71
+ s.add_dependency(%q<awesome_print>, [">= 0"])
72
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
73
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
74
+ s.add_dependency(%q<bundler>, [">= 0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
76
+ s.add_dependency(%q<simplecov>, [">= 0"])
77
+ end
78
+ end
79
+
@@ -0,0 +1,5 @@
1
+ require_relative 'fbcli/constants.rb'
2
+ require_relative 'fbcli/actions.rb'
3
+ require_relative 'fbcli/formatters.rb'
4
+ require_relative 'fbcli/configure.rb'
5
+ require_relative 'fbcli/cli.rb'
@@ -0,0 +1,33 @@
1
+ require 'koala'
2
+
3
+ module FBCLI
4
+ class Actions
5
+
6
+ def self.api_object
7
+ config_file = File.expand_path("~/.fbcli.yml", File.dirname(__FILE__))
8
+ if File.exists?(config_file)
9
+ oauth_access_token = YAML.load_file(config_file)['oauth_access_token']
10
+ @graph = Koala::Facebook::API.new(oauth_access_token)
11
+ else
12
+ raise "Use fbcli configure to configure this application"
13
+ end
14
+ end
15
+
16
+ def self.me
17
+ api_object.get_connections("me", "")
18
+ end
19
+
20
+ FBCLI::GLOBAL_ACTIONS.each do |action|
21
+ self.class.send(:define_method, action.to_sym) do |args|
22
+ api_object.get_connections("", args.first)
23
+ end
24
+ end
25
+
26
+ FBCLI::ME_ACTIONS.each do |me_action|
27
+ self.class.send(:define_method, ('my_' + me_action).to_sym) do
28
+ api_object.get_connections("me", me_action)
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,44 @@
1
+ include FBCLI::Formatters
2
+
3
+ program :version, '1.0.1'
4
+ program :description, 'Facebook CLI Tool. Navigates the Social Graph.'
5
+ program :help, 'Author', 'Ian Morgan <ian@ruby-code.com>'
6
+
7
+ global_option('--json') { $json = true }
8
+
9
+ command :configure do |c|
10
+ c.syntax = 'configure'
11
+ c.description = "Configures Oauth Key."
12
+ c.action do |arg|
13
+ FBCLI::Configure.new
14
+ end
15
+ end
16
+
17
+ command :me do |c|
18
+ c.syntax = 'me'
19
+ c.description = "Displays my current object."
20
+ c.action do
21
+ data FBCLI::Actions.me
22
+ end
23
+ end
24
+
25
+ FBCLI::GLOBAL_ACTIONS.each do |action|
26
+ command action.to_sym do |c|
27
+ c.syntax = action + " <user or page id>"
28
+ c.description = "Displays a user or pages's #{action}."
29
+ c.action do |arg|
30
+ eval("data FBCLI::Actions.#{action}(#{arg})")
31
+ end
32
+ end
33
+ end
34
+
35
+ FBCLI::ME_ACTIONS.each do |me_action|
36
+ command ('my_' + me_action).to_sym do |c|
37
+ c.syntax = "my_" + me_action
38
+ c.description = "Displays my #{me_action}."
39
+ c.action do |arg|
40
+ eval("data FBCLI::Actions.my_#{me_action}")
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,10 @@
1
+ module FBCLI
2
+ class Configure
3
+ def initialize
4
+ oauth_access_token = ask("Oauth Access Token (Copy here: https://developers.facebook.com/tools/explorer): ")
5
+ `echo "oauth_access_token: #{oauth_access_token}" > ~/.fbcli.yml`
6
+ puts "Configured ~/.fbcli.yml"
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module FBCLI
2
+ ME_ACTIONS = ['friends','feed','likes','movies', 'music', 'books', 'notes', 'permissions', 'photos', 'albums', 'videos', 'events', 'groups', 'checkins', 'locations']
3
+ GLOBAL_ACTIONS = ['profile_picture', 'mutual_friends', 'users','pages','events','groups', 'applications', 'status_messages', 'photos', 'photo_albumns', 'videos', 'notes', 'checkins']
4
+ end
@@ -0,0 +1,16 @@
1
+ require "awesome_print"
2
+ require "json"
3
+
4
+ module FBCLI
5
+ module Formatters
6
+ def data(data)
7
+ if $json
8
+ puts data.to_json
9
+ else
10
+ ap data
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Fbcli" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'fbcli'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fbcli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ian Morgan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: koala
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: commander
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: awesome_print
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.8.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.12'
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: '3.12'
94
+ - !ruby/object:Gem::Dependency
95
+ name: bundler
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: jeweler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.4
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: 1.8.4
126
+ - !ruby/object:Gem::Dependency
127
+ name: simplecov
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: Command line interface to the Facebook graph API
143
+ email: ian@ruby-code.com
144
+ executables:
145
+ - fbcli
146
+ extensions: []
147
+ extra_rdoc_files:
148
+ - LICENSE.txt
149
+ - README.rdoc
150
+ files:
151
+ - .document
152
+ - .rspec
153
+ - Gemfile
154
+ - Gemfile.lock
155
+ - LICENSE.txt
156
+ - README.rdoc
157
+ - Rakefile
158
+ - VERSION
159
+ - bin/fbcli
160
+ - fbcli.gemspec
161
+ - lib/fbcli.rb
162
+ - lib/fbcli/actions.rb
163
+ - lib/fbcli/cli.rb
164
+ - lib/fbcli/configure.rb
165
+ - lib/fbcli/constants.rb
166
+ - lib/fbcli/formatters.rb
167
+ - spec/fbcli_spec.rb
168
+ - spec/spec_helper.rb
169
+ homepage: http://github.com/seeingidog/fbcli
170
+ licenses:
171
+ - MIT
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ segments:
183
+ - 0
184
+ hash: -4317853381182366111
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ! '>='
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 1.8.24
194
+ signing_key:
195
+ specification_version: 3
196
+ summary: Command line interface to the Facebook graph API
197
+ test_files: []