Permalink
Browse files

@ some refactoring

  • Loading branch information...
Andrew Zinenko
Andrew Zinenko committed Sep 25, 2012
1 parent 7b44b88 commit 7ec7df864d6cc136485c2b3d27a5fa2d56a14318
View
@@ -0,0 +1,2 @@
+app_id: 3138594
+access_token: 'f2373150a7000d6ff7e3d5524ef770d88bff758f75f3ca8e196ee3adc58662b'
View
@@ -41,7 +41,7 @@ GEM
net-http-persistent (2.7)
oj (1.0.6)
patron (0.4.18)
- rake (0.9.2.2)
+ rake (0.8.7)
transformer (0.3.0)
typhoeus (0.4.2)
ffi (~> 1.0)
@@ -64,7 +64,7 @@ DEPENDENCIES
net-http-persistent (= 2.7)
oj (~> 1.0.6)
patron (~> 0.4.18)
- rake (~> 0.9)
+ rake (~> 0.8.7)
typhoeus (~> 0.4.2)
vk-ruby!
webmock (~> 1.0)
View
@@ -19,11 +19,27 @@ gem install vk-ruby
app = VK::Serverside.new access_token: TOKEN
-app.audio.search q: 'Sting' # => Sting tracks
+app.friends.getOnline uid: 1 # => Online friends
# similar call
-app.vk_call 'audio.search', {q: 'Sting'}
+app.vk_call 'friends.getOnline', {uid: 1}
+
+app = VK::Serverside.new access_token: TOKEN, underscore_methods: true
+
+app.friends.get_online uid: 1
+```
+
+### Underscore methods
+
+
+```.ruby
+
+app.vk_call 'friends.getOnline', {uid: 1}
+
+app = VK::Serverside.new access_token: TOKEN, underscore_methods: true
+
+app.friends.get_online uid: 1
```
### Upload files
@@ -92,30 +108,43 @@ For configuration available this options:
* __verb__ http verb request. Only `:get` or `:post`.
* __access_token__ your access token.
* __open_timeout__ open_timeout request.
-* __timeou__t timeout request.
+* __timeout__ timeout request.
* __proxy__ proxy params request.
* __use_ssl__ indicating that you need to use ssl.
* __verify__ indicating that you need to verify peer.
* __verify_mode__ specifying the ssl verification strategy that you need to use ssl.
* __ca_path__ ssl ca_path.
* __ca_file__ ssl ca_file.
-### Middlewares stack
+### Middlewares
+
+VK-RUBY based on [faraday](https://github.com/technoweenie/faraday).
+
+It is an HTTP client lib that provides a common interface over many adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.
+
+[Advanced middleware usage](https://github.com/technoweenie/faraday#advanced-middleware-usage).
#### Default middlewares stack implementation
```.ruby
def faraday_middleware
@faraday_middleware || proc do |faraday|
+ # request params encoders
faraday.request :multipart
faraday.request :url_encoded
+
+ # response body parse
faraday.response :json, content_type: /\bjson$/
+
+ # http adapter
faraday.adapter self.adapter
end
end
```
+
+
#### Expanding stack
```.ruby
@@ -149,9 +178,9 @@ $ vk --help
-T, --types List application types
$ vk -e 'puts vk.isAppUser'
- 0
-$ vk -a 'your token'
+0
+$ vk -a 'your token'
1.9.3p194 :001 > vk.access_token
=> "your token"
View
@@ -14,9 +14,11 @@ end
require 'rake'
require 'rake/testtask'
-task default: :test
+# task default: :test
Rake::TestTask.new do |test|
- test.pattern = 'tests/*test.rb'
+ # include Rake::DSL
+
+ test.pattern = 'tests/*_test.rb'
test.verbose = true
end
View
@@ -15,9 +15,9 @@
# Register multi_json parser.
FaradayMiddleware::ParseJson.define_parser do |body|
- MultiJson.load(body)
+ MultiJson.load(body) unless body.strip.empty?
end
%w(validate_utf normalize_utf vk_logger).each{|lib| require "vk-ruby/middleware/response/#{lib}"}
-%w(core upload secure serverside standalone vk_exception version).each{|lib| require "vk-ruby/#{lib}"}
+%w(namespace utils core application secure serverside standalone vk_exception version).each{|lib| require "vk-ruby/#{lib}"}
View
@@ -1,130 +0,0 @@
-- isAppUser
-- getProfiles
-- getUserBalance
-- getUserSettings
-- getGroupsFull
-- getVariable
-- getVariables
-- putVariable
-- getHighScores
-- setUserScore
-- getMessages
-- sendMessage
-- getServerTime
-- getAds
-- setNameInMenu
-- resolveScreenName
-- execute
--
- friends:
- - get
- - getAppUsers
- - getOnline
- - getMutual
- users:
- - get
- photos:
- - getAlbums
- - get
- - getById
- - getAll
- - createAlbum
- - editAlbum
- - edit
- - move
- - makeCover
- - reorderAlbums
- - reorderPhotos
- - getUploadServer
- - save
- - getProfileUploadServer
- - saveProfilePhoto
- - getWallUploadServer
- - saveWallPhoto
- wall:
- - get
- - getById
- - savePost
- - getPhotoUploadServer
- audio:
- - get
- - audio
- - getById
- - getLyrics
- - getUploadServer
- - save
- - search
- - add
- - delete
- - edit
- - restore
- - reorder
- video:
- - get
- - edit
- - add
- - delete
- - search
- - getUserVideos
- - getComments
- - createComment
- - editComment
- - deleteComment
- - getTags
- - putTag
- - removeTag
- - save
- notes:
- - get
- - getById
- - getFriendsNotes
- - add
- - edit
- - delete
- - getComments
- - createComment
- - editComment
- - deleteComment
- - restoreComment
- pages:
- - get
- - save
- - saveAccess
- - getVersion
- - getHistory
- - getTitles
- places:
- - add
- - getById
- - search
- - checkin
- - getCheckins
- - getTypes
- - getCountries
- - getCities
- - getCountryById
- - getCityById
- storage:
- - set
- - get
- sms:
- - setSMSPrefix
- - getSMSPrefix
- groups:
- - get
- - getById
- - isMember
- - getMembers
- board:
- - getTopics
- - deleteTopic
- - getComments
- - addComment
- - editComment
- - deleteComment
- - restoreComment
- - addTopic
- - closeTopic
- - fixTopic
- - unfixTopic
- - deleteTopic
View
@@ -1,110 +0,0 @@
-messages:
- - get
- - getDialogs
- - search
- - send
- - delete
- - restore
- - markAsNew
- - markAsRead
- - getHistory
- - getLongPollServer
-docs:
- - get
- - getById
- - getUploadServer
- - getWallUploadServer
- - save
-wall:
- - post
- - delete
- - restore
- - getComments
- - addComment
- - deleteComment
- - restoreComment
- - addLike
- - deleteLike
-photos:
- - getComments
- - getAllComments
- - createComment
- - editComment
- - deleteComment
- - restoreComment
- - getUserPhotos
- - getTags
- - putTag
- - removeTag
-newsfeed:
- - get
- - getBanned
- - addBan
- - deleteBan
-status:
- - get
- - set
-likes:
- - add
- - delete
- - getList
- - isLiked
-friends:
- - getLists
- - addList
- - editList
- - add
- - delete
- - getRequests
-polls:
- - getById
- - addVote
- - deleteVote
-subscriptions:
- - get
- - getFollowers
- - follow
- - unfollow
-ads:
- - getAccounts
- - getClients
- - createClients
- - updateClients
- - deleteClients
- - getCampaigns
- - createCampaigns
- - updateCampaigns
- - deleteCampaigns
- - getAds
- - getAdsLayout
- - getAdsTargeting
- - createAds
- - updateAds
- - deleteAds
- - getStatistics
- - getDemographics
- - getBudget
- - getOfficeUsers
- - addOfficeUsers
- - removeOfficeUsers
- - getTargetingStats
- - getSuggestions
- - getUploadURL
- - getFloodStats
- - getRejectionReason
-fave:
- - getUsersnew
- - getPhotosnew
- - getVideosnew
- - getPostsnew
- - getLinksnew
-auth:
- - signupnew
- - confirmnew
- - checkPhone
-account:
- - importContactsnew
- - registerDevicenew
- - unregisterDevicenew
- - setSilenceModenew
- - setOnlinen
Oops, something went wrong.

0 comments on commit 7ec7df8

Please sign in to comment.