magellan-cli 0.8.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52015bf6bf212d66d63f93c9dcfeeb180177eafb
4
- data.tar.gz: 2f34bc88bee4ad299e8da758af0c5859e65f170c
3
+ metadata.gz: 0c9fd96d822f098ec4cbc9f250db006636748436
4
+ data.tar.gz: 14eadd862a3a35ed7279472125bcc0643380e86b
5
5
  SHA512:
6
- metadata.gz: dd4d4a13201c7452a44e17ec9e1a6892a5bf4cdd378599452159367efc08a108700ed73e8d3b1ec14061b25cfc0fb37d2a15d708d71097d378c6e20282da32f6
7
- data.tar.gz: 00e798cb3ed9ddccf15c17b98cff4f8af15d12a054e8fff4e30f9912857ddcfa63c898f016b1023baba80f5601ca201639f6fcd2657d87aa41ed7647689712e2
6
+ metadata.gz: 86f0d246d8f39d103bf840b05c8d12038a7ef2b5bf4cdc886785b47df83b14ca58fae9c01fb9f9220077344a9d7fbd2729e9f10f4a056ef154f086dee092584a
7
+ data.tar.gz: 22847a8bb4790fb70ebf4e7886d93e3b4ba71a59193cc4baa2b996832549a38658cc65e4e7a5975a1ec95efce05e23ba345a6091437b32bc5022ce0c1ca8730a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.8.0)
4
+ magellan-cli (0.8.1)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
@@ -12,6 +12,19 @@ module Magellan
12
12
  self.field_associations = {"team_id" => {name: "team", class: "Team"},
13
13
  "auth_id" => {name: "project", class: "Project"} }
14
14
 
15
+ filter_field :stage_type do |stype|
16
+ case stype
17
+ when 1, "1", "development"
18
+ "development"
19
+ when 2, "2", "staging"
20
+ "development, staging"
21
+ when 3..9, "3".."9", "production"
22
+ "development, staging, production"
23
+ else
24
+ stype
25
+ end
26
+ end
27
+
15
28
  desc "update ATTRIBUTES", I18n.t(:update, scope: [:resources, :common, :cmd], resource_name: resource_name)
16
29
  def update(attrs)
17
30
  s = load_selection!(self.class)
@@ -120,7 +120,11 @@ module Magellan
120
120
  selected_id = (load_selections[ parameter_name ] || {})["id"]
121
121
  res1.each do |r|
122
122
  row = original_fields.map do |f|
123
- association_get(associations, r, f)
123
+ if self.class.filtered_fields and self.class.filtered_fields[f.to_s]
124
+ self.class.filtered_fields[f.to_s].call(r[f])
125
+ else
126
+ association_get(associations, r, f)
127
+ end
124
128
  end
125
129
  row.unshift(r["id"] == selected_id ? "*" : " ")
126
130
  t.rows << row
@@ -139,7 +143,11 @@ module Magellan
139
143
  table_fields = r.keys - (self.class.multiline_fields || [])
140
144
  associations = association_map(table_fields.dup)
141
145
  table_fields.each do |f|
142
- t.rows << [f, association_get(associations, r, f)]
146
+ if self.class.filtered_fields and self.class.filtered_fields[f.to_s]
147
+ t.rows << [f, self.class.filtered_fields[f.to_s].call(r[f])]
148
+ else
149
+ t.rows << [f, association_get(associations, r, f)]
150
+ end
143
151
  end
144
152
  $stdout.puts t.to_s
145
153
 
@@ -223,6 +231,7 @@ module Magellan
223
231
  cattr_accessor :resource_dependency
224
232
  cattr_accessor :field_associations
225
233
  cattr_accessor :hidden_fields, :multiline_fields
234
+ cattr_accessor :filtered_fields
226
235
  cattr_accessor :caption_attr
227
236
  self.caption_attr = "name"
228
237
 
@@ -235,6 +244,11 @@ module Magellan
235
244
  def self.model_class_name
236
245
  resource_key.split(/~/).map(&:camelize).join('::')
237
246
  end
247
+
248
+ def self.filter_field(field, &blk)
249
+ @@filtered_fields ||= {}
250
+ @@filtered_fields[field.to_s] = blk
251
+ end
238
252
  end
239
253
 
240
254
  desc "list", "#{I18n.t(:list, scope: [:resources, :common, :cmd], res_names: res_name.pluralize)}"
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.8.0"
3
+ VERSION = "0.8.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm2000
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient