mumukit-core 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDZmYzQyZGE2MzAzM2MxZjhkZjFmZWM2Y2QxMGM1ODgxMjhhZGYzYw==
5
+ data.tar.gz: !binary |-
6
+ YTA4NGI5ZWU1MDI0OTFjY2U5ZDljZTg2OTRiMDkyZGZiZmM5ODU3Zg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzhiNWU3YTU1MjhlYzI3OGIwZGIxMjg4YzFmYzM4ZmM4NDlmYzA4NmQ5YTMx
10
+ Y2IwMzVhYjUzODQ4Mjg3N2M0MTg5MmFjZjlmODU2NWJmNTAzNDFjNmNiMTkz
11
+ YmZlYWYxNWRhOWI4ZGVlNmIwMDQxMmUyYzcxNzhkNjFlZDhhNzc=
12
+ data.tar.gz: !binary |-
13
+ YTQ1NGY3NDc5YjExMDM1ZmE4MDBmMGQ3YzE5YjY1MTk5NjM4NDZkZmIxYWY3
14
+ MmI5MDc1YjI2ZjkwMzc0NTllZTY0M2Y1YTA0OTBjZmUxNjY3ZTY5NGEyNDAy
15
+ NzBhMmU2NGU1MDZlYWNkZmRjY2FmZmZkNGU4YTQwMmE3MWMzZjk=
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mumukit/core"
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
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
@@ -0,0 +1,18 @@
1
+ require 'mumukit/core/version'
2
+ require 'active_support/all'
3
+
4
+ module Mumukit
5
+ module Core
6
+ end
7
+ end
8
+
9
+ require_relative './core/object'
10
+ require_relative './core/class'
11
+ require_relative './core/json'
12
+ require_relative './core/hash'
13
+ require_relative './core/string'
14
+ require_relative './core/nil'
15
+ require_relative './core/array'
16
+ require_relative './core/regexp'
17
+ require_relative './core/request'
18
+ require_relative './core/file'
@@ -0,0 +1,7 @@
1
+ class Array
2
+ def merge_numbers!(key=:number)
3
+ self.each_with_index do |r, i|
4
+ r.send "#{key}=", i+1
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class Class
2
+ def required(name, message=nil)
3
+ message ||= "You need to implement method #{name}"
4
+ define_method name do |*|
5
+ raise message
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ class File
2
+ def unlink
3
+ end
4
+ end
@@ -0,0 +1,18 @@
1
+ class Hash
2
+ def dig(key, *keys)
3
+ value = self[key]
4
+ if !value.nil? && !keys.empty?
5
+ value.dig(*keys)
6
+ else
7
+ value
8
+ end
9
+ end
10
+
11
+ def to_struct
12
+ OpenStruct.new self
13
+ end
14
+
15
+ def amend(other)
16
+ other.merge(self)
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ require 'json'
2
+
3
+ module JSON
4
+ def self.pretty_parse(string)
5
+ parse(string)
6
+ rescue => e
7
+ raise JSON::ParserError, "Invalid JSON #{string}:\n\t#{e.message.force_encoding('utf-8')}"
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class NilClass
2
+ def captures(*)
3
+ []
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ class Object
2
+ def ensure_present!(*args)
3
+ raise 'arguments must be non null' if args.any?(&:blank?)
4
+ end
5
+
6
+ def to_stringified_h
7
+ to_h.stringify_keys
8
+ end
9
+
10
+ def defaulting(value, &block)
11
+ try(&block) || value
12
+ end
13
+
14
+ def struct(hash = {})
15
+ hash.to_struct
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ class Regexp
2
+ def matches?(string)
3
+ !!(self =~ string)
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'rack/request'
2
+
3
+ module Rack
4
+ class Request
5
+ def first_subdomain
6
+ @env['rack.env.subdomains'] ||= extract_subdomains
7
+ end
8
+
9
+ def organization_name
10
+ first_subdomain || 'central'
11
+ end
12
+
13
+ private
14
+
15
+ def extract_subdomains
16
+ raise 'no host set' unless host
17
+ raise 'set hostname first!' if /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host)
18
+ return nil if host == 'localhost'
19
+ (host.split('.') - ['mumuki', 'io'])[0]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ class String
2
+ alias_method :captures, :gsub
3
+ end
@@ -0,0 +1,5 @@
1
+ module Mumukit
2
+ module Core
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumukit-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Franco Leonardo Bulgarelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '4.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '4.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ description: Ruby core extensions
98
+ email:
99
+ - franco@mumuki.org
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - bin/console
105
+ - bin/setup
106
+ - lib/mumukit/core.rb
107
+ - lib/mumukit/core/array.rb
108
+ - lib/mumukit/core/class.rb
109
+ - lib/mumukit/core/file.rb
110
+ - lib/mumukit/core/hash.rb
111
+ - lib/mumukit/core/json.rb
112
+ - lib/mumukit/core/nil.rb
113
+ - lib/mumukit/core/object.rb
114
+ - lib/mumukit/core/regexp.rb
115
+ - lib/mumukit/core/request.rb
116
+ - lib/mumukit/core/string.rb
117
+ - lib/mumukit/core/version.rb
118
+ homepage: https://github.com/mumuki/mumukit-core
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ - bin
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.5
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Ruby core extensions for mumuki on top of active support
143
+ test_files: []