easy_api 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a77991b8fb3d4eb69920a343be97d8f51da4a052
4
+ data.tar.gz: f8a381ed79fbe0ca4548921d6a1564462af42d47
5
+ SHA512:
6
+ metadata.gz: fd7f9965b417a7327594b6a87f97e9e2e6f71ecabd33f7e432baaa74d28ff2148326b64ba685c100088fb8001be4a4cd96a7d138608dc9d7704ef167fab0fb17
7
+ data.tar.gz: 1bd175d0d4b05843350edcc469c98eddf3f04df835327b1bee72f4d531f129100c263aff3d631384e5e073e842f467d8a6303c4d590f67631a2b84b90b96a030
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.projectile ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+ git_source(:gitlab) {|repo_name| "https://gitlab.com/#{repo_name}" }
5
+
6
+ gemspec
7
+
8
+ gem 'minitest'
9
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ easy_api (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ method_source (0.9.0)
11
+ minitest (5.11.3)
12
+ pry (0.11.3)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.9.0)
15
+ rake (10.5.0)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler (~> 1.16)
22
+ minitest
23
+ pry
24
+ rake (~> 10.0)
25
+ easy_api!
26
+
27
+ BUNDLED WITH
28
+ 1.16.1
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # EasyApi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/easy_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'easy_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install easy_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test\\` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/easy_api.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.test_files = FileList['test/**/*_test.rb', 'test/*_test.rb']
6
+ end
7
+ desc "Run tests"
8
+
9
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "easy_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/easy_api.gemspec ADDED
@@ -0,0 +1,24 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "easy_api"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "easy_api"
8
+ spec.version = EasyApi::VERSION
9
+ spec.authors = ["Stephan Meijer", "Fabian de Laender"]
10
+ spec.email = ["me@stephanmeijer.com"]
11
+
12
+ spec.summary = %q{The first real Telegram API client}
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.16"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ end
data/lib/easy_api.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "easy_api/object"
2
+
3
+ module EasyApi
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,62 @@
1
+ require 'forwardable'
2
+
3
+ module EasyApi
4
+ class MissingRequiredAttributeError < StandardError; end;
5
+ class UnknownAttributeError < StandardError; end;
6
+
7
+ class Object
8
+ include Enumerable
9
+ extend ::Forwardable
10
+
11
+ def_delegators(:attributes, :size, :[], :each)
12
+
13
+ def initialize(data)
14
+ raise EasyApi::MissingRequiredAttributeError unless required_attribute_names.all? { |name| data.keys.include? name }
15
+ raise EasyApi::UnknownAttributeError if data.keys.any? { |key| !attribute_names.include? key }
16
+
17
+ @attributes = data.map do |k, v|
18
+ next [k, v] unless v.instance_of? Hash
19
+
20
+ v =
21
+ if object_class = schema[k]
22
+ object_class.new(v)
23
+ else
24
+ OpenStruct.new(v) # TODO: maybe create OpenStructObject which creates OpenStruct instance and parses
25
+ end
26
+
27
+ [k, v]
28
+ end.to_h
29
+ end
30
+
31
+ def method_missing(m, *args, &block)
32
+ if v = attributes[m]
33
+ v
34
+ else
35
+ raise UnknownAttributeError
36
+ end
37
+ end
38
+
39
+ def attributes
40
+ @attributes ||= {}
41
+ end
42
+
43
+ def attribute_names
44
+ required_attribute_names + optional_attribute_names
45
+ end
46
+
47
+ # Please override
48
+ def required_attribute_names
49
+ []
50
+ end
51
+
52
+ # Please override
53
+ def optional_attribute_names
54
+ []
55
+ end
56
+
57
+ # Please override
58
+ def schema
59
+ {}
60
+ end
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephan Meijer
8
+ - Fabian de Laender
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2018-05-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.16'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.16'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description:
57
+ email:
58
+ - me@stephanmeijer.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".projectile"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - easy_api.gemspec
72
+ - lib/easy_api.rb
73
+ - lib/easy_api/object.rb
74
+ homepage:
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.6.14
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: The first real Telegram API client
97
+ test_files: []