jeckle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2874609cdcb236683601a9e04386dd1af3e6b3a3
4
+ data.tar.gz: fb456e8f4ff54cd39541841f816ee92721c92f05
5
+ SHA512:
6
+ metadata.gz: ac05f0824c301b8d843d5430084f5edec19d24143bff31cfacb96764f19702b6cc9307e92c6907f522acd47406686f82e399c556e01881033e17a4e82999a498
7
+ data.tar.gz: 46639dc59b51171ef4a8fe63aa8c91b0d659a8d10f219b4e769ce42e9445118de076eb4229fb1ab1cdc5823497f3200f9e17657bcac0efe748542209a36d0249
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jeckle.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tomas D'Stefano
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Jeckle
2
+
3
+ TODO: Write a gem description
4
+
5
+ <img src="http://www.toonopedia.com/hekljekl.jpg" alt="Jeckle" />
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'jeckle'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jeckle
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/jeckle.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jeckle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jeckle"
8
+ spec.version = Jeckle::VERSION
9
+ spec.authors = ["Tomas D'Stefano"]
10
+ spec.email = ["tomas_stefano@successoft.com"]
11
+ spec.description = %q{Simple module for build client apis}
12
+ spec.summary = %q{Simple module for build client apis}
13
+ spec.homepage = "https://github.com/tomas-stefano/jeckle"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'httparty'
22
+ spec.add_dependency 'virtus'
23
+ spec.add_dependency 'activemodel', '>= 4.0'
24
+ spec.add_dependency 'activesupport', '>= 4.0'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec'
29
+ end
@@ -0,0 +1,52 @@
1
+ module Jeckle
2
+ module Resource
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include HTTParty
7
+ include Virtus.model
8
+ include ActiveModel::Validations
9
+
10
+ attribute :response
11
+ end
12
+
13
+ module ClassMethods
14
+ def resource_name
15
+ self.class.name.underscore
16
+ end
17
+
18
+ def find(id)
19
+ get(resource_action)
20
+ end
21
+
22
+ def resource_action(id)
23
+ "#{resource_name}/#{id}"
24
+ end
25
+ end
26
+
27
+ def save
28
+ request(:post)
29
+ end
30
+
31
+ def update
32
+ request(:put)
33
+ end
34
+
35
+ def headers
36
+ {
37
+ 'Content-Type' => 'application/json; charset="UTF-8"',
38
+ 'Accept-Encoding' => 'application/json'
39
+ }
40
+ end
41
+
42
+ private
43
+
44
+ def request(http_method)
45
+ return false if invalid?
46
+
47
+ @response = self.class.send(http_method, resource_name, headers: headers, body: params)
48
+
49
+ @response.success?
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module Jeckle
2
+ VERSION = '0.0.1'
3
+ end
data/lib/jeckle.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'jeckle/version'
2
+ require 'active_support/dependencies/autoload'
3
+ require 'active_support/concern'
4
+ require 'virtus'
5
+ require 'active_model'
6
+
7
+ module Jeckle
8
+ extend ActiveSupport::Autoload
9
+
10
+ autoload :Resource
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'bundler/setup'
2
+ Bundler.require
3
+ require 'jeckle'
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jeckle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomas D'Stefano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: virtus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activemodel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Simple module for build client apis
112
+ email:
113
+ - tomas_stefano@successoft.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - jeckle.gemspec
124
+ - lib/jeckle.rb
125
+ - lib/jeckle/resource.rb
126
+ - lib/jeckle/version.rb
127
+ - spec/spec_helper.rb
128
+ homepage: https://github.com/tomas-stefano/jeckle
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.0.5
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Simple module for build client apis
152
+ test_files:
153
+ - spec/spec_helper.rb