almanack 1.1.0.beta1 → 1.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/almanack.gemspec +3 -0
- data/lib/almanack/cli.rb +3 -1
- data/lib/almanack/configuration.rb +26 -6
- data/lib/almanack/serialized_transformation.rb +1 -1
- data/lib/almanack/version.rb +1 -1
- data/lib/almanack.rb +2 -0
- data/spec/configuration_spec.rb +24 -0
- data/templates/gitignore +4 -0
- data/templates/new/config.ru.tt +4 -0
- metadata +44 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10c99dfffb686948d337e833fb1e6b7ecb1f5158
|
4
|
+
data.tar.gz: c28448a2dd460493f2cbddbdec8a661e5c291726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41f12f532013e4ffe218a7f1cff3fbf794cf412c7f258e78a3a95ec5b9a5934619f7fb092fae6fa68a874ba6370f015499c1d66858bfc2d247cb6c075091110c
|
7
|
+
data.tar.gz: 8c7845973b5ab3bf7e81c508d7a4d249cb1390312008d0eff1d0c162ab98ae1ab1471ba6dc2db88d66cbe88a072bd2ca51f512265587c02fcfbc9235439d2cb0
|
data/.travis.yml
CHANGED
data/almanack.gemspec
CHANGED
@@ -24,9 +24,12 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "addressable"
|
25
25
|
spec.add_dependency "thor"
|
26
26
|
spec.add_dependency "faraday"
|
27
|
+
spec.add_dependency "faraday_middleware"
|
27
28
|
spec.add_dependency "rack-contrib"
|
29
|
+
spec.add_dependency "activesupport"
|
28
30
|
|
29
31
|
spec.add_development_dependency "bundler", "~> 1.5"
|
32
|
+
spec.add_development_dependency "pry"
|
30
33
|
spec.add_development_dependency "rake"
|
31
34
|
spec.add_development_dependency "rspec"
|
32
35
|
spec.add_development_dependency "rack-test"
|
data/lib/almanack/cli.rb
CHANGED
@@ -35,12 +35,14 @@ module Almanack
|
|
35
35
|
def new(path)
|
36
36
|
@path = Pathname(path).cleanpath
|
37
37
|
|
38
|
-
directory "templates/new", path
|
38
|
+
directory "templates/new", @path
|
39
39
|
|
40
40
|
if options[:git]
|
41
41
|
template('templates/gitignore', @path.join(".gitignore"))
|
42
42
|
end
|
43
43
|
|
44
|
+
create_file @path.join('tmp/.keep')
|
45
|
+
|
44
46
|
inside @path do
|
45
47
|
say_status :installing, "bundler dependencies"
|
46
48
|
system "bundle install --quiet"
|
@@ -2,9 +2,12 @@ module Almanack
|
|
2
2
|
class Configuration
|
3
3
|
class ThemeNotFound < StandardError; end
|
4
4
|
|
5
|
+
CACHE_DIR = "tmp"
|
5
6
|
DEFAULT_THEME = "legacy"
|
6
7
|
DEFAULT_DAYS_LOOKAHEAD = 30
|
7
8
|
DEFAULT_FEED_LOOKAHEAD = 365
|
9
|
+
DEFAULT_CACHE_RESPONSES = false
|
10
|
+
DEFAULT_CACHE_EXPIRY = 900
|
8
11
|
|
9
12
|
attr_reader :event_sources
|
10
13
|
attr_accessor :title,
|
@@ -12,21 +15,28 @@ module Almanack
|
|
12
15
|
:theme_paths,
|
13
16
|
:theme_root,
|
14
17
|
:days_lookahead,
|
15
|
-
:feed_lookahead
|
18
|
+
:feed_lookahead,
|
19
|
+
:cache_responses,
|
20
|
+
:cache_expiry
|
16
21
|
|
17
22
|
def initialize
|
18
23
|
reset!
|
19
24
|
end
|
20
25
|
|
21
26
|
def connection
|
22
|
-
@connection ||= Faraday.new
|
27
|
+
@connection ||= Faraday.new do |conn|
|
28
|
+
conn.response(:caching) { cache_store } if cache_responses
|
29
|
+
conn.adapter Faraday.default_adapter
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
def reset!
|
26
|
-
@theme
|
27
|
-
@days_lookahead
|
28
|
-
@feed_lookahead
|
29
|
-
@event_sources
|
34
|
+
@theme = DEFAULT_THEME
|
35
|
+
@days_lookahead = DEFAULT_DAYS_LOOKAHEAD
|
36
|
+
@feed_lookahead = DEFAULT_FEED_LOOKAHEAD
|
37
|
+
@event_sources = []
|
38
|
+
@cache_responses = DEFAULT_CACHE_RESPONSES
|
39
|
+
@cache_expiry = DEFAULT_CACHE_EXPIRY
|
30
40
|
|
31
41
|
@theme_paths = [
|
32
42
|
Pathname.pwd.join('themes'),
|
@@ -55,5 +65,15 @@ module Almanack
|
|
55
65
|
def add_meetup_group(options)
|
56
66
|
add_event_source EventSource::MeetupGroup.new(options.merge(connection: connection))
|
57
67
|
end
|
68
|
+
|
69
|
+
def cache_store
|
70
|
+
@cache_store ||= ActiveSupport::Cache::FileStore.new(cache_dir, expires_in: cache_expiry)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def cache_dir
|
76
|
+
Pathname.pwd.join(CACHE_DIR)
|
77
|
+
end
|
58
78
|
end
|
59
79
|
end
|
data/lib/almanack/version.rb
CHANGED
data/lib/almanack.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -85,5 +85,29 @@ module Almanack
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
describe "#cache_expiry" do
|
89
|
+
it "is 15 minutes by default" do
|
90
|
+
expect(Configuration.new.cache_expiry).to eq(900)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "can be set" do
|
94
|
+
config = Configuration.new
|
95
|
+
config.cache_expiry = 3600
|
96
|
+
expect(config.cache_expiry).to eq(3600)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#cache_responses" do
|
101
|
+
it "is enabled by default" do
|
102
|
+
expect(Configuration.new.cache_responses).to be(false)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "can be disabled" do
|
106
|
+
config = Configuration.new
|
107
|
+
config.cache_responses = true
|
108
|
+
expect(config.cache_responses).to be(true)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
88
112
|
end
|
89
113
|
end
|
data/templates/gitignore
CHANGED
data/templates/new/config.ru.tt
CHANGED
@@ -5,6 +5,10 @@ Almanack.config do |c|
|
|
5
5
|
c.theme = "<%= theme_name %>" # available: <%= available_themes.join(', ') %>
|
6
6
|
c.days_lookahead = 30
|
7
7
|
|
8
|
+
# Don't fetch event information more than once every 15 minutes
|
9
|
+
c.cache_responses = true
|
10
|
+
c.cache_expiry = 900 # seconds
|
11
|
+
|
8
12
|
# Your group's URL name is what you'd find at www.meetup.com/Your-Group-URL-Name/
|
9
13
|
# You can get a Meetup API key from https://secure.meetup.com/meetup_api/key
|
10
14
|
# c.add_meetup_group group_urlname: 'Christchurch-Ruby-Group', key: 'mysecretkey'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: almanack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.
|
4
|
+
version: 1.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Nicholls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: faraday_middleware
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rack-contrib
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: activesupport
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: bundler
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +164,20 @@ dependencies:
|
|
136
164
|
- - "~>"
|
137
165
|
- !ruby/object:Gem::Version
|
138
166
|
version: '1.5'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: pry
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: rake
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|