websmsby 0.0.6 → 0.1.0

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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
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.
@@ -1,3 +1,3 @@
1
1
  module Websmsby
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -15,9 +15,11 @@ module Websmsby
15
15
  }
16
16
  end
17
17
 
18
- def form_post_params(params)
18
+ def form_post_params(r, params = {})
19
19
  post_params = {}
20
- params.each {|key, value| post_params[key] = value}
20
+ params.each do |key, value|
21
+ post_params[key] = value.to_json
22
+ end
21
23
  post_params[:r] = r
22
24
  post_params[:user] = config[:user]
23
25
  post_params[:apikey] = config[:apikey]
@@ -25,13 +27,19 @@ module Websmsby
25
27
  post_params
26
28
  end
27
29
 
28
- def api(r, params = {})
29
- post_params = form_post_params(params)
30
+ def call(r, params = {})
31
+ post_params = form_post_params(r, params)
30
32
 
31
33
  uri = URI(config[:url])
32
34
  response = Net::HTTP.post_form uri, post_params
35
+
36
+ begin
37
+ json_response = JSON.parse response.body
38
+ rescue Exception
39
+ json_response = nil
40
+ end
33
41
 
34
- return JSON.parse response.body
42
+ return json_response
35
43
  end
36
44
  end
37
45
  end
data/lib/websmsby.rb CHANGED
@@ -10,12 +10,21 @@ module Websmsby
10
10
  mattr_accessor :user
11
11
  mattr_accessor :apikey
12
12
 
13
- def self.api(r, params = {})
13
+ def self.setup
14
+ yield self
15
+ end
16
+
17
+ def self.call(r, params = {})
14
18
  params = {} if not params.is_a?(Hash)
15
- return WebsmsbyApi.new.api(r, params)
19
+ return WebsmsbyApi.new.call(r, params)
16
20
  end
17
21
 
18
- def self.setup
19
- yield self
22
+ def self.method_missing(meth, *args, &block)
23
+ if meth.to_s =~ /^(.+)$/
24
+ r = "api/#{$1}"
25
+ call(r, *args)
26
+ else
27
+ super
28
+ end
20
29
  end
21
30
  end
metadata CHANGED
@@ -1,29 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websmsby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - qw4n7y
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-08-23 00:00:00.000000000 Z
12
+ date: 2013-08-23 00:00:00.000000000Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70274216097260 !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 3.2.1
20
22
  type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: 3.2.1
24
+ version_requirements: *70274216097260
27
25
  description: Websms.by API
28
26
  email:
29
27
  - qw4n7y@gmail.com
@@ -44,6 +42,7 @@ files:
44
42
  - lib/websmsby/version.rb
45
43
  - lib/websmsby/websmsby_api.rb
46
44
  - lib/websmsby.rb
45
+ - MIT-LICENSE
47
46
  - Rakefile
48
47
  - test/dummy/app/assets/javascripts/application.js
49
48
  - test/dummy/app/assets/stylesheets/application.css
@@ -82,26 +81,27 @@ files:
82
81
  homepage: https://github.com/qw4n7y/websmsby-gem
83
82
  licenses:
84
83
  - GPL-3
85
- metadata: {}
86
84
  post_install_message:
87
85
  rdoc_options: []
88
86
  require_paths:
89
87
  - lib
90
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
91
90
  requirements:
92
- - - '>='
91
+ - - ! '>='
93
92
  - !ruby/object:Gem::Version
94
93
  version: '0'
95
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
96
  requirements:
97
- - - '>='
97
+ - - ! '>='
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.0.3
102
+ rubygems_version: 1.8.10
103
103
  signing_key:
104
- specification_version: 4
104
+ specification_version: 3
105
105
  summary: Websms.by API
106
106
  test_files:
107
107
  - test/dummy/app/assets/javascripts/application.js
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: d2d7ef9a6c5acc7c4bbc66a2ff2dd59639c2263a
4
- data.tar.gz: 82b17dcafbbc8b08482f8c7a76da36cdf883769d
5
- SHA512:
6
- metadata.gz: d34d9ae7b7fc535c0b472d0b311354ee64f84c139bda36bab12ca425b945a78e39396e8cad94ecfd73382845524946be8e3678256fdd95609514b4db38fed535
7
- data.tar.gz: c0669e77453bdddb70b496ecbaae1b1c8aba132f39457c5f89b30709300863c50c6915965c2df852c8c1d015271ed80c066225f801e334f4b51dd6619c9beeba