north_pole_wrapper 0.2.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/.document ADDED
@@ -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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@ki --create
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "httparty"
4
+ gem "pry"
5
+
6
+ group :development do
7
+ gem "rspec"
8
+ gem "guard-rspec"
9
+ gem 'rb-inotify', '~> 0.8.8'
10
+ gem "bundler"
11
+ gem "jeweler"
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.0.8)
5
+ diff-lcs (1.1.3)
6
+ ffi (1.3.1)
7
+ git (1.2.5)
8
+ guard (1.6.2)
9
+ listen (>= 0.6.0)
10
+ lumberjack (>= 1.0.2)
11
+ pry (>= 0.9.10)
12
+ terminal-table (>= 1.4.3)
13
+ thor (>= 0.14.6)
14
+ guard-rspec (2.4.0)
15
+ guard (>= 1.1)
16
+ rspec (~> 2.11)
17
+ httparty (0.10.2)
18
+ multi_json (~> 1.0)
19
+ multi_xml (>= 0.5.2)
20
+ jeweler (1.8.4)
21
+ bundler (~> 1.0)
22
+ git (>= 1.2.5)
23
+ rake
24
+ rdoc
25
+ json (1.7.7)
26
+ listen (0.7.2)
27
+ lumberjack (1.0.2)
28
+ method_source (0.8.1)
29
+ multi_json (1.6.1)
30
+ multi_xml (0.5.3)
31
+ pry (0.9.12)
32
+ coderay (~> 1.0.5)
33
+ method_source (~> 0.8)
34
+ slop (~> 3.4)
35
+ rake (10.0.3)
36
+ rb-inotify (0.8.8)
37
+ ffi (>= 0.5.0)
38
+ rdoc (3.12.1)
39
+ json (~> 1.4)
40
+ rspec (2.12.0)
41
+ rspec-core (~> 2.12.0)
42
+ rspec-expectations (~> 2.12.0)
43
+ rspec-mocks (~> 2.12.0)
44
+ rspec-core (2.12.2)
45
+ rspec-expectations (2.12.1)
46
+ diff-lcs (~> 1.1.3)
47
+ rspec-mocks (2.12.2)
48
+ slop (3.4.3)
49
+ terminal-table (1.4.5)
50
+ thor (0.17.0)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ bundler
57
+ guard-rspec
58
+ httparty
59
+ jeweler
60
+ pry
61
+ rb-inotify (~> 0.8.8)
62
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Cristian Messel
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.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = north_pole_wrapper
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to north_pole_wrapper
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Cristian Messel. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,33 @@
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.name = "north_pole_wrapper"
17
+ gem.homepage = "http://bitbucket.org/mess110/north_pole_wrapper"
18
+ gem.license = "MIT"
19
+ gem.summary = %Q{wrapper for northpole.ro api}
20
+ gem.description = %Q{wrapper for northpole.ro api}
21
+ gem.email = "mess110@gmail.com"
22
+ gem.authors = ["Cristian Messel"]
23
+ # dependencies defined in Gemfile
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ require 'rspec/core'
28
+ require 'rspec/core/rake_task'
29
+ RSpec::Core::RakeTask.new(:spec) do |spec|
30
+ spec.pattern = FileList['spec/**/*_spec.rb']
31
+ end
32
+
33
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,46 @@
1
+
2
+ require 'httparty'
3
+ require 'pry'
4
+ require 'json'
5
+
6
+ module NorthPoleWrapper
7
+ def self.console
8
+ binding.pry
9
+ end
10
+
11
+ USER = 'guest@northpole.ro'
12
+ APIKEY = 'guest'
13
+
14
+ class Resource
15
+ include HTTParty
16
+
17
+ base_uri 'northpole.ro'
18
+ # base_uri 'localhost:3000'
19
+
20
+ def self.create h
21
+ post("/#{klass}.json", { :body => h.to_json } )
22
+ end
23
+
24
+ def self.find h
25
+ get("/#{klass}.json", { :query => h } )
26
+ end
27
+
28
+ def self.update h
29
+ put("/#{klass}.json", { :body => h.to_json } )
30
+ end
31
+
32
+ def self.destroy h
33
+ delete("/#{klass}.json", { :query => h } )
34
+ end
35
+
36
+ def self.klass
37
+ to_s.downcase.split(':').last
38
+ end
39
+ end
40
+
41
+ class Storage < Resource
42
+ end
43
+
44
+ class User < Resource
45
+ end
46
+ end
@@ -0,0 +1,79 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ include NorthPoleWrapper
4
+
5
+ describe NorthPoleWrapper do
6
+ it "shold work" do
7
+ USER.should == 'guest@northpole.ro'
8
+
9
+ User.klass.should == 'user'
10
+
11
+ module Foo
12
+ module Bar
13
+ class Dar < Resource
14
+ end
15
+ end
16
+ end
17
+
18
+ Foo::Bar::Dar.klass.should == 'dar'
19
+
20
+ class Hello < Resource
21
+ end
22
+
23
+ Hello.klass.should == 'hello'
24
+ end
25
+
26
+ it "should create" do
27
+ body = Storage.create('mail' => USER, 'apikey' => APIKEY,
28
+ 'foo' => 'bar').body
29
+ body.class.should == String
30
+ json = JSON.parse(body)
31
+ end
32
+
33
+ it "should find" do
34
+ body = Storage.create('mail' => USER, 'apikey' => APIKEY,
35
+ 'foo' => 'bar').body
36
+ body.class.should == String
37
+ json = JSON.parse(body)
38
+
39
+ body2 = Storage.find('mail' => USER, 'apikey' => APIKEY,
40
+ '_id' => json['_id']).body
41
+ json2 = JSON.parse(body2)
42
+ json2.count.should > 0
43
+ json2[0]['foo'].should == 'bar'
44
+ end
45
+
46
+ it "should update" do
47
+ body = Storage.create('mail' => USER, 'apikey' => APIKEY,
48
+ 'foo' => 'bar').body
49
+ body.class.should == String
50
+ json = JSON.parse(body)
51
+
52
+ body2 = Storage.update('mail' => USER, 'apikey' => APIKEY,
53
+ '_id' => json['_id'], 'foo' => 'haha').body
54
+ json2 = JSON.parse(body2)
55
+ json2['_id'].should == json['_id']
56
+
57
+
58
+ body3 = Storage.find('mail' => USER, 'apikey' => APIKEY,
59
+ '_id' => json['_id']).body
60
+ json3 = JSON.parse(body3)
61
+ json3.count.should > 0
62
+ json3[0]['foo'].should == 'haha'
63
+ end
64
+
65
+ it "should delete" do
66
+ body = Storage.create('mail' => USER, 'apikey' => APIKEY,
67
+ 'foo' => 'bar').body
68
+ body.class.should == String
69
+ json = JSON.parse(body)
70
+
71
+ Storage.destroy('mail' => USER, 'apikey' => APIKEY,
72
+ '_id' => json['_id'])
73
+
74
+ body2 = Storage.find('mail' => USER, 'apikey' => APIKEY,
75
+ '_id' => json['_id']).body
76
+ json2 = JSON.parse(body2)
77
+ json2.count.should == 0
78
+ end
79
+ 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 'north_pole_wrapper'
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,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: north_pole_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Cristian Messel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
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: pry
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: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
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: guard-rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '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: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rb-inotify
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.8.8
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.8.8
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: '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: wrapper for northpole.ro api
127
+ email: mess110@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files:
131
+ - LICENSE.txt
132
+ - README.rdoc
133
+ files:
134
+ - .document
135
+ - .rspec
136
+ - .rvmrc
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - Guardfile
140
+ - LICENSE.txt
141
+ - README.rdoc
142
+ - Rakefile
143
+ - VERSION
144
+ - lib/north_pole_wrapper.rb
145
+ - spec/north_pole_wrapper_spec.rb
146
+ - spec/spec_helper.rb
147
+ homepage: http://bitbucket.org/mess110/north_pole_wrapper
148
+ licenses:
149
+ - MIT
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ segments:
161
+ - 0
162
+ hash: 1369800214602460510
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 1.8.24
172
+ signing_key:
173
+ specification_version: 3
174
+ summary: wrapper for northpole.ro api
175
+ test_files: []